mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-26 09:58:16 +00:00
Optimize update functions in inc_hash_* helper files by testing for pos == 0
This commit is contained in:
parent
ec63c2f017
commit
b626e7f61b
@ -1282,17 +1282,11 @@ DECLSPEC void append_0x80_1x16 (u32x w[16], const u32 offset)
|
||||
|
||||
DECLSPEC void switch_buffer_by_offset_le (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], const u32 offset)
|
||||
{
|
||||
if (offset == 0) return;
|
||||
|
||||
const int offset_mod_4 = offset & 3;
|
||||
|
||||
const int offset_minus_4 = 4 - offset_mod_4;
|
||||
|
||||
#ifdef IS_AMD
|
||||
const int offset_switch = offset / 4;
|
||||
#else
|
||||
const int offset_switch = offset / 4;
|
||||
#endif
|
||||
|
||||
#if (defined IS_AMD && AMD_GCN < 3) || defined IS_GENERIC
|
||||
w0[0] = swap32 (w0[0]);
|
||||
@ -1991,17 +1985,11 @@ DECLSPEC void switch_buffer_by_offset_le (u32x w0[4], u32x w1[4], u32x w2[4], u3
|
||||
|
||||
DECLSPEC void switch_buffer_by_offset_carry_le (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u32x c0[4], u32x c1[4], u32x c2[4], u32x c3[4], const u32 offset)
|
||||
{
|
||||
if (offset == 0) return;
|
||||
|
||||
const int offset_mod_4 = offset & 3;
|
||||
|
||||
const int offset_minus_4 = 4 - offset_mod_4;
|
||||
|
||||
#ifdef IS_AMD
|
||||
const int offset_switch = offset / 4;
|
||||
#else
|
||||
const int offset_switch = offset / 4;
|
||||
#endif
|
||||
|
||||
#if defined IS_AMD || defined IS_GENERIC
|
||||
w0[0] = swap32 (w0[0]);
|
||||
@ -3315,13 +3303,7 @@ DECLSPEC void switch_buffer_by_offset_carry_le (u32x w0[4], u32x w1[4], u32x w2[
|
||||
|
||||
DECLSPEC void switch_buffer_by_offset_be (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], const u32 offset)
|
||||
{
|
||||
if (offset == 0) return;
|
||||
|
||||
#ifdef IS_AMD
|
||||
const int offset_switch = offset / 4;
|
||||
#else
|
||||
const int offset_switch = offset / 4;
|
||||
#endif
|
||||
|
||||
#if (defined IS_AMD && AMD_GCN < 3) || defined IS_GENERIC
|
||||
|
||||
@ -3988,13 +3970,7 @@ DECLSPEC void switch_buffer_by_offset_be (u32x w0[4], u32x w1[4], u32x w2[4], u3
|
||||
|
||||
DECLSPEC void switch_buffer_by_offset_carry_be (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u32x c0[4], u32x c1[4], u32x c2[4], u32x c3[4], const u32 offset)
|
||||
{
|
||||
if (offset == 0) return;
|
||||
|
||||
#ifdef IS_AMD
|
||||
const int offset_switch = offset / 4;
|
||||
#else
|
||||
const int offset_switch = offset / 4;
|
||||
#endif
|
||||
|
||||
#if (defined IS_AMD && AMD_GCN < 3) || defined IS_GENERIC
|
||||
switch (offset_switch)
|
||||
@ -4930,17 +4906,11 @@ DECLSPEC void switch_buffer_by_offset_carry_be (u32x w0[4], u32x w1[4], u32x w2[
|
||||
|
||||
DECLSPEC void switch_buffer_by_offset_8x4_le (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u32x w4[4], u32x w5[4], u32x w6[4], u32x w7[4], const u32 offset)
|
||||
{
|
||||
if (offset == 0) return;
|
||||
|
||||
const int offset_mod_4 = offset & 3;
|
||||
|
||||
const int offset_minus_4 = 4 - offset_mod_4;
|
||||
|
||||
#ifdef IS_AMD
|
||||
const int offset_switch = offset / 4;
|
||||
#else
|
||||
const int offset_switch = offset / 4;
|
||||
#endif
|
||||
|
||||
#if (defined IS_AMD && AMD_GCN < 3) || defined IS_GENERIC
|
||||
w0[0] = swap32 (w0[0]);
|
||||
@ -6742,13 +6712,7 @@ DECLSPEC void switch_buffer_by_offset_8x4_le (u32x w0[4], u32x w1[4], u32x w2[4]
|
||||
|
||||
DECLSPEC void switch_buffer_by_offset_8x4_be (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u32x w4[4], u32x w5[4], u32x w6[4], u32x w7[4], const u32 offset)
|
||||
{
|
||||
if (offset == 0) return;
|
||||
|
||||
#ifdef IS_AMD
|
||||
const int offset_switch = offset / 4;
|
||||
#else
|
||||
const int offset_switch = offset / 4;
|
||||
#endif
|
||||
|
||||
#if (defined IS_AMD && AMD_GCN < 3) || defined IS_GENERIC
|
||||
switch (offset_switch)
|
||||
@ -9076,13 +9040,7 @@ DECLSPEC void switch_buffer_by_offset_8x4_be (u32x w0[4], u32x w1[4], u32x w2[4]
|
||||
|
||||
DECLSPEC void switch_buffer_by_offset_8x4_carry_be (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u32x w4[4], u32x w5[4], u32x w6[4], u32x w7[4], u32x c0[4], u32x c1[4], u32x c2[4], u32x c3[4], u32x c4[4], u32x c5[4], u32x c6[4], u32x c7[4], const u32 offset)
|
||||
{
|
||||
if (offset == 0) return;
|
||||
|
||||
#ifdef IS_AMD
|
||||
const int offset_switch = offset / 4;
|
||||
#else
|
||||
const int offset_switch = offset / 4;
|
||||
#endif
|
||||
|
||||
#if (defined IS_AMD && AMD_GCN < 3) || defined IS_GENERIC
|
||||
switch (offset_switch)
|
||||
@ -12466,17 +12424,11 @@ DECLSPEC void switch_buffer_by_offset_8x4_carry_be (u32x w0[4], u32x w1[4], u32x
|
||||
|
||||
DECLSPEC void switch_buffer_by_offset_1x64_le (u32x w[64], const u32 offset)
|
||||
{
|
||||
if (offset == 0) return;
|
||||
|
||||
const int offset_mod_4 = offset & 3;
|
||||
|
||||
const int offset_minus_4 = 4 - offset_mod_4;
|
||||
|
||||
#ifdef IS_AMD
|
||||
const int offset_switch = offset / 4;
|
||||
#else
|
||||
const int offset_switch = offset / 4;
|
||||
#endif
|
||||
|
||||
#if (defined IS_AMD && AMD_GCN < 3) || defined IS_GENERIC
|
||||
|
||||
@ -21212,13 +21164,7 @@ DECLSPEC void switch_buffer_by_offset_1x64_le (u32x w[64], const u32 offset)
|
||||
|
||||
DECLSPEC void switch_buffer_by_offset_1x64_be (u32x w[64], const u32 offset)
|
||||
{
|
||||
if (offset == 0) return;
|
||||
|
||||
#ifdef IS_AMD
|
||||
const int offset_switch = offset / 4;
|
||||
#else
|
||||
const int offset_switch = offset / 4;
|
||||
#endif
|
||||
|
||||
#if (defined IS_AMD && AMD_GCN < 3) || defined IS_GENERIC
|
||||
switch (offset_switch)
|
||||
@ -32504,17 +32450,11 @@ DECLSPEC void undo_utf16le_S (const u32 in1[4], const u32 in2[4], u32 out[4])
|
||||
|
||||
DECLSPEC void switch_buffer_by_offset_le_S (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 offset)
|
||||
{
|
||||
if (offset == 0) return;
|
||||
|
||||
const int offset_mod_4 = offset & 3;
|
||||
|
||||
const int offset_minus_4 = 4 - offset_mod_4;
|
||||
|
||||
#ifdef IS_AMD
|
||||
const int offset_switch = offset / 4;
|
||||
#else
|
||||
const int offset_switch = offset / 4;
|
||||
#endif
|
||||
|
||||
#if (defined IS_AMD && AMD_GCN < 3) || defined IS_GENERIC
|
||||
w0[0] = swap32_S (w0[0]);
|
||||
@ -33212,17 +33152,11 @@ DECLSPEC void switch_buffer_by_offset_le_S (u32 w0[4], u32 w1[4], u32 w2[4], u32
|
||||
|
||||
DECLSPEC void switch_buffer_by_offset_carry_le_S (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], u32 c0[4], u32 c1[4], u32 c2[4], u32 c3[4], const u32 offset)
|
||||
{
|
||||
if (offset == 0) return;
|
||||
|
||||
const int offset_mod_4 = offset & 3;
|
||||
|
||||
const int offset_minus_4 = 4 - offset_mod_4;
|
||||
|
||||
#ifdef IS_AMD
|
||||
const int offset_switch = offset / 4;
|
||||
#else
|
||||
const int offset_switch = offset / 4;
|
||||
#endif
|
||||
|
||||
#if defined IS_AMD || defined IS_GENERIC
|
||||
w0[0] = swap32_S (w0[0]);
|
||||
@ -34536,13 +34470,7 @@ DECLSPEC void switch_buffer_by_offset_carry_le_S (u32 w0[4], u32 w1[4], u32 w2[4
|
||||
|
||||
DECLSPEC void switch_buffer_by_offset_be_S (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 offset)
|
||||
{
|
||||
if (offset == 0) return;
|
||||
|
||||
#ifdef IS_AMD
|
||||
const int offset_switch = offset / 4;
|
||||
#else
|
||||
const int offset_switch = offset / 4;
|
||||
#endif
|
||||
|
||||
#if (defined IS_AMD && AMD_GCN < 3) || defined IS_GENERIC
|
||||
switch (offset_switch)
|
||||
@ -35206,13 +35134,7 @@ DECLSPEC void switch_buffer_by_offset_be_S (u32 w0[4], u32 w1[4], u32 w2[4], u32
|
||||
|
||||
DECLSPEC void switch_buffer_by_offset_carry_be_S (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], u32 c0[4], u32 c1[4], u32 c2[4], u32 c3[4], const u32 offset)
|
||||
{
|
||||
if (offset == 0) return;
|
||||
|
||||
#ifdef IS_AMD
|
||||
const int offset_switch = offset / 4;
|
||||
#else
|
||||
const int offset_switch = offset / 4;
|
||||
#endif
|
||||
|
||||
#if (defined IS_AMD && AMD_GCN < 3) || defined IS_GENERIC
|
||||
switch (offset_switch)
|
||||
@ -36148,17 +36070,11 @@ DECLSPEC void switch_buffer_by_offset_carry_be_S (u32 w0[4], u32 w1[4], u32 w2[4
|
||||
|
||||
DECLSPEC void switch_buffer_by_offset_8x4_le_S (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], u32 w4[4], u32 w5[4], u32 w6[4], u32 w7[4], const u32 offset)
|
||||
{
|
||||
if (offset == 0) return;
|
||||
|
||||
const int offset_mod_4 = offset & 3;
|
||||
|
||||
const int offset_minus_4 = 4 - offset_mod_4;
|
||||
|
||||
#ifdef IS_AMD
|
||||
const int offset_switch = offset / 4;
|
||||
#else
|
||||
const int offset_switch = offset / 4;
|
||||
#endif
|
||||
|
||||
#if (defined IS_AMD && AMD_GCN < 3) || defined IS_GENERIC
|
||||
w0[0] = swap32_S (w0[0]);
|
||||
@ -37960,13 +37876,7 @@ DECLSPEC void switch_buffer_by_offset_8x4_le_S (u32 w0[4], u32 w1[4], u32 w2[4],
|
||||
|
||||
DECLSPEC void switch_buffer_by_offset_8x4_be_S (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], u32 w4[4], u32 w5[4], u32 w6[4], u32 w7[4], const u32 offset)
|
||||
{
|
||||
if (offset == 0) return;
|
||||
|
||||
#ifdef IS_AMD
|
||||
const int offset_switch = offset / 4;
|
||||
#else
|
||||
const int offset_switch = offset / 4;
|
||||
#endif
|
||||
|
||||
#if (defined IS_AMD && AMD_GCN < 3) || defined IS_GENERIC
|
||||
switch (offset_switch)
|
||||
@ -40294,13 +40204,7 @@ DECLSPEC void switch_buffer_by_offset_8x4_be_S (u32 w0[4], u32 w1[4], u32 w2[4],
|
||||
|
||||
DECLSPEC void switch_buffer_by_offset_8x4_carry_be_S (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], u32 w4[4], u32 w5[4], u32 w6[4], u32 w7[4], u32 c0[4], u32 c1[4], u32 c2[4], u32 c3[4], u32 c4[4], u32 c5[4], u32 c6[4], u32 c7[4], const u32 offset)
|
||||
{
|
||||
if (offset == 0) return;
|
||||
|
||||
#ifdef IS_AMD
|
||||
const int offset_switch = offset / 4;
|
||||
#else
|
||||
const int offset_switch = offset / 4;
|
||||
#endif
|
||||
|
||||
#if (defined IS_AMD && AMD_GCN < 3) || defined IS_GENERIC
|
||||
switch (offset_switch)
|
||||
@ -43684,17 +43588,11 @@ DECLSPEC void switch_buffer_by_offset_8x4_carry_be_S (u32 w0[4], u32 w1[4], u32
|
||||
|
||||
DECLSPEC void switch_buffer_by_offset_1x64_le_S (u32 w[64], const u32 offset)
|
||||
{
|
||||
if (offset == 0) return;
|
||||
|
||||
const int offset_mod_4 = offset & 3;
|
||||
|
||||
const int offset_minus_4 = 4 - offset_mod_4;
|
||||
|
||||
#ifdef IS_AMD
|
||||
const int offset_switch = offset / 4;
|
||||
#else
|
||||
const int offset_switch = offset / 4;
|
||||
#endif
|
||||
|
||||
#if (defined IS_AMD && AMD_GCN < 3) || defined IS_GENERIC
|
||||
|
||||
@ -52430,13 +52328,7 @@ DECLSPEC void switch_buffer_by_offset_1x64_le_S (u32 w[64], const u32 offset)
|
||||
|
||||
DECLSPEC void switch_buffer_by_offset_1x64_be_S (u32 w[64], const u32 offset)
|
||||
{
|
||||
if (offset == 0) return;
|
||||
|
||||
#ifdef IS_AMD
|
||||
const int offset_switch = offset / 4;
|
||||
#else
|
||||
const int offset_switch = offset / 4;
|
||||
#endif
|
||||
|
||||
#if (defined IS_AMD && AMD_GCN < 3) || defined IS_GENERIC
|
||||
switch (offset_switch)
|
||||
|
@ -1,8 +1,8 @@
|
||||
|
||||
// important notes on this:
|
||||
// input buf unused bytes needs to be set to zero
|
||||
// input buf needs to be in algorithm native byte order (md5 = LE, sha1 = BE, etc)
|
||||
// input buf needs to be 64 byte aligned when using md5_update()
|
||||
// input buf needs to be in algorithm native byte order (md4 = LE, sha1 = BE, etc)
|
||||
// input buf needs to be 64 byte aligned when using md4_update()
|
||||
|
||||
typedef struct md4_ctx
|
||||
{
|
||||
@ -110,79 +110,121 @@ DECLSPEC void md4_init (md4_ctx_t *ctx)
|
||||
|
||||
DECLSPEC void md4_update_64 (md4_ctx_t *ctx, u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const int len)
|
||||
{
|
||||
#ifdef IS_AMD
|
||||
const int pos = ctx->len & 63;
|
||||
#else
|
||||
const int pos = ctx->len & 63;
|
||||
#endif
|
||||
|
||||
ctx->len += len;
|
||||
|
||||
if ((pos + len) < 64)
|
||||
if (pos == 0)
|
||||
{
|
||||
switch_buffer_by_offset_le_S (w0, w1, w2, w3, pos);
|
||||
if (len < 64)
|
||||
{
|
||||
ctx->w0[0] = w0[0];
|
||||
ctx->w0[1] = w0[1];
|
||||
ctx->w0[2] = w0[2];
|
||||
ctx->w0[3] = w0[3];
|
||||
ctx->w1[0] = w1[0];
|
||||
ctx->w1[1] = w1[1];
|
||||
ctx->w1[2] = w1[2];
|
||||
ctx->w1[3] = w1[3];
|
||||
ctx->w2[0] = w2[0];
|
||||
ctx->w2[1] = w2[1];
|
||||
ctx->w2[2] = w2[2];
|
||||
ctx->w2[3] = w2[3];
|
||||
ctx->w3[0] = w3[0];
|
||||
ctx->w3[1] = w3[1];
|
||||
ctx->w3[2] = w3[2];
|
||||
ctx->w3[3] = w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
md4_transform (w0, w1, w2, w3, ctx->h);
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w0[0] = 0;
|
||||
ctx->w0[1] = 0;
|
||||
ctx->w0[2] = 0;
|
||||
ctx->w0[3] = 0;
|
||||
ctx->w1[0] = 0;
|
||||
ctx->w1[1] = 0;
|
||||
ctx->w1[2] = 0;
|
||||
ctx->w1[3] = 0;
|
||||
ctx->w2[0] = 0;
|
||||
ctx->w2[1] = 0;
|
||||
ctx->w2[2] = 0;
|
||||
ctx->w2[3] = 0;
|
||||
ctx->w3[0] = 0;
|
||||
ctx->w3[1] = 0;
|
||||
ctx->w3[2] = 0;
|
||||
ctx->w3[3] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 c0[4] = { 0 };
|
||||
u32 c1[4] = { 0 };
|
||||
u32 c2[4] = { 0 };
|
||||
u32 c3[4] = { 0 };
|
||||
if ((pos + len) < 64)
|
||||
{
|
||||
switch_buffer_by_offset_le_S (w0, w1, w2, w3, pos);
|
||||
|
||||
switch_buffer_by_offset_carry_le_S (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 c0[4] = { 0 };
|
||||
u32 c1[4] = { 0 };
|
||||
u32 c2[4] = { 0 };
|
||||
u32 c3[4] = { 0 };
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
switch_buffer_by_offset_carry_le_S (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
|
||||
md4_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
md4_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1234,79 +1276,121 @@ DECLSPEC void md4_init_vector_from_scalar (md4_ctx_vector_t *ctx, md4_ctx_t *ctx
|
||||
|
||||
DECLSPEC void md4_update_vector_64 (md4_ctx_vector_t *ctx, u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], const int len)
|
||||
{
|
||||
#ifdef IS_AMD
|
||||
const int pos = ctx->len & 63;
|
||||
#else
|
||||
const int pos = ctx->len & 63;
|
||||
#endif
|
||||
|
||||
ctx->len += len;
|
||||
|
||||
if ((pos + len) < 64)
|
||||
if (pos == 0)
|
||||
{
|
||||
switch_buffer_by_offset_le (w0, w1, w2, w3, pos);
|
||||
if (len < 64)
|
||||
{
|
||||
ctx->w0[0] = w0[0];
|
||||
ctx->w0[1] = w0[1];
|
||||
ctx->w0[2] = w0[2];
|
||||
ctx->w0[3] = w0[3];
|
||||
ctx->w1[0] = w1[0];
|
||||
ctx->w1[1] = w1[1];
|
||||
ctx->w1[2] = w1[2];
|
||||
ctx->w1[3] = w1[3];
|
||||
ctx->w2[0] = w2[0];
|
||||
ctx->w2[1] = w2[1];
|
||||
ctx->w2[2] = w2[2];
|
||||
ctx->w2[3] = w2[3];
|
||||
ctx->w3[0] = w3[0];
|
||||
ctx->w3[1] = w3[1];
|
||||
ctx->w3[2] = w3[2];
|
||||
ctx->w3[3] = w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
md4_transform_vector (w0, w1, w2, w3, ctx->h);
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w0[0] = 0;
|
||||
ctx->w0[1] = 0;
|
||||
ctx->w0[2] = 0;
|
||||
ctx->w0[3] = 0;
|
||||
ctx->w1[0] = 0;
|
||||
ctx->w1[1] = 0;
|
||||
ctx->w1[2] = 0;
|
||||
ctx->w1[3] = 0;
|
||||
ctx->w2[0] = 0;
|
||||
ctx->w2[1] = 0;
|
||||
ctx->w2[2] = 0;
|
||||
ctx->w2[3] = 0;
|
||||
ctx->w3[0] = 0;
|
||||
ctx->w3[1] = 0;
|
||||
ctx->w3[2] = 0;
|
||||
ctx->w3[3] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32x c0[4] = { 0 };
|
||||
u32x c1[4] = { 0 };
|
||||
u32x c2[4] = { 0 };
|
||||
u32x c3[4] = { 0 };
|
||||
if ((pos + len) < 64)
|
||||
{
|
||||
switch_buffer_by_offset_le (w0, w1, w2, w3, pos);
|
||||
|
||||
switch_buffer_by_offset_carry_le (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
u32x c0[4] = { 0 };
|
||||
u32x c1[4] = { 0 };
|
||||
u32x c2[4] = { 0 };
|
||||
u32x c3[4] = { 0 };
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
switch_buffer_by_offset_carry_le (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
|
||||
md4_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
md4_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,79 +146,121 @@ DECLSPEC void md5_init (md5_ctx_t *ctx)
|
||||
|
||||
DECLSPEC void md5_update_64 (md5_ctx_t *ctx, u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const int len)
|
||||
{
|
||||
#ifdef IS_AMD
|
||||
const int pos = ctx->len & 63;
|
||||
#else
|
||||
const int pos = ctx->len & 63;
|
||||
#endif
|
||||
|
||||
ctx->len += len;
|
||||
|
||||
if ((pos + len) < 64)
|
||||
if (pos == 0)
|
||||
{
|
||||
switch_buffer_by_offset_le_S (w0, w1, w2, w3, pos);
|
||||
if (len < 64)
|
||||
{
|
||||
ctx->w0[0] = w0[0];
|
||||
ctx->w0[1] = w0[1];
|
||||
ctx->w0[2] = w0[2];
|
||||
ctx->w0[3] = w0[3];
|
||||
ctx->w1[0] = w1[0];
|
||||
ctx->w1[1] = w1[1];
|
||||
ctx->w1[2] = w1[2];
|
||||
ctx->w1[3] = w1[3];
|
||||
ctx->w2[0] = w2[0];
|
||||
ctx->w2[1] = w2[1];
|
||||
ctx->w2[2] = w2[2];
|
||||
ctx->w2[3] = w2[3];
|
||||
ctx->w3[0] = w3[0];
|
||||
ctx->w3[1] = w3[1];
|
||||
ctx->w3[2] = w3[2];
|
||||
ctx->w3[3] = w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
md5_transform (w0, w1, w2, w3, ctx->h);
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w0[0] = 0;
|
||||
ctx->w0[1] = 0;
|
||||
ctx->w0[2] = 0;
|
||||
ctx->w0[3] = 0;
|
||||
ctx->w1[0] = 0;
|
||||
ctx->w1[1] = 0;
|
||||
ctx->w1[2] = 0;
|
||||
ctx->w1[3] = 0;
|
||||
ctx->w2[0] = 0;
|
||||
ctx->w2[1] = 0;
|
||||
ctx->w2[2] = 0;
|
||||
ctx->w2[3] = 0;
|
||||
ctx->w3[0] = 0;
|
||||
ctx->w3[1] = 0;
|
||||
ctx->w3[2] = 0;
|
||||
ctx->w3[3] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 c0[4] = { 0 };
|
||||
u32 c1[4] = { 0 };
|
||||
u32 c2[4] = { 0 };
|
||||
u32 c3[4] = { 0 };
|
||||
if ((pos + len) < 64)
|
||||
{
|
||||
switch_buffer_by_offset_le_S (w0, w1, w2, w3, pos);
|
||||
|
||||
switch_buffer_by_offset_carry_le_S (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 c0[4] = { 0 };
|
||||
u32 c1[4] = { 0 };
|
||||
u32 c2[4] = { 0 };
|
||||
u32 c3[4] = { 0 };
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
switch_buffer_by_offset_carry_le_S (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
|
||||
md5_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
md5_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1306,79 +1348,121 @@ DECLSPEC void md5_init_vector_from_scalar (md5_ctx_vector_t *ctx, md5_ctx_t *ctx
|
||||
|
||||
DECLSPEC void md5_update_vector_64 (md5_ctx_vector_t *ctx, u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], const int len)
|
||||
{
|
||||
#ifdef IS_AMD
|
||||
const int pos = ctx->len & 63;
|
||||
#else
|
||||
const int pos = ctx->len & 63;
|
||||
#endif
|
||||
|
||||
ctx->len += len;
|
||||
|
||||
if ((pos + len) < 64)
|
||||
if (pos == 0)
|
||||
{
|
||||
switch_buffer_by_offset_le (w0, w1, w2, w3, pos);
|
||||
if (len < 64)
|
||||
{
|
||||
ctx->w0[0] = w0[0];
|
||||
ctx->w0[1] = w0[1];
|
||||
ctx->w0[2] = w0[2];
|
||||
ctx->w0[3] = w0[3];
|
||||
ctx->w1[0] = w1[0];
|
||||
ctx->w1[1] = w1[1];
|
||||
ctx->w1[2] = w1[2];
|
||||
ctx->w1[3] = w1[3];
|
||||
ctx->w2[0] = w2[0];
|
||||
ctx->w2[1] = w2[1];
|
||||
ctx->w2[2] = w2[2];
|
||||
ctx->w2[3] = w2[3];
|
||||
ctx->w3[0] = w3[0];
|
||||
ctx->w3[1] = w3[1];
|
||||
ctx->w3[2] = w3[2];
|
||||
ctx->w3[3] = w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
md5_transform_vector (w0, w1, w2, w3, ctx->h);
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w0[0] = 0;
|
||||
ctx->w0[1] = 0;
|
||||
ctx->w0[2] = 0;
|
||||
ctx->w0[3] = 0;
|
||||
ctx->w1[0] = 0;
|
||||
ctx->w1[1] = 0;
|
||||
ctx->w1[2] = 0;
|
||||
ctx->w1[3] = 0;
|
||||
ctx->w2[0] = 0;
|
||||
ctx->w2[1] = 0;
|
||||
ctx->w2[2] = 0;
|
||||
ctx->w2[3] = 0;
|
||||
ctx->w3[0] = 0;
|
||||
ctx->w3[1] = 0;
|
||||
ctx->w3[2] = 0;
|
||||
ctx->w3[3] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32x c0[4] = { 0 };
|
||||
u32x c1[4] = { 0 };
|
||||
u32x c2[4] = { 0 };
|
||||
u32x c3[4] = { 0 };
|
||||
if ((pos + len) < 64)
|
||||
{
|
||||
switch_buffer_by_offset_le (w0, w1, w2, w3, pos);
|
||||
|
||||
switch_buffer_by_offset_carry_le (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
u32x c0[4] = { 0 };
|
||||
u32x c1[4] = { 0 };
|
||||
u32x c2[4] = { 0 };
|
||||
u32x c3[4] = { 0 };
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
switch_buffer_by_offset_carry_le (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
|
||||
md5_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
md5_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,79 +244,121 @@ DECLSPEC void ripemd160_init (ripemd160_ctx_t *ctx)
|
||||
|
||||
DECLSPEC void ripemd160_update_64 (ripemd160_ctx_t *ctx, u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const int len)
|
||||
{
|
||||
#ifdef IS_AMD
|
||||
const int pos = ctx->len & 63;
|
||||
#else
|
||||
const int pos = ctx->len & 63;
|
||||
#endif
|
||||
|
||||
ctx->len += len;
|
||||
|
||||
if ((pos + len) < 64)
|
||||
if (pos == 0)
|
||||
{
|
||||
switch_buffer_by_offset_le_S (w0, w1, w2, w3, pos);
|
||||
if (len < 64)
|
||||
{
|
||||
ctx->w0[0] = w0[0];
|
||||
ctx->w0[1] = w0[1];
|
||||
ctx->w0[2] = w0[2];
|
||||
ctx->w0[3] = w0[3];
|
||||
ctx->w1[0] = w1[0];
|
||||
ctx->w1[1] = w1[1];
|
||||
ctx->w1[2] = w1[2];
|
||||
ctx->w1[3] = w1[3];
|
||||
ctx->w2[0] = w2[0];
|
||||
ctx->w2[1] = w2[1];
|
||||
ctx->w2[2] = w2[2];
|
||||
ctx->w2[3] = w2[3];
|
||||
ctx->w3[0] = w3[0];
|
||||
ctx->w3[1] = w3[1];
|
||||
ctx->w3[2] = w3[2];
|
||||
ctx->w3[3] = w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
ripemd160_transform (w0, w1, w2, w3, ctx->h);
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w0[0] = 0;
|
||||
ctx->w0[1] = 0;
|
||||
ctx->w0[2] = 0;
|
||||
ctx->w0[3] = 0;
|
||||
ctx->w1[0] = 0;
|
||||
ctx->w1[1] = 0;
|
||||
ctx->w1[2] = 0;
|
||||
ctx->w1[3] = 0;
|
||||
ctx->w2[0] = 0;
|
||||
ctx->w2[1] = 0;
|
||||
ctx->w2[2] = 0;
|
||||
ctx->w2[3] = 0;
|
||||
ctx->w3[0] = 0;
|
||||
ctx->w3[1] = 0;
|
||||
ctx->w3[2] = 0;
|
||||
ctx->w3[3] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 c0[4] = { 0 };
|
||||
u32 c1[4] = { 0 };
|
||||
u32 c2[4] = { 0 };
|
||||
u32 c3[4] = { 0 };
|
||||
if ((pos + len) < 64)
|
||||
{
|
||||
switch_buffer_by_offset_le_S (w0, w1, w2, w3, pos);
|
||||
|
||||
switch_buffer_by_offset_carry_le_S (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 c0[4] = { 0 };
|
||||
u32 c1[4] = { 0 };
|
||||
u32 c2[4] = { 0 };
|
||||
u32 c3[4] = { 0 };
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
switch_buffer_by_offset_carry_le_S (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
|
||||
ripemd160_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
ripemd160_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1503,79 +1545,121 @@ DECLSPEC void ripemd160_init_vector_from_scalar (ripemd160_ctx_vector_t *ctx, ri
|
||||
|
||||
DECLSPEC void ripemd160_update_vector_64 (ripemd160_ctx_vector_t *ctx, u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], const int len)
|
||||
{
|
||||
#ifdef IS_AMD
|
||||
const int pos = ctx->len & 63;
|
||||
#else
|
||||
const int pos = ctx->len & 63;
|
||||
#endif
|
||||
|
||||
ctx->len += len;
|
||||
|
||||
if ((pos + len) < 64)
|
||||
if (pos == 0)
|
||||
{
|
||||
switch_buffer_by_offset_le (w0, w1, w2, w3, pos);
|
||||
if (len < 64)
|
||||
{
|
||||
ctx->w0[0] = w0[0];
|
||||
ctx->w0[1] = w0[1];
|
||||
ctx->w0[2] = w0[2];
|
||||
ctx->w0[3] = w0[3];
|
||||
ctx->w1[0] = w1[0];
|
||||
ctx->w1[1] = w1[1];
|
||||
ctx->w1[2] = w1[2];
|
||||
ctx->w1[3] = w1[3];
|
||||
ctx->w2[0] = w2[0];
|
||||
ctx->w2[1] = w2[1];
|
||||
ctx->w2[2] = w2[2];
|
||||
ctx->w2[3] = w2[3];
|
||||
ctx->w3[0] = w3[0];
|
||||
ctx->w3[1] = w3[1];
|
||||
ctx->w3[2] = w3[2];
|
||||
ctx->w3[3] = w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
ripemd160_transform_vector (w0, w1, w2, w3, ctx->h);
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w0[0] = 0;
|
||||
ctx->w0[1] = 0;
|
||||
ctx->w0[2] = 0;
|
||||
ctx->w0[3] = 0;
|
||||
ctx->w1[0] = 0;
|
||||
ctx->w1[1] = 0;
|
||||
ctx->w1[2] = 0;
|
||||
ctx->w1[3] = 0;
|
||||
ctx->w2[0] = 0;
|
||||
ctx->w2[1] = 0;
|
||||
ctx->w2[2] = 0;
|
||||
ctx->w2[3] = 0;
|
||||
ctx->w3[0] = 0;
|
||||
ctx->w3[1] = 0;
|
||||
ctx->w3[2] = 0;
|
||||
ctx->w3[3] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32x c0[4] = { 0 };
|
||||
u32x c1[4] = { 0 };
|
||||
u32x c2[4] = { 0 };
|
||||
u32x c3[4] = { 0 };
|
||||
if ((pos + len) < 64)
|
||||
{
|
||||
switch_buffer_by_offset_le (w0, w1, w2, w3, pos);
|
||||
|
||||
switch_buffer_by_offset_carry_le (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
u32x c0[4] = { 0 };
|
||||
u32x c1[4] = { 0 };
|
||||
u32x c2[4] = { 0 };
|
||||
u32x c3[4] = { 0 };
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
switch_buffer_by_offset_carry_le (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
|
||||
ripemd160_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
ripemd160_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,79 +176,121 @@ DECLSPEC void sha1_init (sha1_ctx_t *ctx)
|
||||
|
||||
DECLSPEC void sha1_update_64 (sha1_ctx_t *ctx, u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const int len)
|
||||
{
|
||||
#ifdef IS_AMD
|
||||
const int pos = ctx->len & 63;
|
||||
#else
|
||||
const int pos = ctx->len & 63;
|
||||
#endif
|
||||
|
||||
ctx->len += len;
|
||||
|
||||
if ((pos + len) < 64)
|
||||
if (pos == 0)
|
||||
{
|
||||
switch_buffer_by_offset_be_S (w0, w1, w2, w3, pos);
|
||||
if (len < 64)
|
||||
{
|
||||
ctx->w0[0] = w0[0];
|
||||
ctx->w0[1] = w0[1];
|
||||
ctx->w0[2] = w0[2];
|
||||
ctx->w0[3] = w0[3];
|
||||
ctx->w1[0] = w1[0];
|
||||
ctx->w1[1] = w1[1];
|
||||
ctx->w1[2] = w1[2];
|
||||
ctx->w1[3] = w1[3];
|
||||
ctx->w2[0] = w2[0];
|
||||
ctx->w2[1] = w2[1];
|
||||
ctx->w2[2] = w2[2];
|
||||
ctx->w2[3] = w2[3];
|
||||
ctx->w3[0] = w3[0];
|
||||
ctx->w3[1] = w3[1];
|
||||
ctx->w3[2] = w3[2];
|
||||
ctx->w3[3] = w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
sha1_transform (w0, w1, w2, w3, ctx->h);
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w0[0] = 0;
|
||||
ctx->w0[1] = 0;
|
||||
ctx->w0[2] = 0;
|
||||
ctx->w0[3] = 0;
|
||||
ctx->w1[0] = 0;
|
||||
ctx->w1[1] = 0;
|
||||
ctx->w1[2] = 0;
|
||||
ctx->w1[3] = 0;
|
||||
ctx->w2[0] = 0;
|
||||
ctx->w2[1] = 0;
|
||||
ctx->w2[2] = 0;
|
||||
ctx->w2[3] = 0;
|
||||
ctx->w3[0] = 0;
|
||||
ctx->w3[1] = 0;
|
||||
ctx->w3[2] = 0;
|
||||
ctx->w3[3] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 c0[4] = { 0 };
|
||||
u32 c1[4] = { 0 };
|
||||
u32 c2[4] = { 0 };
|
||||
u32 c3[4] = { 0 };
|
||||
if ((pos + len) < 64)
|
||||
{
|
||||
switch_buffer_by_offset_be_S (w0, w1, w2, w3, pos);
|
||||
|
||||
switch_buffer_by_offset_carry_be_S (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 c0[4] = { 0 };
|
||||
u32 c1[4] = { 0 };
|
||||
u32 c2[4] = { 0 };
|
||||
u32 c3[4] = { 0 };
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
switch_buffer_by_offset_carry_be_S (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
|
||||
sha1_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
sha1_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1603,79 +1645,121 @@ DECLSPEC void sha1_init_vector_from_scalar (sha1_ctx_vector_t *ctx, sha1_ctx_t *
|
||||
|
||||
DECLSPEC void sha1_update_vector_64 (sha1_ctx_vector_t *ctx, u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], const int len)
|
||||
{
|
||||
#ifdef IS_AMD
|
||||
const int pos = ctx->len & 63;
|
||||
#else
|
||||
const int pos = ctx->len & 63;
|
||||
#endif
|
||||
|
||||
ctx->len += len;
|
||||
|
||||
if ((pos + len) < 64)
|
||||
if (pos == 0)
|
||||
{
|
||||
//switch_buffer_by_offset_be (w0, w1, w2, w3, pos);
|
||||
if (len < 64)
|
||||
{
|
||||
ctx->w0[0] = w0[0];
|
||||
ctx->w0[1] = w0[1];
|
||||
ctx->w0[2] = w0[2];
|
||||
ctx->w0[3] = w0[3];
|
||||
ctx->w1[0] = w1[0];
|
||||
ctx->w1[1] = w1[1];
|
||||
ctx->w1[2] = w1[2];
|
||||
ctx->w1[3] = w1[3];
|
||||
ctx->w2[0] = w2[0];
|
||||
ctx->w2[1] = w2[1];
|
||||
ctx->w2[2] = w2[2];
|
||||
ctx->w2[3] = w2[3];
|
||||
ctx->w3[0] = w3[0];
|
||||
ctx->w3[1] = w3[1];
|
||||
ctx->w3[2] = w3[2];
|
||||
ctx->w3[3] = w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
sha1_transform_vector (w0, w1, w2, w3, ctx->h);
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w0[0] = 0;
|
||||
ctx->w0[1] = 0;
|
||||
ctx->w0[2] = 0;
|
||||
ctx->w0[3] = 0;
|
||||
ctx->w1[0] = 0;
|
||||
ctx->w1[1] = 0;
|
||||
ctx->w1[2] = 0;
|
||||
ctx->w1[3] = 0;
|
||||
ctx->w2[0] = 0;
|
||||
ctx->w2[1] = 0;
|
||||
ctx->w2[2] = 0;
|
||||
ctx->w2[3] = 0;
|
||||
ctx->w3[0] = 0;
|
||||
ctx->w3[1] = 0;
|
||||
ctx->w3[2] = 0;
|
||||
ctx->w3[3] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32x c0[4] = { 0 };
|
||||
u32x c1[4] = { 0 };
|
||||
u32x c2[4] = { 0 };
|
||||
u32x c3[4] = { 0 };
|
||||
if ((pos + len) < 64)
|
||||
{
|
||||
switch_buffer_by_offset_be (w0, w1, w2, w3, pos);
|
||||
|
||||
//switch_buffer_by_offset_carry_be (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
u32x c0[4] = { 0 };
|
||||
u32x c1[4] = { 0 };
|
||||
u32x c2[4] = { 0 };
|
||||
u32x c3[4] = { 0 };
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
switch_buffer_by_offset_carry_be (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
|
||||
sha1_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
sha1_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,79 +161,121 @@ DECLSPEC void sha224_init (sha224_ctx_t *ctx)
|
||||
|
||||
DECLSPEC void sha224_update_64 (sha224_ctx_t *ctx, u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const int len)
|
||||
{
|
||||
#ifdef IS_AMD
|
||||
const int pos = ctx->len & 63;
|
||||
#else
|
||||
const int pos = ctx->len & 63;
|
||||
#endif
|
||||
|
||||
ctx->len += len;
|
||||
|
||||
if ((pos + len) < 64)
|
||||
if (pos == 0)
|
||||
{
|
||||
switch_buffer_by_offset_be_S (w0, w1, w2, w3, pos);
|
||||
if (len < 64)
|
||||
{
|
||||
ctx->w0[0] = w0[0];
|
||||
ctx->w0[1] = w0[1];
|
||||
ctx->w0[2] = w0[2];
|
||||
ctx->w0[3] = w0[3];
|
||||
ctx->w1[0] = w1[0];
|
||||
ctx->w1[1] = w1[1];
|
||||
ctx->w1[2] = w1[2];
|
||||
ctx->w1[3] = w1[3];
|
||||
ctx->w2[0] = w2[0];
|
||||
ctx->w2[1] = w2[1];
|
||||
ctx->w2[2] = w2[2];
|
||||
ctx->w2[3] = w2[3];
|
||||
ctx->w3[0] = w3[0];
|
||||
ctx->w3[1] = w3[1];
|
||||
ctx->w3[2] = w3[2];
|
||||
ctx->w3[3] = w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
sha224_transform (w0, w1, w2, w3, ctx->h);
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w0[0] = 0;
|
||||
ctx->w0[1] = 0;
|
||||
ctx->w0[2] = 0;
|
||||
ctx->w0[3] = 0;
|
||||
ctx->w1[0] = 0;
|
||||
ctx->w1[1] = 0;
|
||||
ctx->w1[2] = 0;
|
||||
ctx->w1[3] = 0;
|
||||
ctx->w2[0] = 0;
|
||||
ctx->w2[1] = 0;
|
||||
ctx->w2[2] = 0;
|
||||
ctx->w2[3] = 0;
|
||||
ctx->w3[0] = 0;
|
||||
ctx->w3[1] = 0;
|
||||
ctx->w3[2] = 0;
|
||||
ctx->w3[3] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 c0[4] = { 0 };
|
||||
u32 c1[4] = { 0 };
|
||||
u32 c2[4] = { 0 };
|
||||
u32 c3[4] = { 0 };
|
||||
if ((pos + len) < 64)
|
||||
{
|
||||
switch_buffer_by_offset_be_S (w0, w1, w2, w3, pos);
|
||||
|
||||
switch_buffer_by_offset_carry_be_S (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 c0[4] = { 0 };
|
||||
u32 c1[4] = { 0 };
|
||||
u32 c2[4] = { 0 };
|
||||
u32 c3[4] = { 0 };
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
switch_buffer_by_offset_carry_be_S (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
|
||||
sha224_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
sha224_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1320,79 +1362,121 @@ DECLSPEC void sha224_init_vector_from_scalar (sha224_ctx_vector_t *ctx, sha224_c
|
||||
|
||||
DECLSPEC void sha224_update_vector_64 (sha224_ctx_vector_t *ctx, u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], const int len)
|
||||
{
|
||||
#ifdef IS_AMD
|
||||
const int pos = ctx->len & 63;
|
||||
#else
|
||||
const int pos = ctx->len & 63;
|
||||
#endif
|
||||
|
||||
ctx->len += len;
|
||||
|
||||
if ((pos + len) < 64)
|
||||
if (pos == 0)
|
||||
{
|
||||
switch_buffer_by_offset_be (w0, w1, w2, w3, pos);
|
||||
if (len < 64)
|
||||
{
|
||||
ctx->w0[0] = w0[0];
|
||||
ctx->w0[1] = w0[1];
|
||||
ctx->w0[2] = w0[2];
|
||||
ctx->w0[3] = w0[3];
|
||||
ctx->w1[0] = w1[0];
|
||||
ctx->w1[1] = w1[1];
|
||||
ctx->w1[2] = w1[2];
|
||||
ctx->w1[3] = w1[3];
|
||||
ctx->w2[0] = w2[0];
|
||||
ctx->w2[1] = w2[1];
|
||||
ctx->w2[2] = w2[2];
|
||||
ctx->w2[3] = w2[3];
|
||||
ctx->w3[0] = w3[0];
|
||||
ctx->w3[1] = w3[1];
|
||||
ctx->w3[2] = w3[2];
|
||||
ctx->w3[3] = w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
sha224_transform_vector (w0, w1, w2, w3, ctx->h);
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w0[0] = 0;
|
||||
ctx->w0[1] = 0;
|
||||
ctx->w0[2] = 0;
|
||||
ctx->w0[3] = 0;
|
||||
ctx->w1[0] = 0;
|
||||
ctx->w1[1] = 0;
|
||||
ctx->w1[2] = 0;
|
||||
ctx->w1[3] = 0;
|
||||
ctx->w2[0] = 0;
|
||||
ctx->w2[1] = 0;
|
||||
ctx->w2[2] = 0;
|
||||
ctx->w2[3] = 0;
|
||||
ctx->w3[0] = 0;
|
||||
ctx->w3[1] = 0;
|
||||
ctx->w3[2] = 0;
|
||||
ctx->w3[3] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32x c0[4] = { 0 };
|
||||
u32x c1[4] = { 0 };
|
||||
u32x c2[4] = { 0 };
|
||||
u32x c3[4] = { 0 };
|
||||
if ((pos + len) < 64)
|
||||
{
|
||||
switch_buffer_by_offset_be (w0, w1, w2, w3, pos);
|
||||
|
||||
switch_buffer_by_offset_carry_be (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
u32x c0[4] = { 0 };
|
||||
u32x c1[4] = { 0 };
|
||||
u32x c2[4] = { 0 };
|
||||
u32x c3[4] = { 0 };
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
switch_buffer_by_offset_carry_be (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
|
||||
sha224_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
sha224_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,79 +161,121 @@ DECLSPEC void sha256_init (sha256_ctx_t *ctx)
|
||||
|
||||
DECLSPEC void sha256_update_64 (sha256_ctx_t *ctx, u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const int len)
|
||||
{
|
||||
#ifdef IS_AMD
|
||||
const int pos = ctx->len & 63;
|
||||
#else
|
||||
const int pos = ctx->len & 63;
|
||||
#endif
|
||||
|
||||
ctx->len += len;
|
||||
|
||||
if ((pos + len) < 64)
|
||||
if (pos == 0)
|
||||
{
|
||||
switch_buffer_by_offset_be_S (w0, w1, w2, w3, pos);
|
||||
if (len < 64)
|
||||
{
|
||||
ctx->w0[0] = w0[0];
|
||||
ctx->w0[1] = w0[1];
|
||||
ctx->w0[2] = w0[2];
|
||||
ctx->w0[3] = w0[3];
|
||||
ctx->w1[0] = w1[0];
|
||||
ctx->w1[1] = w1[1];
|
||||
ctx->w1[2] = w1[2];
|
||||
ctx->w1[3] = w1[3];
|
||||
ctx->w2[0] = w2[0];
|
||||
ctx->w2[1] = w2[1];
|
||||
ctx->w2[2] = w2[2];
|
||||
ctx->w2[3] = w2[3];
|
||||
ctx->w3[0] = w3[0];
|
||||
ctx->w3[1] = w3[1];
|
||||
ctx->w3[2] = w3[2];
|
||||
ctx->w3[3] = w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
sha256_transform (w0, w1, w2, w3, ctx->h);
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w0[0] = 0;
|
||||
ctx->w0[1] = 0;
|
||||
ctx->w0[2] = 0;
|
||||
ctx->w0[3] = 0;
|
||||
ctx->w1[0] = 0;
|
||||
ctx->w1[1] = 0;
|
||||
ctx->w1[2] = 0;
|
||||
ctx->w1[3] = 0;
|
||||
ctx->w2[0] = 0;
|
||||
ctx->w2[1] = 0;
|
||||
ctx->w2[2] = 0;
|
||||
ctx->w2[3] = 0;
|
||||
ctx->w3[0] = 0;
|
||||
ctx->w3[1] = 0;
|
||||
ctx->w3[2] = 0;
|
||||
ctx->w3[3] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 c0[4] = { 0 };
|
||||
u32 c1[4] = { 0 };
|
||||
u32 c2[4] = { 0 };
|
||||
u32 c3[4] = { 0 };
|
||||
if ((pos + len) < 64)
|
||||
{
|
||||
switch_buffer_by_offset_be_S (w0, w1, w2, w3, pos);
|
||||
|
||||
switch_buffer_by_offset_carry_be_S (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 c0[4] = { 0 };
|
||||
u32 c1[4] = { 0 };
|
||||
u32 c2[4] = { 0 };
|
||||
u32 c3[4] = { 0 };
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
switch_buffer_by_offset_carry_be_S (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
|
||||
sha256_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
sha256_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1320,79 +1362,121 @@ DECLSPEC void sha256_init_vector_from_scalar (sha256_ctx_vector_t *ctx, sha256_c
|
||||
|
||||
DECLSPEC void sha256_update_vector_64 (sha256_ctx_vector_t *ctx, u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], const int len)
|
||||
{
|
||||
#ifdef IS_AMD
|
||||
const int pos = ctx->len & 63;
|
||||
#else
|
||||
const int pos = ctx->len & 63;
|
||||
#endif
|
||||
|
||||
ctx->len += len;
|
||||
|
||||
if ((pos + len) < 64)
|
||||
if (pos == 0)
|
||||
{
|
||||
switch_buffer_by_offset_be (w0, w1, w2, w3, pos);
|
||||
if (len < 64)
|
||||
{
|
||||
ctx->w0[0] = w0[0];
|
||||
ctx->w0[1] = w0[1];
|
||||
ctx->w0[2] = w0[2];
|
||||
ctx->w0[3] = w0[3];
|
||||
ctx->w1[0] = w1[0];
|
||||
ctx->w1[1] = w1[1];
|
||||
ctx->w1[2] = w1[2];
|
||||
ctx->w1[3] = w1[3];
|
||||
ctx->w2[0] = w2[0];
|
||||
ctx->w2[1] = w2[1];
|
||||
ctx->w2[2] = w2[2];
|
||||
ctx->w2[3] = w2[3];
|
||||
ctx->w3[0] = w3[0];
|
||||
ctx->w3[1] = w3[1];
|
||||
ctx->w3[2] = w3[2];
|
||||
ctx->w3[3] = w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
sha256_transform_vector (w0, w1, w2, w3, ctx->h);
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w0[0] = 0;
|
||||
ctx->w0[1] = 0;
|
||||
ctx->w0[2] = 0;
|
||||
ctx->w0[3] = 0;
|
||||
ctx->w1[0] = 0;
|
||||
ctx->w1[1] = 0;
|
||||
ctx->w1[2] = 0;
|
||||
ctx->w1[3] = 0;
|
||||
ctx->w2[0] = 0;
|
||||
ctx->w2[1] = 0;
|
||||
ctx->w2[2] = 0;
|
||||
ctx->w2[3] = 0;
|
||||
ctx->w3[0] = 0;
|
||||
ctx->w3[1] = 0;
|
||||
ctx->w3[2] = 0;
|
||||
ctx->w3[3] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32x c0[4] = { 0 };
|
||||
u32x c1[4] = { 0 };
|
||||
u32x c2[4] = { 0 };
|
||||
u32x c3[4] = { 0 };
|
||||
if ((pos + len) < 64)
|
||||
{
|
||||
switch_buffer_by_offset_be (w0, w1, w2, w3, pos);
|
||||
|
||||
switch_buffer_by_offset_carry_be (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
u32x c0[4] = { 0 };
|
||||
u32x c1[4] = { 0 };
|
||||
u32x c2[4] = { 0 };
|
||||
u32x c3[4] = { 0 };
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
switch_buffer_by_offset_carry_be (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
|
||||
sha256_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
sha256_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h);
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,131 +185,205 @@ DECLSPEC void sha384_init (sha384_ctx_t *ctx)
|
||||
|
||||
DECLSPEC void sha384_update_128 (sha384_ctx_t *ctx, u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], u32 w4[4], u32 w5[4], u32 w6[4], u32 w7[4], const int len)
|
||||
{
|
||||
#ifdef IS_AMD
|
||||
const int pos = ctx->len & 127;
|
||||
#else
|
||||
const int pos = ctx->len & 127;
|
||||
#endif
|
||||
|
||||
ctx->len += len;
|
||||
|
||||
if ((pos + len) < 128)
|
||||
if (pos == 0)
|
||||
{
|
||||
switch_buffer_by_offset_8x4_be_S (w0, w1, w2, w3, w4, w5, w6, w7, pos);
|
||||
if (len < 128)
|
||||
{
|
||||
ctx->w0[0] = w0[0];
|
||||
ctx->w0[1] = w0[1];
|
||||
ctx->w0[2] = w0[2];
|
||||
ctx->w0[3] = w0[3];
|
||||
ctx->w1[0] = w1[0];
|
||||
ctx->w1[1] = w1[1];
|
||||
ctx->w1[2] = w1[2];
|
||||
ctx->w1[3] = w1[3];
|
||||
ctx->w2[0] = w2[0];
|
||||
ctx->w2[1] = w2[1];
|
||||
ctx->w2[2] = w2[2];
|
||||
ctx->w2[3] = w2[3];
|
||||
ctx->w3[0] = w3[0];
|
||||
ctx->w3[1] = w3[1];
|
||||
ctx->w3[2] = w3[2];
|
||||
ctx->w3[3] = w3[3];
|
||||
ctx->w4[0] = w4[0];
|
||||
ctx->w4[1] = w4[1];
|
||||
ctx->w4[2] = w4[2];
|
||||
ctx->w4[3] = w4[3];
|
||||
ctx->w5[0] = w5[0];
|
||||
ctx->w5[1] = w5[1];
|
||||
ctx->w5[2] = w5[2];
|
||||
ctx->w5[3] = w5[3];
|
||||
ctx->w6[0] = w6[0];
|
||||
ctx->w6[1] = w6[1];
|
||||
ctx->w6[2] = w6[2];
|
||||
ctx->w6[3] = w6[3];
|
||||
ctx->w7[0] = w7[0];
|
||||
ctx->w7[1] = w7[1];
|
||||
ctx->w7[2] = w7[2];
|
||||
ctx->w7[3] = w7[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
sha384_transform (w0, w1, w2, w3, w4, w5, w6, w7, ctx->h);
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w4[0] |= w4[0];
|
||||
ctx->w4[1] |= w4[1];
|
||||
ctx->w4[2] |= w4[2];
|
||||
ctx->w4[3] |= w4[3];
|
||||
ctx->w5[0] |= w5[0];
|
||||
ctx->w5[1] |= w5[1];
|
||||
ctx->w5[2] |= w5[2];
|
||||
ctx->w5[3] |= w5[3];
|
||||
ctx->w6[0] |= w6[0];
|
||||
ctx->w6[1] |= w6[1];
|
||||
ctx->w6[2] |= w6[2];
|
||||
ctx->w6[3] |= w6[3];
|
||||
ctx->w7[0] |= w7[0];
|
||||
ctx->w7[1] |= w7[1];
|
||||
ctx->w7[2] |= w7[2];
|
||||
ctx->w7[3] |= w7[3];
|
||||
ctx->w0[0] = 0;
|
||||
ctx->w0[1] = 0;
|
||||
ctx->w0[2] = 0;
|
||||
ctx->w0[3] = 0;
|
||||
ctx->w1[0] = 0;
|
||||
ctx->w1[1] = 0;
|
||||
ctx->w1[2] = 0;
|
||||
ctx->w1[3] = 0;
|
||||
ctx->w2[0] = 0;
|
||||
ctx->w2[1] = 0;
|
||||
ctx->w2[2] = 0;
|
||||
ctx->w2[3] = 0;
|
||||
ctx->w3[0] = 0;
|
||||
ctx->w3[1] = 0;
|
||||
ctx->w3[2] = 0;
|
||||
ctx->w3[3] = 0;
|
||||
ctx->w4[0] = 0;
|
||||
ctx->w4[1] = 0;
|
||||
ctx->w4[2] = 0;
|
||||
ctx->w4[3] = 0;
|
||||
ctx->w5[0] = 0;
|
||||
ctx->w5[1] = 0;
|
||||
ctx->w5[2] = 0;
|
||||
ctx->w5[3] = 0;
|
||||
ctx->w6[0] = 0;
|
||||
ctx->w6[1] = 0;
|
||||
ctx->w6[2] = 0;
|
||||
ctx->w6[3] = 0;
|
||||
ctx->w7[0] = 0;
|
||||
ctx->w7[1] = 0;
|
||||
ctx->w7[2] = 0;
|
||||
ctx->w7[3] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 c0[4] = { 0 };
|
||||
u32 c1[4] = { 0 };
|
||||
u32 c2[4] = { 0 };
|
||||
u32 c3[4] = { 0 };
|
||||
u32 c4[4] = { 0 };
|
||||
u32 c5[4] = { 0 };
|
||||
u32 c6[4] = { 0 };
|
||||
u32 c7[4] = { 0 };
|
||||
if ((pos + len) < 128)
|
||||
{
|
||||
switch_buffer_by_offset_8x4_be_S (w0, w1, w2, w3, w4, w5, w6, w7, pos);
|
||||
|
||||
switch_buffer_by_offset_8x4_carry_be_S (w0, w1, w2, w3, w4, w5, w6, w7, c0, c1, c2, c3, c4, c5, c6, c7, pos);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w4[0] |= w4[0];
|
||||
ctx->w4[1] |= w4[1];
|
||||
ctx->w4[2] |= w4[2];
|
||||
ctx->w4[3] |= w4[3];
|
||||
ctx->w5[0] |= w5[0];
|
||||
ctx->w5[1] |= w5[1];
|
||||
ctx->w5[2] |= w5[2];
|
||||
ctx->w5[3] |= w5[3];
|
||||
ctx->w6[0] |= w6[0];
|
||||
ctx->w6[1] |= w6[1];
|
||||
ctx->w6[2] |= w6[2];
|
||||
ctx->w6[3] |= w6[3];
|
||||
ctx->w7[0] |= w7[0];
|
||||
ctx->w7[1] |= w7[1];
|
||||
ctx->w7[2] |= w7[2];
|
||||
ctx->w7[3] |= w7[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 c0[4] = { 0 };
|
||||
u32 c1[4] = { 0 };
|
||||
u32 c2[4] = { 0 };
|
||||
u32 c3[4] = { 0 };
|
||||
u32 c4[4] = { 0 };
|
||||
u32 c5[4] = { 0 };
|
||||
u32 c6[4] = { 0 };
|
||||
u32 c7[4] = { 0 };
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w4[0] |= w4[0];
|
||||
ctx->w4[1] |= w4[1];
|
||||
ctx->w4[2] |= w4[2];
|
||||
ctx->w4[3] |= w4[3];
|
||||
ctx->w5[0] |= w5[0];
|
||||
ctx->w5[1] |= w5[1];
|
||||
ctx->w5[2] |= w5[2];
|
||||
ctx->w5[3] |= w5[3];
|
||||
ctx->w6[0] |= w6[0];
|
||||
ctx->w6[1] |= w6[1];
|
||||
ctx->w6[2] |= w6[2];
|
||||
ctx->w6[3] |= w6[3];
|
||||
ctx->w7[0] |= w7[0];
|
||||
ctx->w7[1] |= w7[1];
|
||||
ctx->w7[2] |= w7[2];
|
||||
ctx->w7[3] |= w7[3];
|
||||
switch_buffer_by_offset_8x4_carry_be_S (w0, w1, w2, w3, w4, w5, w6, w7, c0, c1, c2, c3, c4, c5, c6, c7, pos);
|
||||
|
||||
sha384_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->w4, ctx->w5, ctx->w6, ctx->w7, ctx->h);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w4[0] |= w4[0];
|
||||
ctx->w4[1] |= w4[1];
|
||||
ctx->w4[2] |= w4[2];
|
||||
ctx->w4[3] |= w4[3];
|
||||
ctx->w5[0] |= w5[0];
|
||||
ctx->w5[1] |= w5[1];
|
||||
ctx->w5[2] |= w5[2];
|
||||
ctx->w5[3] |= w5[3];
|
||||
ctx->w6[0] |= w6[0];
|
||||
ctx->w6[1] |= w6[1];
|
||||
ctx->w6[2] |= w6[2];
|
||||
ctx->w6[3] |= w6[3];
|
||||
ctx->w7[0] |= w7[0];
|
||||
ctx->w7[1] |= w7[1];
|
||||
ctx->w7[2] |= w7[2];
|
||||
ctx->w7[3] |= w7[3];
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
ctx->w4[0] = c4[0];
|
||||
ctx->w4[1] = c4[1];
|
||||
ctx->w4[2] = c4[2];
|
||||
ctx->w4[3] = c4[3];
|
||||
ctx->w5[0] = c5[0];
|
||||
ctx->w5[1] = c5[1];
|
||||
ctx->w5[2] = c5[2];
|
||||
ctx->w5[3] = c5[3];
|
||||
ctx->w6[0] = c6[0];
|
||||
ctx->w6[1] = c6[1];
|
||||
ctx->w6[2] = c6[2];
|
||||
ctx->w6[3] = c6[3];
|
||||
ctx->w7[0] = c7[0];
|
||||
ctx->w7[1] = c7[1];
|
||||
ctx->w7[2] = c7[2];
|
||||
ctx->w7[3] = c7[3];
|
||||
sha384_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->w4, ctx->w5, ctx->w6, ctx->w7, ctx->h);
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
ctx->w4[0] = c4[0];
|
||||
ctx->w4[1] = c4[1];
|
||||
ctx->w4[2] = c4[2];
|
||||
ctx->w4[3] = c4[3];
|
||||
ctx->w5[0] = c5[0];
|
||||
ctx->w5[1] = c5[1];
|
||||
ctx->w5[2] = c5[2];
|
||||
ctx->w5[3] = c5[3];
|
||||
ctx->w6[0] = c6[0];
|
||||
ctx->w6[1] = c6[1];
|
||||
ctx->w6[2] = c6[2];
|
||||
ctx->w6[3] = c6[3];
|
||||
ctx->w7[0] = c7[0];
|
||||
ctx->w7[1] = c7[1];
|
||||
ctx->w7[2] = c7[2];
|
||||
ctx->w7[3] = c7[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2016,131 +2090,205 @@ DECLSPEC void sha384_init_vector_from_scalar (sha384_ctx_vector_t *ctx, sha384_c
|
||||
|
||||
DECLSPEC void sha384_update_vector_128 (sha384_ctx_vector_t *ctx, u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u32x w4[4], u32x w5[4], u32x w6[4], u32x w7[4], const int len)
|
||||
{
|
||||
#ifdef IS_AMD
|
||||
const int pos = ctx->len & 127;
|
||||
#else
|
||||
const int pos = ctx->len & 127;
|
||||
#endif
|
||||
|
||||
ctx->len += len;
|
||||
|
||||
if ((pos + len) < 128)
|
||||
if (pos == 0)
|
||||
{
|
||||
switch_buffer_by_offset_8x4_be (w0, w1, w2, w3, w4, w5, w6, w7, pos);
|
||||
if (len < 128)
|
||||
{
|
||||
ctx->w0[0] = w0[0];
|
||||
ctx->w0[1] = w0[1];
|
||||
ctx->w0[2] = w0[2];
|
||||
ctx->w0[3] = w0[3];
|
||||
ctx->w1[0] = w1[0];
|
||||
ctx->w1[1] = w1[1];
|
||||
ctx->w1[2] = w1[2];
|
||||
ctx->w1[3] = w1[3];
|
||||
ctx->w2[0] = w2[0];
|
||||
ctx->w2[1] = w2[1];
|
||||
ctx->w2[2] = w2[2];
|
||||
ctx->w2[3] = w2[3];
|
||||
ctx->w3[0] = w3[0];
|
||||
ctx->w3[1] = w3[1];
|
||||
ctx->w3[2] = w3[2];
|
||||
ctx->w3[3] = w3[3];
|
||||
ctx->w4[0] = w4[0];
|
||||
ctx->w4[1] = w4[1];
|
||||
ctx->w4[2] = w4[2];
|
||||
ctx->w4[3] = w4[3];
|
||||
ctx->w5[0] = w5[0];
|
||||
ctx->w5[1] = w5[1];
|
||||
ctx->w5[2] = w5[2];
|
||||
ctx->w5[3] = w5[3];
|
||||
ctx->w6[0] = w6[0];
|
||||
ctx->w6[1] = w6[1];
|
||||
ctx->w6[2] = w6[2];
|
||||
ctx->w6[3] = w6[3];
|
||||
ctx->w7[0] = w7[0];
|
||||
ctx->w7[1] = w7[1];
|
||||
ctx->w7[2] = w7[2];
|
||||
ctx->w7[3] = w7[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
sha384_transform_vector (w0, w1, w2, w3, w4, w5, w6, w7, ctx->h);
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w4[0] |= w4[0];
|
||||
ctx->w4[1] |= w4[1];
|
||||
ctx->w4[2] |= w4[2];
|
||||
ctx->w4[3] |= w4[3];
|
||||
ctx->w5[0] |= w5[0];
|
||||
ctx->w5[1] |= w5[1];
|
||||
ctx->w5[2] |= w5[2];
|
||||
ctx->w5[3] |= w5[3];
|
||||
ctx->w6[0] |= w6[0];
|
||||
ctx->w6[1] |= w6[1];
|
||||
ctx->w6[2] |= w6[2];
|
||||
ctx->w6[3] |= w6[3];
|
||||
ctx->w7[0] |= w7[0];
|
||||
ctx->w7[1] |= w7[1];
|
||||
ctx->w7[2] |= w7[2];
|
||||
ctx->w7[3] |= w7[3];
|
||||
ctx->w0[0] = 0;
|
||||
ctx->w0[1] = 0;
|
||||
ctx->w0[2] = 0;
|
||||
ctx->w0[3] = 0;
|
||||
ctx->w1[0] = 0;
|
||||
ctx->w1[1] = 0;
|
||||
ctx->w1[2] = 0;
|
||||
ctx->w1[3] = 0;
|
||||
ctx->w2[0] = 0;
|
||||
ctx->w2[1] = 0;
|
||||
ctx->w2[2] = 0;
|
||||
ctx->w2[3] = 0;
|
||||
ctx->w3[0] = 0;
|
||||
ctx->w3[1] = 0;
|
||||
ctx->w3[2] = 0;
|
||||
ctx->w3[3] = 0;
|
||||
ctx->w4[0] = 0;
|
||||
ctx->w4[1] = 0;
|
||||
ctx->w4[2] = 0;
|
||||
ctx->w4[3] = 0;
|
||||
ctx->w5[0] = 0;
|
||||
ctx->w5[1] = 0;
|
||||
ctx->w5[2] = 0;
|
||||
ctx->w5[3] = 0;
|
||||
ctx->w6[0] = 0;
|
||||
ctx->w6[1] = 0;
|
||||
ctx->w6[2] = 0;
|
||||
ctx->w6[3] = 0;
|
||||
ctx->w7[0] = 0;
|
||||
ctx->w7[1] = 0;
|
||||
ctx->w7[2] = 0;
|
||||
ctx->w7[3] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32x c0[4] = { 0 };
|
||||
u32x c1[4] = { 0 };
|
||||
u32x c2[4] = { 0 };
|
||||
u32x c3[4] = { 0 };
|
||||
u32x c4[4] = { 0 };
|
||||
u32x c5[4] = { 0 };
|
||||
u32x c6[4] = { 0 };
|
||||
u32x c7[4] = { 0 };
|
||||
if ((pos + len) < 128)
|
||||
{
|
||||
switch_buffer_by_offset_8x4_be (w0, w1, w2, w3, w4, w5, w6, w7, pos);
|
||||
|
||||
switch_buffer_by_offset_8x4_carry_be (w0, w1, w2, w3, w4, w5, w6, w7, c0, c1, c2, c3, c4, c5, c6, c7, pos);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w4[0] |= w4[0];
|
||||
ctx->w4[1] |= w4[1];
|
||||
ctx->w4[2] |= w4[2];
|
||||
ctx->w4[3] |= w4[3];
|
||||
ctx->w5[0] |= w5[0];
|
||||
ctx->w5[1] |= w5[1];
|
||||
ctx->w5[2] |= w5[2];
|
||||
ctx->w5[3] |= w5[3];
|
||||
ctx->w6[0] |= w6[0];
|
||||
ctx->w6[1] |= w6[1];
|
||||
ctx->w6[2] |= w6[2];
|
||||
ctx->w6[3] |= w6[3];
|
||||
ctx->w7[0] |= w7[0];
|
||||
ctx->w7[1] |= w7[1];
|
||||
ctx->w7[2] |= w7[2];
|
||||
ctx->w7[3] |= w7[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
u32x c0[4] = { 0 };
|
||||
u32x c1[4] = { 0 };
|
||||
u32x c2[4] = { 0 };
|
||||
u32x c3[4] = { 0 };
|
||||
u32x c4[4] = { 0 };
|
||||
u32x c5[4] = { 0 };
|
||||
u32x c6[4] = { 0 };
|
||||
u32x c7[4] = { 0 };
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w4[0] |= w4[0];
|
||||
ctx->w4[1] |= w4[1];
|
||||
ctx->w4[2] |= w4[2];
|
||||
ctx->w4[3] |= w4[3];
|
||||
ctx->w5[0] |= w5[0];
|
||||
ctx->w5[1] |= w5[1];
|
||||
ctx->w5[2] |= w5[2];
|
||||
ctx->w5[3] |= w5[3];
|
||||
ctx->w6[0] |= w6[0];
|
||||
ctx->w6[1] |= w6[1];
|
||||
ctx->w6[2] |= w6[2];
|
||||
ctx->w6[3] |= w6[3];
|
||||
ctx->w7[0] |= w7[0];
|
||||
ctx->w7[1] |= w7[1];
|
||||
ctx->w7[2] |= w7[2];
|
||||
ctx->w7[3] |= w7[3];
|
||||
switch_buffer_by_offset_8x4_carry_be (w0, w1, w2, w3, w4, w5, w6, w7, c0, c1, c2, c3, c4, c5, c6, c7, pos);
|
||||
|
||||
sha384_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->w4, ctx->w5, ctx->w6, ctx->w7, ctx->h);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w4[0] |= w4[0];
|
||||
ctx->w4[1] |= w4[1];
|
||||
ctx->w4[2] |= w4[2];
|
||||
ctx->w4[3] |= w4[3];
|
||||
ctx->w5[0] |= w5[0];
|
||||
ctx->w5[1] |= w5[1];
|
||||
ctx->w5[2] |= w5[2];
|
||||
ctx->w5[3] |= w5[3];
|
||||
ctx->w6[0] |= w6[0];
|
||||
ctx->w6[1] |= w6[1];
|
||||
ctx->w6[2] |= w6[2];
|
||||
ctx->w6[3] |= w6[3];
|
||||
ctx->w7[0] |= w7[0];
|
||||
ctx->w7[1] |= w7[1];
|
||||
ctx->w7[2] |= w7[2];
|
||||
ctx->w7[3] |= w7[3];
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
ctx->w4[0] = c4[0];
|
||||
ctx->w4[1] = c4[1];
|
||||
ctx->w4[2] = c4[2];
|
||||
ctx->w4[3] = c4[3];
|
||||
ctx->w5[0] = c5[0];
|
||||
ctx->w5[1] = c5[1];
|
||||
ctx->w5[2] = c5[2];
|
||||
ctx->w5[3] = c5[3];
|
||||
ctx->w6[0] = c6[0];
|
||||
ctx->w6[1] = c6[1];
|
||||
ctx->w6[2] = c6[2];
|
||||
ctx->w6[3] = c6[3];
|
||||
ctx->w7[0] = c7[0];
|
||||
ctx->w7[1] = c7[1];
|
||||
ctx->w7[2] = c7[2];
|
||||
ctx->w7[3] = c7[3];
|
||||
sha384_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->w4, ctx->w5, ctx->w6, ctx->w7, ctx->h);
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
ctx->w4[0] = c4[0];
|
||||
ctx->w4[1] = c4[1];
|
||||
ctx->w4[2] = c4[2];
|
||||
ctx->w4[3] = c4[3];
|
||||
ctx->w5[0] = c5[0];
|
||||
ctx->w5[1] = c5[1];
|
||||
ctx->w5[2] = c5[2];
|
||||
ctx->w5[3] = c5[3];
|
||||
ctx->w6[0] = c6[0];
|
||||
ctx->w6[1] = c6[1];
|
||||
ctx->w6[2] = c6[2];
|
||||
ctx->w6[3] = c6[3];
|
||||
ctx->w7[0] = c7[0];
|
||||
ctx->w7[1] = c7[1];
|
||||
ctx->w7[2] = c7[2];
|
||||
ctx->w7[3] = c7[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,131 +185,205 @@ DECLSPEC void sha512_init (sha512_ctx_t *ctx)
|
||||
|
||||
DECLSPEC void sha512_update_128 (sha512_ctx_t *ctx, u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], u32 w4[4], u32 w5[4], u32 w6[4], u32 w7[4], const int len)
|
||||
{
|
||||
#ifdef IS_AMD
|
||||
const int pos = ctx->len & 127;
|
||||
#else
|
||||
const int pos = ctx->len & 127;
|
||||
#endif
|
||||
|
||||
ctx->len += len;
|
||||
|
||||
if ((pos + len) < 128)
|
||||
if (pos == 0)
|
||||
{
|
||||
switch_buffer_by_offset_8x4_be_S (w0, w1, w2, w3, w4, w5, w6, w7, pos);
|
||||
if (len < 128)
|
||||
{
|
||||
ctx->w0[0] = w0[0];
|
||||
ctx->w0[1] = w0[1];
|
||||
ctx->w0[2] = w0[2];
|
||||
ctx->w0[3] = w0[3];
|
||||
ctx->w1[0] = w1[0];
|
||||
ctx->w1[1] = w1[1];
|
||||
ctx->w1[2] = w1[2];
|
||||
ctx->w1[3] = w1[3];
|
||||
ctx->w2[0] = w2[0];
|
||||
ctx->w2[1] = w2[1];
|
||||
ctx->w2[2] = w2[2];
|
||||
ctx->w2[3] = w2[3];
|
||||
ctx->w3[0] = w3[0];
|
||||
ctx->w3[1] = w3[1];
|
||||
ctx->w3[2] = w3[2];
|
||||
ctx->w3[3] = w3[3];
|
||||
ctx->w4[0] = w4[0];
|
||||
ctx->w4[1] = w4[1];
|
||||
ctx->w4[2] = w4[2];
|
||||
ctx->w4[3] = w4[3];
|
||||
ctx->w5[0] = w5[0];
|
||||
ctx->w5[1] = w5[1];
|
||||
ctx->w5[2] = w5[2];
|
||||
ctx->w5[3] = w5[3];
|
||||
ctx->w6[0] = w6[0];
|
||||
ctx->w6[1] = w6[1];
|
||||
ctx->w6[2] = w6[2];
|
||||
ctx->w6[3] = w6[3];
|
||||
ctx->w7[0] = w7[0];
|
||||
ctx->w7[1] = w7[1];
|
||||
ctx->w7[2] = w7[2];
|
||||
ctx->w7[3] = w7[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
sha512_transform (w0, w1, w2, w3, w4, w5, w6, w7, ctx->h);
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w4[0] |= w4[0];
|
||||
ctx->w4[1] |= w4[1];
|
||||
ctx->w4[2] |= w4[2];
|
||||
ctx->w4[3] |= w4[3];
|
||||
ctx->w5[0] |= w5[0];
|
||||
ctx->w5[1] |= w5[1];
|
||||
ctx->w5[2] |= w5[2];
|
||||
ctx->w5[3] |= w5[3];
|
||||
ctx->w6[0] |= w6[0];
|
||||
ctx->w6[1] |= w6[1];
|
||||
ctx->w6[2] |= w6[2];
|
||||
ctx->w6[3] |= w6[3];
|
||||
ctx->w7[0] |= w7[0];
|
||||
ctx->w7[1] |= w7[1];
|
||||
ctx->w7[2] |= w7[2];
|
||||
ctx->w7[3] |= w7[3];
|
||||
ctx->w0[0] = 0;
|
||||
ctx->w0[1] = 0;
|
||||
ctx->w0[2] = 0;
|
||||
ctx->w0[3] = 0;
|
||||
ctx->w1[0] = 0;
|
||||
ctx->w1[1] = 0;
|
||||
ctx->w1[2] = 0;
|
||||
ctx->w1[3] = 0;
|
||||
ctx->w2[0] = 0;
|
||||
ctx->w2[1] = 0;
|
||||
ctx->w2[2] = 0;
|
||||
ctx->w2[3] = 0;
|
||||
ctx->w3[0] = 0;
|
||||
ctx->w3[1] = 0;
|
||||
ctx->w3[2] = 0;
|
||||
ctx->w3[3] = 0;
|
||||
ctx->w4[0] = 0;
|
||||
ctx->w4[1] = 0;
|
||||
ctx->w4[2] = 0;
|
||||
ctx->w4[3] = 0;
|
||||
ctx->w5[0] = 0;
|
||||
ctx->w5[1] = 0;
|
||||
ctx->w5[2] = 0;
|
||||
ctx->w5[3] = 0;
|
||||
ctx->w6[0] = 0;
|
||||
ctx->w6[1] = 0;
|
||||
ctx->w6[2] = 0;
|
||||
ctx->w6[3] = 0;
|
||||
ctx->w7[0] = 0;
|
||||
ctx->w7[1] = 0;
|
||||
ctx->w7[2] = 0;
|
||||
ctx->w7[3] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 c0[4] = { 0 };
|
||||
u32 c1[4] = { 0 };
|
||||
u32 c2[4] = { 0 };
|
||||
u32 c3[4] = { 0 };
|
||||
u32 c4[4] = { 0 };
|
||||
u32 c5[4] = { 0 };
|
||||
u32 c6[4] = { 0 };
|
||||
u32 c7[4] = { 0 };
|
||||
if ((pos + len) < 128)
|
||||
{
|
||||
switch_buffer_by_offset_8x4_be_S (w0, w1, w2, w3, w4, w5, w6, w7, pos);
|
||||
|
||||
switch_buffer_by_offset_8x4_carry_be_S (w0, w1, w2, w3, w4, w5, w6, w7, c0, c1, c2, c3, c4, c5, c6, c7, pos);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w4[0] |= w4[0];
|
||||
ctx->w4[1] |= w4[1];
|
||||
ctx->w4[2] |= w4[2];
|
||||
ctx->w4[3] |= w4[3];
|
||||
ctx->w5[0] |= w5[0];
|
||||
ctx->w5[1] |= w5[1];
|
||||
ctx->w5[2] |= w5[2];
|
||||
ctx->w5[3] |= w5[3];
|
||||
ctx->w6[0] |= w6[0];
|
||||
ctx->w6[1] |= w6[1];
|
||||
ctx->w6[2] |= w6[2];
|
||||
ctx->w6[3] |= w6[3];
|
||||
ctx->w7[0] |= w7[0];
|
||||
ctx->w7[1] |= w7[1];
|
||||
ctx->w7[2] |= w7[2];
|
||||
ctx->w7[3] |= w7[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 c0[4] = { 0 };
|
||||
u32 c1[4] = { 0 };
|
||||
u32 c2[4] = { 0 };
|
||||
u32 c3[4] = { 0 };
|
||||
u32 c4[4] = { 0 };
|
||||
u32 c5[4] = { 0 };
|
||||
u32 c6[4] = { 0 };
|
||||
u32 c7[4] = { 0 };
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w4[0] |= w4[0];
|
||||
ctx->w4[1] |= w4[1];
|
||||
ctx->w4[2] |= w4[2];
|
||||
ctx->w4[3] |= w4[3];
|
||||
ctx->w5[0] |= w5[0];
|
||||
ctx->w5[1] |= w5[1];
|
||||
ctx->w5[2] |= w5[2];
|
||||
ctx->w5[3] |= w5[3];
|
||||
ctx->w6[0] |= w6[0];
|
||||
ctx->w6[1] |= w6[1];
|
||||
ctx->w6[2] |= w6[2];
|
||||
ctx->w6[3] |= w6[3];
|
||||
ctx->w7[0] |= w7[0];
|
||||
ctx->w7[1] |= w7[1];
|
||||
ctx->w7[2] |= w7[2];
|
||||
ctx->w7[3] |= w7[3];
|
||||
switch_buffer_by_offset_8x4_carry_be_S (w0, w1, w2, w3, w4, w5, w6, w7, c0, c1, c2, c3, c4, c5, c6, c7, pos);
|
||||
|
||||
sha512_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->w4, ctx->w5, ctx->w6, ctx->w7, ctx->h);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w4[0] |= w4[0];
|
||||
ctx->w4[1] |= w4[1];
|
||||
ctx->w4[2] |= w4[2];
|
||||
ctx->w4[3] |= w4[3];
|
||||
ctx->w5[0] |= w5[0];
|
||||
ctx->w5[1] |= w5[1];
|
||||
ctx->w5[2] |= w5[2];
|
||||
ctx->w5[3] |= w5[3];
|
||||
ctx->w6[0] |= w6[0];
|
||||
ctx->w6[1] |= w6[1];
|
||||
ctx->w6[2] |= w6[2];
|
||||
ctx->w6[3] |= w6[3];
|
||||
ctx->w7[0] |= w7[0];
|
||||
ctx->w7[1] |= w7[1];
|
||||
ctx->w7[2] |= w7[2];
|
||||
ctx->w7[3] |= w7[3];
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
ctx->w4[0] = c4[0];
|
||||
ctx->w4[1] = c4[1];
|
||||
ctx->w4[2] = c4[2];
|
||||
ctx->w4[3] = c4[3];
|
||||
ctx->w5[0] = c5[0];
|
||||
ctx->w5[1] = c5[1];
|
||||
ctx->w5[2] = c5[2];
|
||||
ctx->w5[3] = c5[3];
|
||||
ctx->w6[0] = c6[0];
|
||||
ctx->w6[1] = c6[1];
|
||||
ctx->w6[2] = c6[2];
|
||||
ctx->w6[3] = c6[3];
|
||||
ctx->w7[0] = c7[0];
|
||||
ctx->w7[1] = c7[1];
|
||||
ctx->w7[2] = c7[2];
|
||||
ctx->w7[3] = c7[3];
|
||||
sha512_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->w4, ctx->w5, ctx->w6, ctx->w7, ctx->h);
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
ctx->w4[0] = c4[0];
|
||||
ctx->w4[1] = c4[1];
|
||||
ctx->w4[2] = c4[2];
|
||||
ctx->w4[3] = c4[3];
|
||||
ctx->w5[0] = c5[0];
|
||||
ctx->w5[1] = c5[1];
|
||||
ctx->w5[2] = c5[2];
|
||||
ctx->w5[3] = c5[3];
|
||||
ctx->w6[0] = c6[0];
|
||||
ctx->w6[1] = c6[1];
|
||||
ctx->w6[2] = c6[2];
|
||||
ctx->w6[3] = c6[3];
|
||||
ctx->w7[0] = c7[0];
|
||||
ctx->w7[1] = c7[1];
|
||||
ctx->w7[2] = c7[2];
|
||||
ctx->w7[3] = c7[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2016,131 +2090,205 @@ DECLSPEC void sha512_init_vector_from_scalar (sha512_ctx_vector_t *ctx, sha512_c
|
||||
|
||||
DECLSPEC void sha512_update_vector_128 (sha512_ctx_vector_t *ctx, u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u32x w4[4], u32x w5[4], u32x w6[4], u32x w7[4], const int len)
|
||||
{
|
||||
#ifdef IS_AMD
|
||||
const int pos = ctx->len & 127;
|
||||
#else
|
||||
const int pos = ctx->len & 127;
|
||||
#endif
|
||||
|
||||
ctx->len += len;
|
||||
|
||||
if ((pos + len) < 128)
|
||||
if (pos == 0)
|
||||
{
|
||||
switch_buffer_by_offset_8x4_be (w0, w1, w2, w3, w4, w5, w6, w7, pos);
|
||||
if (len < 128)
|
||||
{
|
||||
ctx->w0[0] = w0[0];
|
||||
ctx->w0[1] = w0[1];
|
||||
ctx->w0[2] = w0[2];
|
||||
ctx->w0[3] = w0[3];
|
||||
ctx->w1[0] = w1[0];
|
||||
ctx->w1[1] = w1[1];
|
||||
ctx->w1[2] = w1[2];
|
||||
ctx->w1[3] = w1[3];
|
||||
ctx->w2[0] = w2[0];
|
||||
ctx->w2[1] = w2[1];
|
||||
ctx->w2[2] = w2[2];
|
||||
ctx->w2[3] = w2[3];
|
||||
ctx->w3[0] = w3[0];
|
||||
ctx->w3[1] = w3[1];
|
||||
ctx->w3[2] = w3[2];
|
||||
ctx->w3[3] = w3[3];
|
||||
ctx->w4[0] = w4[0];
|
||||
ctx->w4[1] = w4[1];
|
||||
ctx->w4[2] = w4[2];
|
||||
ctx->w4[3] = w4[3];
|
||||
ctx->w5[0] = w5[0];
|
||||
ctx->w5[1] = w5[1];
|
||||
ctx->w5[2] = w5[2];
|
||||
ctx->w5[3] = w5[3];
|
||||
ctx->w6[0] = w6[0];
|
||||
ctx->w6[1] = w6[1];
|
||||
ctx->w6[2] = w6[2];
|
||||
ctx->w6[3] = w6[3];
|
||||
ctx->w7[0] = w7[0];
|
||||
ctx->w7[1] = w7[1];
|
||||
ctx->w7[2] = w7[2];
|
||||
ctx->w7[3] = w7[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
sha512_transform_vector (w0, w1, w2, w3, w4, w5, w6, w7, ctx->h);
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w4[0] |= w4[0];
|
||||
ctx->w4[1] |= w4[1];
|
||||
ctx->w4[2] |= w4[2];
|
||||
ctx->w4[3] |= w4[3];
|
||||
ctx->w5[0] |= w5[0];
|
||||
ctx->w5[1] |= w5[1];
|
||||
ctx->w5[2] |= w5[2];
|
||||
ctx->w5[3] |= w5[3];
|
||||
ctx->w6[0] |= w6[0];
|
||||
ctx->w6[1] |= w6[1];
|
||||
ctx->w6[2] |= w6[2];
|
||||
ctx->w6[3] |= w6[3];
|
||||
ctx->w7[0] |= w7[0];
|
||||
ctx->w7[1] |= w7[1];
|
||||
ctx->w7[2] |= w7[2];
|
||||
ctx->w7[3] |= w7[3];
|
||||
ctx->w0[0] = 0;
|
||||
ctx->w0[1] = 0;
|
||||
ctx->w0[2] = 0;
|
||||
ctx->w0[3] = 0;
|
||||
ctx->w1[0] = 0;
|
||||
ctx->w1[1] = 0;
|
||||
ctx->w1[2] = 0;
|
||||
ctx->w1[3] = 0;
|
||||
ctx->w2[0] = 0;
|
||||
ctx->w2[1] = 0;
|
||||
ctx->w2[2] = 0;
|
||||
ctx->w2[3] = 0;
|
||||
ctx->w3[0] = 0;
|
||||
ctx->w3[1] = 0;
|
||||
ctx->w3[2] = 0;
|
||||
ctx->w3[3] = 0;
|
||||
ctx->w4[0] = 0;
|
||||
ctx->w4[1] = 0;
|
||||
ctx->w4[2] = 0;
|
||||
ctx->w4[3] = 0;
|
||||
ctx->w5[0] = 0;
|
||||
ctx->w5[1] = 0;
|
||||
ctx->w5[2] = 0;
|
||||
ctx->w5[3] = 0;
|
||||
ctx->w6[0] = 0;
|
||||
ctx->w6[1] = 0;
|
||||
ctx->w6[2] = 0;
|
||||
ctx->w6[3] = 0;
|
||||
ctx->w7[0] = 0;
|
||||
ctx->w7[1] = 0;
|
||||
ctx->w7[2] = 0;
|
||||
ctx->w7[3] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32x c0[4] = { 0 };
|
||||
u32x c1[4] = { 0 };
|
||||
u32x c2[4] = { 0 };
|
||||
u32x c3[4] = { 0 };
|
||||
u32x c4[4] = { 0 };
|
||||
u32x c5[4] = { 0 };
|
||||
u32x c6[4] = { 0 };
|
||||
u32x c7[4] = { 0 };
|
||||
if ((pos + len) < 128)
|
||||
{
|
||||
switch_buffer_by_offset_8x4_be (w0, w1, w2, w3, w4, w5, w6, w7, pos);
|
||||
|
||||
switch_buffer_by_offset_8x4_carry_be (w0, w1, w2, w3, w4, w5, w6, w7, c0, c1, c2, c3, c4, c5, c6, c7, pos);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w4[0] |= w4[0];
|
||||
ctx->w4[1] |= w4[1];
|
||||
ctx->w4[2] |= w4[2];
|
||||
ctx->w4[3] |= w4[3];
|
||||
ctx->w5[0] |= w5[0];
|
||||
ctx->w5[1] |= w5[1];
|
||||
ctx->w5[2] |= w5[2];
|
||||
ctx->w5[3] |= w5[3];
|
||||
ctx->w6[0] |= w6[0];
|
||||
ctx->w6[1] |= w6[1];
|
||||
ctx->w6[2] |= w6[2];
|
||||
ctx->w6[3] |= w6[3];
|
||||
ctx->w7[0] |= w7[0];
|
||||
ctx->w7[1] |= w7[1];
|
||||
ctx->w7[2] |= w7[2];
|
||||
ctx->w7[3] |= w7[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
u32x c0[4] = { 0 };
|
||||
u32x c1[4] = { 0 };
|
||||
u32x c2[4] = { 0 };
|
||||
u32x c3[4] = { 0 };
|
||||
u32x c4[4] = { 0 };
|
||||
u32x c5[4] = { 0 };
|
||||
u32x c6[4] = { 0 };
|
||||
u32x c7[4] = { 0 };
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w4[0] |= w4[0];
|
||||
ctx->w4[1] |= w4[1];
|
||||
ctx->w4[2] |= w4[2];
|
||||
ctx->w4[3] |= w4[3];
|
||||
ctx->w5[0] |= w5[0];
|
||||
ctx->w5[1] |= w5[1];
|
||||
ctx->w5[2] |= w5[2];
|
||||
ctx->w5[3] |= w5[3];
|
||||
ctx->w6[0] |= w6[0];
|
||||
ctx->w6[1] |= w6[1];
|
||||
ctx->w6[2] |= w6[2];
|
||||
ctx->w6[3] |= w6[3];
|
||||
ctx->w7[0] |= w7[0];
|
||||
ctx->w7[1] |= w7[1];
|
||||
ctx->w7[2] |= w7[2];
|
||||
ctx->w7[3] |= w7[3];
|
||||
switch_buffer_by_offset_8x4_carry_be (w0, w1, w2, w3, w4, w5, w6, w7, c0, c1, c2, c3, c4, c5, c6, c7, pos);
|
||||
|
||||
sha512_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->w4, ctx->w5, ctx->w6, ctx->w7, ctx->h);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w4[0] |= w4[0];
|
||||
ctx->w4[1] |= w4[1];
|
||||
ctx->w4[2] |= w4[2];
|
||||
ctx->w4[3] |= w4[3];
|
||||
ctx->w5[0] |= w5[0];
|
||||
ctx->w5[1] |= w5[1];
|
||||
ctx->w5[2] |= w5[2];
|
||||
ctx->w5[3] |= w5[3];
|
||||
ctx->w6[0] |= w6[0];
|
||||
ctx->w6[1] |= w6[1];
|
||||
ctx->w6[2] |= w6[2];
|
||||
ctx->w6[3] |= w6[3];
|
||||
ctx->w7[0] |= w7[0];
|
||||
ctx->w7[1] |= w7[1];
|
||||
ctx->w7[2] |= w7[2];
|
||||
ctx->w7[3] |= w7[3];
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
ctx->w4[0] = c4[0];
|
||||
ctx->w4[1] = c4[1];
|
||||
ctx->w4[2] = c4[2];
|
||||
ctx->w4[3] = c4[3];
|
||||
ctx->w5[0] = c5[0];
|
||||
ctx->w5[1] = c5[1];
|
||||
ctx->w5[2] = c5[2];
|
||||
ctx->w5[3] = c5[3];
|
||||
ctx->w6[0] = c6[0];
|
||||
ctx->w6[1] = c6[1];
|
||||
ctx->w6[2] = c6[2];
|
||||
ctx->w6[3] = c6[3];
|
||||
ctx->w7[0] = c7[0];
|
||||
ctx->w7[1] = c7[1];
|
||||
ctx->w7[2] = c7[2];
|
||||
ctx->w7[3] = c7[3];
|
||||
sha512_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->w4, ctx->w5, ctx->w6, ctx->w7, ctx->h);
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
ctx->w4[0] = c4[0];
|
||||
ctx->w4[1] = c4[1];
|
||||
ctx->w4[2] = c4[2];
|
||||
ctx->w4[3] = c4[3];
|
||||
ctx->w5[0] = c5[0];
|
||||
ctx->w5[1] = c5[1];
|
||||
ctx->w5[2] = c5[2];
|
||||
ctx->w5[3] = c5[3];
|
||||
ctx->w6[0] = c6[0];
|
||||
ctx->w6[1] = c6[1];
|
||||
ctx->w6[2] = c6[2];
|
||||
ctx->w6[3] = c6[3];
|
||||
ctx->w7[0] = c7[0];
|
||||
ctx->w7[1] = c7[1];
|
||||
ctx->w7[2] = c7[2];
|
||||
ctx->w7[3] = c7[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1344,79 +1344,121 @@ DECLSPEC void whirlpool_init (whirlpool_ctx_t *ctx, SHM_TYPE u32 (*s_Ch)[256], S
|
||||
|
||||
DECLSPEC void whirlpool_update_64 (whirlpool_ctx_t *ctx, u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const int len)
|
||||
{
|
||||
#ifdef IS_AMD
|
||||
const int pos = ctx->len & 63;
|
||||
#else
|
||||
const int pos = ctx->len & 63;
|
||||
#endif
|
||||
|
||||
ctx->len += len;
|
||||
|
||||
if ((pos + len) < 64)
|
||||
if (pos == 0)
|
||||
{
|
||||
switch_buffer_by_offset_be_S (w0, w1, w2, w3, pos);
|
||||
if (len < 64)
|
||||
{
|
||||
ctx->w0[0] = w0[0];
|
||||
ctx->w0[1] = w0[1];
|
||||
ctx->w0[2] = w0[2];
|
||||
ctx->w0[3] = w0[3];
|
||||
ctx->w1[0] = w1[0];
|
||||
ctx->w1[1] = w1[1];
|
||||
ctx->w1[2] = w1[2];
|
||||
ctx->w1[3] = w1[3];
|
||||
ctx->w2[0] = w2[0];
|
||||
ctx->w2[1] = w2[1];
|
||||
ctx->w2[2] = w2[2];
|
||||
ctx->w2[3] = w2[3];
|
||||
ctx->w3[0] = w3[0];
|
||||
ctx->w3[1] = w3[1];
|
||||
ctx->w3[2] = w3[2];
|
||||
ctx->w3[3] = w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
whirlpool_transform (w0, w1, w2, w3, ctx->h, ctx->s_Ch, ctx->s_Cl);
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w0[0] = 0;
|
||||
ctx->w0[1] = 0;
|
||||
ctx->w0[2] = 0;
|
||||
ctx->w0[3] = 0;
|
||||
ctx->w1[0] = 0;
|
||||
ctx->w1[1] = 0;
|
||||
ctx->w1[2] = 0;
|
||||
ctx->w1[3] = 0;
|
||||
ctx->w2[0] = 0;
|
||||
ctx->w2[1] = 0;
|
||||
ctx->w2[2] = 0;
|
||||
ctx->w2[3] = 0;
|
||||
ctx->w3[0] = 0;
|
||||
ctx->w3[1] = 0;
|
||||
ctx->w3[2] = 0;
|
||||
ctx->w3[3] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 c0[4] = { 0 };
|
||||
u32 c1[4] = { 0 };
|
||||
u32 c2[4] = { 0 };
|
||||
u32 c3[4] = { 0 };
|
||||
if ((pos + len) < 64)
|
||||
{
|
||||
switch_buffer_by_offset_be_S (w0, w1, w2, w3, pos);
|
||||
|
||||
switch_buffer_by_offset_carry_be_S (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 c0[4] = { 0 };
|
||||
u32 c1[4] = { 0 };
|
||||
u32 c2[4] = { 0 };
|
||||
u32 c3[4] = { 0 };
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
switch_buffer_by_offset_carry_be_S (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
|
||||
whirlpool_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_Ch, ctx->s_Cl);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
whirlpool_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_Ch, ctx->s_Cl);
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2607,79 +2649,121 @@ DECLSPEC void whirlpool_init_vector_from_scalar (whirlpool_ctx_vector_t *ctx, wh
|
||||
|
||||
DECLSPEC void whirlpool_update_vector_64 (whirlpool_ctx_vector_t *ctx, u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], const int len)
|
||||
{
|
||||
#ifdef IS_AMD
|
||||
const int pos = ctx->len & 63;
|
||||
#else
|
||||
const int pos = ctx->len & 63;
|
||||
#endif
|
||||
|
||||
ctx->len += len;
|
||||
|
||||
if ((pos + len) < 64)
|
||||
if (pos == 0)
|
||||
{
|
||||
switch_buffer_by_offset_be (w0, w1, w2, w3, pos);
|
||||
if (len < 64)
|
||||
{
|
||||
ctx->w0[0] = w0[0];
|
||||
ctx->w0[1] = w0[1];
|
||||
ctx->w0[2] = w0[2];
|
||||
ctx->w0[3] = w0[3];
|
||||
ctx->w1[0] = w1[0];
|
||||
ctx->w1[1] = w1[1];
|
||||
ctx->w1[2] = w1[2];
|
||||
ctx->w1[3] = w1[3];
|
||||
ctx->w2[0] = w2[0];
|
||||
ctx->w2[1] = w2[1];
|
||||
ctx->w2[2] = w2[2];
|
||||
ctx->w2[3] = w2[3];
|
||||
ctx->w3[0] = w3[0];
|
||||
ctx->w3[1] = w3[1];
|
||||
ctx->w3[2] = w3[2];
|
||||
ctx->w3[3] = w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
whirlpool_transform_vector (w0, w1, w2, w3, ctx->h, ctx->s_Ch, ctx->s_Cl);
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
ctx->w0[0] = 0;
|
||||
ctx->w0[1] = 0;
|
||||
ctx->w0[2] = 0;
|
||||
ctx->w0[3] = 0;
|
||||
ctx->w1[0] = 0;
|
||||
ctx->w1[1] = 0;
|
||||
ctx->w1[2] = 0;
|
||||
ctx->w1[3] = 0;
|
||||
ctx->w2[0] = 0;
|
||||
ctx->w2[1] = 0;
|
||||
ctx->w2[2] = 0;
|
||||
ctx->w2[3] = 0;
|
||||
ctx->w3[0] = 0;
|
||||
ctx->w3[1] = 0;
|
||||
ctx->w3[2] = 0;
|
||||
ctx->w3[3] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32x c0[4] = { 0 };
|
||||
u32x c1[4] = { 0 };
|
||||
u32x c2[4] = { 0 };
|
||||
u32x c3[4] = { 0 };
|
||||
if ((pos + len) < 64)
|
||||
{
|
||||
switch_buffer_by_offset_be (w0, w1, w2, w3, pos);
|
||||
|
||||
switch_buffer_by_offset_carry_be (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
u32x c0[4] = { 0 };
|
||||
u32x c1[4] = { 0 };
|
||||
u32x c2[4] = { 0 };
|
||||
u32x c3[4] = { 0 };
|
||||
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
switch_buffer_by_offset_carry_be (w0, w1, w2, w3, c0, c1, c2, c3, pos);
|
||||
|
||||
whirlpool_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_Ch, ctx->s_Cl);
|
||||
ctx->w0[0] |= w0[0];
|
||||
ctx->w0[1] |= w0[1];
|
||||
ctx->w0[2] |= w0[2];
|
||||
ctx->w0[3] |= w0[3];
|
||||
ctx->w1[0] |= w1[0];
|
||||
ctx->w1[1] |= w1[1];
|
||||
ctx->w1[2] |= w1[2];
|
||||
ctx->w1[3] |= w1[3];
|
||||
ctx->w2[0] |= w2[0];
|
||||
ctx->w2[1] |= w2[1];
|
||||
ctx->w2[2] |= w2[2];
|
||||
ctx->w2[3] |= w2[3];
|
||||
ctx->w3[0] |= w3[0];
|
||||
ctx->w3[1] |= w3[1];
|
||||
ctx->w3[2] |= w3[2];
|
||||
ctx->w3[3] |= w3[3];
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
whirlpool_transform_vector (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h, ctx->s_Ch, ctx->s_Cl);
|
||||
|
||||
ctx->w0[0] = c0[0];
|
||||
ctx->w0[1] = c0[1];
|
||||
ctx->w0[2] = c0[2];
|
||||
ctx->w0[3] = c0[3];
|
||||
ctx->w1[0] = c1[0];
|
||||
ctx->w1[1] = c1[1];
|
||||
ctx->w1[2] = c1[2];
|
||||
ctx->w1[3] = c1[3];
|
||||
ctx->w2[0] = c2[0];
|
||||
ctx->w2[1] = c2[1];
|
||||
ctx->w2[2] = c2[2];
|
||||
ctx->w2[3] = c2[3];
|
||||
ctx->w3[0] = c3[0];
|
||||
ctx->w3[1] = c3[1];
|
||||
ctx->w3[2] = c3[2];
|
||||
ctx->w3[3] = c3[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user