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

Side by Side Diff: Source/bindings/core/v8/SerializedScriptValue.cpp

Issue 707743002: WebCrypto: Add ECDSA algorithm (Blink side). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase onto master Created 6 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/modules/crypto/NormalizeAlgorithm.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 ArrayBufferTag = 'B', // byteLength:uint32_t, data:byte[byteLength] -> Array Buffer (ref) 216 ArrayBufferTag = 'B', // byteLength:uint32_t, data:byte[byteLength] -> Array Buffer (ref)
217 ArrayBufferTransferTag = 't', // index:uint32_t -> ArrayBuffer. For ArrayBuf fer transfer 217 ArrayBufferTransferTag = 't', // index:uint32_t -> ArrayBuffer. For ArrayBuf fer transfer
218 ArrayBufferViewTag = 'V', // subtag:byte, byteOffset:uint32_t, byteLength:ui nt32_t -> ArrayBufferView (ref). Consumes an ArrayBuffer from the top of the des erialization stack. 218 ArrayBufferViewTag = 'V', // subtag:byte, byteOffset:uint32_t, byteLength:ui nt32_t -> ArrayBufferView (ref). Consumes an ArrayBuffer from the top of the des erialization stack.
219 CryptoKeyTag = 'K', // subtag:byte, props, usages:uint32_t, keyDataLength:ui nt32_t, keyData:byte[keyDataLength] 219 CryptoKeyTag = 'K', // subtag:byte, props, usages:uint32_t, keyDataLength:ui nt32_t, keyData:byte[keyDataLength]
220 // If subtag=AesKeyTag: 220 // If subtag=AesKeyTag:
221 // props = keyLengthBytes:uint32_t, algorithmId:ui nt32_t 221 // props = keyLengthBytes:uint32_t, algorithmId:ui nt32_t
222 // If subtag=HmacKeyTag: 222 // If subtag=HmacKeyTag:
223 // props = keyLengthBytes:uint32_t, hashId:uint32_ t 223 // props = keyLengthBytes:uint32_t, hashId:uint32_ t
224 // If subtag=RsaHashedKeyTag: 224 // If subtag=RsaHashedKeyTag:
225 // props = algorithmId:uint32_t, type:uint32_t, mo dulusLengthBits:uint32_t, publicExponentLength:uint32_t, publicExponent:byte[pub licExponentLength], hashId:uint32_t 225 // props = algorithmId:uint32_t, type:uint32_t, mo dulusLengthBits:uint32_t, publicExponentLength:uint32_t, publicExponent:byte[pub licExponentLength], hashId:uint32_t
226 // If subtag=EcKeyTag:
227 // props = algorithmId:uint32_t, type:uint32_t, na medCurve:uint32_t
226 ObjectReferenceTag = '^', // ref:uint32_t -> reference table[ref] 228 ObjectReferenceTag = '^', // ref:uint32_t -> reference table[ref]
227 GenerateFreshObjectTag = 'o', // -> empty object allocated an object ID and pushed onto the open stack (ref) 229 GenerateFreshObjectTag = 'o', // -> empty object allocated an object ID and pushed onto the open stack (ref)
228 GenerateFreshSparseArrayTag = 'a', // length:uint32_t -> empty array[length] allocated an object ID and pushed onto the open stack (ref) 230 GenerateFreshSparseArrayTag = 'a', // length:uint32_t -> empty array[length] allocated an object ID and pushed onto the open stack (ref)
229 GenerateFreshDenseArrayTag = 'A', // length:uint32_t -> empty array[length] allocated an object ID and pushed onto the open stack (ref) 231 GenerateFreshDenseArrayTag = 'A', // length:uint32_t -> empty array[length] allocated an object ID and pushed onto the open stack (ref)
230 ReferenceCountTag = '?', // refTableSize:uint32_t -> If the reference table is not refTableSize big, fails. 232 ReferenceCountTag = '?', // refTableSize:uint32_t -> If the reference table is not refTableSize big, fails.
231 StringObjectTag = 's', // string:RawString -> new String(string) (ref) 233 StringObjectTag = 's', // string:RawString -> new String(string) (ref)
232 NumberObjectTag = 'n', // value:double -> new Number(value) (ref) 234 NumberObjectTag = 'n', // value:double -> new Number(value) (ref)
233 TrueObjectTag = 'y', // new Boolean(true) (ref) 235 TrueObjectTag = 'y', // new Boolean(true) (ref)
234 FalseObjectTag = 'x', // new Boolean(false) (ref) 236 FalseObjectTag = 'x', // new Boolean(false) (ref)
235 VersionTag = 0xFF // version:uint32_t -> Uses this as the file version. 237 VersionTag = 0xFF // version:uint32_t -> Uses this as the file version.
(...skipping 10 matching lines...) Expand all
246 FloatArrayTag = 'f', 248 FloatArrayTag = 'f',
247 DoubleArrayTag = 'F', 249 DoubleArrayTag = 'F',
248 DataViewTag = '?' 250 DataViewTag = '?'
249 }; 251 };
250 252
251 enum CryptoKeySubTag { 253 enum CryptoKeySubTag {
252 AesKeyTag = 1, 254 AesKeyTag = 1,
253 HmacKeyTag = 2, 255 HmacKeyTag = 2,
254 // ID 3 was used by RsaKeyTag, while still behind experimental flag. 256 // ID 3 was used by RsaKeyTag, while still behind experimental flag.
255 RsaHashedKeyTag = 4, 257 RsaHashedKeyTag = 4,
258 EcKeyTag = 5,
256 // Maximum allowed value is 255 259 // Maximum allowed value is 255
257 }; 260 };
258 261
259 enum AssymetricCryptoKeyType { 262 enum AssymetricCryptoKeyType {
260 PublicKeyType = 1, 263 PublicKeyType = 1,
261 PrivateKeyType = 2, 264 PrivateKeyType = 2,
262 // Maximum allowed value is 2^32-1 265 // Maximum allowed value is 2^32-1
263 }; 266 };
264 267
265 enum CryptoKeyAlgorithmTag { 268 enum CryptoKeyAlgorithmTag {
266 AesCbcTag = 1, 269 AesCbcTag = 1,
267 HmacTag = 2, 270 HmacTag = 2,
268 RsaSsaPkcs1v1_5Tag = 3, 271 RsaSsaPkcs1v1_5Tag = 3,
269 // ID 4 was used by RsaEs, while still behind experimental flag. 272 // ID 4 was used by RsaEs, while still behind experimental flag.
270 Sha1Tag = 5, 273 Sha1Tag = 5,
271 Sha256Tag = 6, 274 Sha256Tag = 6,
272 Sha384Tag = 7, 275 Sha384Tag = 7,
273 Sha512Tag = 8, 276 Sha512Tag = 8,
274 AesGcmTag = 9, 277 AesGcmTag = 9,
275 RsaOaepTag = 10, 278 RsaOaepTag = 10,
276 AesCtrTag = 11, 279 AesCtrTag = 11,
277 AesKwTag = 12, 280 AesKwTag = 12,
278 RsaPssTag = 13, 281 RsaPssTag = 13,
282 EcdsaTag = 14,
279 // Maximum allowed value is 2^32-1 283 // Maximum allowed value is 2^32-1
280 }; 284 };
281 285
286 enum NamedCurveTag {
287 P256Tag = 1,
288 P384Tag = 2,
289 P521Tag = 3,
290 };
291
282 enum CryptoKeyUsage { 292 enum CryptoKeyUsage {
283 // Extractability is not a "usage" in the WebCryptoKeyUsages sense, however 293 // Extractability is not a "usage" in the WebCryptoKeyUsages sense, however
284 // it fits conveniently into this bitfield. 294 // it fits conveniently into this bitfield.
285 ExtractableUsage = 1 << 0, 295 ExtractableUsage = 1 << 0,
286 296
287 EncryptUsage = 1 << 1, 297 EncryptUsage = 1 << 1,
288 DecryptUsage = 1 << 2, 298 DecryptUsage = 1 << 2,
289 SignUsage = 1 << 3, 299 SignUsage = 1 << 3,
290 VerifyUsage = 1 << 4, 300 VerifyUsage = 1 << 4,
291 DeriveKeyUsage = 1 << 5, 301 DeriveKeyUsage = 1 << 5,
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 switch (key.algorithm().paramsType()) { 522 switch (key.algorithm().paramsType()) {
513 case WebCryptoKeyAlgorithmParamsTypeAes: 523 case WebCryptoKeyAlgorithmParamsTypeAes:
514 doWriteAesKey(key); 524 doWriteAesKey(key);
515 break; 525 break;
516 case WebCryptoKeyAlgorithmParamsTypeHmac: 526 case WebCryptoKeyAlgorithmParamsTypeHmac:
517 doWriteHmacKey(key); 527 doWriteHmacKey(key);
518 break; 528 break;
519 case WebCryptoKeyAlgorithmParamsTypeRsaHashed: 529 case WebCryptoKeyAlgorithmParamsTypeRsaHashed:
520 doWriteRsaHashedKey(key); 530 doWriteRsaHashedKey(key);
521 break; 531 break;
532 case WebCryptoKeyAlgorithmParamsTypeEc:
533 doWriteEcKey(key);
534 break;
522 case WebCryptoKeyAlgorithmParamsTypeNone: 535 case WebCryptoKeyAlgorithmParamsTypeNone:
523 ASSERT_NOT_REACHED(); 536 ASSERT_NOT_REACHED();
524 return false; 537 return false;
525 } 538 }
526 539
527 doWriteKeyUsages(key.usages(), key.extractable()); 540 doWriteKeyUsages(key.usages(), key.extractable());
528 541
529 WebVector<uint8_t> keyData; 542 WebVector<uint8_t> keyData;
530 if (!Platform::current()->crypto()->serializeKeyForClone(key, keyData)) 543 if (!Platform::current()->crypto()->serializeKeyForClone(key, keyData))
531 return false; 544 return false;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 ASSERT(!(key.algorithm().aesParams()->lengthBits() % 8)); 742 ASSERT(!(key.algorithm().aesParams()->lengthBits() % 8));
730 doWriteUint32(key.algorithm().aesParams()->lengthBits() / 8); 743 doWriteUint32(key.algorithm().aesParams()->lengthBits() / 8);
731 } 744 }
732 745
733 void doWriteRsaHashedKey(const WebCryptoKey& key) 746 void doWriteRsaHashedKey(const WebCryptoKey& key)
734 { 747 {
735 ASSERT(key.algorithm().rsaHashedParams()); 748 ASSERT(key.algorithm().rsaHashedParams());
736 append(static_cast<uint8_t>(RsaHashedKeyTag)); 749 append(static_cast<uint8_t>(RsaHashedKeyTag));
737 750
738 doWriteAlgorithmId(key.algorithm().id()); 751 doWriteAlgorithmId(key.algorithm().id());
739 752 doWriteAsymmetricKeyType(key.type());
740 switch (key.type()) {
741 case WebCryptoKeyTypePublic:
742 doWriteUint32(PublicKeyType);
743 break;
744 case WebCryptoKeyTypePrivate:
745 doWriteUint32(PrivateKeyType);
746 break;
747 case WebCryptoKeyTypeSecret:
748 ASSERT_NOT_REACHED();
749 }
750 753
751 const WebCryptoRsaHashedKeyAlgorithmParams* params = key.algorithm().rsa HashedParams(); 754 const WebCryptoRsaHashedKeyAlgorithmParams* params = key.algorithm().rsa HashedParams();
752 doWriteUint32(params->modulusLengthBits()); 755 doWriteUint32(params->modulusLengthBits());
753 doWriteUint32(params->publicExponent().size()); 756 doWriteUint32(params->publicExponent().size());
754 append(params->publicExponent().data(), params->publicExponent().size()) ; 757 append(params->publicExponent().data(), params->publicExponent().size()) ;
755 doWriteAlgorithmId(key.algorithm().rsaHashedParams()->hash().id()); 758 doWriteAlgorithmId(params->hash().id());
759 }
760
761 void doWriteEcKey(const WebCryptoKey& key)
762 {
763 ASSERT(key.algorithm().ecParams());
764 append(static_cast<uint8_t>(EcKeyTag));
765
766 doWriteAlgorithmId(key.algorithm().id());
767 doWriteAsymmetricKeyType(key.type());
768 doWriteNamedCurve(key.algorithm().ecParams()->namedCurve());
756 } 769 }
757 770
758 void doWriteAlgorithmId(WebCryptoAlgorithmId id) 771 void doWriteAlgorithmId(WebCryptoAlgorithmId id)
759 { 772 {
760 switch (id) { 773 switch (id) {
761 case WebCryptoAlgorithmIdAesCbc: 774 case WebCryptoAlgorithmIdAesCbc:
762 return doWriteUint32(AesCbcTag); 775 return doWriteUint32(AesCbcTag);
763 case WebCryptoAlgorithmIdHmac: 776 case WebCryptoAlgorithmIdHmac:
764 return doWriteUint32(HmacTag); 777 return doWriteUint32(HmacTag);
765 case WebCryptoAlgorithmIdRsaSsaPkcs1v1_5: 778 case WebCryptoAlgorithmIdRsaSsaPkcs1v1_5:
766 return doWriteUint32(RsaSsaPkcs1v1_5Tag); 779 return doWriteUint32(RsaSsaPkcs1v1_5Tag);
767 case WebCryptoAlgorithmIdSha1: 780 case WebCryptoAlgorithmIdSha1:
768 return doWriteUint32(Sha1Tag); 781 return doWriteUint32(Sha1Tag);
769 case WebCryptoAlgorithmIdSha256: 782 case WebCryptoAlgorithmIdSha256:
770 return doWriteUint32(Sha256Tag); 783 return doWriteUint32(Sha256Tag);
771 case WebCryptoAlgorithmIdSha384: 784 case WebCryptoAlgorithmIdSha384:
772 return doWriteUint32(Sha384Tag); 785 return doWriteUint32(Sha384Tag);
773 case WebCryptoAlgorithmIdSha512: 786 case WebCryptoAlgorithmIdSha512:
774 return doWriteUint32(Sha512Tag); 787 return doWriteUint32(Sha512Tag);
775 case WebCryptoAlgorithmIdAesGcm: 788 case WebCryptoAlgorithmIdAesGcm:
776 return doWriteUint32(AesGcmTag); 789 return doWriteUint32(AesGcmTag);
777 case WebCryptoAlgorithmIdRsaOaep: 790 case WebCryptoAlgorithmIdRsaOaep:
778 return doWriteUint32(RsaOaepTag); 791 return doWriteUint32(RsaOaepTag);
779 case WebCryptoAlgorithmIdAesCtr: 792 case WebCryptoAlgorithmIdAesCtr:
780 return doWriteUint32(AesCtrTag); 793 return doWriteUint32(AesCtrTag);
781 case WebCryptoAlgorithmIdAesKw: 794 case WebCryptoAlgorithmIdAesKw:
782 return doWriteUint32(AesKwTag); 795 return doWriteUint32(AesKwTag);
783 case WebCryptoAlgorithmIdRsaPss: 796 case WebCryptoAlgorithmIdRsaPss:
784 return doWriteUint32(RsaPssTag); 797 return doWriteUint32(RsaPssTag);
798 case WebCryptoAlgorithmIdEcdsa:
799 return doWriteUint32(EcdsaTag);
785 } 800 }
786 ASSERT_NOT_REACHED(); 801 ASSERT_NOT_REACHED();
787 } 802 }
803
804 void doWriteAsymmetricKeyType(WebCryptoKeyType keyType)
805 {
806 switch (keyType) {
807 case WebCryptoKeyTypePublic:
808 doWriteUint32(PublicKeyType);
809 break;
810 case WebCryptoKeyTypePrivate:
811 doWriteUint32(PrivateKeyType);
812 break;
813 case WebCryptoKeyTypeSecret:
814 ASSERT_NOT_REACHED();
815 }
816 }
817
818 void doWriteNamedCurve(WebCryptoNamedCurve namedCurve)
819 {
820 switch (namedCurve) {
821 case WebCryptoNamedCurveP256:
822 return doWriteUint32(P256Tag);
823 case WebCryptoNamedCurveP384:
824 return doWriteUint32(P384Tag);
825 case WebCryptoNamedCurveP521:
826 return doWriteUint32(P521Tag);
827 }
828 ASSERT_NOT_REACHED();
829 }
788 830
789 void doWriteKeyUsages(const WebCryptoKeyUsageMask usages, bool extractable) 831 void doWriteKeyUsages(const WebCryptoKeyUsageMask usages, bool extractable)
790 { 832 {
791 // Reminder to update this when adding new key usages. 833 // Reminder to update this when adding new key usages.
792 COMPILE_ASSERT(EndOfWebCryptoKeyUsage == (1 << 7) + 1, UpdateMe); 834 COMPILE_ASSERT(EndOfWebCryptoKeyUsage == (1 << 7) + 1, UpdateMe);
793 835
794 uint32_t value = 0; 836 uint32_t value = 0;
795 837
796 if (extractable) 838 if (extractable)
797 value |= ExtractableUsage; 839 value |= ExtractableUsage;
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after
2252 return false; 2294 return false;
2253 break; 2295 break;
2254 case HmacKeyTag: 2296 case HmacKeyTag:
2255 if (!doReadHmacKey(algorithm, type)) 2297 if (!doReadHmacKey(algorithm, type))
2256 return false; 2298 return false;
2257 break; 2299 break;
2258 case RsaHashedKeyTag: 2300 case RsaHashedKeyTag:
2259 if (!doReadRsaHashedKey(algorithm, type)) 2301 if (!doReadRsaHashedKey(algorithm, type))
2260 return false; 2302 return false;
2261 break; 2303 break;
2304 case EcKeyTag:
2305 if (!doReadEcKey(algorithm, type))
2306 return false;
2307 break;
2262 default: 2308 default:
2263 return false; 2309 return false;
2264 } 2310 }
2265 2311
2266 WebCryptoKeyUsageMask usages; 2312 WebCryptoKeyUsageMask usages;
2267 bool extractable; 2313 bool extractable;
2268 if (!doReadKeyUsages(usages, extractable)) 2314 if (!doReadKeyUsages(usages, extractable))
2269 return false; 2315 return false;
2270 2316
2271 uint32_t keyDataLength; 2317 uint32_t keyDataLength;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
2419 type = WebCryptoKeyTypeSecret; 2465 type = WebCryptoKeyTypeSecret;
2420 return !algorithm.isNull(); 2466 return !algorithm.isNull();
2421 } 2467 }
2422 2468
2423 bool doReadRsaHashedKey(WebCryptoKeyAlgorithm& algorithm, WebCryptoKeyType& type) 2469 bool doReadRsaHashedKey(WebCryptoKeyAlgorithm& algorithm, WebCryptoKeyType& type)
2424 { 2470 {
2425 WebCryptoAlgorithmId id; 2471 WebCryptoAlgorithmId id;
2426 if (!doReadAlgorithmId(id)) 2472 if (!doReadAlgorithmId(id))
2427 return false; 2473 return false;
2428 2474
2429 uint32_t rawType; 2475 if (!doReadAsymmetricKeyType(type))
2430 if (!doReadUint32(&rawType))
2431 return false; 2476 return false;
2432 2477
2433 switch (static_cast<AssymetricCryptoKeyType>(rawType)) {
2434 case PublicKeyType:
2435 type = WebCryptoKeyTypePublic;
2436 break;
2437 case PrivateKeyType:
2438 type = WebCryptoKeyTypePrivate;
2439 break;
2440 default:
2441 return false;
2442 }
2443
2444 uint32_t modulusLengthBits; 2478 uint32_t modulusLengthBits;
2445 if (!doReadUint32(&modulusLengthBits)) 2479 if (!doReadUint32(&modulusLengthBits))
2446 return false; 2480 return false;
2447 2481
2448 uint32_t publicExponentSize; 2482 uint32_t publicExponentSize;
2449 if (!doReadUint32(&publicExponentSize)) 2483 if (!doReadUint32(&publicExponentSize))
2450 return false; 2484 return false;
2451 2485
2452 if (m_position + publicExponentSize > m_length) 2486 if (m_position + publicExponentSize > m_length)
2453 return false; 2487 return false;
2454 2488
2455 const uint8_t* publicExponent = m_buffer + m_position; 2489 const uint8_t* publicExponent = m_buffer + m_position;
2456 m_position += publicExponentSize; 2490 m_position += publicExponentSize;
2457 2491
2458 WebCryptoAlgorithmId hash; 2492 WebCryptoAlgorithmId hash;
2459 if (!doReadAlgorithmId(hash)) 2493 if (!doReadAlgorithmId(hash))
2460 return false; 2494 return false;
2461 algorithm = WebCryptoKeyAlgorithm::createRsaHashed(id, modulusLengthBits , publicExponent, publicExponentSize, hash); 2495 algorithm = WebCryptoKeyAlgorithm::createRsaHashed(id, modulusLengthBits , publicExponent, publicExponentSize, hash);
2462 2496
2463 return !algorithm.isNull(); 2497 return !algorithm.isNull();
2464 } 2498 }
2465 2499
2500 bool doReadEcKey(WebCryptoKeyAlgorithm& algorithm, WebCryptoKeyType& type)
2501 {
2502 WebCryptoAlgorithmId id;
2503 if (!doReadAlgorithmId(id))
2504 return false;
2505
2506 if (!doReadAsymmetricKeyType(type))
2507 return false;
2508
2509 WebCryptoNamedCurve namedCurve;
2510 if (!doReadNamedCurve(namedCurve))
2511 return false;
2512
2513 algorithm = WebCryptoKeyAlgorithm::createEc(id, namedCurve);
2514 return !algorithm.isNull();
2515 }
2516
2466 bool doReadAlgorithmId(WebCryptoAlgorithmId& id) 2517 bool doReadAlgorithmId(WebCryptoAlgorithmId& id)
2467 { 2518 {
2468 uint32_t rawId; 2519 uint32_t rawId;
2469 if (!doReadUint32(&rawId)) 2520 if (!doReadUint32(&rawId))
2470 return false; 2521 return false;
2471 2522
2472 switch (static_cast<CryptoKeyAlgorithmTag>(rawId)) { 2523 switch (static_cast<CryptoKeyAlgorithmTag>(rawId)) {
2473 case AesCbcTag: 2524 case AesCbcTag:
2474 id = WebCryptoAlgorithmIdAesCbc; 2525 id = WebCryptoAlgorithmIdAesCbc;
2475 return true; 2526 return true;
(...skipping 23 matching lines...) Expand all
2499 return true; 2550 return true;
2500 case AesCtrTag: 2551 case AesCtrTag:
2501 id = WebCryptoAlgorithmIdAesCtr; 2552 id = WebCryptoAlgorithmIdAesCtr;
2502 return true; 2553 return true;
2503 case AesKwTag: 2554 case AesKwTag:
2504 id = WebCryptoAlgorithmIdAesKw; 2555 id = WebCryptoAlgorithmIdAesKw;
2505 return true; 2556 return true;
2506 case RsaPssTag: 2557 case RsaPssTag:
2507 id = WebCryptoAlgorithmIdRsaPss; 2558 id = WebCryptoAlgorithmIdRsaPss;
2508 return true; 2559 return true;
2560 case EcdsaTag:
2561 id = WebCryptoAlgorithmIdEcdsa;
2562 return true;
2509 } 2563 }
2510 2564
2511 return false; 2565 return false;
2566 }
2567
2568 bool doReadAsymmetricKeyType(WebCryptoKeyType& type)
2569 {
2570 uint32_t rawType;
2571 if (!doReadUint32(&rawType))
2572 return false;
2573
2574 switch (static_cast<AssymetricCryptoKeyType>(rawType)) {
2575 case PublicKeyType:
2576 type = WebCryptoKeyTypePublic;
2577 return true;
2578 case PrivateKeyType:
2579 type = WebCryptoKeyTypePrivate;
2580 return true;
2581 }
2582
2583 return false;
2584 }
2585
2586 bool doReadNamedCurve(WebCryptoNamedCurve& namedCurve)
2587 {
2588 uint32_t rawName;
2589 if (!doReadUint32(&rawName))
2590 return false;
2591
2592 switch (static_cast<NamedCurveTag>(rawName)) {
2593 case P256Tag:
2594 namedCurve = WebCryptoNamedCurveP256;
2595 return true;
2596 case P384Tag:
2597 namedCurve = WebCryptoNamedCurveP384;
2598 return true;
2599 case P521Tag:
2600 namedCurve = WebCryptoNamedCurveP521;
2601 return true;
2602 }
2603
2604 return false;
2512 } 2605 }
2513 2606
2514 bool doReadKeyUsages(WebCryptoKeyUsageMask& usages, bool& extractable) 2607 bool doReadKeyUsages(WebCryptoKeyUsageMask& usages, bool& extractable)
2515 { 2608 {
2516 // Reminder to update this when adding new key usages. 2609 // Reminder to update this when adding new key usages.
2517 COMPILE_ASSERT(EndOfWebCryptoKeyUsage == (1 << 7) + 1, UpdateMe); 2610 COMPILE_ASSERT(EndOfWebCryptoKeyUsage == (1 << 7) + 1, UpdateMe);
2518 const uint32_t allPossibleUsages = ExtractableUsage | EncryptUsage | Dec ryptUsage | SignUsage | VerifyUsage | DeriveKeyUsage | WrapKeyUsage | UnwrapKeyU sage | DeriveBitsUsage; 2611 const uint32_t allPossibleUsages = ExtractableUsage | EncryptUsage | Dec ryptUsage | SignUsage | VerifyUsage | DeriveKeyUsage | WrapKeyUsage | UnwrapKeyU sage | DeriveBitsUsage;
2519 2612
2520 uint32_t rawUsages; 2613 uint32_t rawUsages;
2521 if (!doReadUint32(&rawUsages)) 2614 if (!doReadUint32(&rawUsages))
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
3065 // If the allocated memory was not registered before, then this class is lik ely 3158 // If the allocated memory was not registered before, then this class is lik ely
3066 // used in a context other then Worker's onmessage environment and the prese nce of 3159 // used in a context other then Worker's onmessage environment and the prese nce of
3067 // current v8 context is not guaranteed. Avoid calling v8 then. 3160 // current v8 context is not guaranteed. Avoid calling v8 then.
3068 if (m_externallyAllocatedMemory) { 3161 if (m_externallyAllocatedMemory) {
3069 ASSERT(v8::Isolate::GetCurrent()); 3162 ASSERT(v8::Isolate::GetCurrent());
3070 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte rnallyAllocatedMemory); 3163 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte rnallyAllocatedMemory);
3071 } 3164 }
3072 } 3165 }
3073 3166
3074 } // namespace blink 3167 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/modules/crypto/NormalizeAlgorithm.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698