-/* $OpenBSD: ripemd.c,v 1.6 2023/08/10 11:06:36 jsing Exp $ */
+/* $OpenBSD: ripemd.c,v 1.7 2023/08/10 12:27:35 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
}
#ifndef ripemd160_block_data_order
-#ifdef X
-#undef X
-#endif
void
ripemd160_block_data_order(RIPEMD160_CTX *ctx, const void *p, size_t num)
{
const unsigned char *data = p;
unsigned int A, B, C, D, E;
unsigned int a, b, c, d, e, l;
-#ifndef MD32_XARRAY
- /* See comment in crypto/sha/sha_locl.h for details. */
- unsigned int XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
- XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15;
-# define X(i) XX##i
-#else
- RIPEMD160_LONG XX[16];
-# define X(i) XX[i]
-#endif
+ unsigned int X0, X1, X2, X3, X4, X5, X6, X7,
+ X8, X9, X10, X11, X12, X13, X14, X15;
for (; num--; ) {
E = ctx->E;
HOST_c2l(data, l);
- X( 0) = l;
+ X0 = l;
HOST_c2l(data, l);
- X( 1) = l;
- RIP1(A, B, C, D, E, X(0), 11);
+ X1 = l;
+ RIP1(A, B, C, D, E, X0, 11);
HOST_c2l(data, l);
- X( 2) = l;
- RIP1(E, A, B, C, D, X(1), 14);
+ X2 = l;
+ RIP1(E, A, B, C, D, X1, 14);
HOST_c2l(data, l);
- X( 3) = l;
- RIP1(D, E, A, B, C, X(2), 15);
+ X3 = l;
+ RIP1(D, E, A, B, C, X2, 15);
HOST_c2l(data, l);
- X( 4) = l;
- RIP1(C, D, E, A, B, X(3), 12);
+ X4 = l;
+ RIP1(C, D, E, A, B, X3, 12);
HOST_c2l(data, l);
- X( 5) = l;
- RIP1(B, C, D, E, A, X(4), 5);
+ X5 = l;
+ RIP1(B, C, D, E, A, X4, 5);
HOST_c2l(data, l);
- X( 6) = l;
- RIP1(A, B, C, D, E, X(5), 8);
+ X6 = l;
+ RIP1(A, B, C, D, E, X5, 8);
HOST_c2l(data, l);
- X( 7) = l;
- RIP1(E, A, B, C, D, X(6), 7);
+ X7 = l;
+ RIP1(E, A, B, C, D, X6, 7);
HOST_c2l(data, l);
- X( 8) = l;
- RIP1(D, E, A, B, C, X(7), 9);
+ X8 = l;
+ RIP1(D, E, A, B, C, X7, 9);
HOST_c2l(data, l);
- X( 9) = l;
- RIP1(C, D, E, A, B, X(8), 11);
+ X9 = l;
+ RIP1(C, D, E, A, B, X8, 11);
HOST_c2l(data, l);
- X(10) = l;
- RIP1(B, C, D, E, A, X(9), 13);
+ X10 = l;
+ RIP1(B, C, D, E, A, X9, 13);
HOST_c2l(data, l);
- X(11) = l;
- RIP1(A, B, C, D, E, X(10), 14);
+ X11 = l;
+ RIP1(A, B, C, D, E, X10, 14);
HOST_c2l(data, l);
- X(12) = l;
- RIP1(E, A, B, C, D, X(11), 15);
+ X12 = l;
+ RIP1(E, A, B, C, D, X11, 15);
HOST_c2l(data, l);
- X(13) = l;
- RIP1(D, E, A, B, C, X(12), 6);
+ X13 = l;
+ RIP1(D, E, A, B, C, X12, 6);
HOST_c2l(data, l);
- X(14) = l;
- RIP1(C, D, E, A, B, X(13), 7);
+ X14 = l;
+ RIP1(C, D, E, A, B, X13, 7);
HOST_c2l(data, l);
- X(15) = l;
- RIP1(B, C, D, E, A, X(14), 9);
- RIP1(A, B, C, D, E, X(15), 8);
-
- RIP2(E, A, B, C, D, X(7), 7, KL1);
- RIP2(D, E, A, B, C, X(4), 6, KL1);
- RIP2(C, D, E, A, B, X(13), 8, KL1);
- RIP2(B, C, D, E, A, X(1), 13, KL1);
- RIP2(A, B, C, D, E, X(10), 11, KL1);
- RIP2(E, A, B, C, D, X(6), 9, KL1);
- RIP2(D, E, A, B, C, X(15), 7, KL1);
- RIP2(C, D, E, A, B, X(3), 15, KL1);
- RIP2(B, C, D, E, A, X(12), 7, KL1);
- RIP2(A, B, C, D, E, X(0), 12, KL1);
- RIP2(E, A, B, C, D, X(9), 15, KL1);
- RIP2(D, E, A, B, C, X(5), 9, KL1);
- RIP2(C, D, E, A, B, X(2), 11, KL1);
- RIP2(B, C, D, E, A, X(14), 7, KL1);
- RIP2(A, B, C, D, E, X(11), 13, KL1);
- RIP2(E, A, B, C, D, X(8), 12, KL1);
-
- RIP3(D, E, A, B, C, X(3), 11, KL2);
- RIP3(C, D, E, A, B, X(10), 13, KL2);
- RIP3(B, C, D, E, A, X(14), 6, KL2);
- RIP3(A, B, C, D, E, X(4), 7, KL2);
- RIP3(E, A, B, C, D, X(9), 14, KL2);
- RIP3(D, E, A, B, C, X(15), 9, KL2);
- RIP3(C, D, E, A, B, X(8), 13, KL2);
- RIP3(B, C, D, E, A, X(1), 15, KL2);
- RIP3(A, B, C, D, E, X(2), 14, KL2);
- RIP3(E, A, B, C, D, X(7), 8, KL2);
- RIP3(D, E, A, B, C, X(0), 13, KL2);
- RIP3(C, D, E, A, B, X(6), 6, KL2);
- RIP3(B, C, D, E, A, X(13), 5, KL2);
- RIP3(A, B, C, D, E, X(11), 12, KL2);
- RIP3(E, A, B, C, D, X(5), 7, KL2);
- RIP3(D, E, A, B, C, X(12), 5, KL2);
-
- RIP4(C, D, E, A, B, X(1), 11, KL3);
- RIP4(B, C, D, E, A, X(9), 12, KL3);
- RIP4(A, B, C, D, E, X(11), 14, KL3);
- RIP4(E, A, B, C, D, X(10), 15, KL3);
- RIP4(D, E, A, B, C, X(0), 14, KL3);
- RIP4(C, D, E, A, B, X(8), 15, KL3);
- RIP4(B, C, D, E, A, X(12), 9, KL3);
- RIP4(A, B, C, D, E, X(4), 8, KL3);
- RIP4(E, A, B, C, D, X(13), 9, KL3);
- RIP4(D, E, A, B, C, X(3), 14, KL3);
- RIP4(C, D, E, A, B, X(7), 5, KL3);
- RIP4(B, C, D, E, A, X(15), 6, KL3);
- RIP4(A, B, C, D, E, X(14), 8, KL3);
- RIP4(E, A, B, C, D, X(5), 6, KL3);
- RIP4(D, E, A, B, C, X(6), 5, KL3);
- RIP4(C, D, E, A, B, X(2), 12, KL3);
-
- RIP5(B, C, D, E, A, X(4), 9, KL4);
- RIP5(A, B, C, D, E, X(0), 15, KL4);
- RIP5(E, A, B, C, D, X(5), 5, KL4);
- RIP5(D, E, A, B, C, X(9), 11, KL4);
- RIP5(C, D, E, A, B, X(7), 6, KL4);
- RIP5(B, C, D, E, A, X(12), 8, KL4);
- RIP5(A, B, C, D, E, X(2), 13, KL4);
- RIP5(E, A, B, C, D, X(10), 12, KL4);
- RIP5(D, E, A, B, C, X(14), 5, KL4);
- RIP5(C, D, E, A, B, X(1), 12, KL4);
- RIP5(B, C, D, E, A, X(3), 13, KL4);
- RIP5(A, B, C, D, E, X(8), 14, KL4);
- RIP5(E, A, B, C, D, X(11), 11, KL4);
- RIP5(D, E, A, B, C, X(6), 8, KL4);
- RIP5(C, D, E, A, B, X(15), 5, KL4);
- RIP5(B, C, D, E, A, X(13), 6, KL4);
+ X15 = l;
+ RIP1(B, C, D, E, A, X14, 9);
+ RIP1(A, B, C, D, E, X15, 8);
+
+ RIP2(E, A, B, C, D, X7, 7, KL1);
+ RIP2(D, E, A, B, C, X4, 6, KL1);
+ RIP2(C, D, E, A, B, X13, 8, KL1);
+ RIP2(B, C, D, E, A, X1, 13, KL1);
+ RIP2(A, B, C, D, E, X10, 11, KL1);
+ RIP2(E, A, B, C, D, X6, 9, KL1);
+ RIP2(D, E, A, B, C, X15, 7, KL1);
+ RIP2(C, D, E, A, B, X3, 15, KL1);
+ RIP2(B, C, D, E, A, X12, 7, KL1);
+ RIP2(A, B, C, D, E, X0, 12, KL1);
+ RIP2(E, A, B, C, D, X9, 15, KL1);
+ RIP2(D, E, A, B, C, X5, 9, KL1);
+ RIP2(C, D, E, A, B, X2, 11, KL1);
+ RIP2(B, C, D, E, A, X14, 7, KL1);
+ RIP2(A, B, C, D, E, X11, 13, KL1);
+ RIP2(E, A, B, C, D, X8, 12, KL1);
+
+ RIP3(D, E, A, B, C, X3, 11, KL2);
+ RIP3(C, D, E, A, B, X10, 13, KL2);
+ RIP3(B, C, D, E, A, X14, 6, KL2);
+ RIP3(A, B, C, D, E, X4, 7, KL2);
+ RIP3(E, A, B, C, D, X9, 14, KL2);
+ RIP3(D, E, A, B, C, X15, 9, KL2);
+ RIP3(C, D, E, A, B, X8, 13, KL2);
+ RIP3(B, C, D, E, A, X1, 15, KL2);
+ RIP3(A, B, C, D, E, X2, 14, KL2);
+ RIP3(E, A, B, C, D, X7, 8, KL2);
+ RIP3(D, E, A, B, C, X0, 13, KL2);
+ RIP3(C, D, E, A, B, X6, 6, KL2);
+ RIP3(B, C, D, E, A, X13, 5, KL2);
+ RIP3(A, B, C, D, E, X11, 12, KL2);
+ RIP3(E, A, B, C, D, X5, 7, KL2);
+ RIP3(D, E, A, B, C, X12, 5, KL2);
+
+ RIP4(C, D, E, A, B, X1, 11, KL3);
+ RIP4(B, C, D, E, A, X9, 12, KL3);
+ RIP4(A, B, C, D, E, X11, 14, KL3);
+ RIP4(E, A, B, C, D, X10, 15, KL3);
+ RIP4(D, E, A, B, C, X0, 14, KL3);
+ RIP4(C, D, E, A, B, X8, 15, KL3);
+ RIP4(B, C, D, E, A, X12, 9, KL3);
+ RIP4(A, B, C, D, E, X4, 8, KL3);
+ RIP4(E, A, B, C, D, X13, 9, KL3);
+ RIP4(D, E, A, B, C, X3, 14, KL3);
+ RIP4(C, D, E, A, B, X7, 5, KL3);
+ RIP4(B, C, D, E, A, X15, 6, KL3);
+ RIP4(A, B, C, D, E, X14, 8, KL3);
+ RIP4(E, A, B, C, D, X5, 6, KL3);
+ RIP4(D, E, A, B, C, X6, 5, KL3);
+ RIP4(C, D, E, A, B, X2, 12, KL3);
+
+ RIP5(B, C, D, E, A, X4, 9, KL4);
+ RIP5(A, B, C, D, E, X0, 15, KL4);
+ RIP5(E, A, B, C, D, X5, 5, KL4);
+ RIP5(D, E, A, B, C, X9, 11, KL4);
+ RIP5(C, D, E, A, B, X7, 6, KL4);
+ RIP5(B, C, D, E, A, X12, 8, KL4);
+ RIP5(A, B, C, D, E, X2, 13, KL4);
+ RIP5(E, A, B, C, D, X10, 12, KL4);
+ RIP5(D, E, A, B, C, X14, 5, KL4);
+ RIP5(C, D, E, A, B, X1, 12, KL4);
+ RIP5(B, C, D, E, A, X3, 13, KL4);
+ RIP5(A, B, C, D, E, X8, 14, KL4);
+ RIP5(E, A, B, C, D, X11, 11, KL4);
+ RIP5(D, E, A, B, C, X6, 8, KL4);
+ RIP5(C, D, E, A, B, X15, 5, KL4);
+ RIP5(B, C, D, E, A, X13, 6, KL4);
a = A;
b = B;
D = ctx->D;
E = ctx->E;
- RIP5(A, B, C, D, E, X(5), 8, KR0);
- RIP5(E, A, B, C, D, X(14), 9, KR0);
- RIP5(D, E, A, B, C, X(7), 9, KR0);
- RIP5(C, D, E, A, B, X(0), 11, KR0);
- RIP5(B, C, D, E, A, X(9), 13, KR0);
- RIP5(A, B, C, D, E, X(2), 15, KR0);
- RIP5(E, A, B, C, D, X(11), 15, KR0);
- RIP5(D, E, A, B, C, X(4), 5, KR0);
- RIP5(C, D, E, A, B, X(13), 7, KR0);
- RIP5(B, C, D, E, A, X(6), 7, KR0);
- RIP5(A, B, C, D, E, X(15), 8, KR0);
- RIP5(E, A, B, C, D, X(8), 11, KR0);
- RIP5(D, E, A, B, C, X(1), 14, KR0);
- RIP5(C, D, E, A, B, X(10), 14, KR0);
- RIP5(B, C, D, E, A, X(3), 12, KR0);
- RIP5(A, B, C, D, E, X(12), 6, KR0);
-
- RIP4(E, A, B, C, D, X(6), 9, KR1);
- RIP4(D, E, A, B, C, X(11), 13, KR1);
- RIP4(C, D, E, A, B, X(3), 15, KR1);
- RIP4(B, C, D, E, A, X(7), 7, KR1);
- RIP4(A, B, C, D, E, X(0), 12, KR1);
- RIP4(E, A, B, C, D, X(13), 8, KR1);
- RIP4(D, E, A, B, C, X(5), 9, KR1);
- RIP4(C, D, E, A, B, X(10), 11, KR1);
- RIP4(B, C, D, E, A, X(14), 7, KR1);
- RIP4(A, B, C, D, E, X(15), 7, KR1);
- RIP4(E, A, B, C, D, X(8), 12, KR1);
- RIP4(D, E, A, B, C, X(12), 7, KR1);
- RIP4(C, D, E, A, B, X(4), 6, KR1);
- RIP4(B, C, D, E, A, X(9), 15, KR1);
- RIP4(A, B, C, D, E, X(1), 13, KR1);
- RIP4(E, A, B, C, D, X(2), 11, KR1);
-
- RIP3(D, E, A, B, C, X(15), 9, KR2);
- RIP3(C, D, E, A, B, X(5), 7, KR2);
- RIP3(B, C, D, E, A, X(1), 15, KR2);
- RIP3(A, B, C, D, E, X(3), 11, KR2);
- RIP3(E, A, B, C, D, X(7), 8, KR2);
- RIP3(D, E, A, B, C, X(14), 6, KR2);
- RIP3(C, D, E, A, B, X(6), 6, KR2);
- RIP3(B, C, D, E, A, X(9), 14, KR2);
- RIP3(A, B, C, D, E, X(11), 12, KR2);
- RIP3(E, A, B, C, D, X(8), 13, KR2);
- RIP3(D, E, A, B, C, X(12), 5, KR2);
- RIP3(C, D, E, A, B, X(2), 14, KR2);
- RIP3(B, C, D, E, A, X(10), 13, KR2);
- RIP3(A, B, C, D, E, X(0), 13, KR2);
- RIP3(E, A, B, C, D, X(4), 7, KR2);
- RIP3(D, E, A, B, C, X(13), 5, KR2);
-
- RIP2(C, D, E, A, B, X(8), 15, KR3);
- RIP2(B, C, D, E, A, X(6), 5, KR3);
- RIP2(A, B, C, D, E, X(4), 8, KR3);
- RIP2(E, A, B, C, D, X(1), 11, KR3);
- RIP2(D, E, A, B, C, X(3), 14, KR3);
- RIP2(C, D, E, A, B, X(11), 14, KR3);
- RIP2(B, C, D, E, A, X(15), 6, KR3);
- RIP2(A, B, C, D, E, X(0), 14, KR3);
- RIP2(E, A, B, C, D, X(5), 6, KR3);
- RIP2(D, E, A, B, C, X(12), 9, KR3);
- RIP2(C, D, E, A, B, X(2), 12, KR3);
- RIP2(B, C, D, E, A, X(13), 9, KR3);
- RIP2(A, B, C, D, E, X(9), 12, KR3);
- RIP2(E, A, B, C, D, X(7), 5, KR3);
- RIP2(D, E, A, B, C, X(10), 15, KR3);
- RIP2(C, D, E, A, B, X(14), 8, KR3);
-
- RIP1(B, C, D, E, A, X(12), 8);
- RIP1(A, B, C, D, E, X(15), 5);
- RIP1(E, A, B, C, D, X(10), 12);
- RIP1(D, E, A, B, C, X(4), 9);
- RIP1(C, D, E, A, B, X(1), 12);
- RIP1(B, C, D, E, A, X(5), 5);
- RIP1(A, B, C, D, E, X(8), 14);
- RIP1(E, A, B, C, D, X(7), 6);
- RIP1(D, E, A, B, C, X(6), 8);
- RIP1(C, D, E, A, B, X(2), 13);
- RIP1(B, C, D, E, A, X(13), 6);
- RIP1(A, B, C, D, E, X(14), 5);
- RIP1(E, A, B, C, D, X(0), 15);
- RIP1(D, E, A, B, C, X(3), 13);
- RIP1(C, D, E, A, B, X(9), 11);
- RIP1(B, C, D, E, A, X(11), 11);
+ RIP5(A, B, C, D, E, X5, 8, KR0);
+ RIP5(E, A, B, C, D, X14, 9, KR0);
+ RIP5(D, E, A, B, C, X7, 9, KR0);
+ RIP5(C, D, E, A, B, X0, 11, KR0);
+ RIP5(B, C, D, E, A, X9, 13, KR0);
+ RIP5(A, B, C, D, E, X2, 15, KR0);
+ RIP5(E, A, B, C, D, X11, 15, KR0);
+ RIP5(D, E, A, B, C, X4, 5, KR0);
+ RIP5(C, D, E, A, B, X13, 7, KR0);
+ RIP5(B, C, D, E, A, X6, 7, KR0);
+ RIP5(A, B, C, D, E, X15, 8, KR0);
+ RIP5(E, A, B, C, D, X8, 11, KR0);
+ RIP5(D, E, A, B, C, X1, 14, KR0);
+ RIP5(C, D, E, A, B, X10, 14, KR0);
+ RIP5(B, C, D, E, A, X3, 12, KR0);
+ RIP5(A, B, C, D, E, X12, 6, KR0);
+
+ RIP4(E, A, B, C, D, X6, 9, KR1);
+ RIP4(D, E, A, B, C, X11, 13, KR1);
+ RIP4(C, D, E, A, B, X3, 15, KR1);
+ RIP4(B, C, D, E, A, X7, 7, KR1);
+ RIP4(A, B, C, D, E, X0, 12, KR1);
+ RIP4(E, A, B, C, D, X13, 8, KR1);
+ RIP4(D, E, A, B, C, X5, 9, KR1);
+ RIP4(C, D, E, A, B, X10, 11, KR1);
+ RIP4(B, C, D, E, A, X14, 7, KR1);
+ RIP4(A, B, C, D, E, X15, 7, KR1);
+ RIP4(E, A, B, C, D, X8, 12, KR1);
+ RIP4(D, E, A, B, C, X12, 7, KR1);
+ RIP4(C, D, E, A, B, X4, 6, KR1);
+ RIP4(B, C, D, E, A, X9, 15, KR1);
+ RIP4(A, B, C, D, E, X1, 13, KR1);
+ RIP4(E, A, B, C, D, X2, 11, KR1);
+
+ RIP3(D, E, A, B, C, X15, 9, KR2);
+ RIP3(C, D, E, A, B, X5, 7, KR2);
+ RIP3(B, C, D, E, A, X1, 15, KR2);
+ RIP3(A, B, C, D, E, X3, 11, KR2);
+ RIP3(E, A, B, C, D, X7, 8, KR2);
+ RIP3(D, E, A, B, C, X14, 6, KR2);
+ RIP3(C, D, E, A, B, X6, 6, KR2);
+ RIP3(B, C, D, E, A, X9, 14, KR2);
+ RIP3(A, B, C, D, E, X11, 12, KR2);
+ RIP3(E, A, B, C, D, X8, 13, KR2);
+ RIP3(D, E, A, B, C, X12, 5, KR2);
+ RIP3(C, D, E, A, B, X2, 14, KR2);
+ RIP3(B, C, D, E, A, X10, 13, KR2);
+ RIP3(A, B, C, D, E, X0, 13, KR2);
+ RIP3(E, A, B, C, D, X4, 7, KR2);
+ RIP3(D, E, A, B, C, X13, 5, KR2);
+
+ RIP2(C, D, E, A, B, X8, 15, KR3);
+ RIP2(B, C, D, E, A, X6, 5, KR3);
+ RIP2(A, B, C, D, E, X4, 8, KR3);
+ RIP2(E, A, B, C, D, X1, 11, KR3);
+ RIP2(D, E, A, B, C, X3, 14, KR3);
+ RIP2(C, D, E, A, B, X11, 14, KR3);
+ RIP2(B, C, D, E, A, X15, 6, KR3);
+ RIP2(A, B, C, D, E, X0, 14, KR3);
+ RIP2(E, A, B, C, D, X5, 6, KR3);
+ RIP2(D, E, A, B, C, X12, 9, KR3);
+ RIP2(C, D, E, A, B, X2, 12, KR3);
+ RIP2(B, C, D, E, A, X13, 9, KR3);
+ RIP2(A, B, C, D, E, X9, 12, KR3);
+ RIP2(E, A, B, C, D, X7, 5, KR3);
+ RIP2(D, E, A, B, C, X10, 15, KR3);
+ RIP2(C, D, E, A, B, X14, 8, KR3);
+
+ RIP1(B, C, D, E, A, X12, 8);
+ RIP1(A, B, C, D, E, X15, 5);
+ RIP1(E, A, B, C, D, X10, 12);
+ RIP1(D, E, A, B, C, X4, 9);
+ RIP1(C, D, E, A, B, X1, 12);
+ RIP1(B, C, D, E, A, X5, 5);
+ RIP1(A, B, C, D, E, X8, 14);
+ RIP1(E, A, B, C, D, X7, 6);
+ RIP1(D, E, A, B, C, X6, 8);
+ RIP1(C, D, E, A, B, X2, 13);
+ RIP1(B, C, D, E, A, X13, 6);
+ RIP1(A, B, C, D, E, X14, 5);
+ RIP1(E, A, B, C, D, X0, 15);
+ RIP1(D, E, A, B, C, X3, 13);
+ RIP1(C, D, E, A, B, X9, 11);
+ RIP1(B, C, D, E, A, X11, 11);
D = ctx->B + c + D;
ctx->B = ctx->C + d + E;