diff options
author | danibw <danibw@yandex-team.com> | 2023-11-29 18:32:06 +0300 |
---|---|---|
committer | danibw <danibw@yandex-team.com> | 2023-11-29 19:34:00 +0300 |
commit | 71a7f96673789844090ddb61182238c6ed4d8013 (patch) | |
tree | 16a954cef67f97167bc471903b1034be43f77337 /library/cpp/openssl/crypto/sha.h | |
parent | 2f8c2d284cb97bd7537b4c717f0d24cf289afe20 (diff) | |
download | ydb-71a7f96673789844090ddb61182238c6ed4d8013.tar.gz |
Add SHA224 to library/cpp/openssl/crypto
Add SHA224 to library/cpp/openssl/crypto
Diffstat (limited to 'library/cpp/openssl/crypto/sha.h')
-rw-r--r-- | library/cpp/openssl/crypto/sha.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/library/cpp/openssl/crypto/sha.h b/library/cpp/openssl/crypto/sha.h index dbc2dfa526..49ec8bd009 100644 --- a/library/cpp/openssl/crypto/sha.h +++ b/library/cpp/openssl/crypto/sha.h @@ -76,3 +76,37 @@ namespace NOpenSsl::NSha256 { THolder<SHA256state_st> Context; }; } + +namespace NOpenSsl::NSha224 { + constexpr size_t DIGEST_LENGTH = 28; + using TDigest = std::array<ui8, DIGEST_LENGTH>; + + // not fragmented input + TDigest Calc(const void* data, size_t dataSize); + + inline TDigest Calc(TStringBuf s) { + return Calc(s.data(), s.length()); + } + + // fragmented input + class TCalcer { + public: + TCalcer(); + ~TCalcer(); + void Update(const void* data, size_t dataSize); + + void Update(TStringBuf s) { + Update(s.data(), s.length()); + } + + template <typename T> + void UpdateWithPodValue(const T& value) { + Update(&value, sizeof(value)); + } + + TDigest Final(); + + private: + THolder<SHA256state_st> Context; + }; +} |