simplify padcheck compare

This commit is contained in:
toddouska
2015-06-05 09:42:10 -07:00
parent 670c325f29
commit 96a298018d

View File

@@ -6010,23 +6010,16 @@ static INLINE void CompressRounds(WOLFSSL* ssl, int rounds, const byte* dummy)
/* check all length bytes for the pad value, return 0 on success */ /* check all length bytes for the pad value, return 0 on success */
static int PadCheck(const byte* input, byte pad, int length) static int PadCheck(const byte* a, byte pad, int length)
{ {
int i; int i;
int good = 0; int compareSum = 0;
int bad = 0;
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
if (input[i] == pad) compareSum |= a[i] ^ pad;
good++;
else
bad++;
} }
if (good == length) return compareSum;
return 0;
else
return 0 - bad; /* pad check failed */
} }