[go: nahoru, domu]

blob: 7c64eaa98d600721ee7a799aeab3a66d8b4159d3 [file] [log] [blame]
estark03206a12015-04-25 04:52:251// 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.
4
5#ifndef CRYPTO_AEAD_H_
6#define CRYPTO_AEAD_H_
7
avidd373b82015-12-21 21:34:438#include <stddef.h>
9
davidben6004dc52017-02-03 04:15:2910#include <string>
11
estark03206a12015-04-25 04:52:2512#include "base/strings/string_piece.h"
13#include "crypto/crypto_export.h"
14
15struct evp_aead_st;
16
17namespace crypto {
18
svaldez22de42fe2016-04-21 19:42:2219// This class exposes the AES-128-CTR-HMAC-SHA256 AEAD.
estark03206a12015-04-25 04:52:2520class CRYPTO_EXPORT Aead {
21 public:
22 enum AeadAlgorithm { AES_128_CTR_HMAC_SHA256 };
23
24 explicit Aead(AeadAlgorithm algorithm);
25
26 ~Aead();
27
28 void Init(const std::string* key);
29
David Benjamincda45eb2017-11-06 18:16:5230 bool Seal(base::StringPiece plaintext,
31 base::StringPiece nonce,
32 base::StringPiece additional_data,
estark03206a12015-04-25 04:52:2533 std::string* ciphertext) const;
34
David Benjamincda45eb2017-11-06 18:16:5235 bool Open(base::StringPiece ciphertext,
36 base::StringPiece nonce,
37 base::StringPiece additional_data,
estark03206a12015-04-25 04:52:2538 std::string* plaintext) const;
39
40 size_t KeyLength() const;
41
42 size_t NonceLength() const;
43
44 private:
45 const std::string* key_;
46 const evp_aead_st* aead_;
47};
48
49} // namespace crypto
50
davidben6004dc52017-02-03 04:15:2951#endif // CRYPTO_AEAD_H_