| 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_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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 std::vector<uint8>* exponent1, | 265 std::vector<uint8>* exponent1, |
| 266 std::vector<uint8>* exponent2, | 266 std::vector<uint8>* exponent2, |
| 267 std::vector<uint8>* coefficient); | 267 std::vector<uint8>* coefficient); |
| 268 | 268 |
| 269 // Preconditions: | 269 // Preconditions: |
| 270 // * |key| is non-null. | 270 // * |key| is non-null. |
| 271 Status ExportKeyPkcs8(PrivateKey* key, | 271 Status ExportKeyPkcs8(PrivateKey* key, |
| 272 const blink::WebCryptoKeyAlgorithm& key_algorithm, | 272 const blink::WebCryptoKeyAlgorithm& key_algorithm, |
| 273 std::vector<uint8>* buffer); | 273 std::vector<uint8>* buffer); |
| 274 | 274 |
| 275 // Performs AES-KW encryption/decryption on the input |data|. |
| 275 // Preconditions: | 276 // Preconditions: |
| 276 // * |key| is non-null | 277 // * |key| is non-null |
| 277 // * |wrapping_key| is non-null | 278 // * |data| is multiple of 8 bytes. If encrypting it is at least 16 bytes, and |
| 278 Status WrapSymKeyAesKw(SymKey* key, | 279 // if decrypting at least 24 bytes. |
| 279 SymKey* wrapping_key, | |
| 280 std::vector<uint8>* buffer); | |
| 281 | |
| 282 // Unwraps (decrypts) |wrapped_key_data| using AES-KW and places the results in | |
| 283 // a WebCryptoKey. Raw key data remains inside NSS. This function should be used | |
| 284 // when the input |wrapped_key_data| is known to result in symmetric raw key | |
| 285 // data after AES-KW decryption. | |
| 286 // Preconditions: | |
| 287 // * |wrapping_key| is non-null | |
| 288 // * |key| is non-null | |
| 289 // * |wrapped_key_data| is at least 24 bytes and a multiple of 8 bytes | |
| 290 // * |algorithm.id()| is for a symmetric key algorithm. | |
| 291 // * usage_mask makes sense for the algorithm. | |
| 292 Status UnwrapSymKeyAesKw(const CryptoData& wrapped_key_data, | |
| 293 SymKey* wrapping_key, | |
| 294 const blink::WebCryptoAlgorithm& algorithm, | |
| 295 bool extractable, | |
| 296 blink::WebCryptoKeyUsageMask usage_mask, | |
| 297 blink::WebCryptoKey* key); | |
| 298 | |
| 299 // Performs AES-KW decryption on the input |data|. This function should be used | |
| 300 // when the input |data| does not directly represent a key and should instead be | |
| 301 // interpreted as generic bytes. | |
| 302 // Preconditions: | |
| 303 // * |key| is non-null | |
| 304 // * |data| is at least 24 bytes and a multiple of 8 bytes | |
| 305 // * |buffer| is non-null. | 280 // * |buffer| is non-null. |
| 306 Status DecryptAesKw(SymKey* key, | 281 Status EncryptDecryptAesKw(EncryptOrDecrypt mode, |
| 307 const CryptoData& data, | 282 SymKey* key, |
| 308 std::vector<uint8>* buffer); | 283 const CryptoData& data, |
| 284 std::vector<uint8>* buffer); |
| 309 | 285 |
| 310 } // namespace platform | 286 } // namespace platform |
| 311 | 287 |
| 312 } // namespace webcrypto | 288 } // namespace webcrypto |
| 313 | 289 |
| 314 } // namespace content | 290 } // namespace content |
| 315 | 291 |
| 316 #endif // CONTENT_CHILD_WEBCRYPTO_PLATFORM_CRYPTO_H_ | 292 #endif // CONTENT_CHILD_WEBCRYPTO_PLATFORM_CRYPTO_H_ |
| OLD | NEW |