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 "content/child/webcrypto/shared_crypto.h" | 5 #include "content/child/webcrypto/shared_crypto.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/child/webcrypto/crypto_data.h" | 8 #include "content/child/webcrypto/crypto_data.h" |
9 #include "content/child/webcrypto/platform_crypto.h" | 9 #include "content/child/webcrypto/platform_crypto.h" |
10 #include "content/child/webcrypto/status.h" | 10 #include "content/child/webcrypto/status.h" |
11 #include "content/child/webcrypto/webcrypto_util.h" | 11 #include "content/child/webcrypto/webcrypto_util.h" |
12 #include "crypto/secure_util.h" | 12 #include "crypto/secure_util.h" |
13 #include "jwk.h" | |
eroman
2014/03/25 23:43:37
use a full path:
"content/child/webcrypto/jwk.h"
padolph
2014/03/26 00:01:46
Oops, sorry. Done.
| |
13 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" | 14 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" |
14 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" | 15 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" |
15 #include "third_party/WebKit/public/platform/WebCryptoKey.h" | 16 #include "third_party/WebKit/public/platform/WebCryptoKey.h" |
16 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" | 17 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 | 20 |
20 namespace webcrypto { | 21 namespace webcrypto { |
21 | 22 |
22 namespace { | 23 namespace { |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
476 const blink::WebCryptoAlgorithm& wrapping_algorithm, | 477 const blink::WebCryptoAlgorithm& wrapping_algorithm, |
477 blink::WebArrayBuffer* buffer) { | 478 blink::WebArrayBuffer* buffer) { |
478 blink::WebArrayBuffer exported_data; | 479 blink::WebArrayBuffer exported_data; |
479 Status status = ExportKey(format, key_to_wrap, &exported_data); | 480 Status status = ExportKey(format, key_to_wrap, &exported_data); |
480 if (status.IsError()) | 481 if (status.IsError()) |
481 return status; | 482 return status; |
482 return EncryptDontCheckUsage( | 483 return EncryptDontCheckUsage( |
483 wrapping_algorithm, wrapping_key, CryptoData(exported_data), buffer); | 484 wrapping_algorithm, wrapping_key, CryptoData(exported_data), buffer); |
484 } | 485 } |
485 | 486 |
487 // Returns the internal block size for SHA-* | |
488 unsigned int ShaBlockSizeBytes(blink::WebCryptoAlgorithmId hash_id) { | |
489 switch (hash_id) { | |
490 case blink::WebCryptoAlgorithmIdSha1: | |
491 case blink::WebCryptoAlgorithmIdSha256: | |
492 return 64; | |
493 case blink::WebCryptoAlgorithmIdSha384: | |
494 case blink::WebCryptoAlgorithmIdSha512: | |
495 return 128; | |
496 default: | |
497 NOTREACHED(); | |
498 return 0; | |
499 } | |
500 } | |
501 | |
486 } // namespace | 502 } // namespace |
487 | 503 |
488 void Init() { platform::Init(); } | 504 void Init() { platform::Init(); } |
489 | 505 |
490 Status Encrypt(const blink::WebCryptoAlgorithm& algorithm, | 506 Status Encrypt(const blink::WebCryptoAlgorithm& algorithm, |
491 const blink::WebCryptoKey& key, | 507 const blink::WebCryptoKey& key, |
492 const CryptoData& data, | 508 const CryptoData& data, |
493 blink::WebArrayBuffer* buffer) { | 509 blink::WebArrayBuffer* buffer) { |
494 if (!KeyUsageAllows(key, blink::WebCryptoKeyUsageEncrypt)) | 510 if (!KeyUsageAllows(key, blink::WebCryptoKeyUsageEncrypt)) |
495 return Status::ErrorUnexpected(); | 511 return Status::ErrorUnexpected(); |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
807 key); | 823 key); |
808 if (status.IsError()) | 824 if (status.IsError()) |
809 return status; | 825 return status; |
810 | 826 |
811 return ValidateDeserializedKey(*key, algorithm, type); | 827 return ValidateDeserializedKey(*key, algorithm, type); |
812 } | 828 } |
813 | 829 |
814 } // namespace webcrypto | 830 } // namespace webcrypto |
815 | 831 |
816 } // namespace content | 832 } // namespace content |
OLD | NEW |