diff --git a/OpenCL/inc_hash_md4.cl b/OpenCL/inc_hash_md4.cl index d02add1fb..425aa3e09 100644 --- a/OpenCL/inc_hash_md4.cl +++ b/OpenCL/inc_hash_md4.cl @@ -1057,29 +1057,24 @@ DECLSPEC void md4_hmac_final (md4_hmac_ctx_t *ctx) { md4_final (&ctx->ipad); - u32 t0[4]; - u32 t1[4]; - u32 t2[4]; - u32 t3[4]; + ctx->opad.w0[0] = ctx->ipad.h[0]; + ctx->opad.w0[1] = ctx->ipad.h[1]; + ctx->opad.w0[2] = ctx->ipad.h[2]; + ctx->opad.w0[3] = ctx->ipad.h[3]; + ctx->opad.w1[0] = 0; + ctx->opad.w1[1] = 0; + ctx->opad.w1[2] = 0; + ctx->opad.w1[3] = 0; + ctx->opad.w2[0] = 0; + ctx->opad.w2[1] = 0; + ctx->opad.w2[2] = 0; + ctx->opad.w2[3] = 0; + ctx->opad.w3[0] = 0; + ctx->opad.w3[1] = 0; + ctx->opad.w3[2] = 0; + ctx->opad.w3[3] = 0; - t0[0] = ctx->ipad.h[0]; - t0[1] = ctx->ipad.h[1]; - t0[2] = ctx->ipad.h[2]; - t0[3] = ctx->ipad.h[3]; - t1[0] = 0; - t1[1] = 0; - t1[2] = 0; - t1[3] = 0; - t2[0] = 0; - t2[1] = 0; - t2[2] = 0; - t2[3] = 0; - t3[0] = 0; - t3[1] = 0; - t3[2] = 0; - t3[3] = 0; - - md4_update_64 (&ctx->opad, t0, t1, t2, t3, 16); + ctx->opad.len += 16; md4_final (&ctx->opad); } @@ -1695,29 +1690,24 @@ DECLSPEC void md4_hmac_final_vector (md4_hmac_ctx_vector_t *ctx) { md4_final_vector (&ctx->ipad); - u32x t0[4]; - u32x t1[4]; - u32x t2[4]; - u32x t3[4]; + ctx->opad.w0[0] = ctx->ipad.h[0]; + ctx->opad.w0[1] = ctx->ipad.h[1]; + ctx->opad.w0[2] = ctx->ipad.h[2]; + ctx->opad.w0[3] = ctx->ipad.h[3]; + ctx->opad.w1[0] = 0; + ctx->opad.w1[1] = 0; + ctx->opad.w1[2] = 0; + ctx->opad.w1[3] = 0; + ctx->opad.w2[0] = 0; + ctx->opad.w2[1] = 0; + ctx->opad.w2[2] = 0; + ctx->opad.w2[3] = 0; + ctx->opad.w3[0] = 0; + ctx->opad.w3[1] = 0; + ctx->opad.w3[2] = 0; + ctx->opad.w3[3] = 0; - t0[0] = ctx->ipad.h[0]; - t0[1] = ctx->ipad.h[1]; - t0[2] = ctx->ipad.h[2]; - t0[3] = ctx->ipad.h[3]; - t1[0] = 0; - t1[1] = 0; - t1[2] = 0; - t1[3] = 0; - t2[0] = 0; - t2[1] = 0; - t2[2] = 0; - t2[3] = 0; - t3[0] = 0; - t3[1] = 0; - t3[2] = 0; - t3[3] = 0; - - md4_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 16); + ctx->opad.len += 16; md4_final_vector (&ctx->opad); } diff --git a/OpenCL/inc_hash_md5.cl b/OpenCL/inc_hash_md5.cl index b88bb32ea..7a7dbc3c3 100644 --- a/OpenCL/inc_hash_md5.cl +++ b/OpenCL/inc_hash_md5.cl @@ -1093,29 +1093,24 @@ DECLSPEC void md5_hmac_final (md5_hmac_ctx_t *ctx) { md5_final (&ctx->ipad); - u32 t0[4]; - u32 t1[4]; - u32 t2[4]; - u32 t3[4]; + ctx->opad.w0[0] = ctx->ipad.h[0]; + ctx->opad.w0[1] = ctx->ipad.h[1]; + ctx->opad.w0[2] = ctx->ipad.h[2]; + ctx->opad.w0[3] = ctx->ipad.h[3]; + ctx->opad.w1[0] = 0; + ctx->opad.w1[1] = 0; + ctx->opad.w1[2] = 0; + ctx->opad.w1[3] = 0; + ctx->opad.w2[0] = 0; + ctx->opad.w2[1] = 0; + ctx->opad.w2[2] = 0; + ctx->opad.w2[3] = 0; + ctx->opad.w3[0] = 0; + ctx->opad.w3[1] = 0; + ctx->opad.w3[2] = 0; + ctx->opad.w3[3] = 0; - t0[0] = ctx->ipad.h[0]; - t0[1] = ctx->ipad.h[1]; - t0[2] = ctx->ipad.h[2]; - t0[3] = ctx->ipad.h[3]; - t1[0] = 0; - t1[1] = 0; - t1[2] = 0; - t1[3] = 0; - t2[0] = 0; - t2[1] = 0; - t2[2] = 0; - t2[3] = 0; - t3[0] = 0; - t3[1] = 0; - t3[2] = 0; - t3[3] = 0; - - md5_update_64 (&ctx->opad, t0, t1, t2, t3, 16); + ctx->opad.len += 16; md5_final (&ctx->opad); } @@ -1767,29 +1762,24 @@ DECLSPEC void md5_hmac_final_vector (md5_hmac_ctx_vector_t *ctx) { md5_final_vector (&ctx->ipad); - u32x t0[4]; - u32x t1[4]; - u32x t2[4]; - u32x t3[4]; + ctx->opad.w0[0] = ctx->ipad.h[0]; + ctx->opad.w0[1] = ctx->ipad.h[1]; + ctx->opad.w0[2] = ctx->ipad.h[2]; + ctx->opad.w0[3] = ctx->ipad.h[3]; + ctx->opad.w1[0] = 0; + ctx->opad.w1[1] = 0; + ctx->opad.w1[2] = 0; + ctx->opad.w1[3] = 0; + ctx->opad.w2[0] = 0; + ctx->opad.w2[1] = 0; + ctx->opad.w2[2] = 0; + ctx->opad.w2[3] = 0; + ctx->opad.w3[0] = 0; + ctx->opad.w3[1] = 0; + ctx->opad.w3[2] = 0; + ctx->opad.w3[3] = 0; - t0[0] = ctx->ipad.h[0]; - t0[1] = ctx->ipad.h[1]; - t0[2] = ctx->ipad.h[2]; - t0[3] = ctx->ipad.h[3]; - t1[0] = 0; - t1[1] = 0; - t1[2] = 0; - t1[3] = 0; - t2[0] = 0; - t2[1] = 0; - t2[2] = 0; - t2[3] = 0; - t3[0] = 0; - t3[1] = 0; - t3[2] = 0; - t3[3] = 0; - - md5_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 16); + ctx->opad.len += 16; md5_final_vector (&ctx->opad); } diff --git a/OpenCL/inc_hash_ripemd160.cl b/OpenCL/inc_hash_ripemd160.cl index a02e30452..9434bf527 100644 --- a/OpenCL/inc_hash_ripemd160.cl +++ b/OpenCL/inc_hash_ripemd160.cl @@ -1191,29 +1191,24 @@ DECLSPEC void ripemd160_hmac_final (ripemd160_hmac_ctx_t *ctx) { ripemd160_final (&ctx->ipad); - u32 t0[4]; - u32 t1[4]; - u32 t2[4]; - u32 t3[4]; + ctx->opad.w0[0] = ctx->ipad.h[0]; + ctx->opad.w0[1] = ctx->ipad.h[1]; + ctx->opad.w0[2] = ctx->ipad.h[2]; + ctx->opad.w0[3] = ctx->ipad.h[3]; + ctx->opad.w1[0] = ctx->ipad.h[4]; + ctx->opad.w1[1] = 0; + ctx->opad.w1[2] = 0; + ctx->opad.w1[3] = 0; + ctx->opad.w2[0] = 0; + ctx->opad.w2[1] = 0; + ctx->opad.w2[2] = 0; + ctx->opad.w2[3] = 0; + ctx->opad.w3[0] = 0; + ctx->opad.w3[1] = 0; + ctx->opad.w3[2] = 0; + ctx->opad.w3[3] = 0; - t0[0] = ctx->ipad.h[0]; - t0[1] = ctx->ipad.h[1]; - t0[2] = ctx->ipad.h[2]; - t0[3] = ctx->ipad.h[3]; - t1[0] = ctx->ipad.h[4]; - t1[1] = 0; - t1[2] = 0; - t1[3] = 0; - t2[0] = 0; - t2[1] = 0; - t2[2] = 0; - t2[3] = 0; - t3[0] = 0; - t3[1] = 0; - t3[2] = 0; - t3[3] = 0; - - ripemd160_update_64 (&ctx->opad, t0, t1, t2, t3, 20); + ctx->opad.len += 20; ripemd160_final (&ctx->opad); } @@ -1964,29 +1959,24 @@ DECLSPEC void ripemd160_hmac_final_vector (ripemd160_hmac_ctx_vector_t *ctx) { ripemd160_final_vector (&ctx->ipad); - u32x t0[4]; - u32x t1[4]; - u32x t2[4]; - u32x t3[4]; + ctx->opad.w0[0] = ctx->ipad.h[0]; + ctx->opad.w0[1] = ctx->ipad.h[1]; + ctx->opad.w0[2] = ctx->ipad.h[2]; + ctx->opad.w0[3] = ctx->ipad.h[3]; + ctx->opad.w1[0] = ctx->ipad.h[4]; + ctx->opad.w1[1] = 0; + ctx->opad.w1[2] = 0; + ctx->opad.w1[3] = 0; + ctx->opad.w2[0] = 0; + ctx->opad.w2[1] = 0; + ctx->opad.w2[2] = 0; + ctx->opad.w2[3] = 0; + ctx->opad.w3[0] = 0; + ctx->opad.w3[1] = 0; + ctx->opad.w3[2] = 0; + ctx->opad.w3[3] = 0; - t0[0] = ctx->ipad.h[0]; - t0[1] = ctx->ipad.h[1]; - t0[2] = ctx->ipad.h[2]; - t0[3] = ctx->ipad.h[3]; - t1[0] = ctx->ipad.h[4]; - t1[1] = 0; - t1[2] = 0; - t1[3] = 0; - t2[0] = 0; - t2[1] = 0; - t2[2] = 0; - t2[3] = 0; - t3[0] = 0; - t3[1] = 0; - t3[2] = 0; - t3[3] = 0; - - ripemd160_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 20); + ctx->opad.len += 20; ripemd160_final_vector (&ctx->opad); } diff --git a/OpenCL/inc_hash_sha1.cl b/OpenCL/inc_hash_sha1.cl index 4efea16f0..4638139db 100644 --- a/OpenCL/inc_hash_sha1.cl +++ b/OpenCL/inc_hash_sha1.cl @@ -1359,29 +1359,24 @@ DECLSPEC void sha1_hmac_final (sha1_hmac_ctx_t *ctx) { sha1_final (&ctx->ipad); - u32 t0[4]; - u32 t1[4]; - u32 t2[4]; - u32 t3[4]; + ctx->opad.w0[0] = ctx->ipad.h[0]; + ctx->opad.w0[1] = ctx->ipad.h[1]; + ctx->opad.w0[2] = ctx->ipad.h[2]; + ctx->opad.w0[3] = ctx->ipad.h[3]; + ctx->opad.w1[0] = ctx->ipad.h[4]; + ctx->opad.w1[1] = 0; + ctx->opad.w1[2] = 0; + ctx->opad.w1[3] = 0; + ctx->opad.w2[0] = 0; + ctx->opad.w2[1] = 0; + ctx->opad.w2[2] = 0; + ctx->opad.w2[3] = 0; + ctx->opad.w3[0] = 0; + ctx->opad.w3[1] = 0; + ctx->opad.w3[2] = 0; + ctx->opad.w3[3] = 0; - t0[0] = ctx->ipad.h[0]; - t0[1] = ctx->ipad.h[1]; - t0[2] = ctx->ipad.h[2]; - t0[3] = ctx->ipad.h[3]; - t1[0] = ctx->ipad.h[4]; - t1[1] = 0; - t1[2] = 0; - t1[3] = 0; - t2[0] = 0; - t2[1] = 0; - t2[2] = 0; - t2[3] = 0; - t3[0] = 0; - t3[1] = 0; - t3[2] = 0; - t3[3] = 0; - - sha1_update_64 (&ctx->opad, t0, t1, t2, t3, 20); + ctx->opad.len += 20; sha1_final (&ctx->opad); } @@ -2148,29 +2143,24 @@ DECLSPEC void sha1_hmac_final_vector (sha1_hmac_ctx_vector_t *ctx) { sha1_final_vector (&ctx->ipad); - u32x t0[4]; - u32x t1[4]; - u32x t2[4]; - u32x t3[4]; + ctx->opad.w0[0] = ctx->ipad.h[0]; + ctx->opad.w0[1] = ctx->ipad.h[1]; + ctx->opad.w0[2] = ctx->ipad.h[2]; + ctx->opad.w0[3] = ctx->ipad.h[3]; + ctx->opad.w1[0] = ctx->ipad.h[4]; + ctx->opad.w1[1] = 0; + ctx->opad.w1[2] = 0; + ctx->opad.w1[3] = 0; + ctx->opad.w2[0] = 0; + ctx->opad.w2[1] = 0; + ctx->opad.w2[2] = 0; + ctx->opad.w2[3] = 0; + ctx->opad.w3[0] = 0; + ctx->opad.w3[1] = 0; + ctx->opad.w3[2] = 0; + ctx->opad.w3[3] = 0; - t0[0] = ctx->ipad.h[0]; - t0[1] = ctx->ipad.h[1]; - t0[2] = ctx->ipad.h[2]; - t0[3] = ctx->ipad.h[3]; - t1[0] = ctx->ipad.h[4]; - t1[1] = 0; - t1[2] = 0; - t1[3] = 0; - t2[0] = 0; - t2[1] = 0; - t2[2] = 0; - t2[3] = 0; - t3[0] = 0; - t3[1] = 0; - t3[2] = 0; - t3[3] = 0; - - sha1_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 20); + ctx->opad.len += 20; sha1_final_vector (&ctx->opad); } diff --git a/OpenCL/inc_hash_sha224.cl b/OpenCL/inc_hash_sha224.cl index e8075b707..d64f6a118 100644 --- a/OpenCL/inc_hash_sha224.cl +++ b/OpenCL/inc_hash_sha224.cl @@ -1108,29 +1108,24 @@ DECLSPEC void sha224_hmac_final (sha224_hmac_ctx_t *ctx) { sha224_final (&ctx->ipad); - u32 t0[4]; - u32 t1[4]; - u32 t2[4]; - u32 t3[4]; + ctx->opad.w0[0] = ctx->ipad.h[0]; + ctx->opad.w0[1] = ctx->ipad.h[1]; + ctx->opad.w0[2] = ctx->ipad.h[2]; + ctx->opad.w0[3] = ctx->ipad.h[3]; + ctx->opad.w1[0] = ctx->ipad.h[4]; + ctx->opad.w1[1] = ctx->ipad.h[5]; + ctx->opad.w1[2] = ctx->ipad.h[6]; + ctx->opad.w1[3] = 0; + ctx->opad.w2[0] = 0; + ctx->opad.w2[1] = 0; + ctx->opad.w2[2] = 0; + ctx->opad.w2[3] = 0; + ctx->opad.w3[0] = 0; + ctx->opad.w3[1] = 0; + ctx->opad.w3[2] = 0; + ctx->opad.w3[3] = 0; - t0[0] = ctx->ipad.h[0]; - t0[1] = ctx->ipad.h[1]; - t0[2] = ctx->ipad.h[2]; - t0[3] = ctx->ipad.h[3]; - t1[0] = ctx->ipad.h[4]; - t1[1] = ctx->ipad.h[5]; - t1[2] = ctx->ipad.h[6]; - t1[3] = 0; - t2[0] = 0; - t2[1] = 0; - t2[2] = 0; - t2[3] = 0; - t3[0] = 0; - t3[1] = 0; - t3[2] = 0; - t3[3] = 0; - - sha224_update_64 (&ctx->opad, t0, t1, t2, t3, 28); + ctx->opad.len += 28; sha224_final (&ctx->opad); } @@ -1823,29 +1818,24 @@ DECLSPEC void sha224_hmac_final_vector (sha224_hmac_ctx_vector_t *ctx) { sha224_final_vector (&ctx->ipad); - u32x t0[4]; - u32x t1[4]; - u32x t2[4]; - u32x t3[4]; + ctx->opad.w0[0] = ctx->ipad.h[0]; + ctx->opad.w0[1] = ctx->ipad.h[1]; + ctx->opad.w0[2] = ctx->ipad.h[2]; + ctx->opad.w0[3] = ctx->ipad.h[3]; + ctx->opad.w1[0] = ctx->ipad.h[4]; + ctx->opad.w1[1] = ctx->ipad.h[5]; + ctx->opad.w1[2] = ctx->ipad.h[6]; + ctx->opad.w1[3] = 0: + ctx->opad.w2[0] = 0; + ctx->opad.w2[1] = 0; + ctx->opad.w2[2] = 0; + ctx->opad.w2[3] = 0; + ctx->opad.w3[0] = 0; + ctx->opad.w3[1] = 0; + ctx->opad.w3[2] = 0; + ctx->opad.w3[3] = 0; - t0[0] = ctx->ipad.h[0]; - t0[1] = ctx->ipad.h[1]; - t0[2] = ctx->ipad.h[2]; - t0[3] = ctx->ipad.h[3]; - t1[0] = ctx->ipad.h[4]; - t1[1] = ctx->ipad.h[5]; - t1[2] = ctx->ipad.h[6]; - t1[3] = 0; - t2[0] = 0; - t2[1] = 0; - t2[2] = 0; - t2[3] = 0; - t3[0] = 0; - t3[1] = 0; - t3[2] = 0; - t3[3] = 0; - - sha224_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 28); + ctx->opad.len += 28; sha224_final_vector (&ctx->opad); } diff --git a/OpenCL/inc_hash_sha256.cl b/OpenCL/inc_hash_sha256.cl index ee0cb762e..f47140950 100644 --- a/OpenCL/inc_hash_sha256.cl +++ b/OpenCL/inc_hash_sha256.cl @@ -1108,29 +1108,24 @@ DECLSPEC void sha256_hmac_final (sha256_hmac_ctx_t *ctx) { sha256_final (&ctx->ipad); - u32 t0[4]; - u32 t1[4]; - u32 t2[4]; - u32 t3[4]; + ctx->opad.w0[0] = ctx->ipad.h[0]; + ctx->opad.w0[1] = ctx->ipad.h[1]; + ctx->opad.w0[2] = ctx->ipad.h[2]; + ctx->opad.w0[3] = ctx->ipad.h[3]; + ctx->opad.w1[0] = ctx->ipad.h[4]; + ctx->opad.w1[1] = ctx->ipad.h[5]; + ctx->opad.w1[2] = ctx->ipad.h[6]; + ctx->opad.w1[3] = ctx->ipad.h[7]; + ctx->opad.w2[0] = 0; + ctx->opad.w2[1] = 0; + ctx->opad.w2[2] = 0; + ctx->opad.w2[3] = 0; + ctx->opad.w3[0] = 0; + ctx->opad.w3[1] = 0; + ctx->opad.w3[2] = 0; + ctx->opad.w3[3] = 0; - t0[0] = ctx->ipad.h[0]; - t0[1] = ctx->ipad.h[1]; - t0[2] = ctx->ipad.h[2]; - t0[3] = ctx->ipad.h[3]; - t1[0] = ctx->ipad.h[4]; - t1[1] = ctx->ipad.h[5]; - t1[2] = ctx->ipad.h[6]; - t1[3] = ctx->ipad.h[7]; - t2[0] = 0; - t2[1] = 0; - t2[2] = 0; - t2[3] = 0; - t3[0] = 0; - t3[1] = 0; - t3[2] = 0; - t3[3] = 0; - - sha256_update_64 (&ctx->opad, t0, t1, t2, t3, 32); + ctx->opad.len += 32; sha256_final (&ctx->opad); } @@ -1823,29 +1818,24 @@ DECLSPEC void sha256_hmac_final_vector (sha256_hmac_ctx_vector_t *ctx) { sha256_final_vector (&ctx->ipad); - u32x t0[4]; - u32x t1[4]; - u32x t2[4]; - u32x t3[4]; + ctx->opad.w0[0] = ctx->ipad.h[0]; + ctx->opad.w0[1] = ctx->ipad.h[1]; + ctx->opad.w0[2] = ctx->ipad.h[2]; + ctx->opad.w0[3] = ctx->ipad.h[3]; + ctx->opad.w1[0] = ctx->ipad.h[4]; + ctx->opad.w1[1] = ctx->ipad.h[5]; + ctx->opad.w1[2] = ctx->ipad.h[6]; + ctx->opad.w1[3] = ctx->ipad.h[7]; + ctx->opad.w2[0] = 0; + ctx->opad.w2[1] = 0; + ctx->opad.w2[2] = 0; + ctx->opad.w2[3] = 0; + ctx->opad.w3[0] = 0; + ctx->opad.w3[1] = 0; + ctx->opad.w3[2] = 0; + ctx->opad.w3[3] = 0; - t0[0] = ctx->ipad.h[0]; - t0[1] = ctx->ipad.h[1]; - t0[2] = ctx->ipad.h[2]; - t0[3] = ctx->ipad.h[3]; - t1[0] = ctx->ipad.h[4]; - t1[1] = ctx->ipad.h[5]; - t1[2] = ctx->ipad.h[6]; - t1[3] = ctx->ipad.h[7]; - t2[0] = 0; - t2[1] = 0; - t2[2] = 0; - t2[3] = 0; - t3[0] = 0; - t3[1] = 0; - t3[2] = 0; - t3[3] = 0; - - sha256_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 32); + ctx->opad.len += 32; sha256_final_vector (&ctx->opad); } diff --git a/OpenCL/inc_hash_sha384.cl b/OpenCL/inc_hash_sha384.cl index b37e3a003..b490e756b 100644 --- a/OpenCL/inc_hash_sha384.cl +++ b/OpenCL/inc_hash_sha384.cl @@ -1744,49 +1744,40 @@ DECLSPEC void sha384_hmac_final (sha384_hmac_ctx_t *ctx) { sha384_final (&ctx->ipad); - u32 t0[4]; - u32 t1[4]; - u32 t2[4]; - u32 t3[4]; - u32 t4[4]; - u32 t5[4]; - u32 t6[4]; - u32 t7[4]; + ctx->opad.w0[0] = h32_from_64_S (ctx->ipad.h[0]); + ctx->opad.w0[1] = l32_from_64_S (ctx->ipad.h[0]); + ctx->opad.w0[2] = h32_from_64_S (ctx->ipad.h[1]); + ctx->opad.w0[3] = l32_from_64_S (ctx->ipad.h[1]); + ctx->opad.w1[0] = h32_from_64_S (ctx->ipad.h[2]); + ctx->opad.w1[1] = l32_from_64_S (ctx->ipad.h[2]); + ctx->opad.w1[2] = h32_from_64_S (ctx->ipad.h[3]); + ctx->opad.w1[3] = l32_from_64_S (ctx->ipad.h[3]); + ctx->opad.w2[0] = h32_from_64_S (ctx->ipad.h[4]); + ctx->opad.w2[1] = l32_from_64_S (ctx->ipad.h[4]); + ctx->opad.w2[2] = h32_from_64_S (ctx->ipad.h[5]); + ctx->opad.w2[3] = l32_from_64_S (ctx->ipad.h[5]); + ctx->opad.w3[0] = 0; + ctx->opad.w3[1] = 0; + ctx->opad.w3[2] = 0; + ctx->opad.w3[3] = 0; + ctx->opad.w4[0] = 0; + ctx->opad.w4[1] = 0; + ctx->opad.w4[2] = 0; + ctx->opad.w4[3] = 0; + ctx->opad.w5[0] = 0; + ctx->opad.w5[1] = 0; + ctx->opad.w5[2] = 0; + ctx->opad.w5[3] = 0; + ctx->opad.w6[0] = 0; + ctx->opad.w6[1] = 0; + ctx->opad.w6[2] = 0; + ctx->opad.w6[3] = 0; + ctx->opad.w7[0] = 0; + ctx->opad.w7[1] = 0; + ctx->opad.w7[2] = 0; + ctx->opad.w7[3] = 0; - t0[0] = h32_from_64_S (ctx->ipad.h[0]); - t0[1] = l32_from_64_S (ctx->ipad.h[0]); - t0[2] = h32_from_64_S (ctx->ipad.h[1]); - t0[3] = l32_from_64_S (ctx->ipad.h[1]); - t1[0] = h32_from_64_S (ctx->ipad.h[2]); - t1[1] = l32_from_64_S (ctx->ipad.h[2]); - t1[2] = h32_from_64_S (ctx->ipad.h[3]); - t1[3] = l32_from_64_S (ctx->ipad.h[3]); - t2[0] = h32_from_64_S (ctx->ipad.h[4]); - t2[1] = l32_from_64_S (ctx->ipad.h[4]); - t2[2] = h32_from_64_S (ctx->ipad.h[5]); - t2[3] = l32_from_64_S (ctx->ipad.h[5]); - t3[0] = 0; - t3[1] = 0; - t3[2] = 0; - t3[3] = 0; - t4[0] = 0; - t4[1] = 0; - t4[2] = 0; - t4[3] = 0; - t5[0] = 0; - t5[1] = 0; - t5[2] = 0; - t5[3] = 0; - t6[0] = 0; - t6[1] = 0; - t6[2] = 0; - t6[3] = 0; - t7[0] = 0; - t7[1] = 0; - t7[2] = 0; - t7[3] = 0; - - sha384_update_128 (&ctx->opad, t0, t1, t2, t3, t4, t5, t6, t7, 48); + ctx->opad.len += 48; sha384_final (&ctx->opad); } @@ -2859,49 +2850,40 @@ DECLSPEC void sha384_hmac_final_vector (sha384_hmac_ctx_vector_t *ctx) { sha384_final_vector (&ctx->ipad); - u32x t0[4]; - u32x t1[4]; - u32x t2[4]; - u32x t3[4]; - u32x t4[4]; - u32x t5[4]; - u32x t6[4]; - u32x t7[4]; + ctx->opad.w0[0] = h32_from_64 (ctx->ipad.h[0]); + ctx->opad.w0[1] = l32_from_64 (ctx->ipad.h[0]); + ctx->opad.w0[2] = h32_from_64 (ctx->ipad.h[1]); + ctx->opad.w0[3] = l32_from_64 (ctx->ipad.h[1]); + ctx->opad.w1[0] = h32_from_64 (ctx->ipad.h[2]); + ctx->opad.w1[1] = l32_from_64 (ctx->ipad.h[2]); + ctx->opad.w1[2] = h32_from_64 (ctx->ipad.h[3]); + ctx->opad.w1[3] = l32_from_64 (ctx->ipad.h[3]); + ctx->opad.w2[0] = h32_from_64 (ctx->ipad.h[4]); + ctx->opad.w2[1] = l32_from_64 (ctx->ipad.h[4]); + ctx->opad.w2[2] = h32_from_64 (ctx->ipad.h[5]); + ctx->opad.w2[3] = l32_from_64 (ctx->ipad.h[5]); + ctx->opad.w3[0] = 0; + ctx->opad.w3[1] = 0; + ctx->opad.w3[2] = 0; + ctx->opad.w3[3] = 0; + ctx->opad.w4[0] = 0; + ctx->opad.w4[1] = 0; + ctx->opad.w4[2] = 0; + ctx->opad.w4[3] = 0; + ctx->opad.w5[0] = 0; + ctx->opad.w5[1] = 0; + ctx->opad.w5[2] = 0; + ctx->opad.w5[3] = 0; + ctx->opad.w6[0] = 0; + ctx->opad.w6[1] = 0; + ctx->opad.w6[2] = 0; + ctx->opad.w6[3] = 0; + ctx->opad.w7[0] = 0; + ctx->opad.w7[1] = 0; + ctx->opad.w7[2] = 0; + ctx->opad.w7[3] = 0; - t0[0] = h32_from_64 (ctx->ipad.h[0]); - t0[1] = l32_from_64 (ctx->ipad.h[0]); - t0[2] = h32_from_64 (ctx->ipad.h[1]); - t0[3] = l32_from_64 (ctx->ipad.h[1]); - t1[0] = h32_from_64 (ctx->ipad.h[2]); - t1[1] = l32_from_64 (ctx->ipad.h[2]); - t1[2] = h32_from_64 (ctx->ipad.h[3]); - t1[3] = l32_from_64 (ctx->ipad.h[3]); - t2[0] = h32_from_64 (ctx->ipad.h[4]); - t2[1] = l32_from_64 (ctx->ipad.h[4]); - t2[2] = h32_from_64 (ctx->ipad.h[5]); - t2[3] = l32_from_64 (ctx->ipad.h[5]); - t3[0] = 0; - t3[1] = 0; - t3[2] = 0; - t3[3] = 0; - t4[0] = 0; - t4[1] = 0; - t4[2] = 0; - t4[3] = 0; - t5[0] = 0; - t5[1] = 0; - t5[2] = 0; - t5[3] = 0; - t6[0] = 0; - t6[1] = 0; - t6[2] = 0; - t6[3] = 0; - t7[0] = 0; - t7[1] = 0; - t7[2] = 0; - t7[3] = 0; - - sha384_update_vector_128 (&ctx->opad, t0, t1, t2, t3, t4, t5, t6, t7, 48); + ctx->opad.len += 48; sha384_final_vector (&ctx->opad); } diff --git a/OpenCL/inc_hash_sha512.cl b/OpenCL/inc_hash_sha512.cl index 66b71c958..a33488ac4 100644 --- a/OpenCL/inc_hash_sha512.cl +++ b/OpenCL/inc_hash_sha512.cl @@ -1861,49 +1861,40 @@ DECLSPEC void sha512_hmac_final (sha512_hmac_ctx_t *ctx) { sha512_final (&ctx->ipad); - u32 t0[4]; - u32 t1[4]; - u32 t2[4]; - u32 t3[4]; - u32 t4[4]; - u32 t5[4]; - u32 t6[4]; - u32 t7[4]; + ctx->opad.w0[0] = h32_from_64_S (ctx->ipad.h[0]); + ctx->opad.w0[1] = l32_from_64_S (ctx->ipad.h[0]); + ctx->opad.w0[2] = h32_from_64_S (ctx->ipad.h[1]); + ctx->opad.w0[3] = l32_from_64_S (ctx->ipad.h[1]); + ctx->opad.w1[0] = h32_from_64_S (ctx->ipad.h[2]); + ctx->opad.w1[1] = l32_from_64_S (ctx->ipad.h[2]); + ctx->opad.w1[2] = h32_from_64_S (ctx->ipad.h[3]); + ctx->opad.w1[3] = l32_from_64_S (ctx->ipad.h[3]); + ctx->opad.w2[0] = h32_from_64_S (ctx->ipad.h[4]); + ctx->opad.w2[1] = l32_from_64_S (ctx->ipad.h[4]); + ctx->opad.w2[2] = h32_from_64_S (ctx->ipad.h[5]); + ctx->opad.w2[3] = l32_from_64_S (ctx->ipad.h[5]); + ctx->opad.w3[0] = h32_from_64_S (ctx->ipad.h[6]); + ctx->opad.w3[1] = l32_from_64_S (ctx->ipad.h[6]); + ctx->opad.w3[2] = h32_from_64_S (ctx->ipad.h[7]); + ctx->opad.w3[3] = l32_from_64_S (ctx->ipad.h[7]); + ctx->opad.w4[0] = 0; + ctx->opad.w4[1] = 0; + ctx->opad.w4[2] = 0; + ctx->opad.w4[3] = 0; + ctx->opad.w5[0] = 0; + ctx->opad.w5[1] = 0; + ctx->opad.w5[2] = 0; + ctx->opad.w5[3] = 0; + ctx->opad.w6[0] = 0; + ctx->opad.w6[1] = 0; + ctx->opad.w6[2] = 0; + ctx->opad.w6[3] = 0; + ctx->opad.w7[0] = 0; + ctx->opad.w7[1] = 0; + ctx->opad.w7[2] = 0; + ctx->opad.w7[3] = 0; - t0[0] = h32_from_64_S (ctx->ipad.h[0]); - t0[1] = l32_from_64_S (ctx->ipad.h[0]); - t0[2] = h32_from_64_S (ctx->ipad.h[1]); - t0[3] = l32_from_64_S (ctx->ipad.h[1]); - t1[0] = h32_from_64_S (ctx->ipad.h[2]); - t1[1] = l32_from_64_S (ctx->ipad.h[2]); - t1[2] = h32_from_64_S (ctx->ipad.h[3]); - t1[3] = l32_from_64_S (ctx->ipad.h[3]); - t2[0] = h32_from_64_S (ctx->ipad.h[4]); - t2[1] = l32_from_64_S (ctx->ipad.h[4]); - t2[2] = h32_from_64_S (ctx->ipad.h[5]); - t2[3] = l32_from_64_S (ctx->ipad.h[5]); - t3[0] = h32_from_64_S (ctx->ipad.h[6]); - t3[1] = l32_from_64_S (ctx->ipad.h[6]); - t3[2] = h32_from_64_S (ctx->ipad.h[7]); - t3[3] = l32_from_64_S (ctx->ipad.h[7]); - t4[0] = 0; - t4[1] = 0; - t4[2] = 0; - t4[3] = 0; - t5[0] = 0; - t5[1] = 0; - t5[2] = 0; - t5[3] = 0; - t6[0] = 0; - t6[1] = 0; - t6[2] = 0; - t6[3] = 0; - t7[0] = 0; - t7[1] = 0; - t7[2] = 0; - t7[3] = 0; - - sha512_update_128 (&ctx->opad, t0, t1, t2, t3, t4, t5, t6, t7, 64); + ctx->opad.len += 64; sha512_final (&ctx->opad); } @@ -2976,49 +2967,40 @@ DECLSPEC void sha512_hmac_final_vector (sha512_hmac_ctx_vector_t *ctx) { sha512_final_vector (&ctx->ipad); - u32x t0[4]; - u32x t1[4]; - u32x t2[4]; - u32x t3[4]; - u32x t4[4]; - u32x t5[4]; - u32x t6[4]; - u32x t7[4]; + ctx->opad.w0[0] = h32_from_64 (ctx->ipad.h[0]); + ctx->opad.w0[1] = l32_from_64 (ctx->ipad.h[0]); + ctx->opad.w0[2] = h32_from_64 (ctx->ipad.h[1]); + ctx->opad.w0[3] = l32_from_64 (ctx->ipad.h[1]); + ctx->opad.w1[0] = h32_from_64 (ctx->ipad.h[2]); + ctx->opad.w1[1] = l32_from_64 (ctx->ipad.h[2]); + ctx->opad.w1[2] = h32_from_64 (ctx->ipad.h[3]); + ctx->opad.w1[3] = l32_from_64 (ctx->ipad.h[3]); + ctx->opad.w2[0] = h32_from_64 (ctx->ipad.h[4]); + ctx->opad.w2[1] = l32_from_64 (ctx->ipad.h[4]); + ctx->opad.w2[2] = h32_from_64 (ctx->ipad.h[5]); + ctx->opad.w2[3] = l32_from_64 (ctx->ipad.h[5]); + ctx->opad.w3[0] = h32_from_64 (ctx->ipad.h[6]); + ctx->opad.w3[1] = l32_from_64 (ctx->ipad.h[6]); + ctx->opad.w3[2] = h32_from_64 (ctx->ipad.h[7]); + ctx->opad.w3[3] = l32_from_64 (ctx->ipad.h[7]); + ctx->opad.w4[0] = 0; + ctx->opad.w4[1] = 0; + ctx->opad.w4[2] = 0; + ctx->opad.w4[3] = 0; + ctx->opad.w5[0] = 0; + ctx->opad.w5[1] = 0; + ctx->opad.w5[2] = 0; + ctx->opad.w5[3] = 0; + ctx->opad.w6[0] = 0; + ctx->opad.w6[1] = 0; + ctx->opad.w6[2] = 0; + ctx->opad.w6[3] = 0; + ctx->opad.w7[0] = 0; + ctx->opad.w7[1] = 0; + ctx->opad.w7[2] = 0; + ctx->opad.w7[3] = 0; - t0[0] = h32_from_64 (ctx->ipad.h[0]); - t0[1] = l32_from_64 (ctx->ipad.h[0]); - t0[2] = h32_from_64 (ctx->ipad.h[1]); - t0[3] = l32_from_64 (ctx->ipad.h[1]); - t1[0] = h32_from_64 (ctx->ipad.h[2]); - t1[1] = l32_from_64 (ctx->ipad.h[2]); - t1[2] = h32_from_64 (ctx->ipad.h[3]); - t1[3] = l32_from_64 (ctx->ipad.h[3]); - t2[0] = h32_from_64 (ctx->ipad.h[4]); - t2[1] = l32_from_64 (ctx->ipad.h[4]); - t2[2] = h32_from_64 (ctx->ipad.h[5]); - t2[3] = l32_from_64 (ctx->ipad.h[5]); - t3[0] = h32_from_64 (ctx->ipad.h[6]); - t3[1] = l32_from_64 (ctx->ipad.h[6]); - t3[2] = h32_from_64 (ctx->ipad.h[7]); - t3[3] = l32_from_64 (ctx->ipad.h[7]); - t4[0] = 0; - t4[1] = 0; - t4[2] = 0; - t4[3] = 0; - t5[0] = 0; - t5[1] = 0; - t5[2] = 0; - t5[3] = 0; - t6[0] = 0; - t6[1] = 0; - t6[2] = 0; - t6[3] = 0; - t7[0] = 0; - t7[1] = 0; - t7[2] = 0; - t7[3] = 0; - - sha512_update_vector_128 (&ctx->opad, t0, t1, t2, t3, t4, t5, t6, t7, 64); + ctx->opad.len += 64; sha512_final_vector (&ctx->opad); } diff --git a/OpenCL/inc_hash_streebog256.cl b/OpenCL/inc_hash_streebog256.cl index 7f64d4bb6..13b74beda 100644 --- a/OpenCL/inc_hash_streebog256.cl +++ b/OpenCL/inc_hash_streebog256.cl @@ -1227,29 +1227,24 @@ DECLSPEC void streebog256_hmac_final (streebog256_hmac_ctx_t *ctx) { streebog256_final (&ctx->ipad); - u32 t0[4]; - u32 t1[4]; - u32 t2[4]; - u32 t3[4]; + ctx->opad.w0[0] = h32_from_64_S (ctx->ipad.h[3]); + ctx->opad.w0[1] = l32_from_64_S (ctx->ipad.h[3]); + ctx->opad.w0[2] = h32_from_64_S (ctx->ipad.h[2]); + ctx->opad.w0[3] = l32_from_64_S (ctx->ipad.h[2]); + ctx->opad.w1[0] = h32_from_64_S (ctx->ipad.h[1]); + ctx->opad.w1[1] = l32_from_64_S (ctx->ipad.h[1]); + ctx->opad.w1[2] = h32_from_64_S (ctx->ipad.h[0]); + ctx->opad.w1[3] = l32_from_64_S (ctx->ipad.h[0]); + ctx->opad.w2[0] = 0; + ctx->opad.w2[1] = 0; + ctx->opad.w2[2] = 0; + ctx->opad.w2[3] = 0; + ctx->opad.w3[0] = 0; + ctx->opad.w3[1] = 0; + ctx->opad.w3[2] = 0; + ctx->opad.w3[3] = 0; - t0[0] = h32_from_64_S (ctx->ipad.h[3]); - t0[1] = l32_from_64_S (ctx->ipad.h[3]); - t0[2] = h32_from_64_S (ctx->ipad.h[2]); - t0[3] = l32_from_64_S (ctx->ipad.h[2]); - t1[0] = h32_from_64_S (ctx->ipad.h[1]); - t1[1] = l32_from_64_S (ctx->ipad.h[1]); - t1[2] = h32_from_64_S (ctx->ipad.h[0]); - t1[3] = l32_from_64_S (ctx->ipad.h[0]); - t2[0] = 0; - t2[1] = 0; - t2[2] = 0; - t2[3] = 0; - t3[0] = 0; - t3[1] = 0; - t3[2] = 0; - t3[3] = 0; - - streebog256_update_64 (&ctx->opad, t0, t1, t2, t3, 32); + ctx->opad.len += 32; streebog256_final (&ctx->opad); } @@ -1822,29 +1817,24 @@ DECLSPEC void streebog256_hmac_final_vector (streebog256_hmac_ctx_vector_t *ctx) { streebog256_final_vector (&ctx->ipad); - u32x t0[4]; - u32x t1[4]; - u32x t2[4]; - u32x t3[4]; + ctx->opad.w0[0] = h32_from_64 (ctx->ipad.h[3]); + ctx->opad.w0[1] = l32_from_64 (ctx->ipad.h[3]); + ctx->opad.w0[2] = h32_from_64 (ctx->ipad.h[2]); + ctx->opad.w0[3] = l32_from_64 (ctx->ipad.h[2]); + ctx->opad.w1[0] = h32_from_64 (ctx->ipad.h[1]); + ctx->opad.w1[1] = l32_from_64 (ctx->ipad.h[1]); + ctx->opad.w1[2] = h32_from_64 (ctx->ipad.h[0]); + ctx->opad.w1[3] = l32_from_64 (ctx->ipad.h[0]); + ctx->opad.w2[0] = 0; + ctx->opad.w2[1] = 0; + ctx->opad.w2[2] = 0; + ctx->opad.w2[3] = 0; + ctx->opad.w3[0] = 0; + ctx->opad.w3[1] = 0; + ctx->opad.w3[2] = 0; + ctx->opad.w3[3] = 0; - t0[0] = h32_from_64 (ctx->ipad.h[3]); - t0[1] = l32_from_64 (ctx->ipad.h[3]); - t0[2] = h32_from_64 (ctx->ipad.h[2]); - t0[3] = l32_from_64 (ctx->ipad.h[2]); - t1[0] = h32_from_64 (ctx->ipad.h[1]); - t1[1] = l32_from_64 (ctx->ipad.h[1]); - t1[2] = h32_from_64 (ctx->ipad.h[0]); - t1[3] = l32_from_64 (ctx->ipad.h[0]); - t2[0] = 0; - t2[1] = 0; - t2[2] = 0; - t2[3] = 0; - t3[0] = 0; - t3[1] = 0; - t3[2] = 0; - t3[3] = 0; - - streebog256_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 32); + ctx->opad.len += 32; streebog256_final_vector (&ctx->opad); } diff --git a/OpenCL/inc_hash_streebog512.cl b/OpenCL/inc_hash_streebog512.cl index 5ef89421e..4018ee8e3 100644 --- a/OpenCL/inc_hash_streebog512.cl +++ b/OpenCL/inc_hash_streebog512.cl @@ -1227,29 +1227,43 @@ DECLSPEC void streebog512_hmac_final (streebog512_hmac_ctx_t *ctx) { streebog512_final (&ctx->ipad); - u32 t0[4]; - u32 t1[4]; - u32 t2[4]; - u32 t3[4]; + ctx->opad.w0[0] = h32_from_64_S (ctx->ipad.h[7]); + ctx->opad.w0[1] = l32_from_64_S (ctx->ipad.h[7]); + ctx->opad.w0[2] = h32_from_64_S (ctx->ipad.h[6]); + ctx->opad.w0[3] = l32_from_64_S (ctx->ipad.h[6]); + ctx->opad.w1[0] = h32_from_64_S (ctx->ipad.h[5]); + ctx->opad.w1[1] = l32_from_64_S (ctx->ipad.h[5]); + ctx->opad.w1[2] = h32_from_64_S (ctx->ipad.h[4]); + ctx->opad.w1[3] = l32_from_64_S (ctx->ipad.h[4]); + ctx->opad.w2[0] = h32_from_64_S (ctx->ipad.h[3]); + ctx->opad.w2[1] = l32_from_64_S (ctx->ipad.h[3]); + ctx->opad.w2[2] = h32_from_64_S (ctx->ipad.h[2]); + ctx->opad.w2[3] = l32_from_64_S (ctx->ipad.h[2]); + ctx->opad.w3[0] = h32_from_64_S (ctx->ipad.h[1]); + ctx->opad.w3[1] = l32_from_64_S (ctx->ipad.h[1]); + ctx->opad.w3[2] = h32_from_64_S (ctx->ipad.h[0]); + ctx->opad.w3[3] = l32_from_64_S (ctx->ipad.h[0]); - t0[0] = h32_from_64_S (ctx->ipad.h[7]); - t0[1] = l32_from_64_S (ctx->ipad.h[7]); - t0[2] = h32_from_64_S (ctx->ipad.h[6]); - t0[3] = l32_from_64_S (ctx->ipad.h[6]); - t1[0] = h32_from_64_S (ctx->ipad.h[5]); - t1[1] = l32_from_64_S (ctx->ipad.h[5]); - t1[2] = h32_from_64_S (ctx->ipad.h[4]); - t1[3] = l32_from_64_S (ctx->ipad.h[4]); - t2[0] = h32_from_64_S (ctx->ipad.h[3]); - t2[1] = l32_from_64_S (ctx->ipad.h[3]); - t2[2] = h32_from_64_S (ctx->ipad.h[2]); - t2[3] = l32_from_64_S (ctx->ipad.h[2]); - t3[0] = h32_from_64_S (ctx->ipad.h[1]); - t3[1] = l32_from_64_S (ctx->ipad.h[1]); - t3[2] = h32_from_64_S (ctx->ipad.h[0]); - t3[3] = l32_from_64_S (ctx->ipad.h[0]); + ctx->opad.len = 0; - streebog512_update_64 (&ctx->opad, t0, t1, t2, t3, 64); + streebog512_transform (&ctx->opad, ctx->opad.w0, ctx->opad.w1, ctx->opad.w2, ctx->opad.w3); + + ctx->opad.w0[0] = 0; + ctx->opad.w0[1] = 0; + ctx->opad.w0[2] = 0; + ctx->opad.w0[3] = 0; + ctx->opad.w1[0] = 0; + ctx->opad.w1[1] = 0; + ctx->opad.w1[2] = 0; + ctx->opad.w1[3] = 0; + ctx->opad.w2[0] = 0; + ctx->opad.w2[1] = 0; + ctx->opad.w2[2] = 0; + ctx->opad.w2[3] = 0; + ctx->opad.w3[0] = 0; + ctx->opad.w3[1] = 0; + ctx->opad.w3[2] = 0; + ctx->opad.w3[3] = 0; streebog512_final (&ctx->opad); } @@ -1822,29 +1836,43 @@ DECLSPEC void streebog512_hmac_final_vector (streebog512_hmac_ctx_vector_t *ctx) { streebog512_final_vector (&ctx->ipad); - u32x t0[4]; - u32x t1[4]; - u32x t2[4]; - u32x t3[4]; + ctx->opad.w0[0] = h32_from_64 (ctx->ipad.h[7]); + ctx->opad.w0[1] = l32_from_64 (ctx->ipad.h[7]); + ctx->opad.w0[2] = h32_from_64 (ctx->ipad.h[6]); + ctx->opad.w0[3] = l32_from_64 (ctx->ipad.h[6]); + ctx->opad.w1[0] = h32_from_64 (ctx->ipad.h[5]); + ctx->opad.w1[1] = l32_from_64 (ctx->ipad.h[5]); + ctx->opad.w1[2] = h32_from_64 (ctx->ipad.h[4]); + ctx->opad.w1[3] = l32_from_64 (ctx->ipad.h[4]); + ctx->opad.w2[0] = h32_from_64 (ctx->ipad.h[3]); + ctx->opad.w2[1] = l32_from_64 (ctx->ipad.h[3]); + ctx->opad.w2[2] = h32_from_64 (ctx->ipad.h[2]); + ctx->opad.w2[3] = l32_from_64 (ctx->ipad.h[2]); + ctx->opad.w3[0] = h32_from_64 (ctx->ipad.h[1]); + ctx->opad.w3[1] = l32_from_64 (ctx->ipad.h[1]); + ctx->opad.w3[2] = h32_from_64 (ctx->ipad.h[0]); + ctx->opad.w3[3] = l32_from_64 (ctx->ipad.h[0]); - t0[0] = h32_from_64 (ctx->ipad.h[7]); - t0[1] = l32_from_64 (ctx->ipad.h[7]); - t0[2] = h32_from_64 (ctx->ipad.h[6]); - t0[3] = l32_from_64 (ctx->ipad.h[6]); - t1[0] = h32_from_64 (ctx->ipad.h[5]); - t1[1] = l32_from_64 (ctx->ipad.h[5]); - t1[2] = h32_from_64 (ctx->ipad.h[4]); - t1[3] = l32_from_64 (ctx->ipad.h[4]); - t2[0] = h32_from_64 (ctx->ipad.h[3]); - t2[1] = l32_from_64 (ctx->ipad.h[3]); - t2[2] = h32_from_64 (ctx->ipad.h[2]); - t2[3] = l32_from_64 (ctx->ipad.h[2]); - t3[0] = h32_from_64 (ctx->ipad.h[1]); - t3[1] = l32_from_64 (ctx->ipad.h[1]); - t3[2] = h32_from_64 (ctx->ipad.h[0]); - t3[3] = l32_from_64 (ctx->ipad.h[0]); + ctx->opad.len = 0; - streebog512_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 64); + streebog512_transform_vector (&ctx->opad, ctx->opad.w0, ctx->opad.w1, ctx->opad.w2, ctx->opad.w3); + + ctx->opad.w0[0] = 0; + ctx->opad.w0[1] = 0; + ctx->opad.w0[2] = 0; + ctx->opad.w0[3] = 0; + ctx->opad.w1[0] = 0; + ctx->opad.w1[1] = 0; + ctx->opad.w1[2] = 0; + ctx->opad.w1[3] = 0; + ctx->opad.w2[0] = 0; + ctx->opad.w2[1] = 0; + ctx->opad.w2[2] = 0; + ctx->opad.w2[3] = 0; + ctx->opad.w3[0] = 0; + ctx->opad.w3[1] = 0; + ctx->opad.w3[2] = 0; + ctx->opad.w3[3] = 0; streebog512_final_vector (&ctx->opad); } diff --git a/OpenCL/inc_hash_whirlpool.cl b/OpenCL/inc_hash_whirlpool.cl index 6e9c1b8ab..e233a0cf9 100644 --- a/OpenCL/inc_hash_whirlpool.cl +++ b/OpenCL/inc_hash_whirlpool.cl @@ -2272,29 +2272,43 @@ DECLSPEC void whirlpool_hmac_final (whirlpool_hmac_ctx_t *ctx) { whirlpool_final (&ctx->ipad); - u32 t0[4]; - u32 t1[4]; - u32 t2[4]; - u32 t3[4]; + ctx->opad.w0[0] = ctx->ipad.h[ 0]; + ctx->opad.w0[1] = ctx->ipad.h[ 1]; + ctx->opad.w0[2] = ctx->ipad.h[ 2]; + ctx->opad.w0[3] = ctx->ipad.h[ 3]; + ctx->opad.w1[0] = ctx->ipad.h[ 4]; + ctx->opad.w1[1] = ctx->ipad.h[ 5]; + ctx->opad.w1[2] = ctx->ipad.h[ 6]; + ctx->opad.w1[3] = ctx->ipad.h[ 7]; + ctx->opad.w2[0] = ctx->ipad.h[ 8]; + ctx->opad.w2[1] = ctx->ipad.h[ 9]; + ctx->opad.w2[2] = ctx->ipad.h[10]; + ctx->opad.w2[3] = ctx->ipad.h[11]; + ctx->opad.w3[0] = ctx->ipad.h[12]; + ctx->opad.w3[1] = ctx->ipad.h[13]; + ctx->opad.w3[2] = ctx->ipad.h[14]; + ctx->opad.w3[3] = ctx->ipad.h[15]; - t0[0] = ctx->ipad.h[ 0]; - t0[1] = ctx->ipad.h[ 1]; - t0[2] = ctx->ipad.h[ 2]; - t0[3] = ctx->ipad.h[ 3]; - t1[0] = ctx->ipad.h[ 4]; - t1[1] = ctx->ipad.h[ 5]; - t1[2] = ctx->ipad.h[ 6]; - t1[3] = ctx->ipad.h[ 7]; - t2[0] = ctx->ipad.h[ 8]; - t2[1] = ctx->ipad.h[ 9]; - t2[2] = ctx->ipad.h[10]; - t2[3] = ctx->ipad.h[11]; - t3[0] = ctx->ipad.h[12]; - t3[1] = ctx->ipad.h[13]; - t3[2] = ctx->ipad.h[14]; - t3[3] = ctx->ipad.h[15]; + ctx->opad.len += 64; - whirlpool_update_64 (&ctx->opad, t0, t1, t2, t3, 64); + whirlpool_transform (ctx->opad.w0, ctx->opad.w1, ctx->opad.w2, ctx->opad.w3, ctx->opad.h, ctx->opad.s_Ch, ctx->opad.s_Cl); + + ctx->opad.w0[0] = 0; + ctx->opad.w0[1] = 0; + ctx->opad.w0[2] = 0; + ctx->opad.w0[3] = 0; + ctx->opad.w1[0] = 0; + ctx->opad.w1[1] = 0; + ctx->opad.w1[2] = 0; + ctx->opad.w1[3] = 0; + ctx->opad.w2[0] = 0; + ctx->opad.w2[1] = 0; + ctx->opad.w2[2] = 0; + ctx->opad.w2[3] = 0; + ctx->opad.w3[0] = 0; + ctx->opad.w3[1] = 0; + ctx->opad.w3[2] = 0; + ctx->opad.w3[3] = 0; whirlpool_final (&ctx->opad); } @@ -3046,29 +3060,43 @@ DECLSPEC void whirlpool_hmac_final_vector (whirlpool_hmac_ctx_vector_t *ctx) { whirlpool_final_vector (&ctx->ipad); - u32x t0[4]; - u32x t1[4]; - u32x t2[4]; - u32x t3[4]; + ctx->opad.w0[0] = ctx->ipad.h[ 0]; + ctx->opad.w0[1] = ctx->ipad.h[ 1]; + ctx->opad.w0[2] = ctx->ipad.h[ 2]; + ctx->opad.w0[3] = ctx->ipad.h[ 3]; + ctx->opad.w1[0] = ctx->ipad.h[ 4]; + ctx->opad.w1[1] = ctx->ipad.h[ 5]; + ctx->opad.w1[2] = ctx->ipad.h[ 6]; + ctx->opad.w1[3] = ctx->ipad.h[ 7]; + ctx->opad.w2[0] = ctx->ipad.h[ 8]; + ctx->opad.w2[1] = ctx->ipad.h[ 9]; + ctx->opad.w2[2] = ctx->ipad.h[10]; + ctx->opad.w2[3] = ctx->ipad.h[11]; + ctx->opad.w3[0] = ctx->ipad.h[12]; + ctx->opad.w3[1] = ctx->ipad.h[13]; + ctx->opad.w3[2] = ctx->ipad.h[14]; + ctx->opad.w3[3] = ctx->ipad.h[15]; - t0[0] = ctx->ipad.h[ 0]; - t0[1] = ctx->ipad.h[ 1]; - t0[2] = ctx->ipad.h[ 2]; - t0[3] = ctx->ipad.h[ 3]; - t1[0] = ctx->ipad.h[ 4]; - t1[1] = ctx->ipad.h[ 5]; - t1[2] = ctx->ipad.h[ 6]; - t1[3] = ctx->ipad.h[ 7]; - t2[0] = ctx->ipad.h[ 8]; - t2[1] = ctx->ipad.h[ 9]; - t2[2] = ctx->ipad.h[10]; - t2[3] = ctx->ipad.h[11]; - t3[0] = ctx->ipad.h[12]; - t3[1] = ctx->ipad.h[13]; - t3[2] = ctx->ipad.h[14]; - t3[3] = ctx->ipad.h[15]; + ctx->opad.len += 64; - whirlpool_update_vector_64 (&ctx->opad, t0, t1, t2, t3, 64); + whirlpool_transform_vector (ctx->opad.w0, ctx->opad.w1, ctx->opad.w2, ctx->opad.w3, ctx->opad.h, ctx->opad.s_Ch, ctx->opad.s_Cl); + + ctx->opad.w0[0] = 0; + ctx->opad.w0[1] = 0; + ctx->opad.w0[2] = 0; + ctx->opad.w0[3] = 0; + ctx->opad.w1[0] = 0; + ctx->opad.w1[1] = 0; + ctx->opad.w1[2] = 0; + ctx->opad.w1[3] = 0; + ctx->opad.w2[0] = 0; + ctx->opad.w2[1] = 0; + ctx->opad.w2[2] = 0; + ctx->opad.w2[3] = 0; + ctx->opad.w3[0] = 0; + ctx->opad.w3[1] = 0; + ctx->opad.w3[2] = 0; + ctx->opad.w3[3] = 0; whirlpool_final_vector (&ctx->opad); }