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_OPENSSL_UTIL_OPENSSL_H_ | 5 #ifndef CONTENT_CHILD_WEBCRYPTO_OPENSSL_UTIL_OPENSSL_H_ |
6 #define CONTENT_CHILD_WEBCRYPTO_OPENSSL_UTIL_OPENSSL_H_ | 6 #define CONTENT_CHILD_WEBCRYPTO_OPENSSL_UTIL_OPENSSL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include <openssl/ossl_typ.h> | 10 #include <openssl/ossl_typ.h> |
11 | 11 |
12 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" | 12 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" |
13 #include "third_party/WebKit/public/platform/WebCryptoKey.h" | 13 #include "third_party/WebKit/public/platform/WebCryptoKey.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 namespace webcrypto { | 17 namespace webcrypto { |
18 | 18 |
19 class CryptoData; | 19 class CryptoData; |
20 class Status; | 20 class Status; |
21 | 21 |
22 enum EncryptOrDecrypt { ENCRYPT, DECRYPT }; | 22 // The values of these constants correspond with the "enc" parameter of |
| 23 // EVP_CipherInit_ex(), do not change. |
| 24 enum EncryptOrDecrypt { DECRYPT=0, ENCRYPT=1 }; |
23 | 25 |
24 const EVP_MD* GetDigest(blink::WebCryptoAlgorithmId id); | 26 const EVP_MD* GetDigest(blink::WebCryptoAlgorithmId id); |
25 | 27 |
26 // Does either encryption or decryption for an AEAD algorithm. | 28 // Does either encryption or decryption for an AEAD algorithm. |
27 // * |mode| controls whether encryption or decryption is done | 29 // * |mode| controls whether encryption or decryption is done |
28 // * |aead_alg| the algorithm (for instance AES-GCM) | 30 // * |aead_alg| the algorithm (for instance AES-GCM) |
29 // * |buffer| where the ciphertext or plaintext is written to. | 31 // * |buffer| where the ciphertext or plaintext is written to. |
30 Status AeadEncryptDecrypt(EncryptOrDecrypt mode, | 32 Status AeadEncryptDecrypt(EncryptOrDecrypt mode, |
31 const std::vector<uint8_t>& raw_key, | 33 const std::vector<uint8_t>& raw_key, |
32 const CryptoData& data, | 34 const CryptoData& data, |
33 unsigned int tag_length_bytes, | 35 unsigned int tag_length_bytes, |
34 const CryptoData& iv, | 36 const CryptoData& iv, |
35 const CryptoData& additional_data, | 37 const CryptoData& additional_data, |
36 const EVP_AEAD* aead_alg, | 38 const EVP_AEAD* aead_alg, |
37 std::vector<uint8_t>* buffer); | 39 std::vector<uint8_t>* buffer); |
38 | 40 |
39 } // namespace webcrypto | 41 } // namespace webcrypto |
40 | 42 |
41 } // namespace content | 43 } // namespace content |
42 | 44 |
43 #endif // CONTENT_CHILD_WEBCRYPTO_OPENSSL_UTIL_OPENSSL_H_ | 45 #endif // CONTENT_CHILD_WEBCRYPTO_OPENSSL_UTIL_OPENSSL_H_ |
OLD | NEW |