| Index: Source/bindings/modules/v8/ScriptValueSerializerForModules.cpp
|
| diff --git a/Source/bindings/modules/v8/ScriptValueSerializerForModules.cpp b/Source/bindings/modules/v8/ScriptValueSerializerForModules.cpp
|
| index 08add9b64a162f1c2349c1a1f0b7f4b41428265f..f5cfc43a0ea8bf4cc0e0eef6080376092faf2d28 100644
|
| --- a/Source/bindings/modules/v8/ScriptValueSerializerForModules.cpp
|
| +++ b/Source/bindings/modules/v8/ScriptValueSerializerForModules.cpp
|
| @@ -30,6 +30,7 @@ enum CryptoKeyAlgorithmTag {
|
| RsaPssTag = 13,
|
| EcdsaTag = 14,
|
| EcdhTag = 15,
|
| + HkdfTag = 16,
|
| // Maximum allowed value is 2^32-1
|
| };
|
|
|
| @@ -61,6 +62,7 @@ enum CryptoKeySubTag {
|
| // ID 3 was used by RsaKeyTag, while still behind experimental flag.
|
| RsaHashedKeyTag = 4,
|
| EcKeyTag = 5,
|
| + KdfKeyTag = 6,
|
| // Maximum allowed value is 255
|
| };
|
|
|
| @@ -121,6 +123,9 @@ bool SerializedScriptValueWriterForModules::writeCryptoKey(const WebCryptoKey& k
|
| case WebCryptoKeyAlgorithmParamsTypeEc:
|
| doWriteEcKey(key);
|
| break;
|
| + case WebCryptoKeyAlgorithmParamsTypeKdf:
|
| + doWriteKdfKey(key);
|
| + break;
|
| case WebCryptoKeyAlgorithmParamsTypeNone:
|
| ASSERT_NOT_REACHED();
|
| return false;
|
| @@ -184,6 +189,14 @@ void SerializedScriptValueWriterForModules::doWriteEcKey(const WebCryptoKey& key
|
| doWriteNamedCurve(key.algorithm().ecParams()->namedCurve());
|
| }
|
|
|
| +void SerializedScriptValueWriterForModules::doWriteKdfKey(const WebCryptoKey& key)
|
| +{
|
| + ASSERT(key.algorithm().kdfParams());
|
| + append(static_cast<uint8_t>(KdfKeyTag));
|
| +
|
| + doWriteAlgorithmId(key.algorithm().id());
|
| +}
|
| +
|
| void SerializedScriptValueWriterForModules::doWriteAlgorithmId(WebCryptoAlgorithmId id)
|
| {
|
| switch (id) {
|
| @@ -215,6 +228,8 @@ void SerializedScriptValueWriterForModules::doWriteAlgorithmId(WebCryptoAlgorith
|
| return doWriteUint32(EcdsaTag);
|
| case WebCryptoAlgorithmIdEcdh:
|
| return doWriteUint32(EcdhTag);
|
| + case WebCryptoAlgorithmIdHkdf:
|
| + return doWriteUint32(HkdfTag);
|
| }
|
| ASSERT_NOT_REACHED();
|
| }
|
| @@ -359,6 +374,10 @@ bool SerializedScriptValueReaderForModules::readCryptoKey(v8::Handle<v8::Value>*
|
| if (!doReadEcKey(algorithm, type))
|
| return false;
|
| break;
|
| + case KdfKeyTag:
|
| + if (!doReadKdfKey(algorithm, type))
|
| + return false;
|
| + break;
|
| default:
|
| return false;
|
| }
|
| @@ -458,6 +477,16 @@ bool SerializedScriptValueReaderForModules::doReadEcKey(WebCryptoKeyAlgorithm& a
|
| return !algorithm.isNull();
|
| }
|
|
|
| +bool SerializedScriptValueReaderForModules::doReadKdfKey(WebCryptoKeyAlgorithm& algorithm, WebCryptoKeyType& type)
|
| +{
|
| + WebCryptoAlgorithmId kdf;
|
| + if (!doReadAlgorithmId(kdf))
|
| + return false;
|
| + algorithm = WebCryptoKeyAlgorithm::createKdf(kdf);
|
| + type = WebCryptoKeyTypeSecret;
|
| + return !algorithm.isNull();
|
| +}
|
| +
|
| bool SerializedScriptValueReaderForModules::doReadAlgorithmId(WebCryptoAlgorithmId& id)
|
| {
|
| uint32_t rawId;
|
| @@ -507,6 +536,9 @@ bool SerializedScriptValueReaderForModules::doReadAlgorithmId(WebCryptoAlgorithm
|
| case EcdhTag:
|
| id = WebCryptoAlgorithmIdEcdh;
|
| return true;
|
| + case HkdfTag:
|
| + id = WebCryptoAlgorithmIdHkdf;
|
| + return true;
|
| }
|
|
|
| return false;
|
|
|