|
Sirs, Referring
to the Crypto++ 5.0 implementation of "Portable::Multiply2" below (c.f.,
file "integer.cpp", I would prefer to use the
implementation which is commented-out as I am a little light on stack space.
However, this alternate implementation appears to be missing the
definition or declaration of symbol "N2". Where might I find this? On
a completely different note, is there or are there plans for a C implementation
of Crypto++? Regards, David #define A0 A #define A1 (A+N2) #define B0 B #define B1 (B+N2) #define T0 T #define T1 (T+N2) #define T2 (T+N) #define T3 (T+N+N2) #define R0 R #define R1 (R+N2) #define R2 (R+N) #define R3 (R+N+N2) void
Portable::Multiply2(word *C, const word *A, const word *B) { /* word s; dword d; if (A1 >= A0) if
(B0 >= B1) { s
= 0; d
= (dword)(A1-A0)*(B0-B1); } else { s
= (A1-A0); d
= (dword)s*(word)(B0-B1); } else if
(B0 > B1) { s
= (B0-B1); d
= (word)(A1-A0)*(dword)s; } else { s
= 0; d
= (dword)(A0-A1)*(B1-B0); } */ // this segment is the branchless
equivalent of above word D[4] = {A[1]-A[0], A[0]-A[1],
B[0]-B[1], B[1]-B[0]}; unsigned int ai = A[1] < A[0]; unsigned int bi = B[0] < B[1]; unsigned int di = ai & bi; dword d = (dword)D[di]*D[di+2]; D[1] = D[3] = 0; unsigned int si = ai + !bi; word s = D[si]; dword A0B0 = (dword)A[0]*B[0]; C[0] = LOW_WORD(A0B0); dword A1B1 = (dword)A[1]*B[1]; dword t = (dword) HIGH_WORD(A0B0) +
LOW_WORD(A0B0) + LOW_WORD(d) + LOW_WORD(A1B1); C[1] = LOW_WORD(t); t = A1B1 + HIGH_WORD(t) +
HIGH_WORD(A0B0) + HIGH_WORD(d) + HIGH_WORD(A1B1) - s; C[2] = LOW_WORD(t); C[3] = HIGH_WORD(t); } |
