OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "bindings/modules/v8/ScriptValueSerializerForModules.h" | 6 #include "bindings/modules/v8/ScriptValueSerializerForModules.h" |
7 | 7 |
8 #include "bindings/core/v8/SerializationTag.h" | 8 #include "bindings/core/v8/SerializationTag.h" |
9 #include "bindings/core/v8/V8Binding.h" | 9 #include "bindings/core/v8/V8Binding.h" |
10 #include "bindings/modules/v8/V8CryptoKey.h" | 10 #include "bindings/modules/v8/V8CryptoKey.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 Sha256Tag = 6, | 23 Sha256Tag = 6, |
24 Sha384Tag = 7, | 24 Sha384Tag = 7, |
25 Sha512Tag = 8, | 25 Sha512Tag = 8, |
26 AesGcmTag = 9, | 26 AesGcmTag = 9, |
27 RsaOaepTag = 10, | 27 RsaOaepTag = 10, |
28 AesCtrTag = 11, | 28 AesCtrTag = 11, |
29 AesKwTag = 12, | 29 AesKwTag = 12, |
30 RsaPssTag = 13, | 30 RsaPssTag = 13, |
31 EcdsaTag = 14, | 31 EcdsaTag = 14, |
32 EcdhTag = 15, | 32 EcdhTag = 15, |
33 HkdfTag = 16, | |
33 // Maximum allowed value is 2^32-1 | 34 // Maximum allowed value is 2^32-1 |
34 }; | 35 }; |
35 | 36 |
36 enum NamedCurveTag { | 37 enum NamedCurveTag { |
37 P256Tag = 1, | 38 P256Tag = 1, |
38 P384Tag = 2, | 39 P384Tag = 2, |
39 P521Tag = 3, | 40 P521Tag = 3, |
40 }; | 41 }; |
41 | 42 |
42 enum CryptoKeyUsage { | 43 enum CryptoKeyUsage { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 case WebCryptoKeyAlgorithmParamsTypeHmac: | 116 case WebCryptoKeyAlgorithmParamsTypeHmac: |
116 doWriteHmacKey(key); | 117 doWriteHmacKey(key); |
117 break; | 118 break; |
118 case WebCryptoKeyAlgorithmParamsTypeRsaHashed: | 119 case WebCryptoKeyAlgorithmParamsTypeRsaHashed: |
119 doWriteRsaHashedKey(key); | 120 doWriteRsaHashedKey(key); |
120 break; | 121 break; |
121 case WebCryptoKeyAlgorithmParamsTypeEc: | 122 case WebCryptoKeyAlgorithmParamsTypeEc: |
122 doWriteEcKey(key); | 123 doWriteEcKey(key); |
123 break; | 124 break; |
124 case WebCryptoKeyAlgorithmParamsTypeNone: | 125 case WebCryptoKeyAlgorithmParamsTypeNone: |
125 ASSERT_NOT_REACHED(); | 126 ASSERT_NOT_REACHED(); |
eroman
2014/12/23 20:58:24
This is incomplete. Serialization of HKDF keys is
nharper
2014/12/23 22:46:59
Can you point me to an example CL that added seria
eroman
2014/12/23 23:34:29
Example:
https://code.google.com/p/chromium/codes
eroman
2014/12/24 00:38:27
Given that PBKDF2's key will be exactly the same,
nharper
2015/01/06 21:53:00
I added a Kdf params type (to be used for both HKD
| |
126 return false; | 127 return false; |
127 } | 128 } |
128 | 129 |
129 doWriteKeyUsages(key.usages(), key.extractable()); | 130 doWriteKeyUsages(key.usages(), key.extractable()); |
130 | 131 |
131 WebVector<uint8_t> keyData; | 132 WebVector<uint8_t> keyData; |
132 if (!Platform::current()->crypto()->serializeKeyForClone(key, keyData)) | 133 if (!Platform::current()->crypto()->serializeKeyForClone(key, keyData)) |
133 return false; | 134 return false; |
134 | 135 |
135 doWriteUint32(keyData.size()); | 136 doWriteUint32(keyData.size()); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 case WebCryptoAlgorithmIdAesCtr: | 209 case WebCryptoAlgorithmIdAesCtr: |
209 return doWriteUint32(AesCtrTag); | 210 return doWriteUint32(AesCtrTag); |
210 case WebCryptoAlgorithmIdAesKw: | 211 case WebCryptoAlgorithmIdAesKw: |
211 return doWriteUint32(AesKwTag); | 212 return doWriteUint32(AesKwTag); |
212 case WebCryptoAlgorithmIdRsaPss: | 213 case WebCryptoAlgorithmIdRsaPss: |
213 return doWriteUint32(RsaPssTag); | 214 return doWriteUint32(RsaPssTag); |
214 case WebCryptoAlgorithmIdEcdsa: | 215 case WebCryptoAlgorithmIdEcdsa: |
215 return doWriteUint32(EcdsaTag); | 216 return doWriteUint32(EcdsaTag); |
216 case WebCryptoAlgorithmIdEcdh: | 217 case WebCryptoAlgorithmIdEcdh: |
217 return doWriteUint32(EcdhTag); | 218 return doWriteUint32(EcdhTag); |
219 case WebCryptoAlgorithmIdHkdf: | |
220 return doWriteUint32(HkdfTag); | |
218 } | 221 } |
219 ASSERT_NOT_REACHED(); | 222 ASSERT_NOT_REACHED(); |
220 } | 223 } |
221 | 224 |
222 void SerializedScriptValueWriterForModules::doWriteAsymmetricKeyType(WebCryptoKe yType keyType) | 225 void SerializedScriptValueWriterForModules::doWriteAsymmetricKeyType(WebCryptoKe yType keyType) |
223 { | 226 { |
224 switch (keyType) { | 227 switch (keyType) { |
225 case WebCryptoKeyTypePublic: | 228 case WebCryptoKeyTypePublic: |
226 doWriteUint32(PublicKeyType); | 229 doWriteUint32(PublicKeyType); |
227 break; | 230 break; |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
500 return true; | 503 return true; |
501 case RsaPssTag: | 504 case RsaPssTag: |
502 id = WebCryptoAlgorithmIdRsaPss; | 505 id = WebCryptoAlgorithmIdRsaPss; |
503 return true; | 506 return true; |
504 case EcdsaTag: | 507 case EcdsaTag: |
505 id = WebCryptoAlgorithmIdEcdsa; | 508 id = WebCryptoAlgorithmIdEcdsa; |
506 return true; | 509 return true; |
507 case EcdhTag: | 510 case EcdhTag: |
508 id = WebCryptoAlgorithmIdEcdh; | 511 id = WebCryptoAlgorithmIdEcdh; |
509 return true; | 512 return true; |
513 case HkdfTag: | |
514 id = WebCryptoAlgorithmIdHkdf; | |
515 return true; | |
510 } | 516 } |
511 | 517 |
512 return false; | 518 return false; |
513 } | 519 } |
514 | 520 |
515 bool SerializedScriptValueReaderForModules::doReadAsymmetricKeyType(WebCryptoKey Type& type) | 521 bool SerializedScriptValueReaderForModules::doReadAsymmetricKeyType(WebCryptoKey Type& type) |
516 { | 522 { |
517 uint32_t rawType; | 523 uint32_t rawType; |
518 if (!doReadUint32(&rawType)) | 524 if (!doReadUint32(&rawType)) |
519 return false; | 525 return false; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
593 : ScriptValueDeserializer(reader, messagePorts, arrayBufferContents) | 599 : ScriptValueDeserializer(reader, messagePorts, arrayBufferContents) |
594 { | 600 { |
595 } | 601 } |
596 | 602 |
597 bool ScriptValueDeserializerForModules::read(v8::Local<v8::Value>* value) | 603 bool ScriptValueDeserializerForModules::read(v8::Local<v8::Value>* value) |
598 { | 604 { |
599 return toSerializedScriptValueReaderForModules(reader()).read(value, *this); | 605 return toSerializedScriptValueReaderForModules(reader()).read(value, *this); |
600 } | 606 } |
601 | 607 |
602 } // namespace blink | 608 } // namespace blink |
OLD | NEW |