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 <algorithm> | 5 #include <algorithm> |
6 #include <functional> | 6 #include <functional> |
7 #include <map> | 7 #include <map> |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "content/child/webcrypto/crypto_data.h" | 12 #include "content/child/webcrypto/crypto_data.h" |
13 #include "content/child/webcrypto/platform_crypto.h" | 13 #include "content/child/webcrypto/platform_crypto.h" |
14 #include "content/child/webcrypto/shared_crypto.h" | 14 #include "content/child/webcrypto/shared_crypto.h" |
15 #include "content/child/webcrypto/status.h" | 15 #include "content/child/webcrypto/status.h" |
16 #include "content/child/webcrypto/webcrypto_util.h" | 16 #include "content/child/webcrypto/webcrypto_util.h" |
17 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" | 17 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 | 20 |
21 namespace webcrypto { | 21 namespace webcrypto { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
| 25 // Creates an RSASSA-PKCS1-v1_5 algorithm. It is an error to call this with a |
| 26 // hash_id that is not a SHA*. |
| 27 blink::WebCryptoAlgorithm CreateRsaSsaImportAlgorithm( |
| 28 blink::WebCryptoAlgorithmId hash_id) { |
| 29 return CreateRsaHashedImportAlgorithm( |
| 30 blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, hash_id); |
| 31 } |
| 32 |
| 33 // Creates an RSA-OAEP algorithm. It is an error to call this with a hash_id |
| 34 // that is not a SHA*. |
| 35 blink::WebCryptoAlgorithm CreateRsaOaepImportAlgorithm( |
| 36 blink::WebCryptoAlgorithmId hash_id) { |
| 37 return CreateRsaHashedImportAlgorithm(blink::WebCryptoAlgorithmIdRsaOaep, |
| 38 hash_id); |
| 39 } |
| 40 |
25 // Web Crypto equivalent usage mask for JWK 'use' = 'enc'. | 41 // Web Crypto equivalent usage mask for JWK 'use' = 'enc'. |
26 // TODO(padolph): Add 'deriveBits' once supported by Blink. | 42 // TODO(padolph): Add 'deriveBits' once supported by Blink. |
27 const blink::WebCryptoKeyUsageMask kJwkEncUsage = | 43 const blink::WebCryptoKeyUsageMask kJwkEncUsage = |
28 blink::WebCryptoKeyUsageEncrypt | blink::WebCryptoKeyUsageDecrypt | | 44 blink::WebCryptoKeyUsageEncrypt | blink::WebCryptoKeyUsageDecrypt | |
29 blink::WebCryptoKeyUsageWrapKey | blink::WebCryptoKeyUsageUnwrapKey | | 45 blink::WebCryptoKeyUsageWrapKey | blink::WebCryptoKeyUsageUnwrapKey | |
30 blink::WebCryptoKeyUsageDeriveKey; | 46 blink::WebCryptoKeyUsageDeriveKey; |
31 // Web Crypto equivalent usage mask for JWK 'use' = 'sig'. | 47 // Web Crypto equivalent usage mask for JWK 'use' = 'sig'. |
32 const blink::WebCryptoKeyUsageMask kJwkSigUsage = | 48 const blink::WebCryptoKeyUsageMask kJwkSigUsage = |
33 blink::WebCryptoKeyUsageSign | blink::WebCryptoKeyUsageVerify; | 49 blink::WebCryptoKeyUsageSign | blink::WebCryptoKeyUsageVerify; |
34 | 50 |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 std::string json; | 836 std::string json; |
821 base::JSONWriter::Write(&jwk_dict, &json); | 837 base::JSONWriter::Write(&jwk_dict, &json); |
822 *buffer = CreateArrayBuffer(reinterpret_cast<const uint8*>(json.data()), | 838 *buffer = CreateArrayBuffer(reinterpret_cast<const uint8*>(json.data()), |
823 json.size()); | 839 json.size()); |
824 return Status::Success(); | 840 return Status::Success(); |
825 } | 841 } |
826 | 842 |
827 } // namespace webcrypto | 843 } // namespace webcrypto |
828 | 844 |
829 } // namespace content | 845 } // namespace content |
OLD | NEW |