Skip to content

Commit

Permalink
Update picosha2 and stb_image
Browse files Browse the repository at this point in the history
  • Loading branch information
sz3 committed Feb 18, 2022
1 parent 39b37d9 commit cc6abee
Show file tree
Hide file tree
Showing 2 changed files with 214 additions and 80 deletions.
12 changes: 6 additions & 6 deletions src/third_party_lib/PicoSHA2/picosha2.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void hash256_block(RaIter1 message_digest, RaIter2 first, RaIter2 last) {
assert(first + 64 == last);
static_cast<void>(last); // for avoiding unused-variable warning
word_t w[64];
std::fill(w, w + 64, 0);
std::fill(w, w + 64, word_t(0));
for (std::size_t i = 0; i < 16; ++i) {
w[i] = (static_cast<word_t>(mask_8bit(*(first + i * 4))) << 24) |
(static_cast<word_t>(mask_8bit(*(first + i * 4 + 1))) << 16) |
Expand Down Expand Up @@ -185,7 +185,7 @@ class hash256_one_by_one {

void init() {
buffer_.clear();
std::fill(data_length_digits_, data_length_digits_ + 4, 0);
std::fill(data_length_digits_, data_length_digits_ + 4, word_t(0));
std::copy(detail::initial_message_digest,
detail::initial_message_digest + 8, h_);
}
Expand All @@ -204,17 +204,17 @@ class hash256_one_by_one {

void finish() {
byte_t temp[64];
std::fill(temp, temp + 64, 0);
std::fill(temp, temp + 64, byte_t(0));
std::size_t remains = buffer_.size();
std::copy(buffer_.begin(), buffer_.end(), temp);
temp[remains] = 0x80;

if (remains > 55) {
std::fill(temp + remains + 1, temp + 64, 0);
std::fill(temp + remains + 1, temp + 64, byte_t(0));
detail::hash256_block(h_, temp, temp + 64);
std::fill(temp, temp + 64 - 4, 0);
std::fill(temp, temp + 64 - 4, byte_t(0));
} else {
std::fill(temp + remains + 1, temp + 64 - 4, 0);
std::fill(temp + remains + 1, temp + 64 - 4, byte_t(0));
}

write_data_bit_length(&(temp[56]));
Expand Down
Loading

0 comments on commit cc6abee

Please sign in to comment.