blob: 1adad076d9b237f75a4fb81b04a8b6e11b935dac [file] [log] [blame]
Bence Békybac04052022-04-07 15:44:29 -04001// 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
vasilvvdaa2fda2022-04-11 14:08:36 -07007#include "openssl/evp.h"
Bence Békybac04052022-04-07 15:44:29 -04008
9namespace quic {
10
11namespace {
12
13const size_t kKeySize = 32;
14const size_t kNonceSize = 12;
15
16} // namespace
17
18ChaCha20Poly1305Encrypter::ChaCha20Poly1305Encrypter()
bncb91850e2022-04-13 08:34:05 -070019 : ChaChaBaseEncrypter(EVP_aead_chacha20_poly1305, kKeySize, kAuthTagSize,
Bence Békybac04052022-04-07 15:44:29 -040020 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
26ChaCha20Poly1305Encrypter::~ChaCha20Poly1305Encrypter() {}
27
28QuicPacketCount 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