1 // Copyright 2017 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 #include "quiche/quic/core/crypto/chacha20_poly1305_tls_encrypter.h"
6 
7 #include "openssl/evp.h"
8 
9 namespace quic {
10 
11 namespace {
12 
13 const size_t kKeySize = 32;
14 const size_t kNonceSize = 12;
15 
16 }  // namespace
17 
ChaCha20Poly1305TlsEncrypter()18 ChaCha20Poly1305TlsEncrypter::ChaCha20Poly1305TlsEncrypter()
19     : ChaChaBaseEncrypter(EVP_aead_chacha20_poly1305, kKeySize, kAuthTagSize,
20                           kNonceSize,
21                           /* use_ietf_nonce_construction */ true) {
22   static_assert(kKeySize <= kMaxKeySize, "key size too big");
23   static_assert(kNonceSize <= kMaxNonceSize, "nonce size too big");
24 }
25 
~ChaCha20Poly1305TlsEncrypter()26 ChaCha20Poly1305TlsEncrypter::~ChaCha20Poly1305TlsEncrypter() {}
27 
GetConfidentialityLimit() const28 QuicPacketCount ChaCha20Poly1305TlsEncrypter::GetConfidentialityLimit() const {
29   // For AEAD_CHACHA20_POLY1305, the confidentiality limit is greater than the
30   // number of possible packets (2^62) and so can be disregarded.
31   // https://quicwg.org/base-drafts/draft-ietf-quic-tls.html#name-limits-on-aead-usage
32   return std::numeric_limits<QuicPacketCount>::max();
33 }
34 
35 }  // namespace quic
36