aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYawning Angel <yawning@schwanenlied.me>2023-11-16 21:53:42 +0900
committerYawning Angel <yawning@schwanenlied.me>2023-11-17 19:31:51 +0900
commit8d943f590218beb970b4ef3f9b6caf7a8a852c18 (patch)
tree8dd704c073c592a3acae7c5938ff2db61651f6a8
parent32b27c690d0b2864a86786e9a115e21ab2bbb25f (diff)
core/crypto/streebog: Remove, exotic
-rw-r--r--core/crypto/README.md1
-rw-r--r--core/crypto/streebog/streebog.odin517
-rw-r--r--examples/all/all_main.odin2
-rw-r--r--examples/all/all_vendor.odin2
-rw-r--r--tests/core/crypto/test_core_crypto.odin31
-rw-r--r--tests/vendor/botan/test_vendor_botan.odin31
-rw-r--r--vendor/botan/README.md1
-rw-r--r--vendor/botan/bindings/botan.odin2
-rw-r--r--vendor/botan/streebog/streebog.odin204
9 files changed, 0 insertions, 791 deletions
diff --git a/core/crypto/README.md b/core/crypto/README.md
index 82db2775f..eaf8c13e2 100644
--- a/core/crypto/README.md
+++ b/core/crypto/README.md
@@ -17,7 +17,6 @@ Please see the chart below for the options.
| [SHA-3](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf) | &#10004;&#65039; |
| [SHAKE](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf) | &#10004;&#65039; |
| [SM3](https://datatracker.ietf.org/doc/html/draft-sca-cfrg-sm3-02) | &#10004;&#65039; |
-| [Streebog](https://datatracker.ietf.org/doc/html/rfc6986) | &#10004;&#65039; |
| [Tiger](https://www.cs.technion.ac.il/~biham/Reports/Tiger/) | &#10004;&#65039; |
| [Tiger2](https://www.cs.technion.ac.il/~biham/Reports/Tiger/) | &#10004;&#65039; |
| [Whirlpool](https://web.archive.org/web/20171129084214/http://www.larc.usp.br/~pbarreto/WhirlpoolPage.html) | &#10004;&#65039; |
diff --git a/core/crypto/streebog/streebog.odin b/core/crypto/streebog/streebog.odin
deleted file mode 100644
index 42da1e695..000000000
--- a/core/crypto/streebog/streebog.odin
+++ /dev/null
@@ -1,517 +0,0 @@
-package streebog
-
-/*
- Copyright 2021 zhibog
- Made available under the BSD-3 license.
-
- List of contributors:
- zhibog, dotbmp: Initial implementation.
-
- Implementation of the Streebog hashing algorithm, standardized as GOST R 34.11-2012 in RFC 6986 <https://datatracker.ietf.org/doc/html/rfc6986>
-*/
-
-import "core:os"
-import "core:io"
-
-import "../util"
-
-/*
- High level API
-*/
-
-DIGEST_SIZE_256 :: 32
-DIGEST_SIZE_512 :: 64
-
-// hash_string_256 will hash the given input and return the
-// computed hash
-hash_string_256 :: proc(data: string) -> [DIGEST_SIZE_256]byte {
- return hash_bytes_256(transmute([]byte)(data))
-}
-
-// hash_bytes_256 will hash the given input and return the
-// computed hash
-hash_bytes_256 :: proc(data: []byte) -> [DIGEST_SIZE_256]byte {
- hash: [DIGEST_SIZE_256]byte
- ctx: Streebog_Context
- ctx.is256 = true
- init(&ctx)
- update(&ctx, data)
- final(&ctx, hash[:])
- return hash
-}
-
-// hash_string_to_buffer_256 will hash the given input and assign the
-// computed hash to the second parameter.
-// It requires that the destination buffer is at least as big as the digest size
-hash_string_to_buffer_256 :: proc(data: string, hash: []byte) {
- hash_bytes_to_buffer_256(transmute([]byte)(data), hash)
-}
-
-// hash_bytes_to_buffer_256 will hash the given input and write the
-// computed hash into the second parameter.
-// It requires that the destination buffer is at least as big as the digest size
-hash_bytes_to_buffer_256 :: proc(data, hash: []byte) {
- assert(len(hash) >= DIGEST_SIZE_256, "Size of destination buffer is smaller than the digest size")
- ctx: Streebog_Context
- ctx.is256 = true
- init(&ctx)
- update(&ctx, data)
- final(&ctx, hash[:])
-}
-
-// hash_stream_256 will read the stream in chunks and compute a
-// hash from its contents
-hash_stream_256 :: proc(s: io.Stream) -> ([DIGEST_SIZE_256]byte, bool) {
- hash: [DIGEST_SIZE_256]byte
- ctx: Streebog_Context
- ctx.is256 = true
- init(&ctx)
- buf := make([]byte, 512)
- defer delete(buf)
- read := 1
- for read > 0 {
- read, _ = io.read(s, buf)
- if read > 0 {
- update(&ctx, buf[:read])
- }
- }
- final(&ctx, hash[:])
- return hash, true
-}
-
-// hash_file_256 will read the file provided by the given handle
-// and compute a hash
-hash_file_256 :: proc(hd: os.Handle, load_at_once := false) -> ([DIGEST_SIZE_256]byte, bool) {
- if !load_at_once {
- return hash_stream_256(os.stream_from_handle(hd))
- } else {
- if buf, ok := os.read_entire_file(hd); ok {
- return hash_bytes_256(buf[:]), ok
- }
- }
- return [DIGEST_SIZE_256]byte{}, false
-}
-
-hash_256 :: proc {
- hash_stream_256,
- hash_file_256,
- hash_bytes_256,
- hash_string_256,
- hash_bytes_to_buffer_256,
- hash_string_to_buffer_256,
-}
-
-// hash_string_512 will hash the given input and return the
-// computed hash
-hash_string_512 :: proc(data: string) -> [DIGEST_SIZE_512]byte {
- return hash_bytes_512(transmute([]byte)(data))
-}
-
-// hash_bytes_512 will hash the given input and return the
-// computed hash
-hash_bytes_512 :: proc(data: []byte) -> [DIGEST_SIZE_512]byte {
- hash: [DIGEST_SIZE_512]byte
- ctx: Streebog_Context
- init(&ctx)
- update(&ctx, data)
- final(&ctx, hash[:])
- return hash
-}
-
-// hash_string_to_buffer_512 will hash the given input and assign the
-// computed hash to the second parameter.
-// It requires that the destination buffer is at least as big as the digest size
-hash_string_to_buffer_512 :: proc(data: string, hash: []byte) {
- hash_bytes_to_buffer_512(transmute([]byte)(data), hash)
-}
-
-// hash_bytes_to_buffer_512 will hash the given input and write the
-// computed hash into the second parameter.
-// It requires that the destination buffer is at least as big as the digest size
-hash_bytes_to_buffer_512 :: proc(data, hash: []byte) {
- assert(len(hash) >= DIGEST_SIZE_512, "Size of destination buffer is smaller than the digest size")
- ctx: Streebog_Context
- init(&ctx)
- update(&ctx, data)
- final(&ctx, hash[:])
-}
-
-// hash_stream_512 will read the stream in chunks and compute a
-// hash from its contents
-hash_stream_512 :: proc(s: io.Stream) -> ([DIGEST_SIZE_512]byte, bool) {
- hash: [DIGEST_SIZE_512]byte
- ctx: Streebog_Context
- init(&ctx)
- buf := make([]byte, 512)
- defer delete(buf)
- read := 1
- for read > 0 {
- read, _ = io.read(s, buf)
- if read > 0 {
- update(&ctx, buf[:read])
- }
- }
- final(&ctx, hash[:])
- return hash, true
-}
-
-// hash_file_512 will read the file provided by the given handle
-// and compute a hash
-hash_file_512 :: proc(hd: os.Handle, load_at_once := false) -> ([DIGEST_SIZE_512]byte, bool) {
- if !load_at_once {
- return hash_stream_512(os.stream_from_handle(hd))
- } else {
- if buf, ok := os.read_entire_file(hd); ok {
- return hash_bytes_512(buf[:]), ok
- }
- }
- return [DIGEST_SIZE_512]byte{}, false
-}
-
-hash_512 :: proc {
- hash_stream_512,
- hash_file_512,
- hash_bytes_512,
- hash_string_512,
- hash_bytes_to_buffer_512,
- hash_string_to_buffer_512,
-}
-
-/*
- Low level API
-*/
-
-init :: proc(ctx: ^Streebog_Context) {
- if ctx.is256 {
- ctx.hash_size = 256
- for _, i in ctx.h {
- ctx.h[i] = 0x01
- }
- } else {
- ctx.hash_size = 512
- }
- ctx.v_512[1] = 0x02
-}
-
-update :: proc(ctx: ^Streebog_Context, data: []byte) {
- length := u64(len(data))
- chk_size: u64
- data := data
- for (length > 63) && (ctx.buf_size == 0) {
- stage2(ctx, data)
- data = data[64:]
- length -= 64
- }
-
- for length != 0 {
- chk_size = 64 - ctx.buf_size
- if chk_size > length {
- chk_size = length
- }
- copy(ctx.buffer[ctx.buf_size:], data[:chk_size])
- ctx.buf_size += chk_size
- length -= chk_size
- data = data[chk_size:]
- if ctx.buf_size == 64 {
- stage2(ctx, ctx.buffer[:])
- ctx.buf_size = 0
- }
- }
-}
-
-final :: proc(ctx: ^Streebog_Context, hash: []byte) {
- t: [64]byte
- t[1] = byte((ctx.buf_size * 8) >> 8) & 0xff
- t[0] = byte((ctx.buf_size) * 8) & 0xff
-
- padding(ctx)
-
- G(ctx.h[:], ctx.n[:], ctx.buffer[:])
-
- add_mod_512(ctx.n[:], t[:], ctx.n[:])
- add_mod_512(ctx.sigma[:], ctx.buffer[:], ctx.sigma[:])
-
- G(ctx.h[:], ctx.v_0[:], ctx.n[:])
- G(ctx.h[:], ctx.v_0[:], ctx.sigma[:])
-
- if ctx.is256 {
- copy(hash[:], ctx.h[32:])
- } else {
- copy(hash[:], ctx.h[:])
- }
-}
-
-/*
- Streebog implementation
-*/
-
-PI := [256]byte {
- 252, 238, 221, 17, 207, 110, 49, 22, 251, 196, 250, 218, 35, 197, 4, 77,
- 233, 119, 240, 219, 147, 46, 153, 186, 23, 54, 241, 187, 20, 205, 95, 193,
- 249, 24, 101, 90, 226, 92, 239, 33, 129, 28, 60, 66, 139, 1, 142, 79,
- 5, 132, 2, 174, 227, 106, 143, 160, 6, 11, 237, 152, 127, 212, 211, 31,
- 235, 52, 44, 81, 234, 200, 72, 171, 242, 42, 104, 162, 253, 58, 206, 204,
- 181, 112, 14, 86, 8, 12, 118, 18, 191, 114, 19, 71, 156, 183, 93, 135,
- 21, 161, 150, 41, 16, 123, 154, 199, 243, 145, 120, 111, 157, 158, 178, 177,
- 50, 117, 25, 61, 255, 53, 138, 126, 109, 84, 198, 128, 195, 189, 13, 87,
- 223, 245, 36, 169, 62, 168, 67, 201, 215, 121, 214, 246, 124, 34, 185, 3,
- 224, 15, 236, 222, 122, 148, 176, 188, 220, 232, 40, 80, 78, 51, 10, 74,
- 167, 151, 96, 115, 30, 0, 98, 68, 26, 184, 56, 130, 100, 159, 38, 65,
- 173, 69, 70, 146, 39, 94, 85, 47, 140, 163, 165, 125, 105, 213, 149, 59,
- 7, 88, 179, 64, 134, 172, 29, 247, 48, 55, 107, 228, 136, 217, 231, 137,
- 225, 27, 131, 73, 76, 63, 248, 254, 141, 83, 170, 144, 202, 216, 133, 97,
- 32, 113, 103, 164, 45, 43, 9, 91, 203, 155, 37, 208, 190, 229, 108, 82,
- 89, 166, 116, 210, 230, 244, 180, 192, 209, 102, 175, 194, 57, 75, 99, 182,
-}
-
-TAU := [64]byte {
- 0, 8, 16, 24, 32, 40, 48, 56,
- 1, 9, 17, 25, 33, 41, 49, 57,
- 2, 10, 18, 26, 34, 42, 50, 58,
- 3, 11, 19, 27, 35, 43, 51, 59,
- 4, 12, 20, 28, 36, 44, 52, 60,
- 5, 13, 21, 29, 37, 45, 53, 61,
- 6, 14, 22, 30, 38, 46, 54, 62,
- 7, 15, 23, 31, 39, 47, 55, 63,
-}
-
-STREEBOG_A := [64]u64 {
- 0x8e20faa72ba0b470, 0x47107ddd9b505a38, 0xad08b0e0c3282d1c, 0xd8045870ef14980e,
- 0x6c022c38f90a4c07, 0x3601161cf205268d, 0x1b8e0b0e798c13c8, 0x83478b07b2468764,
- 0xa011d380818e8f40, 0x5086e740ce47c920, 0x2843fd2067adea10, 0x14aff010bdd87508,
- 0x0ad97808d06cb404, 0x05e23c0468365a02, 0x8c711e02341b2d01, 0x46b60f011a83988e,
- 0x90dab52a387ae76f, 0x486dd4151c3dfdb9, 0x24b86a840e90f0d2, 0x125c354207487869,
- 0x092e94218d243cba, 0x8a174a9ec8121e5d, 0x4585254f64090fa0, 0xaccc9ca9328a8950,
- 0x9d4df05d5f661451, 0xc0a878a0a1330aa6, 0x60543c50de970553, 0x302a1e286fc58ca7,
- 0x18150f14b9ec46dd, 0x0c84890ad27623e0, 0x0642ca05693b9f70, 0x0321658cba93c138,
- 0x86275df09ce8aaa8, 0x439da0784e745554, 0xafc0503c273aa42a, 0xd960281e9d1d5215,
- 0xe230140fc0802984, 0x71180a8960409a42, 0xb60c05ca30204d21, 0x5b068c651810a89e,
- 0x456c34887a3805b9, 0xac361a443d1c8cd2, 0x561b0d22900e4669, 0x2b838811480723ba,
- 0x9bcf4486248d9f5d, 0xc3e9224312c8c1a0, 0xeffa11af0964ee50, 0xf97d86d98a327728,
- 0xe4fa2054a80b329c, 0x727d102a548b194e, 0x39b008152acb8227, 0x9258048415eb419d,
- 0x492c024284fbaec0, 0xaa16012142f35760, 0x550b8e9e21f7a530, 0xa48b474f9ef5dc18,
- 0x70a6a56e2440598e, 0x3853dc371220a247, 0x1ca76e95091051ad, 0x0edd37c48a08a6d8,
- 0x07e095624504536c, 0x8d70c431ac02a736, 0xc83862965601dd1b, 0x641c314b2b8ee083,
-}
-
-STREEBOG_C := [12][64]byte {
- {
- 0x07, 0x45, 0xa6, 0xf2, 0x59, 0x65, 0x80, 0xdd,
- 0x23, 0x4d, 0x74, 0xcc, 0x36, 0x74, 0x76, 0x05,
- 0x15, 0xd3, 0x60, 0xa4, 0x08, 0x2a, 0x42, 0xa2,
- 0x01, 0x69, 0x67, 0x92, 0x91, 0xe0, 0x7c, 0x4b,
- 0xfc, 0xc4, 0x85, 0x75, 0x8d, 0xb8, 0x4e, 0x71,
- 0x16, 0xd0, 0x45, 0x2e, 0x43, 0x76, 0x6a, 0x2f,
- 0x1f, 0x7c, 0x65, 0xc0, 0x81, 0x2f, 0xcb, 0xeb,
- 0xe9, 0xda, 0xca, 0x1e, 0xda, 0x5b, 0x08, 0xb1,
- },
- {
- 0xb7, 0x9b, 0xb1, 0x21, 0x70, 0x04, 0x79, 0xe6,
- 0x56, 0xcd, 0xcb, 0xd7, 0x1b, 0xa2, 0xdd, 0x55,
- 0xca, 0xa7, 0x0a, 0xdb, 0xc2, 0x61, 0xb5, 0x5c,
- 0x58, 0x99, 0xd6, 0x12, 0x6b, 0x17, 0xb5, 0x9a,
- 0x31, 0x01, 0xb5, 0x16, 0x0f, 0x5e, 0xd5, 0x61,
- 0x98, 0x2b, 0x23, 0x0a, 0x72, 0xea, 0xfe, 0xf3,
- 0xd7, 0xb5, 0x70, 0x0f, 0x46, 0x9d, 0xe3, 0x4f,
- 0x1a, 0x2f, 0x9d, 0xa9, 0x8a, 0xb5, 0xa3, 0x6f,
- },
- {
- 0xb2, 0x0a, 0xba, 0x0a, 0xf5, 0x96, 0x1e, 0x99,
- 0x31, 0xdb, 0x7a, 0x86, 0x43, 0xf4, 0xb6, 0xc2,
- 0x09, 0xdb, 0x62, 0x60, 0x37, 0x3a, 0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, 0x1d, 0x8a,
- 0x79, 0x66, 0x84, 0x14, 0x21, 0x80, 0x01, 0x20,
- 0x61, 0x07, 0xab, 0xeb, 0xbb, 0x6b, 0xfa, 0xd8,
- 0x94, 0xfe, 0x5a, 0x63, 0xcd, 0xc6, 0x02, 0x30,
- 0xfb, 0x89, 0xc8, 0xef, 0xd0, 0x9e, 0xcd, 0x7b,
- },
- {
- 0x20, 0xd7, 0x1b, 0xf1, 0x4a, 0x92, 0xbc, 0x48,
- 0x99, 0x1b, 0xb2, 0xd9, 0xd5, 0x17, 0xf4, 0xfa,
- 0x52, 0x28, 0xe1, 0x88, 0xaa, 0xa4, 0x1d, 0xe7,
- 0x86, 0xcc, 0x91, 0x18, 0x9d, 0xef, 0x80, 0x5d,
- 0x9b, 0x9f, 0x21, 0x30, 0xd4, 0x12, 0x20, 0xf8,
- 0x77, 0x1d, 0xdf, 0xbc, 0x32, 0x3c, 0xa4, 0xcd,
- 0x7a, 0xb1, 0x49, 0x04, 0xb0, 0x80, 0x13, 0xd2,
- 0xba, 0x31, 0x16, 0xf1, 0x67, 0xe7, 0x8e, 0x37,
- },
-}
-
-Streebog_Context :: struct {
- buffer: [64]byte,
- h: [64]byte,
- n: [64]byte,
- sigma: [64]byte,
- v_0: [64]byte,
- v_512: [64]byte,
- buf_size: u64,
- hash_size: int,
- is256: bool,
-}
-
-add_mod_512 :: proc(first_vector, second_vector, result_vector: []byte) {
- t: i32 = 0
- for i: i32 = 0; i < 64; i += 1 {
- t = i32(first_vector[i]) + i32(second_vector[i]) + (t >> 8)
- result_vector[i] = byte(t & 0xff)
- }
-}
-
-X :: #force_inline proc(a, k, out: []byte) {
- for i := 0; i < 64; i += 1 {
- out[i] = a[i] ~ k[i]
- }
-}
-
-S :: #force_inline proc(state: []byte) {
- t: [64]byte
- for i: i32 = 63; i >= 0; i -= 1 {
- t[i] = PI[state[i]]
- }
- copy(state, t[:])
-}
-
-P :: #force_inline proc(state: []byte) {
- t: [64]byte
- for i: i32 = 63; i >= 0; i -= 1 {
- t[i] = state[TAU[i]]
- }
- copy(state, t[:])
-}
-
-L :: #force_inline proc(state: []byte) {
- ins := util.cast_slice([]u64, state)
- out: [8]u64
- for i: i32 = 7; i >= 0; i -= 1 {
- for j: i32 = 63; j >= 0; j -= 1 {
- if (ins[i] >> u32(j)) & 1 != 0 {
- out[i] ~= STREEBOG_A[63 - j]
- }
- }
- }
- copy(state, util.cast_slice([]byte, out[:]))
-}
-
-E :: #force_inline proc(K, m, state: []byte) {
- X(m, K, state)
- for i: i32 = 0; i < 12; i += 1 {
- S(state)
- P(state)
- L(state)
- get_key(K, i)
- X(state, K, state)
- }
-}
-
-get_key :: #force_inline proc(K: []byte, i: i32) {
- X(K, STREEBOG_C[i][:], K)
- S(K)
- P(K)
- L(K)
-}
-
-G :: #force_inline proc(h, N, m: []byte) {
- t, K: [64]byte
- X(N, h, K[:])
- S(K[:])
- P(K[:])
- L(K[:])
- E(K[:], m, t[:])
- X(t[:], h, t[:])
- X(t[:], m, h)
-}
-
-stage2 :: proc(ctx: ^Streebog_Context, m: []byte) {
- G(ctx.h[:], ctx.n[:], m)
- add_mod_512(ctx.n[:], ctx.v_512[:], ctx.n[:])
- add_mod_512(ctx.sigma[:], m, ctx.sigma[:])
-}
-
-padding :: proc(ctx: ^Streebog_Context) {
- if ctx.buf_size < 64 {
- t: [64]byte
- copy(t[:], ctx.buffer[:int(ctx.buf_size)])
- t[ctx.buf_size] = 0x01
- copy(ctx.buffer[:], t[:])
- }
-}
diff --git a/examples/all/all_main.odin b/examples/all/all_main.odin
index 74ac7401e..f26672514 100644
--- a/examples/all/all_main.odin
+++ b/examples/all/all_main.odin
@@ -35,7 +35,6 @@ import sha2 "core:crypto/sha2"
import sha3 "core:crypto/sha3"
import shake "core:crypto/shake"
import sm3 "core:crypto/sm3"
-import streebog "core:crypto/streebog"
import tiger "core:crypto/tiger"
import tiger2 "core:crypto/tiger2"
import crypto_util "core:crypto/util"
@@ -154,7 +153,6 @@ _ :: sha2
_ :: sha3
_ :: shake
_ :: sm3
-_ :: streebog
_ :: tiger
_ :: tiger2
_ :: crypto_util
diff --git a/examples/all/all_vendor.odin b/examples/all/all_vendor.odin
index 432059f6a..bcfd15609 100644
--- a/examples/all/all_vendor.odin
+++ b/examples/all/all_vendor.odin
@@ -10,7 +10,6 @@ import sha3 "vendor:botan/sha3"
import shake "vendor:botan/shake"
import siphash "vendor:botan/siphash"
import sm3 "vendor:botan/sm3"
-import streebog "vendor:botan/streebog"
import tiger "vendor:botan/tiger"
import whirlpool "vendor:botan/whirlpool"
@@ -52,7 +51,6 @@ _ :: sha3
_ :: shake
_ :: siphash
_ :: sm3
-_ :: streebog
_ :: tiger
_ :: whirlpool
diff --git a/tests/core/crypto/test_core_crypto.odin b/tests/core/crypto/test_core_crypto.odin
index 362d79d2b..adb2bf0d9 100644
--- a/tests/core/crypto/test_core_crypto.odin
+++ b/tests/core/crypto/test_core_crypto.odin
@@ -27,7 +27,6 @@ import "core:crypto/blake2b"
import "core:crypto/blake2s"
import "core:crypto/tiger"
import "core:crypto/tiger2"
-import "core:crypto/streebog"
import "core:crypto/sm3"
import "core:crypto/siphash"
import "core:os"
@@ -73,8 +72,6 @@ main :: proc() {
test_keccak_384(&t)
test_keccak_512(&t)
test_whirlpool(&t)
- test_streebog_256(&t)
- test_streebog_512(&t)
test_blake2b(&t)
test_blake2s(&t)
test_tiger_128(&t)
@@ -454,34 +451,6 @@ test_whirlpool :: proc(t: ^testing.T) {
}
@(test)
-test_streebog_256 :: proc(t: ^testing.T) {
- test_vectors := [?]TestHash {
- TestHash{"3f539a213e97c802cc229d474c6aa32a825a360b2a933a949fd925208d9ce1bb", ""},
- TestHash{"3e7dea7f2384b6c5a3d0e24aaa29c05e89ddd762145030ec22c71a6db8b2c1f4", "The quick brown fox jumps over the lazy dog"},
- TestHash{"36816a824dcbe7d6171aa58500741f2ea2757ae2e1784ab72c5c3c6c198d71da", "The quick brown fox jumps over the lazy dog."},
- }
- for v, _ in test_vectors {
- computed := streebog.hash_256(v.str)
- computed_str := hex_string(computed[:])
- expect(t, computed_str == v.hash, fmt.tprintf("Expected: %s for input of %s, but got %s instead", v.hash, v.str, computed_str))
- }
-}
-
-@(test)
-test_streebog_512 :: proc(t: ^testing.T) {
- test_vectors := [?]TestHash {
- TestHash{"8e945da209aa869f0455928529bcae4679e9873ab707b55315f56ceb98bef0a7362f715528356ee83cda5f2aac4c6ad2ba3a715c1bcd81cb8e9f90bf4c1c1a8a", ""},
- TestHash{"d2b793a0bb6cb5904828b5b6dcfb443bb8f33efc06ad09368878ae4cdc8245b97e60802469bed1e7c21a64ff0b179a6a1e0bb74d92965450a0adab69162c00fe", "The quick brown fox jumps over the lazy dog"},
- TestHash{"fe0c42f267d921f940faa72bd9fcf84f9f1bd7e9d055e9816e4c2ace1ec83be82d2957cd59b86e123d8f5adee80b3ca08a017599a9fc1a14d940cf87c77df070", "The quick brown fox jumps over the lazy dog."},
- }
- for v, _ in test_vectors {
- computed := streebog.hash_512(v.str)
- computed_str := hex_string(computed[:])
- expect(t, computed_str == v.hash, fmt.tprintf("Expected: %s for input of %s, but got %s instead", v.hash, v.str, computed_str))
- }
-}
-
-@(test)
test_blake2b :: proc(t: ^testing.T) {
test_vectors := [?]TestHash {
TestHash{"786a02f742015903c6c6fd852552d272912f4740e15847618a86e217f71f5419d25e1031afee585313896444934eb04b903a685b1448b755d56f701afe9be2ce", ""},
diff --git a/tests/vendor/botan/test_vendor_botan.odin b/tests/vendor/botan/test_vendor_botan.odin
index 99d4e5c3f..9350486a9 100644
--- a/tests/vendor/botan/test_vendor_botan.odin
+++ b/tests/vendor/botan/test_vendor_botan.odin
@@ -26,7 +26,6 @@ import "vendor:botan/shake"
import "vendor:botan/whirlpool"
import "vendor:botan/blake2b"
import "vendor:botan/tiger"
-import "vendor:botan/streebog"
import "vendor:botan/sm3"
import "vendor:botan/siphash"
@@ -69,8 +68,6 @@ main :: proc() {
// test_shake_256(&t)
test_keccak_512(&t)
test_whirlpool(&t)
- test_streebog_256(&t)
- test_streebog_512(&t)
test_blake2b(&t)
// test_tiger_128(&t)
// test_tiger_160(&t)
@@ -374,34 +371,6 @@ test_whirlpool :: proc(t: ^testing.T) {
}
@(test)
-test_streebog_256 :: proc(t: ^testing.T) {
- test_vectors := [?]TestHash {
- TestHash{"3f539a213e97c802cc229d474c6aa32a825a360b2a933a949fd925208d9ce1bb", ""},
- TestHash{"3e7dea7f2384b6c5a3d0e24aaa29c05e89ddd762145030ec22c71a6db8b2c1f4", "The quick brown fox jumps over the lazy dog"},
- TestHash{"36816a824dcbe7d6171aa58500741f2ea2757ae2e1784ab72c5c3c6c198d71da", "The quick brown fox jumps over the lazy dog."},
- }
- for v, _ in test_vectors {
- computed := streebog.hash_256(v.str)
- computed_str := hex_string(computed[:])
- expect(t, computed_str == v.hash, fmt.tprintf("Expected: %s for input of %s, but got %s instead", v.hash, v.str, computed_str))
- }
-}
-
-@(test)
-test_streebog_512 :: proc(t: ^testing.T) {
- test_vectors := [?]TestHash {
- TestHash{"8e945da209aa869f0455928529bcae4679e9873ab707b55315f56ceb98bef0a7362f715528356ee83cda5f2aac4c6ad2ba3a715c1bcd81cb8e9f90bf4c1c1a8a", ""},
- TestHash{"d2b793a0bb6cb5904828b5b6dcfb443bb8f33efc06ad09368878ae4cdc8245b97e60802469bed1e7c21a64ff0b179a6a1e0bb74d92965450a0adab69162c00fe", "The quick brown fox jumps over the lazy dog"},
- TestHash{"fe0c42f267d921f940faa72bd9fcf84f9f1bd7e9d055e9816e4c2ace1ec83be82d2957cd59b86e123d8f5adee80b3ca08a017599a9fc1a14d940cf87c77df070", "The quick brown fox jumps over the lazy dog."},
- }
- for v, _ in test_vectors {
- computed := streebog.hash_512(v.str)
- computed_str := hex_string(computed[:])
- expect(t, computed_str == v.hash, fmt.tprintf("Expected: %s for input of %s, but got %s instead", v.hash, v.str, computed_str))
- }
-}
-
-@(test)
test_blake2b :: proc(t: ^testing.T) {
test_vectors := [?]TestHash {
TestHash{"786a02f742015903c6c6fd852552d272912f4740e15847618a86e217f71f5419d25e1031afee585313896444934eb04b903a685b1448b755d56f701afe9be2ce", ""},
diff --git a/vendor/botan/README.md b/vendor/botan/README.md
index 6d1087cbf..ec733d47a 100644
--- a/vendor/botan/README.md
+++ b/vendor/botan/README.md
@@ -16,7 +16,6 @@ Wrappers for hashing algorithms have been added to match the API within the Odin
| [SHA-3](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf) | &#10004;&#65039; |
| [SHAKE](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf) | &#10004;&#65039; |
| [SM3](https://datatracker.ietf.org/doc/html/draft-sca-cfrg-sm3-02) | &#10004;&#65039; |
-| [Streebog](https://datatracker.ietf.org/doc/html/rfc6986) | &#10004;&#65039; |
| [Tiger](https://www.cs.technion.ac.il/~biham/Reports/Tiger/) | &#10004;&#65039; |
| [Whirlpool](https://web.archive.org/web/20171129084214/http://www.larc.usp.br/~pbarreto/WhirlpoolPage.html) | &#10004;&#65039; |
diff --git a/vendor/botan/bindings/botan.odin b/vendor/botan/bindings/botan.odin
index 7f3dc99b9..a006977c2 100644
--- a/vendor/botan/bindings/botan.odin
+++ b/vendor/botan/bindings/botan.odin
@@ -80,8 +80,6 @@ HASH_MD5 :: "MD5"
HASH_TIGER_128 :: "Tiger(16,3)"
HASH_TIGER_160 :: "Tiger(20,3)"
HASH_TIGER_192 :: "Tiger(24,3)"
-HASH_STREEBOG_256 :: "Streebog-256"
-HASH_STREEBOG_512 :: "Streebog-512"
HASH_SM3 :: "SM3"
MAC_HMAC_SHA1 :: "HMAC(SHA1)"
diff --git a/vendor/botan/streebog/streebog.odin b/vendor/botan/streebog/streebog.odin
deleted file mode 100644
index 07c39684a..000000000
--- a/vendor/botan/streebog/streebog.odin
+++ /dev/null
@@ -1,204 +0,0 @@
-package vendor_streebog
-
-/*
- Copyright 2021 zhibog
- Made available under the BSD-3 license.
-
- List of contributors:
- zhibog: Initial implementation.
-
- Interface for the Streebog hashing algorithm.
- The hash will be computed via bindings to the Botan crypto library
-*/
-
-import "core:os"
-import "core:io"
-
-import botan "../bindings"
-
-/*
- High level API
-*/
-
-DIGEST_SIZE_256 :: 32
-DIGEST_SIZE_512 :: 64
-
-// hash_string_256 will hash the given input and return the
-// computed hash
-hash_string_256 :: proc(data: string) -> [DIGEST_SIZE_256]byte {
- return hash_bytes_256(transmute([]byte)(data))
-}
-
-// hash_bytes_256 will hash the given input and return the
-// computed hash
-hash_bytes_256 :: proc(data: []byte) -> [DIGEST_SIZE_256]byte {
- hash: [DIGEST_SIZE_256]byte
- ctx: botan.hash_t
- botan.hash_init(&ctx, botan.HASH_STREEBOG_256, 0)
- botan.hash_update(ctx, len(data) == 0 ? nil : &data[0], uint(len(data)))
- botan.hash_final(ctx, &hash[0])
- botan.hash_destroy(ctx)
- return hash
-}
-
-// hash_string_to_buffer_256 will hash the given input and assign the
-// computed hash to the second parameter.
-// It requires that the destination buffer is at least as big as the digest size
-hash_string_to_buffer_256 :: proc(data: string, hash: []byte) {
- hash_bytes_to_buffer_256(transmute([]byte)(data), hash)
-}
-
-// hash_bytes_to_buffer_256 will hash the given input and write the
-// computed hash into the second parameter.
-// It requires that the destination buffer is at least as big as the digest size
-hash_bytes_to_buffer_256 :: proc(data, hash: []byte) {
- assert(len(hash) >= DIGEST_SIZE_256, "Size of destination buffer is smaller than the digest size")
- ctx: botan.hash_t
- botan.hash_init(&ctx, botan.HASH_STREEBOG_256, 0)
- botan.hash_update(ctx, len(data) == 0 ? nil : &data[0], uint(len(data)))
- botan.hash_final(ctx, &hash[0])
- botan.hash_destroy(ctx)
-}
-
-// hash_stream_256 will read the stream in chunks and compute a
-// hash from its contents
-hash_stream_256 :: proc(s: io.Stream) -> ([DIGEST_SIZE_256]byte, bool) {
- hash: [DIGEST_SIZE_256]byte
- ctx: botan.hash_t
- botan.hash_init(&ctx, botan.HASH_STREEBOG_256, 0)
- buf := make([]byte, 512)
- defer delete(buf)
- i := 1
- for i > 0 {
- i, _ = io.read(s, buf)
- if i > 0 {
- botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i))
- }
- }
- botan.hash_final(ctx, &hash[0])
- botan.hash_destroy(ctx)
- return hash, true
-}
-
-// hash_file_256 will read the file provided by the given handle
-// and compute a hash
-hash_file_256 :: proc(hd: os.Handle, load_at_once := false) -> ([DIGEST_SIZE_256]byte, bool) {
- if !load_at_once {
- return hash_stream_256(os.stream_from_handle(hd))
- } else {
- if buf, ok := os.read_entire_file(hd); ok {
- return hash_bytes_256(buf[:]), ok
- }
- }
- return [DIGEST_SIZE_256]byte{}, false
-}
-
-hash_256 :: proc {
- hash_stream_256,
- hash_file_256,
- hash_bytes_256,
- hash_string_256,
- hash_bytes_to_buffer_256,
- hash_string_to_buffer_256,
-}
-
-// hash_string_512 will hash the given input and return the
-// computed hash
-hash_string_512 :: proc(data: string) -> [DIGEST_SIZE_512]byte {
- return hash_bytes_512(transmute([]byte)(data))
-}
-
-// hash_bytes_512 will hash the given input and return the
-// computed hash
-hash_bytes_512 :: proc(data: []byte) -> [DIGEST_SIZE_512]byte {
- hash: [DIGEST_SIZE_512]byte
- ctx: botan.hash_t
- botan.hash_init(&ctx, botan.HASH_STREEBOG_512, 0)
- botan.hash_update(ctx, len(data) == 0 ? nil : &data[0], uint(len(data)))
- botan.hash_final(ctx, &hash[0])
- botan.hash_destroy(ctx)
- return hash
-}
-
-// hash_string_to_buffer_512 will hash the given input and assign the
-// computed hash to the second parameter.
-// It requires that the destination buffer is at least as big as the digest size
-hash_string_to_buffer_512 :: proc(data: string, hash: []byte) {
- hash_bytes_to_buffer_512(transmute([]byte)(data), hash)
-}
-
-// hash_bytes_to_buffer_512 will hash the given input and write the
-// computed hash into the second parameter.
-// It requires that the destination buffer is at least as big as the digest size
-hash_bytes_to_buffer_512 :: proc(data, hash: []byte) {
- assert(len(hash) >= DIGEST_SIZE_512, "Size of destination buffer is smaller than the digest size")
- ctx: botan.hash_t
- botan.hash_init(&ctx, botan.HASH_STREEBOG_512, 0)
- botan.hash_update(ctx, len(data) == 0 ? nil : &data[0], uint(len(data)))
- botan.hash_final(ctx, &hash[0])
- botan.hash_destroy(ctx)
-}
-
-// hash_stream_512 will read the stream in chunks and compute a
-// hash from its contents
-hash_stream_512 :: proc(s: io.Stream) -> ([DIGEST_SIZE_512]byte, bool) {
- hash: [DIGEST_SIZE_512]byte
- ctx: botan.hash_t
- botan.hash_init(&ctx, botan.HASH_STREEBOG_512, 0)
- buf := make([]byte, 512)
- defer delete(buf)
- i := 1
- for i > 0 {
- i, _ = io.read(s, buf)
- if i > 0 {
- botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i))
- }
- }
- botan.hash_final(ctx, &hash[0])
- botan.hash_destroy(ctx)
- return hash, true
-}
-
-// hash_file_512 will read the file provided by the given handle
-// and compute a hash
-hash_file_512 :: proc(hd: os.Handle, load_at_once := false) -> ([DIGEST_SIZE_512]byte, bool) {
- if !load_at_once {
- return hash_stream_512(os.stream_from_handle(hd))
- } else {
- if buf, ok := os.read_entire_file(hd); ok {
- return hash_bytes_512(buf[:]), ok
- }
- }
- return [DIGEST_SIZE_512]byte{}, false
-}
-
-hash_512 :: proc {
- hash_stream_512,
- hash_file_512,
- hash_bytes_512,
- hash_string_512,
- hash_bytes_to_buffer_512,
- hash_string_to_buffer_512,
-}
-
-/*
- Low level API
-*/
-
-Streebog_Context :: botan.hash_t
-
-init :: proc "contextless" (ctx: ^botan.hash_t, hash_size := 512) {
- switch hash_size {
- case 256: botan.hash_init(ctx, botan.HASH_STREEBOG_256, 0)
- case 512: botan.hash_init(ctx, botan.HASH_STREEBOG_512, 0)
- }
-}
-
-update :: proc "contextless" (ctx: ^botan.hash_t, data: []byte) {
- botan.hash_update(ctx^, len(data) == 0 ? nil : &data[0], uint(len(data)))
-}
-
-final :: proc "contextless" (ctx: ^botan.hash_t, hash: []byte) {
- botan.hash_final(ctx^, &hash[0])
- botan.hash_destroy(ctx^)
-} \ No newline at end of file