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

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

Issue 195983010: [webcrypto] Add JWK symmetric key AES-KW unwrap for NSS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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
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_PLATFORM_CRYPTO_H_ 5 #ifndef CONTENT_CHILD_WEBCRYPTO_PLATFORM_CRYPTO_H_
6 #define CONTENT_CHILD_WEBCRYPTO_PLATFORM_CRYPTO_H_ 6 #define CONTENT_CHILD_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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // * |key| is non-null. 176 // * |key| is non-null.
177 Status ExportKeySpki(PublicKey* key, blink::WebArrayBuffer* buffer); 177 Status ExportKeySpki(PublicKey* key, blink::WebArrayBuffer* buffer);
178 178
179 // Preconditions: 179 // Preconditions:
180 // * |wrapping_key| is non-null 180 // * |wrapping_key| is non-null
181 // * |key| is non-null 181 // * |key| is non-null
182 Status WrapSymKeyAesKw(SymKey* wrapping_key, 182 Status WrapSymKeyAesKw(SymKey* wrapping_key,
183 SymKey* key, 183 SymKey* key,
184 blink::WebArrayBuffer* buffer); 184 blink::WebArrayBuffer* buffer);
185 185
186 // Unwraps (decrypts) |wrapped_key_data| using AES-KW and places the results in
187 // a WebCryptoKey. Raw key data remains inside NSS. This function should be used
188 // when the input |wrapped_key_data| is known to result in symmetric raw key
189 // data after AES-KW decryption.
186 // Preconditions: 190 // Preconditions:
187 // * |wrapping_key| is non-null 191 // * |wrapping_key| is non-null
188 // * |key| is non-null 192 // * |key| is non-null
189 // * |wrapped_key_data| is at least 24 bytes and a multiple of 8 bytes 193 // * |wrapped_key_data| is at least 24 bytes and a multiple of 8 bytes
190 // * |algorithm.id()| is for a symmetric key algorithm. 194 // * |algorithm.id()| is for a symmetric key algorithm.
191 Status UnwrapSymKeyAesKw(const CryptoData& wrapped_key_data, 195 Status UnwrapSymKeyAesKw(const CryptoData& wrapped_key_data,
192 SymKey* wrapping_key, 196 SymKey* wrapping_key,
193 const blink::WebCryptoAlgorithm& algorithm, 197 const blink::WebCryptoAlgorithm& algorithm,
194 bool extractable, 198 bool extractable,
195 blink::WebCryptoKeyUsageMask usage_mask, 199 blink::WebCryptoKeyUsageMask usage_mask,
196 blink::WebCryptoKey* key); 200 blink::WebCryptoKey* key);
197 201
202 // Performs AES-KW decryption on the input |data|, of which no assumptions are
eroman 2014/03/17 19:47:47 Not sure what "of which no assumptions are made" m
padolph 2014/03/17 22:12:49 Done.
203 // made, and returns the result to the caller. This function should be used when
204 // the input |data| does not directly represent a key and should instead be
205 // interpreted as generic bytes.
206 // Preconditions:
207 // * |key| is non-null
208 // * |data| is at least 24 bytes and a multiple of 8 bytes
209 // * |buffer| is non-null.
210 Status DecryptAesKw(SymKey* key,
211 const CryptoData& data,
212 blink::WebArrayBuffer* buffer);
213
198 // Preconditions: 214 // Preconditions:
199 // * |wrapping_key| is non-null 215 // * |wrapping_key| is non-null
200 // * |key| is non-null 216 // * |key| is non-null
201 Status WrapSymKeyRsaEs(PublicKey* wrapping_key, 217 Status WrapSymKeyRsaEs(PublicKey* wrapping_key,
202 SymKey* key, 218 SymKey* key,
203 blink::WebArrayBuffer* buffer); 219 blink::WebArrayBuffer* buffer);
204 220
205 // Preconditions: 221 // Preconditions:
206 // * |wrapping_key| is non-null 222 // * |wrapping_key| is non-null
207 // * |key| is non-null 223 // * |key| is non-null
208 // * |algorithm.id()| is for a symmetric key algorithm. 224 // * |algorithm.id()| is for a symmetric key algorithm.
209 Status UnwrapSymKeyRsaEs(const CryptoData& wrapped_key_data, 225 Status UnwrapSymKeyRsaEs(const CryptoData& wrapped_key_data,
210 PrivateKey* wrapping_key, 226 PrivateKey* wrapping_key,
211 const blink::WebCryptoAlgorithm& algorithm, 227 const blink::WebCryptoAlgorithm& algorithm,
212 bool extractable, 228 bool extractable,
213 blink::WebCryptoKeyUsageMask usage_mask, 229 blink::WebCryptoKeyUsageMask usage_mask,
214 blink::WebCryptoKey* key); 230 blink::WebCryptoKey* key);
215 231
216 } // namespace platform 232 } // namespace platform
217 233
218 } // namespace webcrypto 234 } // namespace webcrypto
219 235
220 } // namespace content 236 } // namespace content
221 237
222 #endif // CONTENT_CHILD_WEBCRYPTO_PLATFORM_CRYPTO_H_ 238 #endif // CONTENT_CHILD_WEBCRYPTO_PLATFORM_CRYPTO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698