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

Unified Diff: content/renderer/webcrypto/webcrypto_util.cc

Issue 68303009: [webcrypto] Add RSASSA-PKCS1-v1_5 sign and verify for NSS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes for eroman and rebase Created 7 years 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/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();
}

Powered by Google App Engine
This is Rietveld 408576698