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

Unified Diff: trunk/Source/modules/crypto/NormalizeAlgorithm.cpp

Issue 296333002: Revert 174726 "[webcrypto] Remove RSA-ES support (3 of 3)" (Closed) Base URL: svn://svn.chromium.org/blink/
Patch Set: Created 6 years, 7 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 | « trunk/Source/modules/crypto/KeyAlgorithm.idl ('k') | trunk/Source/modules/crypto/RsaKeyAlgorithm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/Source/modules/crypto/NormalizeAlgorithm.cpp
===================================================================
--- trunk/Source/modules/crypto/NormalizeAlgorithm.cpp (revision 174732)
+++ trunk/Source/modules/crypto/NormalizeAlgorithm.cpp (working copy)
@@ -73,6 +73,7 @@
{"AES-GCM", 7, blink::WebCryptoAlgorithmIdAesGcm},
{"AES-CTR", 7, blink::WebCryptoAlgorithmIdAesCtr},
{"RSA-OAEP", 8, blink::WebCryptoAlgorithmIdRsaOaep},
+ {"RSAES-PKCS1-V1_5", 16, blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5},
{"RSASSA-PKCS1-V1_5", 17, blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5},
};
@@ -133,6 +134,20 @@
Undefined // UnwrapKey
}
}, { // Index 3
+ "RSAES-PKCS1-v1_5", {
+ blink::WebCryptoAlgorithmParamsTypeNone, // Encrypt
+ blink::WebCryptoAlgorithmParamsTypeNone, // Decrypt
+ Undefined, // Sign
+ Undefined, // Verify
+ Undefined, // Digest
+ blink::WebCryptoAlgorithmParamsTypeRsaKeyGenParams, // GenerateKey
+ blink::WebCryptoAlgorithmParamsTypeNone, // ImportKey
+ Undefined, // DeriveKey
+ Undefined, // DeriveBits
+ blink::WebCryptoAlgorithmParamsTypeNone, // WrapKey
+ blink::WebCryptoAlgorithmParamsTypeNone // UnwrapKey
+ }
+ }, { // Index 4
"SHA-1", {
Undefined, // Encrypt
Undefined, // Decrypt
@@ -146,7 +161,7 @@
Undefined, // WrapKey
Undefined // UnwrapKey
}
- }, { // Index 4
+ }, { // Index 5
"SHA-256", {
Undefined, // Encrypt
Undefined, // Decrypt
@@ -160,7 +175,7 @@
Undefined, // WrapKey
Undefined // UnwrapKey
}
- }, { // Index 5
+ }, { // Index 6
"SHA-384", {
Undefined, // Encrypt
Undefined, // Decrypt
@@ -174,7 +189,7 @@
Undefined, // WrapKey
Undefined // UnwrapKey
}
- }, { // Index 6
+ }, { // Index 7
"SHA-512", {
Undefined, // Encrypt
Undefined, // Decrypt
@@ -188,7 +203,7 @@
Undefined, // WrapKey
Undefined // UnwrapKey
}
- }, { // Index 7
+ }, { // Index 8
"AES-GCM", {
blink::WebCryptoAlgorithmParamsTypeAesGcmParams, // Encrypt
blink::WebCryptoAlgorithmParamsTypeAesGcmParams, // Decrypt
@@ -202,7 +217,7 @@
blink::WebCryptoAlgorithmParamsTypeAesGcmParams, // WrapKey
blink::WebCryptoAlgorithmParamsTypeAesGcmParams // UnwrapKey
}
- }, { // Index 8
+ }, { // Index 9
"RSA-OAEP", {
blink::WebCryptoAlgorithmParamsTypeRsaOaepParams, // Encrypt
blink::WebCryptoAlgorithmParamsTypeRsaOaepParams, // Decrypt
@@ -216,7 +231,7 @@
blink::WebCryptoAlgorithmParamsTypeRsaOaepParams, // WrapKey
blink::WebCryptoAlgorithmParamsTypeRsaOaepParams // UnwrapKey
}
- }, { // Index 9
+ }, { // Index 10
"AES-CTR", {
blink::WebCryptoAlgorithmParamsTypeAesCtrParams, // Encrypt
blink::WebCryptoAlgorithmParamsTypeAesCtrParams, // Decrypt
@@ -230,7 +245,7 @@
blink::WebCryptoAlgorithmParamsTypeAesCtrParams, // WrapKey
blink::WebCryptoAlgorithmParamsTypeAesCtrParams // UnwrapKey
}
- }, { // Index 10
+ }, { // Index 11
"AES-KW", {
Undefined, // Encrypt
Undefined, // Decrypt
@@ -253,15 +268,16 @@
COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesCbc == 0, AesCbc_idDoesntMatch);
COMPILE_ASSERT(blink::WebCryptoAlgorithmIdHmac == 1, Hmac_idDoesntMatch);
COMPILE_ASSERT(blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 == 2, RsaSsaPkcs1v1_5_idDoesntMatch);
-COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha1 == 3, Sha1_idDoesntMatch);
-COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha256 == 4, Sha256_idDoesntMatch);
-COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha384 == 5, Sha384_idDoesntMatch);
-COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha512 == 6, Sha512_idDoesntMatch);
-COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesGcm == 7, AesGcm_idDoesntMatch);
-COMPILE_ASSERT(blink::WebCryptoAlgorithmIdRsaOaep == 8, RsaOaep_idDoesntMatch);
-COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesCtr == 9, AesCtr_idDoesntMatch);
-COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesKw == 10, AesKw_idDoesntMatch);
-COMPILE_ASSERT(blink::WebCryptoAlgorithmIdLast == 10, Last_idDoesntMatch);
+COMPILE_ASSERT(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5 == 3, RsaEsPkcs1v1_5_idDoesntMatch);
+COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha1 == 4, Sha1_idDoesntMatch);
+COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha256 == 5, Sha256_idDoesntMatch);
+COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha384 == 6, Sha384_idDoesntMatch);
+COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha512 == 7, Sha512_idDoesntMatch);
+COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesGcm == 8, AesGcm_idDoesntMatch);
+COMPILE_ASSERT(blink::WebCryptoAlgorithmIdRsaOaep == 9, RsaOaep_idDoesntMatch);
+COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesCtr == 10, AesCtr_idDoesntMatch);
+COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesKw == 11, AesKw_idDoesntMatch);
+COMPILE_ASSERT(blink::WebCryptoAlgorithmIdLast == 11, Last_idDoesntMatch);
COMPILE_ASSERT(10 == LastAlgorithmOperation, UpdateParamsMapping);
#if ASSERT_ENABLED
@@ -703,24 +719,44 @@
// Defined by the WebCrypto spec as:
//
-// dictionary RsaHashedKeyGenParams : RsaKeyGenParams {
-// AlgorithmIdentifier hash;
-// };
-//
// dictionary RsaKeyGenParams : Algorithm {
// unsigned long modulusLength;
// BigInteger publicExponent;
// };
-bool parseRsaHashedKeyGenParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmParams>& params, const ErrorContext& context, CryptoResult* result)
+bool parseRsaKeyGenParams(const Dictionary& raw, uint32_t& modulusLength, RefPtr<Uint8Array>& publicExponent, const ErrorContext& context, CryptoResult* result)
{
- uint32_t modulusLength;
if (!getUint32(raw, "modulusLength", modulusLength, context, result))
return false;
- RefPtr<Uint8Array> publicExponent;
if (!getBigInteger(raw, "publicExponent", publicExponent, context, result))
return false;
+ return true;
+}
+
+bool parseRsaKeyGenParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmParams>& params, const ErrorContext& context, CryptoResult* result)
+{
+ uint32_t modulusLength;
+ RefPtr<Uint8Array> publicExponent;
+ if (!parseRsaKeyGenParams(raw, modulusLength, publicExponent, context, result))
+ return false;
+
+ params = adoptPtr(new blink::WebCryptoRsaKeyGenParams(modulusLength, static_cast<const unsigned char*>(publicExponent->baseAddress()), publicExponent->byteLength()));
+ return true;
+}
+
+// Defined by the WebCrypto spec as:
+//
+// dictionary RsaHashedKeyGenParams : RsaKeyGenParams {
+// AlgorithmIdentifier hash;
+// };
+bool parseRsaHashedKeyGenParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmParams>& params, const ErrorContext& context, CryptoResult* result)
+{
+ uint32_t modulusLength;
+ RefPtr<Uint8Array> publicExponent;
+ if (!parseRsaKeyGenParams(raw, modulusLength, publicExponent, context, result))
+ return false;
+
blink::WebCryptoAlgorithm hash;
if (!parseHash(raw, hash, context, result))
return false;
@@ -824,6 +860,9 @@
case blink::WebCryptoAlgorithmParamsTypeRsaHashedImportParams:
context.add("RsaHashedImportParams");
return parseRsaHashedImportParams(raw, params, context, result);
+ case blink::WebCryptoAlgorithmParamsTypeRsaKeyGenParams:
+ context.add("RsaKeyGenParams");
+ return parseRsaKeyGenParams(raw, params, context, result);
case blink::WebCryptoAlgorithmParamsTypeAesCtrParams:
context.add("AesCtrParams");
return parseAesCtrParams(raw, params, context, result);
« no previous file with comments | « trunk/Source/modules/crypto/KeyAlgorithm.idl ('k') | trunk/Source/modules/crypto/RsaKeyAlgorithm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698