mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-24 00:17:54 +00:00
core/crypto: Stop using context.temp_allocator
The max digest size for the foreseeable future will be 512 bits, and the max block size is currently 1152 bits (SHA3-224). If people add more exotic hash algorithms without bumping the constants when required, tests will fail. The stream buffer will currently be 576 bytes, which is "fine" to just stick on the stack, and is a sensible multiple of the more common block size of 64 bytes.
This commit is contained in:
@@ -514,6 +514,31 @@ test_hash :: proc(t: ^testing.T) {
|
||||
|
||||
algo_name := hash.ALGORITHM_NAMES[algo]
|
||||
|
||||
// Ensure that the MAX_(DIGEST_SIZE, BLOCK_SIZE) constants are
|
||||
// still correct.
|
||||
digest_sz := hash.DIGEST_SIZES[algo]
|
||||
block_sz := hash.BLOCK_SIZES[algo]
|
||||
expect(
|
||||
t,
|
||||
digest_sz <= hash.MAX_DIGEST_SIZE,
|
||||
fmt.tprintf(
|
||||
"%s: Digest size %d exceeds max %d",
|
||||
algo_name,
|
||||
digest_sz,
|
||||
hash.MAX_DIGEST_SIZE,
|
||||
),
|
||||
)
|
||||
expect(
|
||||
t,
|
||||
block_sz <= hash.MAX_BLOCK_SIZE,
|
||||
fmt.tprintf(
|
||||
"%s: Block size %d exceeds max %d",
|
||||
algo_name,
|
||||
block_sz,
|
||||
hash.MAX_BLOCK_SIZE,
|
||||
),
|
||||
)
|
||||
|
||||
// Exercise most of the happy-path for the high level interface.
|
||||
rd: bytes.Reader
|
||||
bytes.reader_init(&rd, transmute([]byte)(data_1_000_000_a))
|
||||
|
||||
Reference in New Issue
Block a user