Upgrade libtomcrypt
This commit is contained in:
@@ -24,12 +24,12 @@ int lrw_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, s
|
||||
LTC_ARGCHK(ct != NULL);
|
||||
LTC_ARGCHK(lrw != NULL);
|
||||
|
||||
if ((err = cipher_is_valid(lrw->cipher)) != CRYPT_OK) {
|
||||
if ((err = cipher_is_valid(lrw->ecb.cipher)) != CRYPT_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (cipher_descriptor[lrw->cipher].accel_lrw_decrypt != NULL) {
|
||||
return cipher_descriptor[lrw->cipher].accel_lrw_decrypt(ct, pt, len, lrw->IV, lrw->tweak, &lrw->key);
|
||||
if (cipher_descriptor[lrw->ecb.cipher].accel_lrw_decrypt != NULL) {
|
||||
return cipher_descriptor[lrw->ecb.cipher].accel_lrw_decrypt(ct, pt, len, lrw->IV, lrw->tweak, &lrw->ecb.key);
|
||||
}
|
||||
|
||||
return lrw_process(ct, pt, len, LRW_DECRYPT, lrw);
|
||||
|
||||
@@ -16,16 +16,9 @@
|
||||
*/
|
||||
int lrw_done(symmetric_LRW *lrw)
|
||||
{
|
||||
int err;
|
||||
|
||||
LTC_ARGCHK(lrw != NULL);
|
||||
|
||||
if ((err = cipher_is_valid(lrw->cipher)) != CRYPT_OK) {
|
||||
return err;
|
||||
}
|
||||
cipher_descriptor[lrw->cipher].done(&lrw->key);
|
||||
|
||||
return CRYPT_OK;
|
||||
return ecb_done(&lrw->ecb);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,12 +24,12 @@ int lrw_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, s
|
||||
LTC_ARGCHK(ct != NULL);
|
||||
LTC_ARGCHK(lrw != NULL);
|
||||
|
||||
if ((err = cipher_is_valid(lrw->cipher)) != CRYPT_OK) {
|
||||
if ((err = cipher_is_valid(lrw->ecb.cipher)) != CRYPT_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (cipher_descriptor[lrw->cipher].accel_lrw_encrypt != NULL) {
|
||||
return cipher_descriptor[lrw->cipher].accel_lrw_encrypt(pt, ct, len, lrw->IV, lrw->tweak, &lrw->key);
|
||||
if (cipher_descriptor[lrw->ecb.cipher].accel_lrw_encrypt != NULL) {
|
||||
return cipher_descriptor[lrw->ecb.cipher].accel_lrw_encrypt(pt, ct, len, lrw->IV, lrw->tweak, &lrw->ecb.key);
|
||||
}
|
||||
|
||||
return lrw_process(pt, ct, len, LRW_ENCRYPT, lrw);
|
||||
|
||||
@@ -77,11 +77,11 @@ int lrw_process(const unsigned char *pt, unsigned char *ct, unsigned long len, i
|
||||
|
||||
/* send through cipher */
|
||||
if (mode == LRW_ENCRYPT) {
|
||||
if ((err = cipher_descriptor[lrw->cipher].ecb_encrypt(ct, ct, &lrw->key)) != CRYPT_OK) {
|
||||
if ((err = ecb_encrypt_block(ct, ct, &lrw->ecb)) != CRYPT_OK) {
|
||||
return err;
|
||||
}
|
||||
} else {
|
||||
if ((err = cipher_descriptor[lrw->cipher].ecb_decrypt(ct, ct, &lrw->key)) != CRYPT_OK) {
|
||||
if ((err = ecb_decrypt_block(ct, ct, &lrw->ecb)) != CRYPT_OK) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ int lrw_setiv(const unsigned char *IV, unsigned long len, symmetric_LRW *lrw)
|
||||
return CRYPT_INVALID_ARG;
|
||||
}
|
||||
|
||||
if ((err = cipher_is_valid(lrw->cipher)) != CRYPT_OK) {
|
||||
if ((err = cipher_is_valid(lrw->ecb.cipher)) != CRYPT_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ int lrw_setiv(const unsigned char *IV, unsigned long len, symmetric_LRW *lrw)
|
||||
XMEMCPY(lrw->IV, IV, 16);
|
||||
|
||||
/* check if we have to actually do work */
|
||||
if (cipher_descriptor[lrw->cipher].accel_lrw_encrypt != NULL && cipher_descriptor[lrw->cipher].accel_lrw_decrypt != NULL) {
|
||||
if (cipher_descriptor[lrw->ecb.cipher].accel_lrw_encrypt != NULL && cipher_descriptor[lrw->ecb.cipher].accel_lrw_decrypt != NULL) {
|
||||
/* we have accelerators, let's bail since they don't use lrw->pad anyways */
|
||||
return CRYPT_OK;
|
||||
}
|
||||
|
||||
@@ -53,10 +53,10 @@ int lrw_start( int cipher,
|
||||
}
|
||||
|
||||
/* schedule key */
|
||||
if ((err = cipher_descriptor[cipher].setup(key, keylen, num_rounds, &lrw->key)) != CRYPT_OK) {
|
||||
if ((err = ecb_start(cipher, key, keylen, num_rounds, &lrw->ecb)) != CRYPT_OK) {
|
||||
return err;
|
||||
}
|
||||
lrw->cipher = cipher;
|
||||
lrw->ecb.cipher = cipher;
|
||||
|
||||
/* copy the IV and tweak */
|
||||
XMEMCPY(lrw->tweak, tweak, 16);
|
||||
|
||||
@@ -73,7 +73,7 @@ int lrw_test(void)
|
||||
}
|
||||
}
|
||||
|
||||
for (x = 0; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) {
|
||||
for (x = 0; x < (int)LTC_ARRAY_SIZE(tests); x++) {
|
||||
/* schedule it */
|
||||
if ((err = lrw_start(idx, tests[x].IV, tests[x].key, 16, tests[x].tweak, 0, &lrw)) != CRYPT_OK) {
|
||||
return err;
|
||||
|
||||
Reference in New Issue
Block a user