src/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter_test.cc
// EncryptWithNonce wraps the |Encrypt| method of |encrypter| to allow passing
// in an nonce and also to allocate the buffer needed for the ciphertext.
EncryptWithNonce wraps the |Encrypt| method of |encrypter| to allow passing
in an nonce and also to allocate the buffer needed for the ciphertext.
EncryptWithNonce wraps the |Encrypt| method of |encrypter| to allow passing in an nonce and also to allocate the buffer needed for the ciphertext .
QuicData* EncryptWithNonce(ChaCha20Poly1305Encrypter* encrypter,
                           quiche::QuicheStringPiece nonce,
                           quiche::QuicheStringPiece associated_data,
                           quiche::QuicheStringPiece plaintext) {
  size_t ciphertext_size = encrypter->GetCiphertextSize(plaintext.length());
  std::unique_ptr<char[]> ciphertext(new char[ciphertext_size]);
  if (!encrypter->Encrypt(nonce, associated_data, plaintext,
                          reinterpret_cast<unsigned char*>(ciphertext.get()))) {
    return nullptr;
  }
  return new QuicData(ciphertext.release(), ciphertext_size, true);
}
QuicData * EncryptWithNonce ( ChaCha20Poly1305Encrypter * encrypter , quiche :: QuicheStringPiece nonce , quiche :: QuicheStringPiece associated_data , quiche :: QuicheStringPiece plaintext ) { size_t ciphertext_size = encrypter -> GetCiphertextSize ( plaintext . length ( ) ) ; std :: unique_ptr < char [ ] > ciphertext ( new char [ ciphertext_size ] ) ; if ( ! encrypter -> Encrypt ( nonce , associated_data , plaintext , reinterpret_cast < unsigned char * > ( ciphertext . get ( ) ) ) ) { return nullptr ; } return new QuicData ( ciphertext . release ( ) , ciphertext_size , true ) ; }
EncryptWithNonce wraps the |Encrypt| method of |encrypter| to allow passing
in an nonce and also to allocate the buffer needed for the ciphertext.
EncryptWithNonce wraps the |Encrypt| method of |encrypter| to allow passing in an nonce and also to allocate the buffer needed for the ciphertext .