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 <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
11 #include "third_party/WebKit/public/platform/WebCrypto.h" | 12 #include "third_party/WebKit/public/platform/WebCrypto.h" |
12 | 13 |
13 namespace content { | 14 namespace content { |
14 | 15 |
15 namespace webcrypto { | 16 namespace webcrypto { |
16 | 17 |
17 class CryptoData; | 18 class CryptoData; |
(...skipping 19 matching lines...) Expand all Loading... |
37 // to Encrypt()/Decrypt() the corresponding key usages may not be present | 38 // to Encrypt()/Decrypt() the corresponding key usages may not be present |
38 // (when wrapping/unwrapping). | 39 // (when wrapping/unwrapping). |
39 class AlgorithmImplementation { | 40 class AlgorithmImplementation { |
40 public: | 41 public: |
41 virtual ~AlgorithmImplementation(); | 42 virtual ~AlgorithmImplementation(); |
42 | 43 |
43 // This method corresponds to Web Crypto's crypto.subtle.encrypt(). | 44 // This method corresponds to Web Crypto's crypto.subtle.encrypt(). |
44 virtual Status Encrypt(const blink::WebCryptoAlgorithm& algorithm, | 45 virtual Status Encrypt(const blink::WebCryptoAlgorithm& algorithm, |
45 const blink::WebCryptoKey& key, | 46 const blink::WebCryptoKey& key, |
46 const CryptoData& data, | 47 const CryptoData& data, |
47 std::vector<uint8>* buffer) const; | 48 std::vector<uint8_t>* buffer) const; |
48 | 49 |
49 // This method corresponds to Web Crypto's crypto.subtle.decrypt(). | 50 // This method corresponds to Web Crypto's crypto.subtle.decrypt(). |
50 virtual Status Decrypt(const blink::WebCryptoAlgorithm& algorithm, | 51 virtual Status Decrypt(const blink::WebCryptoAlgorithm& algorithm, |
51 const blink::WebCryptoKey& key, | 52 const blink::WebCryptoKey& key, |
52 const CryptoData& data, | 53 const CryptoData& data, |
53 std::vector<uint8>* buffer) const; | 54 std::vector<uint8_t>* buffer) const; |
54 | 55 |
55 // This method corresponds to Web Crypto's crypto.subtle.sign(). | 56 // This method corresponds to Web Crypto's crypto.subtle.sign(). |
56 virtual Status Sign(const blink::WebCryptoAlgorithm& algorithm, | 57 virtual Status Sign(const blink::WebCryptoAlgorithm& algorithm, |
57 const blink::WebCryptoKey& key, | 58 const blink::WebCryptoKey& key, |
58 const CryptoData& data, | 59 const CryptoData& data, |
59 std::vector<uint8>* buffer) const; | 60 std::vector<uint8_t>* buffer) const; |
60 | 61 |
61 // This method corresponds to Web Crypto's crypto.subtle.verify(). | 62 // This method corresponds to Web Crypto's crypto.subtle.verify(). |
62 virtual Status Verify(const blink::WebCryptoAlgorithm& algorithm, | 63 virtual Status Verify(const blink::WebCryptoAlgorithm& algorithm, |
63 const blink::WebCryptoKey& key, | 64 const blink::WebCryptoKey& key, |
64 const CryptoData& signature, | 65 const CryptoData& signature, |
65 const CryptoData& data, | 66 const CryptoData& data, |
66 bool* signature_match) const; | 67 bool* signature_match) const; |
67 | 68 |
68 // This method corresponds to Web Crypto's crypto.subtle.digest(). | 69 // This method corresponds to Web Crypto's crypto.subtle.digest(). |
69 virtual Status Digest(const blink::WebCryptoAlgorithm& algorithm, | 70 virtual Status Digest(const blink::WebCryptoAlgorithm& algorithm, |
70 const CryptoData& data, | 71 const CryptoData& data, |
71 std::vector<uint8>* buffer) const; | 72 std::vector<uint8_t>* buffer) const; |
72 | 73 |
73 // VerifyKeyUsagesBeforeGenerateKey() must be called prior to | 74 // VerifyKeyUsagesBeforeGenerateKey() must be called prior to |
74 // GenerateSecretKey() to validate the requested key usages. | 75 // GenerateSecretKey() to validate the requested key usages. |
75 virtual Status VerifyKeyUsagesBeforeGenerateKey( | 76 virtual Status VerifyKeyUsagesBeforeGenerateKey( |
76 blink::WebCryptoKeyUsageMask usage_mask) const; | 77 blink::WebCryptoKeyUsageMask usage_mask) const; |
77 | 78 |
78 // This method corresponds to Web Crypto's crypto.subtle.generateKey(). | 79 // This method corresponds to Web Crypto's crypto.subtle.generateKey(). |
79 virtual Status GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm, | 80 virtual Status GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm, |
80 bool extractable, | 81 bool extractable, |
81 blink::WebCryptoKeyUsageMask usage_mask, | 82 blink::WebCryptoKeyUsageMask usage_mask, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 const blink::WebCryptoAlgorithm& algorithm, | 148 const blink::WebCryptoAlgorithm& algorithm, |
148 bool extractable, | 149 bool extractable, |
149 blink::WebCryptoKeyUsageMask usage_mask, | 150 blink::WebCryptoKeyUsageMask usage_mask, |
150 blink::WebCryptoKey* key) const; | 151 blink::WebCryptoKey* key) const; |
151 | 152 |
152 // ----------------------------------------------- | 153 // ----------------------------------------------- |
153 // Key export | 154 // Key export |
154 // ----------------------------------------------- | 155 // ----------------------------------------------- |
155 | 156 |
156 virtual Status ExportKeyRaw(const blink::WebCryptoKey& key, | 157 virtual Status ExportKeyRaw(const blink::WebCryptoKey& key, |
157 std::vector<uint8>* buffer) const; | 158 std::vector<uint8_t>* buffer) const; |
158 | 159 |
159 virtual Status ExportKeyPkcs8(const blink::WebCryptoKey& key, | 160 virtual Status ExportKeyPkcs8(const blink::WebCryptoKey& key, |
160 std::vector<uint8>* buffer) const; | 161 std::vector<uint8_t>* buffer) const; |
161 | 162 |
162 virtual Status ExportKeySpki(const blink::WebCryptoKey& key, | 163 virtual Status ExportKeySpki(const blink::WebCryptoKey& key, |
163 std::vector<uint8>* buffer) const; | 164 std::vector<uint8_t>* buffer) const; |
164 | 165 |
165 virtual Status ExportKeyJwk(const blink::WebCryptoKey& key, | 166 virtual Status ExportKeyJwk(const blink::WebCryptoKey& key, |
166 std::vector<uint8>* buffer) const; | 167 std::vector<uint8_t>* buffer) const; |
167 }; | 168 }; |
168 | 169 |
169 } // namespace webcrypto | 170 } // namespace webcrypto |
170 | 171 |
171 } // namespace content | 172 } // namespace content |
172 | 173 |
173 #endif // CONTENT_CHILD_WEBCRYPTO_CRYPTO_ALGORITHM_IMPLEMENTATION_H_ | 174 #endif // CONTENT_CHILD_WEBCRYPTO_CRYPTO_ALGORITHM_IMPLEMENTATION_H_ |
OLD | NEW |