Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: trunk/src/content/child/webcrypto/shared_crypto.h

Issue 252213003: Revert 266798 "[webcrypto] Make operations run on a background t..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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>
9
10 #include "base/basictypes.h" 8 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
13 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
14 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" 12 #include "third_party/WebKit/public/platform/WebArrayBuffer.h"
15 #include "third_party/WebKit/public/platform/WebCrypto.h" 13 #include "third_party/WebKit/public/platform/WebCrypto.h"
16 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" 14 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h"
17 15
18 namespace content { 16 namespace content {
19 17
(...skipping 12 matching lines...) Expand all
32 // 30 //
33 // Blink 31 // Blink
34 // | 32 // |
35 // ==============|========================== 33 // ==============|==========================
36 // | 34 // |
37 // content 35 // content
38 // | 36 // |
39 // | 37 // |
40 // v 38 // v
41 // WebCryptoImpl (Implements the blink::WebCrypto interface for 39 // WebCryptoImpl (Implements the blink::WebCrypto interface for
42 // | asynchronous completions; posts tasks to 40 // | asynchronous completions)
43 // | the webcrypto worker pool to fulfill the request
44 // using the synchronous methods of shared_crypto.h)
45 // | 41 // |
46 // | [shared_crypto_unittest.cc] 42 // | [shared_crypto_unittest.cc]
47 // | / 43 // | /
48 // | / (The blink::WebCrypto interface is not 44 // | / (The blink::WebCrypto interface is not
49 // | / testable from the chromium side because 45 // | / testable from the chromium side because
50 // | / the result object is not mockable. 46 // | / the result object is not mockable.
51 // | / Tests are done on shared_crypto instead. 47 // | / Tests are done on shared_crypto instead.
52 // V v 48 // V v
53 // [shared_crypto.h] (Exposes synchronous functions in the 49 // [shared_crypto.h] (Exposes synchronous functions in the
54 // | webcrypto:: namespace. This does 50 // | webcrypto:: namespace. This does
55 // | common validations, infers default 51 // | common validations, infers default
56 // | parameters, and casts the algorithm 52 // | parameters, and casts the algorithm
57 // | parameters to the right types) 53 // | parameters to the right types)
58 // | 54 // |
59 // V 55 // V
60 // [platform_crypto.h] (Exposes functions in the webcrypto::platform 56 // [platform_crypto.h] (Exposes functions in the webcrypto::platform
61 // | namespace) 57 // | namespace)
62 // | 58 // |
63 // | 59 // |
64 // V 60 // V
65 // [platform_crypto_{nss|openssl}.cc] (Implements using the platform crypto 61 // [platform_crypto_{nss|openssl}.cc] (Implements using the platform crypto
66 // library) 62 // library)
67 // 63 //
68 // The shared_crypto.h functions are responsible for: 64 // The shared_crypto.h functions are responsible for:
69 // 65 //
70 // * Validating the key usages 66 // * Validating the key usages
71 // * Inferring default parameters when not specified 67 // * Inferring default parameters when not specified
72 // * Validating key exportability 68 // * Validating key exportability
73 // * Validating algorithm with key.algorithm 69 // * Validating algorithm with key.algorithm
74 // * Converting the Blink key to a more specific platform::{PublicKey, 70 // * Converting the blink key to a more specific platform::{PublicKey,
75 // PrivateKey, SymKey} and making sure it was the right type. 71 // PrivateKey, SymKey} and making sure it was the right type.
76 // * Validating alogorithm specific parameters (for instance, was the iv for 72 // * Validating alogorithm specific parameters (for instance, was the iv for
77 // AES-CBC 16 bytes). 73 // AES-CBC 16 bytes).
78 // * Parse a JWK 74 // * Parse a JWK
79 75
80 CONTENT_EXPORT Status Encrypt(const blink::WebCryptoAlgorithm& algorithm, 76 CONTENT_EXPORT Status Encrypt(const blink::WebCryptoAlgorithm& algorithm,
81 const blink::WebCryptoKey& key, 77 const blink::WebCryptoKey& key,
82 const CryptoData& data, 78 const CryptoData& data,
83 std::vector<uint8>* buffer); 79 blink::WebArrayBuffer* buffer);
84 80
85 CONTENT_EXPORT Status Decrypt(const blink::WebCryptoAlgorithm& algorithm, 81 CONTENT_EXPORT Status Decrypt(const blink::WebCryptoAlgorithm& algorithm,
86 const blink::WebCryptoKey& key, 82 const blink::WebCryptoKey& key,
87 const CryptoData& data, 83 const CryptoData& data,
88 std::vector<uint8>* buffer); 84 blink::WebArrayBuffer* buffer);
89 85
90 CONTENT_EXPORT Status Digest(const blink::WebCryptoAlgorithm& algorithm, 86 CONTENT_EXPORT Status Digest(const blink::WebCryptoAlgorithm& algorithm,
91 const CryptoData& data, 87 const CryptoData& data,
92 std::vector<uint8>* buffer); 88 blink::WebArrayBuffer* buffer);
93 89
94 CONTENT_EXPORT scoped_ptr<blink::WebCryptoDigestor> CreateDigestor( 90 CONTENT_EXPORT scoped_ptr<blink::WebCryptoDigestor> CreateDigestor(
95 blink::WebCryptoAlgorithmId algorithm); 91 blink::WebCryptoAlgorithmId algorithm);
96 92
97 CONTENT_EXPORT Status 93 CONTENT_EXPORT Status
98 GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm, 94 GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm,
99 bool extractable, 95 bool extractable,
100 blink::WebCryptoKeyUsageMask usage_mask, 96 blink::WebCryptoKeyUsageMask usage_mask,
101 blink::WebCryptoKey* key); 97 blink::WebCryptoKey* key);
102 98
103 CONTENT_EXPORT Status 99 CONTENT_EXPORT Status
104 GenerateKeyPair(const blink::WebCryptoAlgorithm& algorithm, 100 GenerateKeyPair(const blink::WebCryptoAlgorithm& algorithm,
105 bool extractable, 101 bool extractable,
106 blink::WebCryptoKeyUsageMask usage_mask, 102 blink::WebCryptoKeyUsageMask usage_mask,
107 blink::WebCryptoKey* public_key, 103 blink::WebCryptoKey* public_key,
108 blink::WebCryptoKey* private_key); 104 blink::WebCryptoKey* private_key);
109 105
110 CONTENT_EXPORT Status ImportKey(blink::WebCryptoKeyFormat format, 106 CONTENT_EXPORT Status ImportKey(blink::WebCryptoKeyFormat format,
111 const CryptoData& key_data, 107 const CryptoData& key_data,
112 const blink::WebCryptoAlgorithm& algorithm, 108 const blink::WebCryptoAlgorithm& algorithm,
113 bool extractable, 109 bool extractable,
114 blink::WebCryptoKeyUsageMask usage_mask, 110 blink::WebCryptoKeyUsageMask usage_mask,
115 blink::WebCryptoKey* key); 111 blink::WebCryptoKey* key);
116 112
117 CONTENT_EXPORT Status ExportKey(blink::WebCryptoKeyFormat format, 113 CONTENT_EXPORT Status ExportKey(blink::WebCryptoKeyFormat format,
118 const blink::WebCryptoKey& key, 114 const blink::WebCryptoKey& key,
119 std::vector<uint8>* buffer); 115 blink::WebArrayBuffer* buffer);
120 116
121 CONTENT_EXPORT Status Sign(const blink::WebCryptoAlgorithm& algorithm, 117 CONTENT_EXPORT Status Sign(const blink::WebCryptoAlgorithm& algorithm,
122 const blink::WebCryptoKey& key, 118 const blink::WebCryptoKey& key,
123 const CryptoData& data, 119 const CryptoData& data,
124 std::vector<uint8>* buffer); 120 blink::WebArrayBuffer* buffer);
125 121
126 CONTENT_EXPORT Status 122 CONTENT_EXPORT Status
127 VerifySignature(const blink::WebCryptoAlgorithm& algorithm, 123 VerifySignature(const blink::WebCryptoAlgorithm& algorithm,
128 const blink::WebCryptoKey& key, 124 const blink::WebCryptoKey& key,
129 const CryptoData& signature, 125 const CryptoData& signature,
130 const CryptoData& data, 126 const CryptoData& data,
131 bool* signature_match); 127 bool* signature_match);
132 128
133 CONTENT_EXPORT Status 129 CONTENT_EXPORT Status
134 WrapKey(blink::WebCryptoKeyFormat format, 130 WrapKey(blink::WebCryptoKeyFormat format,
135 const blink::WebCryptoKey& wrapping_key, 131 const blink::WebCryptoKey& wrapping_key,
136 const blink::WebCryptoKey& key_to_wrap, 132 const blink::WebCryptoKey& key_to_wrap,
137 const blink::WebCryptoAlgorithm& wrapping_algorithm, 133 const blink::WebCryptoAlgorithm& wrapping_algorithm,
138 std::vector<uint8>* buffer); 134 blink::WebArrayBuffer* buffer);
139 135
140 CONTENT_EXPORT Status 136 CONTENT_EXPORT Status
141 UnwrapKey(blink::WebCryptoKeyFormat format, 137 UnwrapKey(blink::WebCryptoKeyFormat format,
142 const CryptoData& wrapped_key_data, 138 const CryptoData& wrapped_key_data,
143 const blink::WebCryptoKey& wrapping_key, 139 const blink::WebCryptoKey& wrapping_key,
144 const blink::WebCryptoAlgorithm& wrapping_algorithm, 140 const blink::WebCryptoAlgorithm& wrapping_algorithm,
145 const blink::WebCryptoAlgorithm& algorithm, 141 const blink::WebCryptoAlgorithm& algorithm,
146 bool extractable, 142 bool extractable,
147 blink::WebCryptoKeyUsageMask usage_mask, 143 blink::WebCryptoKeyUsageMask usage_mask,
148 blink::WebCryptoKey* key); 144 blink::WebCryptoKey* key);
149 145
150 // Called on the target Blink thread. 146 CONTENT_EXPORT Status
151 CONTENT_EXPORT bool SerializeKeyForClone(const blink::WebCryptoKey& key, 147 SerializeKeyForClone(const blink::WebCryptoKey& key,
152 blink::WebVector<uint8>* key_data); 148 blink::WebVector<unsigned char>* data);
153 149
154 // Called on the target Blink thread. 150 CONTENT_EXPORT Status
155 CONTENT_EXPORT bool DeserializeKeyForClone( 151 DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm,
156 const blink::WebCryptoKeyAlgorithm& algorithm, 152 blink::WebCryptoKeyType type,
157 blink::WebCryptoKeyType type, 153 bool extractable,
158 bool extractable, 154 blink::WebCryptoKeyUsageMask usage_mask,
159 blink::WebCryptoKeyUsageMask usage_mask, 155 const CryptoData& key_data,
160 const CryptoData& key_data, 156 blink::WebCryptoKey* key);
161 blink::WebCryptoKey* key);
162 157
163 } // namespace webcrypto 158 } // namespace webcrypto
164 159
165 } // namespace content 160 } // namespace content
166 161
167 #endif // CONTENT_CHILD_WEBCRYPTO_SHARED_CRYPTO_H_ 162 #endif // CONTENT_CHILD_WEBCRYPTO_SHARED_CRYPTO_H_
OLDNEW
« no previous file with comments | « trunk/src/content/child/webcrypto/platform_crypto_openssl.cc ('k') | trunk/src/content/child/webcrypto/shared_crypto.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698