Index: content/renderer/webcrypto/webcrypto_util.cc |
diff --git a/content/renderer/webcrypto/webcrypto_util.cc b/content/renderer/webcrypto/webcrypto_util.cc |
index 977c282c63b72230c52704bb74a9691d04ee0eec..fa464c00336b9bb383a8aab56f8abaec6b507fdd 100644 |
--- a/content/renderer/webcrypto/webcrypto_util.cc |
+++ b/content/renderer/webcrypto/webcrypto_util.cc |
@@ -22,14 +22,6 @@ blink::WebCryptoAlgorithm CreateAesKeyGenAlgorithm( |
aes_alg_id, new blink::WebCryptoAesKeyGenParams(length)); |
} |
-bool IsHashAlgorithm(blink::WebCryptoAlgorithmId alg_id) { |
- return alg_id == blink::WebCryptoAlgorithmIdSha1 || |
- alg_id == blink::WebCryptoAlgorithmIdSha224 || |
- alg_id == blink::WebCryptoAlgorithmIdSha256 || |
- alg_id == blink::WebCryptoAlgorithmIdSha384 || |
- alg_id == blink::WebCryptoAlgorithmIdSha512; |
-} |
- |
} // namespace |
const uint8* Uint8VectorStart(const std::vector<uint8>& data) { |
@@ -71,16 +63,35 @@ bool Base64DecodeUrlSafe(const std::string& input, std::string* output) { |
return base::Base64Decode(base64EncodedText, output); |
} |
+bool IsHashAlgorithm(blink::WebCryptoAlgorithmId alg_id) { |
+ return alg_id == blink::WebCryptoAlgorithmIdSha1 || |
+ alg_id == blink::WebCryptoAlgorithmIdSha224 || |
+ alg_id == blink::WebCryptoAlgorithmIdSha256 || |
+ alg_id == blink::WebCryptoAlgorithmIdSha384 || |
+ alg_id == blink::WebCryptoAlgorithmIdSha512; |
+} |
+ |
blink::WebCryptoAlgorithm GetInnerHashAlgorithm( |
const blink::WebCryptoAlgorithm& algorithm) { |
- if (algorithm.hmacParams()) |
- return algorithm.hmacParams()->hash(); |
- if (algorithm.hmacKeyParams()) |
- return algorithm.hmacKeyParams()->hash(); |
- if (algorithm.rsaSsaParams()) |
- return algorithm.rsaSsaParams()->hash(); |
- if (algorithm.rsaOaepParams()) |
- return algorithm.rsaOaepParams()->hash(); |
+ DCHECK(!algorithm.isNull()); |
+ switch (algorithm.id()) { |
+ case blink::WebCryptoAlgorithmIdHmac: |
+ if (algorithm.hmacParams()) |
+ return algorithm.hmacParams()->hash(); |
+ else if (algorithm.hmacKeyParams()) |
+ return algorithm.hmacKeyParams()->hash(); |
+ break; |
+ case blink::WebCryptoAlgorithmIdRsaOaep: |
+ if (algorithm.rsaOaepParams()) |
+ return algorithm.rsaOaepParams()->hash(); |
+ break; |
+ case blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5: |
+ if (algorithm.rsaSsaParams()) |
+ return algorithm.rsaSsaParams()->hash(); |
+ break; |
+ default: |
+ break; |
+ } |
return blink::WebCryptoAlgorithm::createNull(); |
} |