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 #ifndef CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_UTIL_H_ | 5 #ifndef CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
6 #define CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_UTIL_H_ | 6 #define CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "content/common/content_export.h" | |
13 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" | 12 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" |
14 #include "third_party/WebKit/public/platform/WebCryptoKey.h" | 13 #include "third_party/WebKit/public/platform/WebCryptoKey.h" |
15 | 14 |
16 namespace content { | 15 namespace components { |
17 | 16 |
18 namespace webcrypto { | 17 namespace webcrypto { |
19 | 18 |
20 class Status; | 19 class Status; |
21 | 20 |
22 // Creates a WebCryptoAlgorithm without any parameters. | 21 // Creates a WebCryptoAlgorithm without any parameters. |
23 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateAlgorithm( | 22 blink::WebCryptoAlgorithm CreateAlgorithm(blink::WebCryptoAlgorithmId id); |
24 blink::WebCryptoAlgorithmId id); | |
25 | 23 |
26 // Creates an HMAC import algorithm whose inner hash algorithm is determined by | 24 // Creates an HMAC import algorithm whose inner hash algorithm is determined by |
27 // the specified algorithm ID. It is an error to call this method with a hash | 25 // the specified algorithm ID. It is an error to call this method with a hash |
28 // algorithm that is not SHA*. | 26 // algorithm that is not SHA*. |
29 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateHmacImportAlgorithm( | 27 blink::WebCryptoAlgorithm CreateHmacImportAlgorithm( |
30 blink::WebCryptoAlgorithmId hash_id, | 28 blink::WebCryptoAlgorithmId hash_id, |
31 unsigned int length_bits); | 29 unsigned int length_bits); |
32 | 30 |
33 // Same as above but without specifying a length. | 31 // Same as above but without specifying a length. |
34 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateHmacImportAlgorithmNoLength( | 32 blink::WebCryptoAlgorithm CreateHmacImportAlgorithmNoLength( |
35 blink::WebCryptoAlgorithmId hash_id); | 33 blink::WebCryptoAlgorithmId hash_id); |
36 | 34 |
37 // Creates an import algorithm for RSA algorithms that take a hash. | 35 // Creates an import algorithm for RSA algorithms that take a hash. |
38 // It is an error to call this with a hash_id that is not a SHA*. | 36 // It is an error to call this with a hash_id that is not a SHA*. |
39 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateRsaHashedImportAlgorithm( | 37 blink::WebCryptoAlgorithm CreateRsaHashedImportAlgorithm( |
40 blink::WebCryptoAlgorithmId id, | 38 blink::WebCryptoAlgorithmId id, |
41 blink::WebCryptoAlgorithmId hash_id); | 39 blink::WebCryptoAlgorithmId hash_id); |
42 | 40 |
43 // Creates an import algorithm for EC keys. | 41 // Creates an import algorithm for EC keys. |
44 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateEcImportAlgorithm( | 42 blink::WebCryptoAlgorithm CreateEcImportAlgorithm( |
45 blink::WebCryptoAlgorithmId id, | 43 blink::WebCryptoAlgorithmId id, |
46 blink::WebCryptoNamedCurve named_curve); | 44 blink::WebCryptoNamedCurve named_curve); |
47 | 45 |
48 // Returns true if the set bits in b make up a subset of the set bits in a. | 46 // Returns true if the set bits in b make up a subset of the set bits in a. |
49 bool ContainsKeyUsages(blink::WebCryptoKeyUsageMask a, | 47 bool ContainsKeyUsages(blink::WebCryptoKeyUsageMask a, |
50 blink::WebCryptoKeyUsageMask b); | 48 blink::WebCryptoKeyUsageMask b); |
51 | 49 |
52 bool KeyUsageAllows(const blink::WebCryptoKey& key, | 50 bool KeyUsageAllows(const blink::WebCryptoKey& key, |
53 const blink::WebCryptoKeyUsage usage); | 51 const blink::WebCryptoKeyUsage usage); |
54 | 52 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // invalid. | 125 // invalid. |
128 Status GetUsagesForGenerateAsymmetricKey( | 126 Status GetUsagesForGenerateAsymmetricKey( |
129 blink::WebCryptoKeyUsageMask combined_usages, | 127 blink::WebCryptoKeyUsageMask combined_usages, |
130 blink::WebCryptoKeyUsageMask all_public_usages, | 128 blink::WebCryptoKeyUsageMask all_public_usages, |
131 blink::WebCryptoKeyUsageMask all_private_usages, | 129 blink::WebCryptoKeyUsageMask all_private_usages, |
132 blink::WebCryptoKeyUsageMask* public_usages, | 130 blink::WebCryptoKeyUsageMask* public_usages, |
133 blink::WebCryptoKeyUsageMask* private_usages); | 131 blink::WebCryptoKeyUsageMask* private_usages); |
134 | 132 |
135 } // namespace webcrypto | 133 } // namespace webcrypto |
136 | 134 |
137 } // namespace content | 135 } // namespace components |
138 | 136 |
139 #endif // CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_UTIL_H_ | 137 #endif // CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
OLD | NEW |