1 // Copyright 2015 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.
12 #include "base/strings/string_piece.h"
13 #include "crypto/crypto_export.h"
19 // This class exposes the AES-128-CTR-HMAC-SHA256 AEAD.
20 class CRYPTO_EXPORT Aead {
22 enum AeadAlgorithm { AES_128_CTR_HMAC_SHA256 };
24 explicit Aead(AeadAlgorithm algorithm);
28 void Init(const std::string* key);
30 bool Seal(base::StringPiece plaintext,
31 base::StringPiece nonce,
32 base::StringPiece additional_data,
33 std::string* ciphertext) const;
35 bool Open(base::StringPiece ciphertext,
36 base::StringPiece nonce,
37 base::StringPiece additional_data,
38 std::string* plaintext) const;
40 size_t KeyLength() const;
42 size_t NonceLength() const;
45 const std::string* key_;
46 const evp_aead_st* aead_;
51 #endif // CRYPTO_AEAD_H_