/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/crypto/crypto_kmac.h
79 строк
2 KB
Filip Skokan
src: implement MemoryRetainer protocol for ByteSource
29 июл 2026, 20:48
Не верифицирован
29 июл 2026, 20:48
29d183d
Код
Авторство
О чём код?
#ifndef SRC_CRYPTO_CRYPTO_KMAC_H_ #define SRC_CRYPTO_CRYPTO_KMAC_H_ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #include <string> #include "crypto/crypto_keys.h" #include "crypto/crypto_sig.h" #include "crypto/crypto_util.h" namespace node::crypto { #if OPENSSL_WITH_EVP_MAC enum class KmacVariant { KMAC128, KMAC256 }; struct KmacConfig final : public MemoryRetainer { SignConfiguration::Mode mode; KeyObjectData key; ByteSource data; ByteSource signature; ByteSource customization; KmacVariant variant; size_t key_length; // Key length in bits uint32_t length; // Output length in bits KmacConfig() = default; explicit KmacConfig(KmacConfig&& other) noexcept; KmacConfig& operator=(KmacConfig&& other) noexcept; void MemoryInfo(MemoryTracker* tracker) const override; SET_MEMORY_INFO_NAME(KmacConfig) SET_SELF_SIZE(KmacConfig) }; struct KmacTraits final { using AdditionalParameters = KmacConfig; static constexpr const char* JobName = "KmacJob"; static constexpr AsyncWrap::ProviderType Provider = AsyncWrap::PROVIDER_SIGNREQUEST; static v8::Maybe<void> AdditionalConfig( CryptoJobMode mode, const v8::FunctionCallbackInfo<v8::Value>& args, unsigned int offset, KmacConfig* params); static bool DeriveBits(Environment* env, const KmacConfig& params, ByteSource* out, CryptoJobMode mode, CryptoErrorStore* errors); static v8::MaybeLocal<v8::Value> EncodeOutput(Environment* env, const KmacConfig& params, ByteSource* out); }; using KmacJob = DeriveBitsJob<KmacTraits>; namespace Kmac { void Initialize(Environment* env, v8::Local<v8::Object> target); void RegisterExternalReferences(ExternalReferenceRegistry* registry); } // namespace Kmac #else // If there is no KMAC support, provide empty namespace functions. namespace Kmac { void Initialize(Environment* env, v8::Local<v8::Object> target) {} void RegisterExternalReferences(ExternalReferenceRegistry* registry) {} } // namespace Kmac #endif // OPENSSL_WITH_EVP_MAC } // namespace node::crypto #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #endif // SRC_CRYPTO_CRYPTO_KMAC_H_