Chromium Code Reviews| 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..c2432bce179f24c9c4ded5c230e1a7137fe0bdf3 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 |
| }; |
| @@ -122,8 +124,8 @@ bool SerializedScriptValueWriterForModules::writeCryptoKey(const WebCryptoKey& k |
| doWriteEcKey(key); |
| break; |
| case WebCryptoKeyAlgorithmParamsTypeNone: |
| - ASSERT_NOT_REACHED(); |
| - return false; |
| + ASSERT(WebCryptoAlgorithm::isKdf(key.algorithm().id())); |
| + doWriteKdfKey(key); |
|
eroman
2015/01/09 03:07:29
Given the switch statement on params type, I think
nharper
2015/01/09 04:45:52
I think this is reasonable, but the changes needed
nharper
2015/01/09 21:21:09
We discussed this, and I've changed it.
|
| } |
| doWriteKeyUsages(key.usages(), key.extractable()); |
| @@ -184,6 +186,13 @@ void SerializedScriptValueWriterForModules::doWriteEcKey(const WebCryptoKey& key |
| doWriteNamedCurve(key.algorithm().ecParams()->namedCurve()); |
| } |
| +void SerializedScriptValueWriterForModules::doWriteKdfKey(const WebCryptoKey& key) |
| +{ |
| + append(static_cast<uint8_t>(KdfKeyTag)); |
| + |
| + doWriteAlgorithmId(key.algorithm().id()); |
| +} |
| + |
| void SerializedScriptValueWriterForModules::doWriteAlgorithmId(WebCryptoAlgorithmId id) |
| { |
| switch (id) { |
| @@ -215,6 +224,8 @@ void SerializedScriptValueWriterForModules::doWriteAlgorithmId(WebCryptoAlgorith |
| return doWriteUint32(EcdsaTag); |
| case WebCryptoAlgorithmIdEcdh: |
| return doWriteUint32(EcdhTag); |
| + case WebCryptoAlgorithmIdHkdf: |
| + return doWriteUint32(HkdfTag); |
| } |
| ASSERT_NOT_REACHED(); |
| } |
| @@ -359,6 +370,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 +473,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 +532,9 @@ bool SerializedScriptValueReaderForModules::doReadAlgorithmId(WebCryptoAlgorithm |
| case EcdhTag: |
| id = WebCryptoAlgorithmIdEcdh; |
| return true; |
| + case HkdfTag: |
| + id = WebCryptoAlgorithmIdHkdf; |
| + return true; |
| } |
| return false; |