Bence Béky | bac0405 | 2022-04-07 15:44:29 -0400 | [diff] [blame] | 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 | #include "quiche/quic/core/crypto/chacha20_poly1305_encrypter.h" |
| 6 | |
vasilvv | daa2fda | 2022-04-11 14:08:36 -0700 | [diff] [blame] | 7 | #include "openssl/evp.h" |
Bence Béky | bac0405 | 2022-04-07 15:44:29 -0400 | [diff] [blame] | 8 | |
| 9 | namespace quic { |
| 10 | |
| 11 | namespace { |
| 12 | |
| 13 | const size_t kKeySize = 32; |
| 14 | const size_t kNonceSize = 12; |
| 15 | |
| 16 | } // namespace |
| 17 | |
| 18 | ChaCha20Poly1305Encrypter::ChaCha20Poly1305Encrypter() |
bnc | b91850e | 2022-04-13 08:34:05 -0700 | [diff] [blame] | 19 | : ChaChaBaseEncrypter(EVP_aead_chacha20_poly1305, kKeySize, kAuthTagSize, |
Bence Béky | bac0405 | 2022-04-07 15:44:29 -0400 | [diff] [blame] | 20 | kNonceSize, |
| 21 | /* use_ietf_nonce_construction */ false) { |
| 22 | static_assert(kKeySize <= kMaxKeySize, "key size too big"); |
| 23 | static_assert(kNonceSize <= kMaxNonceSize, "nonce size too big"); |
| 24 | } |
| 25 | |
| 26 | ChaCha20Poly1305Encrypter::~ChaCha20Poly1305Encrypter() {} |
| 27 | |
| 28 | QuicPacketCount ChaCha20Poly1305Encrypter::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 |