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