commit
f60e045034
@ -38,7 +38,7 @@ int ccm_add_aad(ccm_state *ccm,
|
|||||||
if (ccm->x == 16) {
|
if (ccm->x == 16) {
|
||||||
/* full block so let's encrypt it */
|
/* full block so let's encrypt it */
|
||||||
if ((err = cipher_descriptor[ccm->cipher].ecb_encrypt(ccm->PAD, ccm->PAD, &ccm->K)) != CRYPT_OK) {
|
if ((err = cipher_descriptor[ccm->cipher].ecb_encrypt(ccm->PAD, ccm->PAD, &ccm->K)) != CRYPT_OK) {
|
||||||
return CRYPT_ERROR;
|
return err;
|
||||||
}
|
}
|
||||||
ccm->x = 0;
|
ccm->x = 0;
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ int ccm_add_aad(ccm_state *ccm,
|
|||||||
if (ccm->aadlen == ccm->current_aadlen) {
|
if (ccm->aadlen == ccm->current_aadlen) {
|
||||||
if (ccm->x != 0) {
|
if (ccm->x != 0) {
|
||||||
if ((err = cipher_descriptor[ccm->cipher].ecb_encrypt(ccm->PAD, ccm->PAD, &ccm->K)) != CRYPT_OK) {
|
if ((err = cipher_descriptor[ccm->cipher].ecb_encrypt(ccm->PAD, ccm->PAD, &ccm->K)) != CRYPT_OK) {
|
||||||
return CRYPT_ERROR;
|
return err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ccm->x = 0;
|
ccm->x = 0;
|
||||||
|
@ -45,14 +45,14 @@ const struct ltc_hash_descriptor whirlpool_desc =
|
|||||||
|
|
||||||
/* shortcut macro to perform three functions at once */
|
/* shortcut macro to perform three functions at once */
|
||||||
#define theta_pi_gamma(a, i) \
|
#define theta_pi_gamma(a, i) \
|
||||||
SB0(GB(a, i-0, 7)) ^ \
|
(SB0(GB(a, i-0, 7)) ^ \
|
||||||
SB1(GB(a, i-1, 6)) ^ \
|
SB1(GB(a, i-1, 6)) ^ \
|
||||||
SB2(GB(a, i-2, 5)) ^ \
|
SB2(GB(a, i-2, 5)) ^ \
|
||||||
SB3(GB(a, i-3, 4)) ^ \
|
SB3(GB(a, i-3, 4)) ^ \
|
||||||
SB4(GB(a, i-4, 3)) ^ \
|
SB4(GB(a, i-4, 3)) ^ \
|
||||||
SB5(GB(a, i-5, 2)) ^ \
|
SB5(GB(a, i-5, 2)) ^ \
|
||||||
SB6(GB(a, i-6, 1)) ^ \
|
SB6(GB(a, i-6, 1)) ^ \
|
||||||
SB7(GB(a, i-7, 0))
|
SB7(GB(a, i-7, 0)))
|
||||||
|
|
||||||
#ifdef LTC_CLEAN_STACK
|
#ifdef LTC_CLEAN_STACK
|
||||||
static int _whirlpool_compress(hash_state *md, unsigned char *buf)
|
static int _whirlpool_compress(hash_state *md, unsigned char *buf)
|
||||||
|
@ -267,7 +267,7 @@ static inline ulong32 ROR(ulong32 word, int i)
|
|||||||
#ifndef LTC_NO_ROLC
|
#ifndef LTC_NO_ROLC
|
||||||
|
|
||||||
#define ROLc(word,i) ({ \
|
#define ROLc(word,i) ({ \
|
||||||
ulong32 __ROLc_tmp = word; \
|
ulong32 __ROLc_tmp = (word); \
|
||||||
__asm__ ("roll %2, %0" : \
|
__asm__ ("roll %2, %0" : \
|
||||||
"=r" (__ROLc_tmp) : \
|
"=r" (__ROLc_tmp) : \
|
||||||
"0" (__ROLc_tmp), \
|
"0" (__ROLc_tmp), \
|
||||||
@ -275,7 +275,7 @@ static inline ulong32 ROR(ulong32 word, int i)
|
|||||||
__ROLc_tmp; \
|
__ROLc_tmp; \
|
||||||
})
|
})
|
||||||
#define RORc(word,i) ({ \
|
#define RORc(word,i) ({ \
|
||||||
ulong32 __RORc_tmp = word; \
|
ulong32 __RORc_tmp = (word); \
|
||||||
__asm__ ("rorl %2, %0" : \
|
__asm__ ("rorl %2, %0" : \
|
||||||
"=r" (__RORc_tmp) : \
|
"=r" (__RORc_tmp) : \
|
||||||
"0" (__RORc_tmp), \
|
"0" (__RORc_tmp), \
|
||||||
|
@ -126,8 +126,8 @@ static int compare(void *a, void *b)
|
|||||||
case MP_LT: return LTC_MP_LT;
|
case MP_LT: return LTC_MP_LT;
|
||||||
case MP_EQ: return LTC_MP_EQ;
|
case MP_EQ: return LTC_MP_EQ;
|
||||||
case MP_GT: return LTC_MP_GT;
|
case MP_GT: return LTC_MP_GT;
|
||||||
|
default: return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int compare_d(void *a, unsigned long b)
|
static int compare_d(void *a, unsigned long b)
|
||||||
@ -139,8 +139,8 @@ static int compare_d(void *a, unsigned long b)
|
|||||||
case MP_LT: return LTC_MP_LT;
|
case MP_LT: return LTC_MP_LT;
|
||||||
case MP_EQ: return LTC_MP_EQ;
|
case MP_EQ: return LTC_MP_EQ;
|
||||||
case MP_GT: return LTC_MP_GT;
|
case MP_GT: return LTC_MP_GT;
|
||||||
|
default: return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int count_bits(void *a)
|
static int count_bits(void *a)
|
||||||
|
@ -94,8 +94,8 @@ int xts_decrypt(const unsigned char *ct, unsigned long ptlen, unsigned char *pt,
|
|||||||
if (cipher_descriptor[xts->cipher].accel_xts_decrypt && lim > 0) {
|
if (cipher_descriptor[xts->cipher].accel_xts_decrypt && lim > 0) {
|
||||||
|
|
||||||
/* use accelerated decryption for whole blocks */
|
/* use accelerated decryption for whole blocks */
|
||||||
if ((err = cipher_descriptor[xts->cipher].accel_xts_decrypt(ct, pt, lim, tweak, &xts->key1, &xts->key2) !=
|
if ((err = cipher_descriptor[xts->cipher].accel_xts_decrypt(ct, pt, lim, tweak, &xts->key1, &xts->key2)) !=
|
||||||
CRYPT_OK)) {
|
CRYPT_OK) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
ct += lim * 16;
|
ct += lim * 16;
|
||||||
|
@ -96,8 +96,8 @@ int xts_encrypt(const unsigned char *pt, unsigned long ptlen, unsigned char *ct,
|
|||||||
if (cipher_descriptor[xts->cipher].accel_xts_encrypt && lim > 0) {
|
if (cipher_descriptor[xts->cipher].accel_xts_encrypt && lim > 0) {
|
||||||
|
|
||||||
/* use accelerated encryption for whole blocks */
|
/* use accelerated encryption for whole blocks */
|
||||||
if ((err = cipher_descriptor[xts->cipher].accel_xts_encrypt(pt, ct, lim, tweak, &xts->key1, &xts->key2) !=
|
if ((err = cipher_descriptor[xts->cipher].accel_xts_encrypt(pt, ct, lim, tweak, &xts->key1, &xts->key2)) !=
|
||||||
CRYPT_OK)) {
|
CRYPT_OK) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
ct += lim * 16;
|
ct += lim * 16;
|
||||||
|
@ -107,7 +107,7 @@ int ecc_import_ex(const unsigned char *in, unsigned long inlen, ecc_key *key, co
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* find out what type of key it is */
|
/* find out what type of key it is */
|
||||||
if ((err = der_decode_sequence_multi(in, inlen,
|
if ((err = der_decode_sequence_multi(in, inlen,
|
||||||
LTC_ASN1_BIT_STRING, 1UL, &flags,
|
LTC_ASN1_BIT_STRING, 1UL, &flags,
|
||||||
LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) {
|
LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) {
|
||||||
goto done;
|
goto done;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user