fix for makefile and Panama cipher validation failure on armel http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=619856

pull/2/head
weidai 2011-04-25 17:42:11 +00:00
parent 4621a652a8
commit 0171970142
3 changed files with 18 additions and 19 deletions

View File

@ -12,6 +12,7 @@ MKDIR = mkdir
EGREP = egrep EGREP = egrep
UNAME = $(shell uname) UNAME = $(shell uname)
ISX86 = $(shell uname -m | $(EGREP) -c "i.86|x86|i86|amd64") ISX86 = $(shell uname -m | $(EGREP) -c "i.86|x86|i86|amd64")
IS_SUN_CC = $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: Sun")
# Default prefix for make install # Default prefix for make install
ifeq ($(PREFIX),) ifeq ($(PREFIX),)
@ -27,7 +28,6 @@ ifeq ($(ISX86),1)
GCC42_OR_LATER = $(shell $(CXX) -v 2>&1 | $(EGREP) -c "^gcc version (4.[2-9]|[5-9])") GCC42_OR_LATER = $(shell $(CXX) -v 2>&1 | $(EGREP) -c "^gcc version (4.[2-9]|[5-9])")
INTEL_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\)") INTEL_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\)")
ICC111_OR_LATER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\) ([2-9][0-9]|1[2-9]|11\.[1-9])") ICC111_OR_LATER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\) ([2-9][0-9]|1[2-9]|11\.[1-9])")
IS_SUN_CC = $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: Sun")
GAS210_OR_LATER = $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler version (2\.[1-9][0-9]|[3-9])") GAS210_OR_LATER = $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler version (2\.[1-9][0-9]|[3-9])")
GAS217_OR_LATER = $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler version (2\.1[7-9]|2\.[2-9]|[3-9])") GAS217_OR_LATER = $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler version (2\.1[7-9]|2\.[2-9]|[3-9])")
GAS219_OR_LATER = $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler version (2\.19|2\.[2-9]|[3-9])") GAS219_OR_LATER = $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler version (2\.19|2\.[2-9]|[3-9])")

View File

@ -313,7 +313,7 @@ void CRYPTOPP_NOINLINE Panama_SSE2_Pull(size_t count, word32 *state, word32 *z,
#ifndef CRYPTOPP_GENERATE_X64_MASM #ifndef CRYPTOPP_GENERATE_X64_MASM
template <class B> template <class B>
void Panama<B>::Iterate(size_t count, const word32 *p, word32 *z, const word32 *y) void Panama<B>::Iterate(size_t count, const word32 *p, byte *output, const byte *input, KeystreamOperation operation)
{ {
word32 bstart = m_state[17]; word32 bstart = m_state[17];
word32 *const aPtr = m_state; word32 *const aPtr = m_state;
@ -329,9 +329,6 @@ void Panama<B>::Iterate(size_t count, const word32 *p, word32 *z, const word32 *
// b: 0 4 | 1 5 | 2 6 | 3 7 // b: 0 4 | 1 5 | 2 6 | 3 7
#define b(i, j) b##i[(j)*2%8 + (j)/4] #define b(i, j) b##i[(j)*2%8 + (j)/4]
// output
#define OA(i) z[i] = ConditionalByteReverse(B::ToEnum(), a(i+9))
#define OX(i) z[i] = y[i] ^ ConditionalByteReverse(B::ToEnum(), a(i+9))
// buffer update // buffer update
#define US(i) {word32 t=b(0,i); b(0,i)=ConditionalByteReverse(B::ToEnum(), p[i])^t; b(25,(i+6)%8)^=t;} #define US(i) {word32 t=b(0,i); b(0,i)=ConditionalByteReverse(B::ToEnum(), p[i])^t; b(25,(i+6)%8)^=t;}
#define UL(i) {word32 t=b(0,i); b(0,i)=a(i+1)^t; b(25,(i+6)%8)^=t;} #define UL(i) {word32 t=b(0,i); b(0,i)=a(i+1)^t; b(25,(i+6)%8)^=t;}
@ -345,18 +342,20 @@ void Panama<B>::Iterate(size_t count, const word32 *p, word32 *z, const word32 *
while (count--) while (count--)
{ {
if (z) if (output)
{ {
if (y) #define PANAMA_OUTPUT(x) \
{ CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, B::ToEnum(), 0, a(0+9));\
OX(0); OX(1); OX(2); OX(3); OX(4); OX(5); OX(6); OX(7); CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, B::ToEnum(), 1, a(1+9));\
y += 8; CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, B::ToEnum(), 2, a(2+9));\
} CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, B::ToEnum(), 3, a(3+9));\
else CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, B::ToEnum(), 4, a(4+9));\
{ CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, B::ToEnum(), 5, a(5+9));\
OA(0); OA(1); OA(2); OA(3); OA(4); OA(5); OA(6); OA(7); CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, B::ToEnum(), 6, a(6+9));\
} CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, B::ToEnum(), 7, a(7+9));
z += 8;
typedef word32 WordType;
CRYPTOPP_KEYSTREAM_OUTPUT_SWITCH(PANAMA_OUTPUT, 4*8);
} }
word32 *const b16 = (word32 *)(bPtr+((bstart+16*32) & 31*32)); word32 *const b16 = (word32 *)(bPtr+((bstart+16*32) & 31*32));
@ -429,7 +428,7 @@ void PanamaHash<B>::TruncatedFinal(byte *hash, size_t size)
this->Iterate(32); // pull this->Iterate(32); // pull
FixedSizeSecBlock<word32, 8> buf; FixedSizeSecBlock<word32, 8> buf;
this->Iterate(1, NULL, buf, NULL); this->Iterate(1, NULL, buf.BytePtr(), NULL);
memcpy(hash, buf, size); memcpy(hash, buf, size);
@ -491,7 +490,7 @@ void PanamaCipherPolicy<B>::OperateKeystream(KeystreamOperation operation, byte
Panama_SSE2_Pull(iterationCount, this->m_state, (word32 *)output, (const word32 *)input); Panama_SSE2_Pull(iterationCount, this->m_state, (word32 *)output, (const word32 *)input);
else else
#endif #endif
this->Iterate(iterationCount, NULL, (word32 *)output, (const word32 *)input); this->Iterate(iterationCount, NULL, output, input, operation);
} }
template class Panama<BigEndian>; template class Panama<BigEndian>;

View File

@ -12,7 +12,7 @@ class CRYPTOPP_NO_VTABLE Panama
{ {
public: public:
void Reset(); void Reset();
void Iterate(size_t count, const word32 *p=NULL, word32 *z=NULL, const word32 *y=NULL); void Iterate(size_t count, const word32 *p=NULL, byte *output=NULL, const byte *input=NULL, KeystreamOperation operation=WRITE_KEYSTREAM);
protected: protected:
typedef word32 Stage[8]; typedef word32 Stage[8];