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_CRYPTO_ALGORITHM_IMPLEMENTATION_H_ | 5 #ifndef CONTENT_CHILD_WEBCRYPTO_CRYPTO_ALGORITHM_IMPLEMENTATION_H_ |
6 #define CONTENT_CHILD_WEBCRYPTO_CRYPTO_ALGORITHM_IMPLEMENTATION_H_ | 6 #define CONTENT_CHILD_WEBCRYPTO_CRYPTO_ALGORITHM_IMPLEMENTATION_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 const blink::WebCryptoKey& key, | 64 const blink::WebCryptoKey& key, |
65 const CryptoData& signature, | 65 const CryptoData& signature, |
66 const CryptoData& data, | 66 const CryptoData& data, |
67 bool* signature_match) const; | 67 bool* signature_match) const; |
68 | 68 |
69 // This method corresponds to Web Crypto's crypto.subtle.digest(). | 69 // This method corresponds to Web Crypto's crypto.subtle.digest(). |
70 virtual Status Digest(const blink::WebCryptoAlgorithm& algorithm, | 70 virtual Status Digest(const blink::WebCryptoAlgorithm& algorithm, |
71 const CryptoData& data, | 71 const CryptoData& data, |
72 std::vector<uint8_t>* buffer) const; | 72 std::vector<uint8_t>* buffer) const; |
73 | 73 |
74 // VerifyKeyUsagesBeforeGenerateKey() must be called prior to | |
75 // GenerateSecretKey() to validate the requested key usages. | |
76 virtual Status VerifyKeyUsagesBeforeGenerateKey( | |
77 blink::WebCryptoKeyUsageMask usage_mask) const; | |
78 | |
79 // This method corresponds to Web Crypto's crypto.subtle.generateKey(). | 74 // This method corresponds to Web Crypto's crypto.subtle.generateKey(). |
80 virtual Status GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm, | 75 // In the case of a symmetric algorithm, the secret key should be written to |
81 bool extractable, | 76 // |*private_key|. |
82 blink::WebCryptoKeyUsageMask usage_mask, | 77 // |
83 blink::WebCryptoKey* key) const; | 78 // Implementations MUST verify |usage_mask| and return an error if it is not |
84 | 79 // appropriate. |
85 // VerifyKeyUsagesBeforeGenerateKeyPair() must be called prior to | 80 virtual Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, |
86 // GenerateKeyPair() to validate the requested key usages. | 81 bool extractable, |
87 virtual Status VerifyKeyUsagesBeforeGenerateKeyPair( | 82 blink::WebCryptoKeyUsageMask usage_mask, |
88 blink::WebCryptoKeyUsageMask combined_usage_mask, | 83 blink::WebCryptoKey* public_key, |
89 blink::WebCryptoKeyUsageMask* public_usage_mask, | 84 blink::WebCryptoKey* private_key) const; |
90 blink::WebCryptoKeyUsageMask* private_usage_mask) const; | |
91 | |
92 // This method corresponds to Web Crypto's crypto.subtle.generateKey(). | |
93 virtual Status GenerateKeyPair( | |
94 const blink::WebCryptoAlgorithm& algorithm, | |
95 bool extractable, | |
96 blink::WebCryptoKeyUsageMask public_usage_mask, | |
97 blink::WebCryptoKeyUsageMask private_usage_mask, | |
98 blink::WebCryptoKey* public_key, | |
99 blink::WebCryptoKey* private_key) const; | |
100 | 85 |
101 // ----------------------------------------------- | 86 // ----------------------------------------------- |
102 // Key import | 87 // Key import |
103 // ----------------------------------------------- | 88 // ----------------------------------------------- |
104 | 89 |
105 // VerifyKeyUsagesBeforeImportKey() must be called before either | 90 // VerifyKeyUsagesBeforeImportKey() must be called before either |
106 // importing a key, or unwrapping a key. | 91 // importing a key, or unwrapping a key. |
107 // | 92 // |
108 // Implementations should return an error if the requested usages are invalid | 93 // Implementations should return an error if the requested usages are invalid |
109 // when importing for the specified format. | 94 // when importing for the specified format. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 150 |
166 virtual Status ExportKeyJwk(const blink::WebCryptoKey& key, | 151 virtual Status ExportKeyJwk(const blink::WebCryptoKey& key, |
167 std::vector<uint8_t>* buffer) const; | 152 std::vector<uint8_t>* buffer) const; |
168 }; | 153 }; |
169 | 154 |
170 } // namespace webcrypto | 155 } // namespace webcrypto |
171 | 156 |
172 } // namespace content | 157 } // namespace content |
173 | 158 |
174 #endif // CONTENT_CHILD_WEBCRYPTO_CRYPTO_ALGORITHM_IMPLEMENTATION_H_ | 159 #endif // CONTENT_CHILD_WEBCRYPTO_CRYPTO_ALGORITHM_IMPLEMENTATION_H_ |
OLD | NEW |