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

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: minor code formatting fix Created 6 years, 11 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
« no previous file with comments | « content/renderer/webcrypto/webcrypto_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/webcrypto/webcrypto_util.cc
diff --git a/content/renderer/webcrypto/webcrypto_util.cc b/content/renderer/webcrypto/webcrypto_util.cc
index 4d89dacb3a2eb8184e78ebd9621b1e423ba4acdf..f8f706847e1d99066f062ac300588aa769a1e7da 100644
--- a/content/renderer/webcrypto/webcrypto_util.cc
+++ b/content/renderer/webcrypto/webcrypto_util.cc
@@ -15,14 +15,6 @@ namespace webcrypto {
namespace {
-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) {
@@ -64,16 +56,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();
}
« no previous file with comments | « content/renderer/webcrypto/webcrypto_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698