[go: nahoru, domu]

blob: fa96eab9eb9f1342889f3ff9524bf176bbfe8ca0 [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
estark03206a12015-04-25 04:52:2510#include "base/strings/string_piece.h"
11#include "crypto/crypto_export.h"
12
13struct evp_aead_st;
14
15namespace crypto {
16
svaldez22de42fe2016-04-21 19:42:2217// This class exposes the AES-128-CTR-HMAC-SHA256 AEAD.
estark03206a12015-04-25 04:52:2518class CRYPTO_EXPORT Aead {
19 public:
20 enum AeadAlgorithm { AES_128_CTR_HMAC_SHA256 };
21
22 explicit Aead(AeadAlgorithm algorithm);
23
24 ~Aead();
25
26 void Init(const std::string* key);
27
28 bool Seal(const base::StringPiece& plaintext,
29 const base::StringPiece& nonce,
30 const base::StringPiece& additional_data,
31 std::string* ciphertext) const;
32
33 bool Open(const base::StringPiece& ciphertext,
34 const base::StringPiece& nonce,
35 const base::StringPiece& additional_data,
36 std::string* plaintext) const;
37
38 size_t KeyLength() const;
39
40 size_t NonceLength() const;
41
42 private:
43 const std::string* key_;
44 const evp_aead_st* aead_;
45};
46
47} // namespace crypto
48
49#endif // CRYPTO_ENCRYPTOR_H_