Index: Source/modules/crypto/NormalizeAlgorithm.cpp |
diff --git a/Source/modules/crypto/NormalizeAlgorithm.cpp b/Source/modules/crypto/NormalizeAlgorithm.cpp |
index 713c04beeffdfc6316939a2b5742f67dca32bde4..69fa12846e92da5c8f0abe30e9c0a3a08e2797b6 100644 |
--- a/Source/modules/crypto/NormalizeAlgorithm.cpp |
+++ b/Source/modules/crypto/NormalizeAlgorithm.cpp |
@@ -99,16 +99,16 @@ const OperationParamsMapping operationParamsMappings[] = { |
{blink::WebCryptoAlgorithmIdAesCtr, WrapKey, blink::WebCryptoAlgorithmParamsTypeAesCtrParams}, |
// HMAC |
- {blink::WebCryptoAlgorithmIdHmac, Sign, blink::WebCryptoAlgorithmParamsTypeHmacParams}, |
- {blink::WebCryptoAlgorithmIdHmac, Verify, blink::WebCryptoAlgorithmParamsTypeHmacParams}, |
- {blink::WebCryptoAlgorithmIdHmac, GenerateKey, blink::WebCryptoAlgorithmParamsTypeHmacKeyParams}, |
- {blink::WebCryptoAlgorithmIdHmac, ImportKey, blink::WebCryptoAlgorithmParamsTypeHmacParams}, |
+ {blink::WebCryptoAlgorithmIdHmac, Sign, blink::WebCryptoAlgorithmParamsTypeNone}, |
+ {blink::WebCryptoAlgorithmIdHmac, Verify, blink::WebCryptoAlgorithmParamsTypeNone}, |
+ {blink::WebCryptoAlgorithmIdHmac, GenerateKey, blink::WebCryptoAlgorithmParamsTypeHmacKeyGenParams}, |
+ {blink::WebCryptoAlgorithmIdHmac, ImportKey, blink::WebCryptoAlgorithmParamsTypeHmacImportParams}, |
// RSASSA-PKCS1-v1_5 |
- {blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, Sign, blink::WebCryptoAlgorithmParamsTypeRsaSsaParams}, |
- {blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, Verify, blink::WebCryptoAlgorithmParamsTypeRsaSsaParams}, |
- {blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, GenerateKey, blink::WebCryptoAlgorithmParamsTypeRsaKeyGenParams}, |
- {blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, ImportKey, blink::WebCryptoAlgorithmParamsTypeNone}, |
+ {blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, Sign, blink::WebCryptoAlgorithmParamsTypeNone}, |
+ {blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, Verify, blink::WebCryptoAlgorithmParamsTypeNone}, |
+ {blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, GenerateKey, blink::WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams}, |
+ {blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, ImportKey, blink::WebCryptoAlgorithmParamsTypeRsaHashedImportParams}, |
// RSAES-PKCS1-v1_5 |
{blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5, Encrypt, blink::WebCryptoAlgorithmParamsTypeNone}, |
@@ -390,13 +390,13 @@ bool parseHash(const Dictionary& raw, blink::WebCryptoAlgorithm& hash, ErrorCont |
return parseAlgorithm(rawHash, Digest, hash, context, errorDetails); |
} |
-bool parseHmacParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmParams>& params, const ErrorContext& context, String& errorDetails) |
+bool parseHmacImportParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmParams>& params, const ErrorContext& context, String& errorDetails) |
{ |
blink::WebCryptoAlgorithm hash; |
if (!parseHash(raw, hash, context, errorDetails)) |
return false; |
- params = adoptPtr(new blink::WebCryptoHmacParams(hash)); |
+ params = adoptPtr(new blink::WebCryptoHmacImportParams(hash)); |
return true; |
} |
@@ -411,34 +411,57 @@ bool parseHmacKeyParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmP |
if (!getOptionalUint32(raw, "length", hasLength, length, context, errorDetails)) |
return false; |
- params = adoptPtr(new blink::WebCryptoHmacKeyParams(hash, hasLength, length)); |
+ params = adoptPtr(new blink::WebCryptoHmacKeyGenParams(hash, hasLength, length)); |
return true; |
} |
-bool parseRsaSsaParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmParams>& params, const ErrorContext& context, String& errorDetails) |
+bool parseRsaHashedImportParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmParams>& params, const ErrorContext& context, String& errorDetails) |
{ |
blink::WebCryptoAlgorithm hash; |
if (!parseHash(raw, hash, context, errorDetails)) |
return false; |
- params = adoptPtr(new blink::WebCryptoRsaSsaParams(hash)); |
+ params = adoptPtr(new blink::WebCryptoRsaHashedImportParams(hash)); |
return true; |
} |
-bool parseRsaKeyGenParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmParams>& params, const ErrorContext& context, String& errorDetails) |
+bool parseRsaKeyGenParams(const Dictionary& raw, uint32_t& modulusLength, RefPtr<Uint8Array>& publicExponent, const ErrorContext& context, String& errorDetails) |
{ |
- uint32_t modulusLength; |
if (!getUint32(raw, "modulusLength", modulusLength, context, errorDetails)) |
return false; |
- RefPtr<Uint8Array> publicExponent; |
if (!getUint8Array(raw, "publicExponent", publicExponent, context, errorDetails)) |
return false; |
+ return true; |
+} |
+ |
+bool parseRsaKeyGenParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmParams>& params, const ErrorContext& context, String& errorDetails) |
+{ |
+ uint32_t modulusLength; |
+ RefPtr<Uint8Array> publicExponent; |
+ if (!parseRsaKeyGenParams(raw, modulusLength, publicExponent, context, errorDetails)) |
+ return false; |
+ |
params = adoptPtr(new blink::WebCryptoRsaKeyGenParams(modulusLength, static_cast<const unsigned char*>(publicExponent->baseAddress()), publicExponent->byteLength())); |
return true; |
} |
+bool parseRsaHashedKeyGenParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmParams>& params, const ErrorContext& context, String& errorDetails) |
+{ |
+ uint32_t modulusLength; |
+ RefPtr<Uint8Array> publicExponent; |
+ if (!parseRsaKeyGenParams(raw, modulusLength, publicExponent, context, errorDetails)) |
+ return false; |
+ |
+ blink::WebCryptoAlgorithm hash; |
+ if (!parseHash(raw, hash, context, errorDetails)) |
+ return false; |
+ |
+ params = adoptPtr(new blink::WebCryptoRsaHashedKeyGenParams(hash, modulusLength, static_cast<const unsigned char*>(publicExponent->baseAddress()), publicExponent->byteLength())); |
+ return true; |
+} |
+ |
bool parseAesCtrParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmParams>& params, const ErrorContext& context, String& es) |
{ |
RefPtr<Uint8Array> counter; |
@@ -464,15 +487,18 @@ bool parseAlgorithmParams(const Dictionary& raw, blink::WebCryptoAlgorithmParams |
case blink::WebCryptoAlgorithmParamsTypeAesKeyGenParams: |
context.add("AesKeyGenParams"); |
return parseAesKeyGenParams(raw, params, context, errorDetails); |
- case blink::WebCryptoAlgorithmParamsTypeHmacParams: |
- context.add("HmacParams"); |
- return parseHmacParams(raw, params, context, errorDetails); |
- case blink::WebCryptoAlgorithmParamsTypeHmacKeyParams: |
- context.add("HmacKeyParams"); |
+ case blink::WebCryptoAlgorithmParamsTypeHmacImportParams: |
+ context.add("HmacImporParams"); |
+ return parseHmacImportParams(raw, params, context, errorDetails); |
+ case blink::WebCryptoAlgorithmParamsTypeHmacKeyGenParams: |
+ context.add("HmacKeyGenParams"); |
return parseHmacKeyParams(raw, params, context, errorDetails); |
- case blink::WebCryptoAlgorithmParamsTypeRsaSsaParams: |
- context.add("RsaSSaParams"); |
- return parseRsaSsaParams(raw, params, context, errorDetails); |
+ case blink::WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams: |
+ context.add("RsaHashedKeyGenParams"); |
+ return parseRsaHashedKeyGenParams(raw, params, context, errorDetails); |
+ case blink::WebCryptoAlgorithmParamsTypeRsaHashedImportParams: |
+ context.add("RsaHashedImportParams"); |
+ return parseRsaHashedImportParams(raw, params, context, errorDetails); |
case blink::WebCryptoAlgorithmParamsTypeRsaKeyGenParams: |
context.add("RsaKeyGenParams"); |
return parseRsaKeyGenParams(raw, params, context, errorDetails); |