diff options
| author | zhibog <zhibog-github@web.de> | 2022-05-04 22:13:50 +0200 |
|---|---|---|
| committer | zhibog <zhibog-github@web.de> | 2022-05-04 22:13:50 +0200 |
| commit | 0e91e63043bd5b49dd81dd0f4e9eb1e29e457b87 (patch) | |
| tree | b0f6b4dab6db8ac45de0db7b40f68950a1d13e52 /core/crypto/sha2/sha2.odin | |
| parent | 0cf37bde8b9d21cb2f7392dab5a91000b89fa6ae (diff) | |
Fix issue 1761. Added the test vector to the core and vendor tests
Diffstat (limited to 'core/crypto/sha2/sha2.odin')
| -rw-r--r-- | core/crypto/sha2/sha2.odin | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/core/crypto/sha2/sha2.odin b/core/crypto/sha2/sha2.odin index 7c7b2da81..9792a4cb8 100644 --- a/core/crypto/sha2/sha2.odin +++ b/core/crypto/sha2/sha2.odin @@ -419,8 +419,10 @@ update :: proc(ctx: ^$T, data: []byte) { sha2_transf(ctx, shifted_message, block_nb) rem_len = new_len % CURR_BLOCK_SIZE - when T == Sha256_Context {copy(ctx.block[:], shifted_message[block_nb << 6:rem_len])} - else when T == Sha512_Context {copy(ctx.block[:], shifted_message[block_nb << 7:rem_len])} + if rem_len > 0 { + when T == Sha256_Context {copy(ctx.block[:], shifted_message[block_nb << 6:rem_len])} + else when T == Sha512_Context {copy(ctx.block[:], shifted_message[block_nb << 7:rem_len])} + } ctx.length = rem_len when T == Sha256_Context {ctx.tot_len += (block_nb + 1) << 6} |