Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
make rijndael_cipherInit() to take binary IV, not hex IV
  • Loading branch information
itojun committed Jul 24, 2003
1 parent f66b5d8 commit fb93a37
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions kame/sys/crypto/rijndael/rijndael-api-fst.c
@@ -1,5 +1,5 @@
/* $NetBSD: rijndael-api-fst.c,v 1.14 2003/07/16 05:08:08 itojun Exp $ */
/* $KAME: rijndael-api-fst.c,v 1.17 2003/07/16 05:09:38 itojun Exp $ */
/* $KAME: rijndael-api-fst.c,v 1.18 2003/07/24 15:10:30 itojun Exp $ */

/**
* rijndael-api-fst.c
Expand Down Expand Up @@ -94,24 +94,7 @@ int rijndael_cipherInit(cipherInstance *cipher, BYTE mode, char *IV) {
return BAD_CIPHER_MODE;
}
if (IV != NULL) {
int i;
for (i = 0; i < RIJNDAEL_MAX_IV_SIZE; i++) {
int t, j;

t = IV[2*i];
if ((t >= '0') && (t <= '9')) j = (t - '0') << 4;
else if ((t >= 'a') && (t <= 'f')) j = (t - 'a' + 10) << 4;
else if ((t >= 'A') && (t <= 'F')) j = (t - 'A' + 10) << 4;
else return BAD_CIPHER_INSTANCE;

t = IV[2*i+1];
if ((t >= '0') && (t <= '9')) j ^= (t - '0');
else if ((t >= 'a') && (t <= 'f')) j ^= (t - 'a' + 10);
else if ((t >= 'A') && (t <= 'F')) j ^= (t - 'A' + 10);
else return BAD_CIPHER_INSTANCE;

cipher->IV[i] = (u_int8_t)j;
}
memcpy(cipher->IV, IV, RIJNDAEL_MAX_IV_SIZE);
} else {
memset(cipher->IV, 0, RIJNDAEL_MAX_IV_SIZE);
}
Expand Down

0 comments on commit fb93a37

Please sign in to comment.