mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-07 13:33:13 +00:00
Merge branch 'master' of https://github.com/odin-lang/Odin
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -746,6 +746,8 @@ dynamic_pool_reset :: proc(using pool: ^Dynamic_Pool) {
|
||||
free(a, block_allocator)
|
||||
}
|
||||
clear(&out_band_allocations)
|
||||
|
||||
bytes_left = 0 // Make new allocations call `cycle_new_block` again.
|
||||
}
|
||||
|
||||
dynamic_pool_free_all :: proc(using pool: ^Dynamic_Pool) {
|
||||
|
||||
@@ -14,6 +14,7 @@ package test_core_crypto
|
||||
|
||||
import "core:testing"
|
||||
import "core:fmt"
|
||||
import "core:strings"
|
||||
|
||||
import "core:crypto/md2"
|
||||
import "core:crypto/md4"
|
||||
@@ -230,11 +231,14 @@ test_sha224 :: proc(t: ^testing.T) {
|
||||
// Test vectors from
|
||||
// https://csrc.nist.gov/csrc/media/projects/cryptographic-standards-and-guidelines/documents/examples/sha_all.pdf
|
||||
// https://www.di-mgt.com.au/sha_testvectors.html
|
||||
// https://datatracker.ietf.org/doc/html/rfc3874#section-3.3
|
||||
data_1_000_000_a := strings.repeat("a", 1_000_000)
|
||||
test_vectors := [?]TestHash {
|
||||
TestHash{"d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f", ""},
|
||||
TestHash{"23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7", "abc"},
|
||||
TestHash{"75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525", "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"},
|
||||
TestHash{"c97ca9a559850ce97a04a96def6d99a9e0e0e2ab14e6b8df265fc0b3", "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"},
|
||||
TestHash{"20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67", data_1_000_000_a},
|
||||
}
|
||||
for v, _ in test_vectors {
|
||||
computed := sha2.hash_224(v.str)
|
||||
|
||||
4
tests/vendor/botan/test_vendor_botan.odin
vendored
4
tests/vendor/botan/test_vendor_botan.odin
vendored
@@ -15,6 +15,7 @@ package test_vendor_botan
|
||||
import "core:testing"
|
||||
import "core:fmt"
|
||||
import "core:os"
|
||||
import "core:strings"
|
||||
|
||||
import "vendor:botan/md4"
|
||||
import "vendor:botan/md5"
|
||||
@@ -172,11 +173,14 @@ test_sha224 :: proc(t: ^testing.T) {
|
||||
// Test vectors from
|
||||
// https://csrc.nist.gov/csrc/media/projects/cryptographic-standards-and-guidelines/documents/examples/sha_all.pdf
|
||||
// https://www.di-mgt.com.au/sha_testvectors.html
|
||||
// https://datatracker.ietf.org/doc/html/rfc3874#section-3.3
|
||||
data_1_000_000_a := strings.repeat("a", 1_000_000)
|
||||
test_vectors := [?]TestHash {
|
||||
TestHash{"d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f", ""},
|
||||
TestHash{"23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7", "abc"},
|
||||
TestHash{"75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525", "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"},
|
||||
TestHash{"c97ca9a559850ce97a04a96def6d99a9e0e0e2ab14e6b8df265fc0b3", "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"},
|
||||
TestHash{"20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67", data_1_000_000_a},
|
||||
}
|
||||
for v, _ in test_vectors {
|
||||
computed := sha2.hash_224(v.str)
|
||||
|
||||
Reference in New Issue
Block a user