xref: /aosp_15_r20/external/cronet/net/third_party/quiche/src/quiche/quic/core/crypto/chacha20_poly1305_encrypter.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
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.
4 
5 #ifndef QUICHE_QUIC_CORE_CRYPTO_CHACHA20_POLY1305_ENCRYPTER_H_
6 #define QUICHE_QUIC_CORE_CRYPTO_CHACHA20_POLY1305_ENCRYPTER_H_
7 
8 #include "quiche/quic/core/crypto/chacha_base_encrypter.h"
9 #include "quiche/quic/platform/api/quic_export.h"
10 
11 namespace quic {
12 
13 // A ChaCha20Poly1305Encrypter is a QuicEncrypter that implements the
14 // AEAD_CHACHA20_POLY1305 algorithm specified in RFC 7539, except that
15 // it truncates the Poly1305 authenticator to 12 bytes. Create an instance
16 // by calling QuicEncrypter::Create(kCC20).
17 //
18 // It uses an authentication tag of 12 bytes (96 bits). The fixed prefix of the
19 // nonce is four bytes.
20 class QUICHE_EXPORT ChaCha20Poly1305Encrypter : public ChaChaBaseEncrypter {
21  public:
22   enum {
23     kAuthTagSize = 12,
24   };
25 
26   ChaCha20Poly1305Encrypter();
27   ChaCha20Poly1305Encrypter(const ChaCha20Poly1305Encrypter&) = delete;
28   ChaCha20Poly1305Encrypter& operator=(const ChaCha20Poly1305Encrypter&) =
29       delete;
30   ~ChaCha20Poly1305Encrypter() override;
31 
32   QuicPacketCount GetConfidentialityLimit() const override;
33 };
34 
35 }  // namespace quic
36 
37 #endif  // QUICHE_QUIC_CORE_CRYPTO_CHACHA20_POLY1305_ENCRYPTER_H_
38