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

Side by Side Diff: content/renderer/webcrypto/platform_crypto.h

Issue 178073007: [webcrypto] Update to use the KeyAlgorithm. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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_RENDERER_WEBCRYPTO_PLATFORM_CRYPTO_H_ 5 #ifndef CONTENT_RENDERER_WEBCRYPTO_PLATFORM_CRYPTO_H_
6 #define CONTENT_RENDERER_WEBCRYPTO_PLATFORM_CRYPTO_H_ 6 #define CONTENT_RENDERER_WEBCRYPTO_PLATFORM_CRYPTO_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" 10 #include "third_party/WebKit/public/platform/WebArrayBuffer.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // * keylen_bytes is non-zero (TODO(eroman): revisit this). 115 // * keylen_bytes is non-zero (TODO(eroman): revisit this).
116 // * For AES algorithms |keylen_bytes| is either 16, 24, or 32 bytes long. 116 // * For AES algorithms |keylen_bytes| is either 16, 24, or 32 bytes long.
117 Status GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm, 117 Status GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm,
118 bool extractable, 118 bool extractable,
119 blink::WebCryptoKeyUsageMask usage_mask, 119 blink::WebCryptoKeyUsageMask usage_mask,
120 unsigned keylen_bytes, 120 unsigned keylen_bytes,
121 blink::WebCryptoKey* key); 121 blink::WebCryptoKey* key);
122 122
123 // Preconditions: 123 // Preconditions:
124 // * algorithm.id() is for an RSA algorithm. 124 // * algorithm.id() is for an RSA algorithm.
125 // * algorithm.rsaKeyGenParams() is non-null. 125 // * public_exponent, modulus_length_bits and hash_or_null are the same as what
126 // is in algorithm. They are split out for convenience.
127 // * hash_or_null.isNull() may be true if a hash is not applicable to the
128 // algorithm
129 // * modulus_length_bits is not 0
130 // * public_exponent is not empty.
126 Status GenerateRsaKeyPair(const blink::WebCryptoAlgorithm& algorithm, 131 Status GenerateRsaKeyPair(const blink::WebCryptoAlgorithm& algorithm,
127 bool extractable, 132 bool extractable,
128 blink::WebCryptoKeyUsageMask usage_mask, 133 blink::WebCryptoKeyUsageMask usage_mask,
134 unsigned int modulus_length_bits,
135 const CryptoData& public_exponent,
136 const blink::WebCryptoAlgorithm& hash,
129 blink::WebCryptoKey* public_key, 137 blink::WebCryptoKey* public_key,
130 blink::WebCryptoKey* private_key); 138 blink::WebCryptoKey* private_key);
131 139
132 // Preconditions: 140 // Preconditions:
133 // * |key| is non-null. 141 // * |key| is non-null.
134 // * |algorithm.id()| is for a symmetric key algorithm. 142 // * |algorithm.id()| is for a symmetric key algorithm.
135 // * For AES algorithms |key_data| is either 16, 24, or 32 bytes long. 143 // * For AES algorithms |key_data| is either 16, 24, or 32 bytes long.
136 Status ImportKeyRaw(const blink::WebCryptoAlgorithm& algorithm, 144 Status ImportKeyRaw(const blink::WebCryptoAlgorithm& algorithm,
137 const CryptoData& key_data, 145 const CryptoData& key_data,
138 bool extractable, 146 bool extractable,
139 blink::WebCryptoKeyUsageMask usage_mask, 147 blink::WebCryptoKeyUsageMask usage_mask,
140 blink::WebCryptoKey* key); 148 blink::WebCryptoKey* key);
141 149
142 // Preconditions: 150 // Preconditions:
143 // * algorithm.id() is for an RSA algorithm. 151 // * algorithm.id() is for an RSA algorithm.
144 Status ImportRsaPublicKey(const blink::WebCryptoAlgorithm& algorithm, 152 Status ImportRsaPublicKey(const blink::WebCryptoAlgorithm& algorithm,
145 bool extractable, 153 bool extractable,
146 blink::WebCryptoKeyUsageMask usage_mask, 154 blink::WebCryptoKeyUsageMask usage_mask,
147 const CryptoData& modulus_data, 155 const CryptoData& modulus_data,
148 const CryptoData& exponent_data, 156 const CryptoData& exponent_data,
149 blink::WebCryptoKey* key); 157 blink::WebCryptoKey* key);
150 158
151 Status ImportKeySpki(const blink::WebCryptoAlgorithm& algorithm_or_null, 159 Status ImportKeySpki(const blink::WebCryptoAlgorithm& algorithm_or_null,
152 const CryptoData& key_data, 160 const CryptoData& key_data,
153 bool extractable,
154 blink::WebCryptoKeyUsageMask usage_mask, 161 blink::WebCryptoKeyUsageMask usage_mask,
155 blink::WebCryptoKey* key); 162 blink::WebCryptoKey* key);
156 163
157 Status ImportKeyPkcs8(const blink::WebCryptoAlgorithm& algorithm_or_null, 164 Status ImportKeyPkcs8(const blink::WebCryptoAlgorithm& algorithm_or_null,
158 const CryptoData& key_data, 165 const CryptoData& key_data,
159 bool extractable, 166 bool extractable,
160 blink::WebCryptoKeyUsageMask usage_mask, 167 blink::WebCryptoKeyUsageMask usage_mask,
161 blink::WebCryptoKey* key); 168 blink::WebCryptoKey* key);
162 169
163 // Preconditions: 170 // Preconditions:
164 // * |key| is non-null. 171 // * |key| is non-null.
165 Status ExportKeyRaw(SymKey* key, blink::WebArrayBuffer* buffer); 172 Status ExportKeyRaw(SymKey* key, blink::WebArrayBuffer* buffer);
166 173
167 // Preconditions: 174 // Preconditions:
168 // * |key| is non-null. 175 // * |key| is non-null.
169 Status ExportKeySpki(PublicKey* key, blink::WebArrayBuffer* buffer); 176 Status ExportKeySpki(PublicKey* key, blink::WebArrayBuffer* buffer);
170 177
171 } // namespace platform 178 } // namespace platform
172 179
173 } // namespace webcrypto 180 } // namespace webcrypto
174 181
175 } // namespace content 182 } // namespace content
176 183
177 #endif // CONTENT_RENDERER_WEBCRYPTO_PLATFORM_CRYPTO_H_ 184 #endif // CONTENT_RENDERER_WEBCRYPTO_PLATFORM_CRYPTO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698