OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CRYPTO_AEAD_H_ | |
6 #define CRYPTO_AEAD_H_ | |
7 | |
8 #include <stddef.h> | |
9 | |
10 #include "base/strings/string_piece.h" | |
11 #include "crypto/crypto_export.h" | |
12 | |
13 struct evp_aead_st; | |
14 | |
15 namespace crypto { | |
16 | |
17 // This class exposes the AES-128-CTR-HMAC-SHA256 AEAD, currently only | |
18 // for OpenSSL builds. | |
19 class CRYPTO_EXPORT Aead { | |
20 public: | |
21 enum AeadAlgorithm { AES_128_CTR_HMAC_SHA256 }; | |
22 | |
23 explicit Aead(AeadAlgorithm algorithm); | |
24 | |
25 ~Aead(); | |
26 | |
27 void Init(const std::string* key); | |
28 | |
29 bool Seal(const base::StringPiece& plaintext, | |
30 const base::StringPiece& nonce, | |
31 const base::StringPiece& additional_data, | |
32 std::string* ciphertext) const; | |
33 | |
34 bool Open(const base::StringPiece& ciphertext, | |
35 const base::StringPiece& nonce, | |
36 const base::StringPiece& additional_data, | |
37 std::string* plaintext) const; | |
38 | |
39 size_t KeyLength() const; | |
40 | |
41 size_t NonceLength() const; | |
42 | |
43 private: | |
44 const std::string* key_; | |
45 const evp_aead_st* aead_; | |
46 }; | |
47 | |
48 } // namespace crypto | |
49 | |
50 #endif // CRYPTO_ENCRYPTOR_H_ | |
OLD | NEW |