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