Fix a couple more signed/unsigned compares.

Different compilers find different problems.

Change-Id: I732611005ae1cbfcb4bc70c3f98af2c18b0a04da
This commit is contained in:
Adam Langley 2015-10-27 16:07:26 -07:00
parent 96c2a28171
commit 13f1dd497f
2 changed files with 9 additions and 10 deletions

View File

@ -356,7 +356,7 @@ static int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx,
goto err;
}
long iterations = ASN1_INTEGER_get(pbkdf2param->iter);
if (iterations <= 0 || iterations > UINT_MAX) {
if (iterations <= 0 || iterations > (long) UINT_MAX) {
OPENSSL_PUT_ERROR(PKCS8, PKCS8_R_BAD_ITERATION_COUNT);
goto err;
}

View File

@ -234,23 +234,22 @@ void RC4(RC4_KEY *key, size_t len, const uint8_t *in, uint8_t *out) {
void RC4_set_key(RC4_KEY *rc4key, unsigned len, const uint8_t *key) {
uint32_t tmp;
int id1, id2;
unsigned i, id1, id2;
uint32_t *d;
unsigned int i;
d = &rc4key->data[0];
rc4key->x = 0;
rc4key->y = 0;
id1 = id2 = 0;
#define SK_LOOP(d, n) \
{ \
tmp = d[(n)]; \
#define SK_LOOP(d, n) \
{ \
tmp = d[(n)]; \
id2 = (key[id1] + tmp + id2) & 0xff; \
if (++id1 == len) \
id1 = 0; \
d[(n)] = d[id2]; \
d[id2] = tmp; \
if (++id1 == len) \
id1 = 0; \
d[(n)] = d[id2]; \
d[id2] = tmp; \
}
for (i = 0; i < 256; i++) {