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_SHARED_CRYPTO_H_ | 5 #ifndef CONTENT_CHILD_WEBCRYPTO_SHARED_CRYPTO_H_ |
6 #define CONTENT_CHILD_WEBCRYPTO_SHARED_CRYPTO_H_ | 6 #define CONTENT_CHILD_WEBCRYPTO_SHARED_CRYPTO_H_ |
7 | 7 |
8 #include <vector> | |
Ryan Sleevi
2014/04/18 00:51:26
style nit: newline
| |
8 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
11 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
12 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" | 13 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" |
13 #include "third_party/WebKit/public/platform/WebCrypto.h" | 14 #include "third_party/WebKit/public/platform/WebCrypto.h" |
14 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" | 15 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 | 18 |
(...skipping 12 matching lines...) Expand all Loading... | |
30 // | 31 // |
31 // Blink | 32 // Blink |
32 // | | 33 // | |
33 // ==============|========================== | 34 // ==============|========================== |
34 // | | 35 // | |
35 // content | 36 // content |
36 // | | 37 // | |
37 // | | 38 // | |
38 // v | 39 // v |
39 // WebCryptoImpl (Implements the blink::WebCrypto interface for | 40 // WebCryptoImpl (Implements the blink::WebCrypto interface for |
40 // | asynchronous completions) | 41 // | asynchronous completions; posts tasks to |
42 // | the webcrypto worker pool to fulfill the request | |
43 // using the synchronous methods of shared_crypto.h) | |
41 // | | 44 // | |
42 // | [shared_crypto_unittest.cc] | 45 // | [shared_crypto_unittest.cc] |
43 // | / | 46 // | / |
44 // | / (The blink::WebCrypto interface is not | 47 // | / (The blink::WebCrypto interface is not |
45 // | / testable from the chromium side because | 48 // | / testable from the chromium side because |
46 // | / the result object is not mockable. | 49 // | / the result object is not mockable. |
47 // | / Tests are done on shared_crypto instead. | 50 // | / Tests are done on shared_crypto instead. |
48 // V v | 51 // V v |
49 // [shared_crypto.h] (Exposes synchronous functions in the | 52 // [shared_crypto.h] (Exposes synchronous functions in the |
50 // | webcrypto:: namespace. This does | 53 // | webcrypto:: namespace. This does |
(...skipping 18 matching lines...) Expand all Loading... | |
69 // * Validating algorithm with key.algorithm | 72 // * Validating algorithm with key.algorithm |
70 // * Converting the blink key to a more specific platform::{PublicKey, | 73 // * Converting the blink key to a more specific platform::{PublicKey, |
71 // PrivateKey, SymKey} and making sure it was the right type. | 74 // PrivateKey, SymKey} and making sure it was the right type. |
72 // * Validating alogorithm specific parameters (for instance, was the iv for | 75 // * Validating alogorithm specific parameters (for instance, was the iv for |
73 // AES-CBC 16 bytes). | 76 // AES-CBC 16 bytes). |
74 // * Parse a JWK | 77 // * Parse a JWK |
75 | 78 |
76 CONTENT_EXPORT Status Encrypt(const blink::WebCryptoAlgorithm& algorithm, | 79 CONTENT_EXPORT Status Encrypt(const blink::WebCryptoAlgorithm& algorithm, |
77 const blink::WebCryptoKey& key, | 80 const blink::WebCryptoKey& key, |
78 const CryptoData& data, | 81 const CryptoData& data, |
79 blink::WebArrayBuffer* buffer); | 82 std::vector<uint8>* buffer); |
80 | 83 |
81 CONTENT_EXPORT Status Decrypt(const blink::WebCryptoAlgorithm& algorithm, | 84 CONTENT_EXPORT Status Decrypt(const blink::WebCryptoAlgorithm& algorithm, |
82 const blink::WebCryptoKey& key, | 85 const blink::WebCryptoKey& key, |
83 const CryptoData& data, | 86 const CryptoData& data, |
84 blink::WebArrayBuffer* buffer); | 87 std::vector<uint8>* buffer); |
85 | 88 |
86 CONTENT_EXPORT Status Digest(const blink::WebCryptoAlgorithm& algorithm, | 89 CONTENT_EXPORT Status Digest(const blink::WebCryptoAlgorithm& algorithm, |
87 const CryptoData& data, | 90 const CryptoData& data, |
88 blink::WebArrayBuffer* buffer); | 91 std::vector<uint8>* buffer); |
89 | 92 |
90 CONTENT_EXPORT scoped_ptr<blink::WebCryptoDigestor> CreateDigestor( | 93 CONTENT_EXPORT scoped_ptr<blink::WebCryptoDigestor> CreateDigestor( |
91 blink::WebCryptoAlgorithmId algorithm); | 94 blink::WebCryptoAlgorithmId algorithm); |
92 | 95 |
93 CONTENT_EXPORT Status | 96 CONTENT_EXPORT Status |
94 GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm, | 97 GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm, |
95 bool extractable, | 98 bool extractable, |
96 blink::WebCryptoKeyUsageMask usage_mask, | 99 blink::WebCryptoKeyUsageMask usage_mask, |
97 blink::WebCryptoKey* key); | 100 blink::WebCryptoKey* key); |
98 | 101 |
99 CONTENT_EXPORT Status | 102 CONTENT_EXPORT Status |
100 GenerateKeyPair(const blink::WebCryptoAlgorithm& algorithm, | 103 GenerateKeyPair(const blink::WebCryptoAlgorithm& algorithm, |
101 bool extractable, | 104 bool extractable, |
102 blink::WebCryptoKeyUsageMask usage_mask, | 105 blink::WebCryptoKeyUsageMask usage_mask, |
103 blink::WebCryptoKey* public_key, | 106 blink::WebCryptoKey* public_key, |
104 blink::WebCryptoKey* private_key); | 107 blink::WebCryptoKey* private_key); |
105 | 108 |
106 CONTENT_EXPORT Status ImportKey(blink::WebCryptoKeyFormat format, | 109 CONTENT_EXPORT Status ImportKey(blink::WebCryptoKeyFormat format, |
107 const CryptoData& key_data, | 110 const CryptoData& key_data, |
108 const blink::WebCryptoAlgorithm& algorithm, | 111 const blink::WebCryptoAlgorithm& algorithm, |
109 bool extractable, | 112 bool extractable, |
110 blink::WebCryptoKeyUsageMask usage_mask, | 113 blink::WebCryptoKeyUsageMask usage_mask, |
111 blink::WebCryptoKey* key); | 114 blink::WebCryptoKey* key); |
112 | 115 |
113 CONTENT_EXPORT Status ExportKey(blink::WebCryptoKeyFormat format, | 116 CONTENT_EXPORT Status ExportKey(blink::WebCryptoKeyFormat format, |
114 const blink::WebCryptoKey& key, | 117 const blink::WebCryptoKey& key, |
115 blink::WebArrayBuffer* buffer); | 118 std::vector<uint8>* buffer); |
116 | 119 |
117 CONTENT_EXPORT Status Sign(const blink::WebCryptoAlgorithm& algorithm, | 120 CONTENT_EXPORT Status Sign(const blink::WebCryptoAlgorithm& algorithm, |
118 const blink::WebCryptoKey& key, | 121 const blink::WebCryptoKey& key, |
119 const CryptoData& data, | 122 const CryptoData& data, |
120 blink::WebArrayBuffer* buffer); | 123 std::vector<uint8>* buffer); |
121 | 124 |
122 CONTENT_EXPORT Status | 125 CONTENT_EXPORT Status |
123 VerifySignature(const blink::WebCryptoAlgorithm& algorithm, | 126 VerifySignature(const blink::WebCryptoAlgorithm& algorithm, |
124 const blink::WebCryptoKey& key, | 127 const blink::WebCryptoKey& key, |
125 const CryptoData& signature, | 128 const CryptoData& signature, |
126 const CryptoData& data, | 129 const CryptoData& data, |
127 bool* signature_match); | 130 bool* signature_match); |
128 | 131 |
129 CONTENT_EXPORT Status | 132 CONTENT_EXPORT Status |
130 WrapKey(blink::WebCryptoKeyFormat format, | 133 WrapKey(blink::WebCryptoKeyFormat format, |
131 const blink::WebCryptoKey& wrapping_key, | 134 const blink::WebCryptoKey& wrapping_key, |
132 const blink::WebCryptoKey& key_to_wrap, | 135 const blink::WebCryptoKey& key_to_wrap, |
133 const blink::WebCryptoAlgorithm& wrapping_algorithm, | 136 const blink::WebCryptoAlgorithm& wrapping_algorithm, |
134 blink::WebArrayBuffer* buffer); | 137 std::vector<uint8>* buffer); |
135 | 138 |
136 CONTENT_EXPORT Status | 139 CONTENT_EXPORT Status |
137 UnwrapKey(blink::WebCryptoKeyFormat format, | 140 UnwrapKey(blink::WebCryptoKeyFormat format, |
138 const CryptoData& wrapped_key_data, | 141 const CryptoData& wrapped_key_data, |
139 const blink::WebCryptoKey& wrapping_key, | 142 const blink::WebCryptoKey& wrapping_key, |
140 const blink::WebCryptoAlgorithm& wrapping_algorithm, | 143 const blink::WebCryptoAlgorithm& wrapping_algorithm, |
141 const blink::WebCryptoAlgorithm& algorithm, | 144 const blink::WebCryptoAlgorithm& algorithm, |
142 bool extractable, | 145 bool extractable, |
143 blink::WebCryptoKeyUsageMask usage_mask, | 146 blink::WebCryptoKeyUsageMask usage_mask, |
144 blink::WebCryptoKey* key); | 147 blink::WebCryptoKey* key); |
145 | 148 |
146 CONTENT_EXPORT Status | 149 // Called on the target Blink thread. |
147 SerializeKeyForClone(const blink::WebCryptoKey& key, | 150 CONTENT_EXPORT bool SerializeKeyForClone(const blink::WebCryptoKey& key, |
148 blink::WebVector<unsigned char>* data); | 151 blink::WebVector<uint8>* key_data); |
149 | 152 |
150 CONTENT_EXPORT Status | 153 // Called on the target Blink thread. |
151 DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm, | 154 CONTENT_EXPORT bool DeserializeKeyForClone( |
152 blink::WebCryptoKeyType type, | 155 const blink::WebCryptoKeyAlgorithm& algorithm, |
153 bool extractable, | 156 blink::WebCryptoKeyType type, |
154 blink::WebCryptoKeyUsageMask usage_mask, | 157 bool extractable, |
155 const CryptoData& key_data, | 158 blink::WebCryptoKeyUsageMask usage_mask, |
156 blink::WebCryptoKey* key); | 159 const CryptoData& key_data, |
160 blink::WebCryptoKey* key); | |
157 | 161 |
158 } // namespace webcrypto | 162 } // namespace webcrypto |
159 | 163 |
160 } // namespace content | 164 } // namespace content |
161 | 165 |
162 #endif // CONTENT_CHILD_WEBCRYPTO_SHARED_CRYPTO_H_ | 166 #endif // CONTENT_CHILD_WEBCRYPTO_SHARED_CRYPTO_H_ |
OLD | NEW |