Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1228)

Unified Diff: content/child/webcrypto/jwk.cc

Issue 195893034: [webcrypto] Add JWK symmetric key RSAES-PKCS1-v1_5 wrap / unwrap for NSS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/child/webcrypto/jwk.cc
diff --git a/content/child/webcrypto/jwk.cc b/content/child/webcrypto/jwk.cc
index a540c025eede6ed328e7d45d5b152fb0537ea30d..70529e407fe89223093aa1c4a9969b6045e64977 100644
--- a/content/child/webcrypto/jwk.cc
+++ b/content/child/webcrypto/jwk.cc
@@ -165,20 +165,25 @@ bool ImportAlgorithmsConsistent(const blink::WebCryptoAlgorithm& alg1,
DCHECK(!alg2.isNull());
if (alg1.id() != alg2.id())
return false;
- if (alg1.paramsType() != alg2.paramsType())
- return false;
- switch (alg1.paramsType()) {
- case blink::WebCryptoAlgorithmParamsTypeNone:
- return true;
- case blink::WebCryptoAlgorithmParamsTypeRsaHashedImportParams:
- return ImportAlgorithmsConsistent(alg1.rsaHashedImportParams()->hash(),
- alg2.rsaHashedImportParams()->hash());
- case blink::WebCryptoAlgorithmParamsTypeHmacImportParams:
- return ImportAlgorithmsConsistent(alg1.hmacImportParams()->hash(),
- alg2.hmacImportParams()->hash());
- default:
+ // Inner hash algorithms must be compared too, but only if present.
+ if (alg1.paramsType() ==
+ blink::WebCryptoAlgorithmParamsTypeRsaHashedImportParams ||
+ alg1.paramsType() ==
+ blink::WebCryptoAlgorithmParamsTypeHmacImportParams) {
+ if (alg1.paramsType() != alg2.paramsType())
return false;
+ switch (alg1.paramsType()) {
+ case blink::WebCryptoAlgorithmParamsTypeRsaHashedImportParams:
+ return ImportAlgorithmsConsistent(alg1.rsaHashedImportParams()->hash(),
+ alg2.rsaHashedImportParams()->hash());
+ case blink::WebCryptoAlgorithmParamsTypeHmacImportParams:
+ return ImportAlgorithmsConsistent(alg1.hmacImportParams()->hash(),
+ alg2.hmacImportParams()->hash());
+ default:
+ return false;
+ }
}
+ return true;
}
// Extracts the required string property with key |path| from |dict| and saves
@@ -388,9 +393,6 @@ Status ImportKeyJwk(const CryptoData& key_data,
// TODO(padolph): Generalize this comment to include export, and move to top
// of file.
- // TODO(padolph): Generalize this comment to include export, and move to top
- // of file.
-
// The goal of this method is to extract key material and meta data from the
// incoming JWK, combine them with the input parameters, and ultimately import
// a Web Crypto Key.
« no previous file with comments | « no previous file | content/child/webcrypto/shared_crypto.cc » ('j') | content/child/webcrypto/shared_crypto_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698