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
3 // found in the LICENSE file.
5 #ifndef CONTENT_CHILD_WEBCRYPTO_OPENSSL_UTIL_OPENSSL_H_
6 #define CONTENT_CHILD_WEBCRYPTO_OPENSSL_UTIL_OPENSSL_H_
10 #include <openssl/ossl_typ.h>
12 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h"
13 #include "third_party/WebKit/public/platform/WebCryptoKey.h"
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 };
26 const EVP_MD* GetDigest(blink::WebCryptoAlgorithmId id);
28 // Does either encryption or decryption for an AEAD algorithm.
29 // * |mode| controls whether encryption or decryption is done
30 // * |aead_alg| the algorithm (for instance AES-GCM)
31 // * |buffer| where the ciphertext or plaintext is written to.
32 Status AeadEncryptDecrypt(EncryptOrDecrypt mode,
33 const std::vector<uint8_t>& raw_key,
34 const CryptoData& data,
35 unsigned int tag_length_bytes,
37 const CryptoData& additional_data,
38 const EVP_AEAD* aead_alg,
39 std::vector<uint8_t>* buffer);
41 } // namespace webcrypto
43 } // namespace content
45 #endif // CONTENT_CHILD_WEBCRYPTO_OPENSSL_UTIL_OPENSSL_H_