added tests for setting Camellia key and IV
This commit is contained in:
parent
f65b0fc092
commit
b8b968d77f
@ -42,6 +42,20 @@ int CamelliaSetKey(Camellia* cam,
|
||||
(void)cam;
|
||||
(void)key;
|
||||
(void)dir;
|
||||
|
||||
if (cam == NULL) return BAD_FUNC_ARG;
|
||||
|
||||
switch (len) {
|
||||
case CAMELLIA_KEY_128_BITS:
|
||||
break;
|
||||
case CAMELLIA_KEY_192_BITS:
|
||||
break;
|
||||
case CAMELLIA_KEY_256_BITS:
|
||||
break;
|
||||
default:
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
cam->keySz = len;
|
||||
return CamelliaSetIV(cam, iv);
|
||||
}
|
||||
|
@ -1854,6 +1854,28 @@ int camellia_test(void)
|
||||
return testVectors[i].plainErrorCode;
|
||||
}
|
||||
|
||||
/* Setting the IV and checking it was actually set. */
|
||||
CamelliaSetIV(&enc, ivc);
|
||||
if (XMEMCMP(enc.reg, ivc, CAMELLIA_BLOCK_SIZE))
|
||||
return -1;
|
||||
|
||||
/* Setting the IV to NULL should leave the IV unchanged */
|
||||
if (CamelliaSetIV(&enc, NULL) != 0 ||
|
||||
XMEMCMP(enc.reg, ivc, CAMELLIA_BLOCK_SIZE))
|
||||
return -1;
|
||||
|
||||
/* First parameter should never be null */
|
||||
if (CamelliaSetIV(NULL, NULL) == 0)
|
||||
return -1;
|
||||
|
||||
/* First parameter should never be null, check it fails */
|
||||
if (CamelliaSetKey(NULL, k1, sizeof(k1), NULL, CAMELLIA_ENCRYPTION) == 0)
|
||||
return -1;
|
||||
|
||||
/* Key should have a size of 16, 24, or 32 */
|
||||
if (CamelliaSetKey(&enc, k1, 0, NULL, CAMELLIA_ENCRYPTION) == 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* HAVE_CAMELLIA */
|
||||
|
@ -35,7 +35,10 @@
|
||||
enum {
|
||||
CAMELLIA_ENCRYPTION = 0,
|
||||
CAMELLIA_DECRYPTION = 1,
|
||||
CAMELLIA_BLOCK_SIZE = 16
|
||||
CAMELLIA_BLOCK_SIZE = 16,
|
||||
CAMELLIA_KEY_128_BITS = 16,
|
||||
CAMELLIA_KEY_192_BITS = 24,
|
||||
CAMELLIA_KEY_256_BITS = 32
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user