diff options
author | leo <leo@yandex-team.ru> | 2022-02-10 16:46:40 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:40 +0300 |
commit | 99609724f661f7e21d1cb08e8d80e87c3632fdb3 (patch) | |
tree | 49e222ea1c5804306084bb3ae065bb702625360f /library/cpp/digest | |
parent | 980edcd3304699edf9d4e4d6a656e585028e2a72 (diff) | |
download | ydb-99609724f661f7e21d1cb08e8d80e87c3632fdb3.tar.gz |
Restoring authorship annotation for <leo@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/digest')
-rw-r--r-- | library/cpp/digest/md5/md5.cpp | 84 | ||||
-rw-r--r-- | library/cpp/digest/md5/md5.h | 6 | ||||
-rw-r--r-- | library/cpp/digest/old_crc/crc.h | 4 | ||||
-rw-r--r-- | library/cpp/digest/old_crc/gencrc/main.cpp | 2 | ||||
-rw-r--r-- | library/cpp/digest/sfh/sfh.h | 4 |
5 files changed, 50 insertions, 50 deletions
diff --git a/library/cpp/digest/md5/md5.cpp b/library/cpp/digest/md5/md5.cpp index 4d6168c4e8..24a5b69eef 100644 --- a/library/cpp/digest/md5/md5.cpp +++ b/library/cpp/digest/md5/md5.cpp @@ -5,7 +5,7 @@ #include <util/stream/input.h> #include <util/stream/file.h> #include <util/string/hex.h> - + #include <contrib/libs/nayuki_md5/md5.h> namespace { @@ -42,11 +42,11 @@ char* MD5::File(const char* filename, char* buf) { return Stream(&fi, buf); } catch (...) { - } + } return nullptr; -} - +} + TString MD5::File(const TString& filename) { TString buf; buf.ReserveAndResize(MD5_HEX_DIGEST_LENGTH); @@ -63,8 +63,8 @@ char* MD5::Data(const TArrayRef<const ui8>& data, char* buf) { char* MD5::Data(const void* data, size_t len, char* buf) { return Data(MakeUnsignedArrayRef(data, len), buf); -} - +} + TString MD5::Data(const TArrayRef<const ui8>& data) { TString buf; buf.ReserveAndResize(MD5_HEX_DIGEST_LENGTH); @@ -92,25 +92,25 @@ static const ui8 PADDING[MD5_BLOCK_LENGTH] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - -/* MD5 initialization. Begins an MD5 operation, writing a new context. */ - + +/* MD5 initialization. Begins an MD5 operation, writing a new context. */ + void MD5::Init() { BufferSize = 0; StreamSize = 0; - /* Load magic initialization constants. */ + /* Load magic initialization constants. */ State[0] = 0x67452301; State[1] = 0xefcdab89; State[2] = 0x98badcfe; State[3] = 0x10325476; -} - +} + /* - * MD5 block update operation. Continues an MD5 message-digest - * operation, processing another message block, and updating the - * context. - */ - + * MD5 block update operation. Continues an MD5 message-digest + * operation, processing another message block, and updating the + * context. + */ + void MD5::UpdatePart(TArrayRef<const ui8> data) { /* Count input bytes */ StreamSize += data.size(); @@ -135,12 +135,12 @@ void MD5::UpdatePart(TArrayRef<const ui8> data) { /* Save remaining input in buffer */ memcpy(Buffer, data.data(), data.size()); BufferSize += data.size(); -} - -/* - * MD5 padding. Adds padding followed by original length. - */ - +} + +/* + * MD5 padding. Adds padding followed by original length. + */ + void MD5::Pad() { size_t streamSize = StreamSize; @@ -155,40 +155,40 @@ void MD5::Pad() { Buffer[MD5_PADDING_SHIFT + i] = static_cast<ui8>(streamSize & 0xFFU); } md5_compress(State, Buffer); -} - -/* - * MD5 finalization. Ends an MD5 message-digest operation, writing the - * the message digest and zeroizing the context. - */ - +} + +/* + * MD5 finalization. Ends an MD5 message-digest operation, writing the + * the message digest and zeroizing the context. + */ + ui8* MD5::Final(ui8 digest[16]) { - /* Do padding. */ - Pad(); - /* Store state in digest */ + /* Do padding. */ + Pad(); + /* Store state in digest */ memcpy(digest, State, 16); - /* Zeroize sensitive information. */ + /* Zeroize sensitive information. */ Init(); return digest; -} - +} + char* MD5::End(char* buf) { static const char hex[] = "0123456789abcdef"; ui8 digest[16]; if (!buf) - buf = (char*)malloc(33); + buf = (char*)malloc(33); if (!buf) return nullptr; - Final(digest); + Final(digest); for (ui8 i = 0; i < MD5_HEX_DIGEST_LENGTH / 2; i++) { buf[i * 2] = hex[digest[i] >> 4]; buf[i * 2 + 1] = hex[digest[i] & 0x0f]; - } + } buf[32] = '\0'; - return buf; -} - + return buf; +} + char* MD5::End_b64(char* buf) { ui8 digest[16]; if (!buf) diff --git a/library/cpp/digest/md5/md5.h b/library/cpp/digest/md5/md5.h index ead7158a6e..2c17aa0518 100644 --- a/library/cpp/digest/md5/md5.h +++ b/library/cpp/digest/md5/md5.h @@ -1,8 +1,8 @@ #pragma once - + #include <util/generic/array_ref.h> #include <util/generic/strbuf.h> - + class IInputStream; class MD5 { @@ -74,4 +74,4 @@ private: ui8 Buffer[64]; /* input buffer */ ui32 State[4]; /* state (ABCD) */ ui64 StreamSize; /* total bytes in input stream */ -}; +}; diff --git a/library/cpp/digest/old_crc/crc.h b/library/cpp/digest/old_crc/crc.h index a737f2e8b7..4a3ce6d05e 100644 --- a/library/cpp/digest/old_crc/crc.h +++ b/library/cpp/digest/old_crc/crc.h @@ -46,8 +46,8 @@ inline ui32 crc32(const char* buf, size_t buflen, ui32 crcinit = CRC32INIT) { inline ui32 crc32(const void* buf, size_t buflen, ui32 crcinit = CRC32INIT) { return crc32((const char*)buf, buflen, crcinit); -} - +} + // Copyright (C) Sewell Development Corporation, 1994 - 1998. inline ui64 crc64(const void* buf, size_t buflen, ui64 crcinit = CRC64INIT) { const unsigned char* ptr = (const unsigned char*)buf; diff --git a/library/cpp/digest/old_crc/gencrc/main.cpp b/library/cpp/digest/old_crc/gencrc/main.cpp index a7e3c25561..d5821304ce 100644 --- a/library/cpp/digest/old_crc/gencrc/main.cpp +++ b/library/cpp/digest/old_crc/gencrc/main.cpp @@ -2,7 +2,7 @@ #define POLY_16 0x1021 #define POLY_32 0xEDB88320UL -#define POLY_64 ULL(0xE543279765927881) +#define POLY_64 ULL(0xE543279765927881) static void crc16init() { ui32 CRCTAB16[256]; diff --git a/library/cpp/digest/sfh/sfh.h b/library/cpp/digest/sfh/sfh.h index aa48f3ceeb..372938654c 100644 --- a/library/cpp/digest/sfh/sfh.h +++ b/library/cpp/digest/sfh/sfh.h @@ -6,9 +6,9 @@ inline ui32 SuperFastHash(const void* d, size_t l) noexcept { ui32 hash = (ui32)l; ui32 tmp; - + if (!l || !d) - return 0; + return 0; TUnalignedMemoryIterator<ui16, 4> iter(d, l); |