Files
ladybird/Libraries/LibCrypto/Cipher/ChaCha.h
mikiubo ba75d4c014 LibCrypto: Add ChaCha20-Poly1305 support
Implement ChaCha20-Poly1305 AEAD using OpenSSL and expose it through
the WebCrypto API, including key management and AEAD parameters.

Add WPT:
/encrypt_decrypt/chacha20_poly1305.tentative.https.any.worker.html
2026-01-26 10:03:09 +01:00

40 lines
784 B
C++

/*
* Copyright (c) 2026, mikiubo <michele.uboldi@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/Error.h>
#include <LibCrypto/OpenSSLForward.h>
namespace Crypto::Cipher {
class ChaCha20Poly1305 {
public:
// 256 bits
static constexpr size_t key_size = 32;
// 96 bits
static constexpr size_t nonce_size = 12;
// 128 bits
static constexpr size_t tag_size = 16;
static ErrorOr<ByteBuffer> encrypt(
ReadonlyBytes key,
ReadonlyBytes nonce,
ReadonlyBytes plaintext,
ReadonlyBytes aad);
static ErrorOr<ByteBuffer> decrypt(
ReadonlyBytes key,
ReadonlyBytes nonce,
ReadonlyBytes ciphertext_and_tag,
ReadonlyBytes aad);
};
}