Files
ladybird/Libraries/LibCrypto/Hash/SHAKE.h
mikiubo cd8465a6b5 LibCrypto: Add SHAKE digest support
Introduce a new SHAKE hash wrapper in LibCrypto backed by OpenSSL.

Wire cSHAKE128 and cSHAKE256 into WebCrypto.

Note that cSHAKE with non-empty functionName or customization is
currently rejected due to OpenSSL EVP limitations.

This fixes WPT:
WebCryptoAPI/digest/cshake.tentative.https.any.html
2026-01-22 19:47:09 -05:00

40 lines
655 B
C++

/*
* Copyright (c) 2025, mikiubo <michele.uboldi@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/Error.h>
#include <AK/Noncopyable.h>
#include <LibCrypto/OpenSSLForward.h>
namespace Crypto::Hash {
enum class SHAKEKind {
CSHAKE128,
CSHAKE256
};
class SHAKE {
AK_MAKE_NONCOPYABLE(SHAKE);
public:
explicit SHAKE(SHAKEKind);
~SHAKE() = default;
ErrorOr<ByteBuffer> digest(
ReadonlyBytes data,
u32 length,
Optional<ReadonlyBytes> customization,
Optional<ReadonlyBytes> function_name) const;
private:
EVP_MD const* m_md;
};
}