Remove untested, unnecessary big-endian SHA-1/SHA-256 optimizations.
Change-Id: I3939923d297b901719cb3fb4cff20e770f780c7a Reviewed-on: https://boringssl-review.googlesource.com/6441 Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
parent
38feb990a1
commit
9d94d5e4ae
@ -198,98 +198,54 @@ static void sha1_block_data_order(uint32_t *state, const uint8_t *data,
|
||||
E = state[4];
|
||||
|
||||
for (;;) {
|
||||
const union {
|
||||
long one;
|
||||
char little;
|
||||
} is_endian = {1};
|
||||
|
||||
if (!is_endian.little && ((uintptr_t)data % 4) == 0) {
|
||||
const uint32_t *W = (const uint32_t *)data;
|
||||
|
||||
X(0) = W[0];
|
||||
X(1) = W[1];
|
||||
BODY_00_15(0, A, B, C, D, E, T, X(0));
|
||||
X(2) = W[2];
|
||||
BODY_00_15(1, T, A, B, C, D, E, X(1));
|
||||
X(3) = W[3];
|
||||
BODY_00_15(2, E, T, A, B, C, D, X(2));
|
||||
X(4) = W[4];
|
||||
BODY_00_15(3, D, E, T, A, B, C, X(3));
|
||||
X(5) = W[5];
|
||||
BODY_00_15(4, C, D, E, T, A, B, X(4));
|
||||
X(6) = W[6];
|
||||
BODY_00_15(5, B, C, D, E, T, A, X(5));
|
||||
X(7) = W[7];
|
||||
BODY_00_15(6, A, B, C, D, E, T, X(6));
|
||||
X(8) = W[8];
|
||||
BODY_00_15(7, T, A, B, C, D, E, X(7));
|
||||
X(9) = W[9];
|
||||
BODY_00_15(8, E, T, A, B, C, D, X(8));
|
||||
X(10) = W[10];
|
||||
BODY_00_15(9, D, E, T, A, B, C, X(9));
|
||||
X(11) = W[11];
|
||||
BODY_00_15(10, C, D, E, T, A, B, X(10));
|
||||
X(12) = W[12];
|
||||
BODY_00_15(11, B, C, D, E, T, A, X(11));
|
||||
X(13) = W[13];
|
||||
BODY_00_15(12, A, B, C, D, E, T, X(12));
|
||||
X(14) = W[14];
|
||||
BODY_00_15(13, T, A, B, C, D, E, X(13));
|
||||
X(15) = W[15];
|
||||
BODY_00_15(14, E, T, A, B, C, D, X(14));
|
||||
BODY_00_15(15, D, E, T, A, B, C, X(15));
|
||||
|
||||
data += HASH_CBLOCK;
|
||||
} else {
|
||||
(void)HOST_c2l(data, l);
|
||||
X(0) = l;
|
||||
(void)HOST_c2l(data, l);
|
||||
X(1) = l;
|
||||
BODY_00_15(0, A, B, C, D, E, T, X(0));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(2) = l;
|
||||
BODY_00_15(1, T, A, B, C, D, E, X(1));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(3) = l;
|
||||
BODY_00_15(2, E, T, A, B, C, D, X(2));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(4) = l;
|
||||
BODY_00_15(3, D, E, T, A, B, C, X(3));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(5) = l;
|
||||
BODY_00_15(4, C, D, E, T, A, B, X(4));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(6) = l;
|
||||
BODY_00_15(5, B, C, D, E, T, A, X(5));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(7) = l;
|
||||
BODY_00_15(6, A, B, C, D, E, T, X(6));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(8) = l;
|
||||
BODY_00_15(7, T, A, B, C, D, E, X(7));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(9) = l;
|
||||
BODY_00_15(8, E, T, A, B, C, D, X(8));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(10) = l;
|
||||
BODY_00_15(9, D, E, T, A, B, C, X(9));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(11) = l;
|
||||
BODY_00_15(10, C, D, E, T, A, B, X(10));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(12) = l;
|
||||
BODY_00_15(11, B, C, D, E, T, A, X(11));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(13) = l;
|
||||
BODY_00_15(12, A, B, C, D, E, T, X(12));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(14) = l;
|
||||
BODY_00_15(13, T, A, B, C, D, E, X(13));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(15) = l;
|
||||
BODY_00_15(14, E, T, A, B, C, D, X(14));
|
||||
BODY_00_15(15, D, E, T, A, B, C, X(15));
|
||||
}
|
||||
(void)HOST_c2l(data, l);
|
||||
X(0) = l;
|
||||
(void)HOST_c2l(data, l);
|
||||
X(1) = l;
|
||||
BODY_00_15(0, A, B, C, D, E, T, X(0));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(2) = l;
|
||||
BODY_00_15(1, T, A, B, C, D, E, X(1));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(3) = l;
|
||||
BODY_00_15(2, E, T, A, B, C, D, X(2));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(4) = l;
|
||||
BODY_00_15(3, D, E, T, A, B, C, X(3));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(5) = l;
|
||||
BODY_00_15(4, C, D, E, T, A, B, X(4));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(6) = l;
|
||||
BODY_00_15(5, B, C, D, E, T, A, X(5));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(7) = l;
|
||||
BODY_00_15(6, A, B, C, D, E, T, X(6));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(8) = l;
|
||||
BODY_00_15(7, T, A, B, C, D, E, X(7));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(9) = l;
|
||||
BODY_00_15(8, E, T, A, B, C, D, X(8));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(10) = l;
|
||||
BODY_00_15(9, D, E, T, A, B, C, X(9));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(11) = l;
|
||||
BODY_00_15(10, C, D, E, T, A, B, X(10));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(12) = l;
|
||||
BODY_00_15(11, B, C, D, E, T, A, X(11));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(13) = l;
|
||||
BODY_00_15(12, A, B, C, D, E, T, X(12));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(14) = l;
|
||||
BODY_00_15(13, T, A, B, C, D, E, X(13));
|
||||
(void)HOST_c2l(data, l);
|
||||
X(15) = l;
|
||||
BODY_00_15(14, E, T, A, B, C, D, X(14));
|
||||
BODY_00_15(15, D, E, T, A, B, C, X(15));
|
||||
|
||||
BODY_16_19(16, C, D, E, T, A, B, X(0), X(0), X(2), X(8), X(13));
|
||||
BODY_16_19(17, B, C, D, E, T, A, X(1), X(1), X(3), X(9), X(14));
|
||||
|
@ -238,10 +238,6 @@ static void sha256_block_data_order(uint32_t *state, const uint8_t *data,
|
||||
uint32_t a, b, c, d, e, f, g, h, s0, s1, T1;
|
||||
uint32_t X[16];
|
||||
int i;
|
||||
const union {
|
||||
long one;
|
||||
char little;
|
||||
} is_endian = {1};
|
||||
|
||||
while (num--) {
|
||||
a = state[0];
|
||||
@ -253,95 +249,56 @@ static void sha256_block_data_order(uint32_t *state, const uint8_t *data,
|
||||
g = state[6];
|
||||
h = state[7];
|
||||
|
||||
if (!is_endian.little && ((uintptr_t)data % 4) == 0) {
|
||||
const uint32_t *W = (const uint32_t *)data;
|
||||
uint32_t l;
|
||||
|
||||
T1 = X[0] = W[0];
|
||||
ROUND_00_15(0, a, b, c, d, e, f, g, h);
|
||||
T1 = X[1] = W[1];
|
||||
ROUND_00_15(1, h, a, b, c, d, e, f, g);
|
||||
T1 = X[2] = W[2];
|
||||
ROUND_00_15(2, g, h, a, b, c, d, e, f);
|
||||
T1 = X[3] = W[3];
|
||||
ROUND_00_15(3, f, g, h, a, b, c, d, e);
|
||||
T1 = X[4] = W[4];
|
||||
ROUND_00_15(4, e, f, g, h, a, b, c, d);
|
||||
T1 = X[5] = W[5];
|
||||
ROUND_00_15(5, d, e, f, g, h, a, b, c);
|
||||
T1 = X[6] = W[6];
|
||||
ROUND_00_15(6, c, d, e, f, g, h, a, b);
|
||||
T1 = X[7] = W[7];
|
||||
ROUND_00_15(7, b, c, d, e, f, g, h, a);
|
||||
T1 = X[8] = W[8];
|
||||
ROUND_00_15(8, a, b, c, d, e, f, g, h);
|
||||
T1 = X[9] = W[9];
|
||||
ROUND_00_15(9, h, a, b, c, d, e, f, g);
|
||||
T1 = X[10] = W[10];
|
||||
ROUND_00_15(10, g, h, a, b, c, d, e, f);
|
||||
T1 = X[11] = W[11];
|
||||
ROUND_00_15(11, f, g, h, a, b, c, d, e);
|
||||
T1 = X[12] = W[12];
|
||||
ROUND_00_15(12, e, f, g, h, a, b, c, d);
|
||||
T1 = X[13] = W[13];
|
||||
ROUND_00_15(13, d, e, f, g, h, a, b, c);
|
||||
T1 = X[14] = W[14];
|
||||
ROUND_00_15(14, c, d, e, f, g, h, a, b);
|
||||
T1 = X[15] = W[15];
|
||||
ROUND_00_15(15, b, c, d, e, f, g, h, a);
|
||||
|
||||
data += HASH_CBLOCK;
|
||||
} else {
|
||||
uint32_t l;
|
||||
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[0] = l;
|
||||
ROUND_00_15(0, a, b, c, d, e, f, g, h);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[1] = l;
|
||||
ROUND_00_15(1, h, a, b, c, d, e, f, g);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[2] = l;
|
||||
ROUND_00_15(2, g, h, a, b, c, d, e, f);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[3] = l;
|
||||
ROUND_00_15(3, f, g, h, a, b, c, d, e);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[4] = l;
|
||||
ROUND_00_15(4, e, f, g, h, a, b, c, d);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[5] = l;
|
||||
ROUND_00_15(5, d, e, f, g, h, a, b, c);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[6] = l;
|
||||
ROUND_00_15(6, c, d, e, f, g, h, a, b);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[7] = l;
|
||||
ROUND_00_15(7, b, c, d, e, f, g, h, a);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[8] = l;
|
||||
ROUND_00_15(8, a, b, c, d, e, f, g, h);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[9] = l;
|
||||
ROUND_00_15(9, h, a, b, c, d, e, f, g);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[10] = l;
|
||||
ROUND_00_15(10, g, h, a, b, c, d, e, f);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[11] = l;
|
||||
ROUND_00_15(11, f, g, h, a, b, c, d, e);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[12] = l;
|
||||
ROUND_00_15(12, e, f, g, h, a, b, c, d);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[13] = l;
|
||||
ROUND_00_15(13, d, e, f, g, h, a, b, c);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[14] = l;
|
||||
ROUND_00_15(14, c, d, e, f, g, h, a, b);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[15] = l;
|
||||
ROUND_00_15(15, b, c, d, e, f, g, h, a);
|
||||
}
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[0] = l;
|
||||
ROUND_00_15(0, a, b, c, d, e, f, g, h);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[1] = l;
|
||||
ROUND_00_15(1, h, a, b, c, d, e, f, g);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[2] = l;
|
||||
ROUND_00_15(2, g, h, a, b, c, d, e, f);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[3] = l;
|
||||
ROUND_00_15(3, f, g, h, a, b, c, d, e);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[4] = l;
|
||||
ROUND_00_15(4, e, f, g, h, a, b, c, d);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[5] = l;
|
||||
ROUND_00_15(5, d, e, f, g, h, a, b, c);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[6] = l;
|
||||
ROUND_00_15(6, c, d, e, f, g, h, a, b);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[7] = l;
|
||||
ROUND_00_15(7, b, c, d, e, f, g, h, a);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[8] = l;
|
||||
ROUND_00_15(8, a, b, c, d, e, f, g, h);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[9] = l;
|
||||
ROUND_00_15(9, h, a, b, c, d, e, f, g);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[10] = l;
|
||||
ROUND_00_15(10, g, h, a, b, c, d, e, f);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[11] = l;
|
||||
ROUND_00_15(11, f, g, h, a, b, c, d, e);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[12] = l;
|
||||
ROUND_00_15(12, e, f, g, h, a, b, c, d);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[13] = l;
|
||||
ROUND_00_15(13, d, e, f, g, h, a, b, c);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[14] = l;
|
||||
ROUND_00_15(14, c, d, e, f, g, h, a, b);
|
||||
HOST_c2l(data, l);
|
||||
T1 = X[15] = l;
|
||||
ROUND_00_15(15, b, c, d, e, f, g, h, a);
|
||||
|
||||
for (i = 16; i < 64; i += 8) {
|
||||
ROUND_16_63(i + 0, a, b, c, d, e, f, g, h, X);
|
||||
|
Loading…
Reference in New Issue
Block a user