mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
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
40 lines
655 B
C++
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;
|
|
};
|
|
|
|
}
|