| 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 std::vector<uint8>* modulus, | 222 std::vector<uint8>* modulus, |
| 223 std::vector<uint8>* public_exponent); | 223 std::vector<uint8>* public_exponent); |
| 224 | 224 |
| 225 // Preconditions: | 225 // Preconditions: |
| 226 // * |key| is non-null. | 226 // * |key| is non-null. |
| 227 Status ExportKeyPkcs8(PrivateKey* key, | 227 Status ExportKeyPkcs8(PrivateKey* key, |
| 228 const blink::WebCryptoKeyAlgorithm& key_algorithm, | 228 const blink::WebCryptoKeyAlgorithm& key_algorithm, |
| 229 std::vector<uint8>* buffer); | 229 std::vector<uint8>* buffer); |
| 230 | 230 |
| 231 // Preconditions: | 231 // Preconditions: |
| 232 // * |key| is non-null |
| 232 // * |wrapping_key| is non-null | 233 // * |wrapping_key| is non-null |
| 233 // * |key| is non-null | 234 Status WrapSymKeyAesKw(SymKey* key, |
| 234 Status WrapSymKeyAesKw(SymKey* wrapping_key, | 235 SymKey* wrapping_key, |
| 235 SymKey* key, | |
| 236 std::vector<uint8>* buffer); | 236 std::vector<uint8>* buffer); |
| 237 | 237 |
| 238 // Unwraps (decrypts) |wrapped_key_data| using AES-KW and places the results in | 238 // Unwraps (decrypts) |wrapped_key_data| using AES-KW and places the results in |
| 239 // a WebCryptoKey. Raw key data remains inside NSS. This function should be used | 239 // a WebCryptoKey. Raw key data remains inside NSS. This function should be used |
| 240 // when the input |wrapped_key_data| is known to result in symmetric raw key | 240 // when the input |wrapped_key_data| is known to result in symmetric raw key |
| 241 // data after AES-KW decryption. | 241 // data after AES-KW decryption. |
| 242 // Preconditions: | 242 // Preconditions: |
| 243 // * |wrapping_key| is non-null | 243 // * |wrapping_key| is non-null |
| 244 // * |key| is non-null | 244 // * |key| is non-null |
| 245 // * |wrapped_key_data| is at least 24 bytes and a multiple of 8 bytes | 245 // * |wrapped_key_data| is at least 24 bytes and a multiple of 8 bytes |
| (...skipping 10 matching lines...) Expand all Loading... |
| 256 // interpreted as generic bytes. | 256 // interpreted as generic bytes. |
| 257 // Preconditions: | 257 // Preconditions: |
| 258 // * |key| is non-null | 258 // * |key| is non-null |
| 259 // * |data| is at least 24 bytes and a multiple of 8 bytes | 259 // * |data| is at least 24 bytes and a multiple of 8 bytes |
| 260 // * |buffer| is non-null. | 260 // * |buffer| is non-null. |
| 261 Status DecryptAesKw(SymKey* key, | 261 Status DecryptAesKw(SymKey* key, |
| 262 const CryptoData& data, | 262 const CryptoData& data, |
| 263 std::vector<uint8>* buffer); | 263 std::vector<uint8>* buffer); |
| 264 | 264 |
| 265 // Preconditions: | 265 // Preconditions: |
| 266 // * |key| is non-null |
| 266 // * |wrapping_key| is non-null | 267 // * |wrapping_key| is non-null |
| 267 // * |key| is non-null | 268 Status WrapSymKeyRsaEs(SymKey* key, |
| 268 Status WrapSymKeyRsaEs(PublicKey* wrapping_key, | 269 PublicKey* wrapping_key, |
| 269 SymKey* key, | |
| 270 std::vector<uint8>* buffer); | 270 std::vector<uint8>* buffer); |
| 271 | 271 |
| 272 // Preconditions: | 272 // Preconditions: |
| 273 // * |wrapping_key| is non-null | 273 // * |wrapping_key| is non-null |
| 274 // * |key| is non-null | 274 // * |key| is non-null |
| 275 // * |algorithm.id()| is for a symmetric key algorithm. | 275 // * |algorithm.id()| is for a symmetric key algorithm. |
| 276 Status UnwrapSymKeyRsaEs(const CryptoData& wrapped_key_data, | 276 Status UnwrapSymKeyRsaEs(const CryptoData& wrapped_key_data, |
| 277 PrivateKey* wrapping_key, | 277 PrivateKey* wrapping_key, |
| 278 const blink::WebCryptoAlgorithm& algorithm, | 278 const blink::WebCryptoAlgorithm& algorithm, |
| 279 bool extractable, | 279 bool extractable, |
| 280 blink::WebCryptoKeyUsageMask usage_mask, | 280 blink::WebCryptoKeyUsageMask usage_mask, |
| 281 blink::WebCryptoKey* key); | 281 blink::WebCryptoKey* key); |
| 282 | 282 |
| 283 } // namespace platform | 283 } // namespace platform |
| 284 | 284 |
| 285 } // namespace webcrypto | 285 } // namespace webcrypto |
| 286 | 286 |
| 287 } // namespace content | 287 } // namespace content |
| 288 | 288 |
| 289 #endif // CONTENT_CHILD_WEBCRYPTO_PLATFORM_CRYPTO_H_ | 289 #endif // CONTENT_CHILD_WEBCRYPTO_PLATFORM_CRYPTO_H_ |
| OLD | NEW |