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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // algorithm that is not SHA*. | 60 // algorithm that is not SHA*. |
61 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateHmacImportAlgorithm( | 61 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateHmacImportAlgorithm( |
62 blink::WebCryptoAlgorithmId hash_id); | 62 blink::WebCryptoAlgorithmId hash_id); |
63 | 63 |
64 // Creates an import algorithm for RSA algorithms that take a hash. | 64 // Creates an import algorithm for RSA algorithms that take a hash. |
65 // It is an error to call this with a hash_id that is not a SHA*. | 65 // It is an error to call this with a hash_id that is not a SHA*. |
66 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateRsaHashedImportAlgorithm( | 66 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateRsaHashedImportAlgorithm( |
67 blink::WebCryptoAlgorithmId id, | 67 blink::WebCryptoAlgorithmId id, |
68 blink::WebCryptoAlgorithmId hash_id); | 68 blink::WebCryptoAlgorithmId hash_id); |
69 | 69 |
70 bool CreateSecretKeyAlgorithm(const blink::WebCryptoAlgorithm& algorithm, | |
71 unsigned int keylen_bytes, | |
72 blink::WebCryptoKeyAlgorithm* key_algorithm); | |
73 | |
74 // Returns true if the set bits in b make up a subset of the set bits in a. | 70 // Returns true if the set bits in b make up a subset of the set bits in a. |
75 bool ContainsKeyUsages(blink::WebCryptoKeyUsageMask a, | 71 bool ContainsKeyUsages(blink::WebCryptoKeyUsageMask a, |
76 blink::WebCryptoKeyUsageMask b); | 72 blink::WebCryptoKeyUsageMask b); |
77 | 73 |
| 74 bool KeyUsageAllows(const blink::WebCryptoKey& key, |
| 75 const blink::WebCryptoKeyUsage usage); |
| 76 |
78 bool IsAlgorithmRsa(blink::WebCryptoAlgorithmId alg_id); | 77 bool IsAlgorithmRsa(blink::WebCryptoAlgorithmId alg_id); |
79 bool IsAlgorithmAsymmetric(blink::WebCryptoAlgorithmId alg_id); | 78 bool IsAlgorithmAsymmetric(blink::WebCryptoAlgorithmId alg_id); |
80 | 79 |
| 80 Status GetAesGcmTagLengthInBits(const blink::WebCryptoAesGcmParams* params, |
| 81 unsigned int* tag_length_bits); |
| 82 |
| 83 Status GetAesKeyGenLengthInBits(const blink::WebCryptoAesKeyGenParams* params, |
| 84 unsigned int* keylen_bits); |
| 85 |
| 86 Status GetHmacKeyGenLengthInBits(const blink::WebCryptoHmacKeyGenParams* params, |
| 87 unsigned int* keylen_bits); |
| 88 |
| 89 Status VerifyAesKeyLengthForImport(unsigned int keylen_bytes); |
| 90 |
| 91 Status CheckKeyCreationUsages(blink::WebCryptoKeyUsageMask all_possible_usages, |
| 92 blink::WebCryptoKeyUsageMask actual_usages); |
| 93 |
81 } // namespace webcrypto | 94 } // namespace webcrypto |
82 | 95 |
83 } // namespace content | 96 } // namespace content |
84 | 97 |
85 #endif // CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_UTIL_H_ | 98 #endif // CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
OLD | NEW |