forked from wolfSSL/wolfssl
change word type to cyassl_word to prevent conflicts with some toolchains
This commit is contained in:
@ -940,7 +940,7 @@ static void AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* check alignment, decrypt doesn't need alignment */
|
/* check alignment, decrypt doesn't need alignment */
|
||||||
if ((word)inBlock % 16) {
|
if ((cyassl_word)inBlock % 16) {
|
||||||
#ifndef NO_CYASSL_ALLOC_ALIGN
|
#ifndef NO_CYASSL_ALLOC_ALIGN
|
||||||
byte* tmp = (byte*)XMALLOC(AES_BLOCK_SIZE, NULL,
|
byte* tmp = (byte*)XMALLOC(AES_BLOCK_SIZE, NULL,
|
||||||
DYNAMIC_TYPE_TMP_BUFFER);
|
DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
@ -1968,7 +1968,7 @@ int AesSetIV(Aes* aes, const byte* iv)
|
|||||||
iv = (byte*)aes->reg;
|
iv = (byte*)aes->reg;
|
||||||
enc_key = (byte*)aes->key;
|
enc_key = (byte*)aes->key;
|
||||||
|
|
||||||
if ((word)out % CYASSL_MMCAU_ALIGNMENT) {
|
if ((cyassl_word)out % CYASSL_MMCAU_ALIGNMENT) {
|
||||||
CYASSL_MSG("Bad cau_aes_encrypt alignment");
|
CYASSL_MSG("Bad cau_aes_encrypt alignment");
|
||||||
return BAD_ALIGN_E;
|
return BAD_ALIGN_E;
|
||||||
}
|
}
|
||||||
@ -2005,7 +2005,7 @@ int AesSetIV(Aes* aes, const byte* iv)
|
|||||||
iv = (byte*)aes->reg;
|
iv = (byte*)aes->reg;
|
||||||
dec_key = (byte*)aes->key;
|
dec_key = (byte*)aes->key;
|
||||||
|
|
||||||
if ((word)out % CYASSL_MMCAU_ALIGNMENT) {
|
if ((cyassl_word)out % CYASSL_MMCAU_ALIGNMENT) {
|
||||||
CYASSL_MSG("Bad cau_aes_decrypt alignment");
|
CYASSL_MSG("Bad cau_aes_decrypt alignment");
|
||||||
return BAD_ALIGN_E;
|
return BAD_ALIGN_E;
|
||||||
}
|
}
|
||||||
@ -2163,7 +2163,7 @@ int AesSetIV(Aes* aes, const byte* iv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* check alignment, decrypt doesn't need alignment */
|
/* check alignment, decrypt doesn't need alignment */
|
||||||
if ((word)in % 16) {
|
if ((cyassl_word)in % 16) {
|
||||||
#ifndef NO_CYASSL_ALLOC_ALIGN
|
#ifndef NO_CYASSL_ALLOC_ALIGN
|
||||||
byte* tmp = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
byte* tmp = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
CYASSL_MSG("AES-CBC encrypt with bad alignment");
|
CYASSL_MSG("AES-CBC encrypt with bad alignment");
|
||||||
@ -3643,7 +3643,7 @@ static int AesCaviumSetKey(Aes* aes, const byte* key, word32 length,
|
|||||||
static int AesCaviumCbcEncrypt(Aes* aes, byte* out, const byte* in,
|
static int AesCaviumCbcEncrypt(Aes* aes, byte* out, const byte* in,
|
||||||
word32 length)
|
word32 length)
|
||||||
{
|
{
|
||||||
word offset = 0;
|
cyassl_word offset = 0;
|
||||||
word32 requestId;
|
word32 requestId;
|
||||||
|
|
||||||
while (length > CYASSL_MAX_16BIT) {
|
while (length > CYASSL_MAX_16BIT) {
|
||||||
@ -3677,7 +3677,7 @@ static int AesCaviumCbcDecrypt(Aes* aes, byte* out, const byte* in,
|
|||||||
word32 length)
|
word32 length)
|
||||||
{
|
{
|
||||||
word32 requestId;
|
word32 requestId;
|
||||||
word offset = 0;
|
cyassl_word offset = 0;
|
||||||
|
|
||||||
while (length > CYASSL_MAX_16BIT) {
|
while (length > CYASSL_MAX_16BIT) {
|
||||||
word16 slen = (word16)CYASSL_MAX_16BIT;
|
word16 slen = (word16)CYASSL_MAX_16BIT;
|
||||||
|
@ -150,7 +150,7 @@ static void Arc4CaviumSetKey(Arc4* arc4, const byte* key, word32 length)
|
|||||||
static void Arc4CaviumProcess(Arc4* arc4, byte* out, const byte* in,
|
static void Arc4CaviumProcess(Arc4* arc4, byte* out, const byte* in,
|
||||||
word32 length)
|
word32 length)
|
||||||
{
|
{
|
||||||
word offset = 0;
|
cyassl_word offset = 0;
|
||||||
word32 requestId;
|
word32 requestId;
|
||||||
|
|
||||||
while (length > CYASSL_MAX_16BIT) {
|
while (length > CYASSL_MAX_16BIT) {
|
||||||
|
@ -284,7 +284,7 @@ int blake2b_update( blake2b_state *S, const byte *in, word64 inlen )
|
|||||||
|
|
||||||
if( inlen > fill )
|
if( inlen > fill )
|
||||||
{
|
{
|
||||||
XMEMCPY( S->buf + left, in, (word)fill ); /* Fill buffer */
|
XMEMCPY( S->buf + left, in, (cyassl_word)fill ); /* Fill buffer */
|
||||||
S->buflen += fill;
|
S->buflen += fill;
|
||||||
blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES );
|
blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES );
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ int blake2b_update( blake2b_state *S, const byte *in, word64 inlen )
|
|||||||
}
|
}
|
||||||
else /* inlen <= fill */
|
else /* inlen <= fill */
|
||||||
{
|
{
|
||||||
XMEMCPY( S->buf + left, in, (word)inlen );
|
XMEMCPY( S->buf + left, in, (cyassl_word)inlen );
|
||||||
S->buflen += inlen; /* Be lazy, do not compress */
|
S->buflen += inlen; /* Be lazy, do not compress */
|
||||||
in += inlen;
|
in += inlen;
|
||||||
inlen -= inlen;
|
inlen -= inlen;
|
||||||
@ -321,12 +321,12 @@ int blake2b_final( blake2b_state *S, byte *out, byte outlen )
|
|||||||
if ( blake2b_compress( S, S->buf ) < 0 ) return -1;
|
if ( blake2b_compress( S, S->buf ) < 0 ) return -1;
|
||||||
|
|
||||||
S->buflen -= BLAKE2B_BLOCKBYTES;
|
S->buflen -= BLAKE2B_BLOCKBYTES;
|
||||||
XMEMCPY( S->buf, S->buf + BLAKE2B_BLOCKBYTES, (word)S->buflen );
|
XMEMCPY( S->buf, S->buf + BLAKE2B_BLOCKBYTES, (cyassl_word)S->buflen );
|
||||||
}
|
}
|
||||||
|
|
||||||
blake2b_increment_counter( S, S->buflen );
|
blake2b_increment_counter( S, S->buflen );
|
||||||
blake2b_set_lastblock( S );
|
blake2b_set_lastblock( S );
|
||||||
XMEMSET( S->buf + S->buflen, 0, (word)(2 * BLAKE2B_BLOCKBYTES - S->buflen) );
|
XMEMSET( S->buf + S->buflen, 0, (cyassl_word)(2 * BLAKE2B_BLOCKBYTES - S->buflen) );
|
||||||
/* Padding */
|
/* Padding */
|
||||||
if ( blake2b_compress( S, S->buf ) < 0 ) return -1;
|
if ( blake2b_compress( S, S->buf ) < 0 ) return -1;
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ int Chacha_SetKey(ChaCha* ctx, const byte* key, word32 keySz)
|
|||||||
|
|
||||||
#ifdef XSTREAM_ALIGN
|
#ifdef XSTREAM_ALIGN
|
||||||
word32 alignKey[keySz / 4];
|
word32 alignKey[keySz / 4];
|
||||||
if ((word)key % 4) {
|
if ((cyassl_word)key % 4) {
|
||||||
CYASSL_MSG("ChachaSetKey unaligned key");
|
CYASSL_MSG("ChachaSetKey unaligned key");
|
||||||
XMEMCPY(alignKey, key, sizeof(alignKey));
|
XMEMCPY(alignKey, key, sizeof(alignKey));
|
||||||
k = (byte*)alignKey;
|
k = (byte*)alignKey;
|
||||||
|
@ -572,7 +572,7 @@ int Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir)
|
|||||||
|
|
||||||
iv = (byte*)des->reg;
|
iv = (byte*)des->reg;
|
||||||
|
|
||||||
if ((word)out % CYASSL_MMCAU_ALIGNMENT) {
|
if ((cyassl_word)out % CYASSL_MMCAU_ALIGNMENT) {
|
||||||
CYASSL_MSG("Bad cau_des_encrypt alignment");
|
CYASSL_MSG("Bad cau_des_encrypt alignment");
|
||||||
return BAD_ALIGN_E;
|
return BAD_ALIGN_E;
|
||||||
}
|
}
|
||||||
@ -607,7 +607,7 @@ int Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir)
|
|||||||
|
|
||||||
iv = (byte*)des->reg;
|
iv = (byte*)des->reg;
|
||||||
|
|
||||||
if ((word)out % CYASSL_MMCAU_ALIGNMENT) {
|
if ((cyassl_word)out % CYASSL_MMCAU_ALIGNMENT) {
|
||||||
CYASSL_MSG("Bad cau_des_decrypt alignment");
|
CYASSL_MSG("Bad cau_des_decrypt alignment");
|
||||||
return BAD_ALIGN_E;
|
return BAD_ALIGN_E;
|
||||||
}
|
}
|
||||||
@ -643,7 +643,7 @@ int Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir)
|
|||||||
|
|
||||||
iv = (byte*)des->reg;
|
iv = (byte*)des->reg;
|
||||||
|
|
||||||
if ((word)out % CYASSL_MMCAU_ALIGNMENT) {
|
if ((cyassl_word)out % CYASSL_MMCAU_ALIGNMENT) {
|
||||||
CYASSL_MSG("Bad 3ede cau_des_encrypt alignment");
|
CYASSL_MSG("Bad 3ede cau_des_encrypt alignment");
|
||||||
return BAD_ALIGN_E;
|
return BAD_ALIGN_E;
|
||||||
}
|
}
|
||||||
@ -681,7 +681,7 @@ int Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir)
|
|||||||
|
|
||||||
iv = (byte*)des->reg;
|
iv = (byte*)des->reg;
|
||||||
|
|
||||||
if ((word)out % CYASSL_MMCAU_ALIGNMENT) {
|
if ((cyassl_word)out % CYASSL_MMCAU_ALIGNMENT) {
|
||||||
CYASSL_MSG("Bad 3ede cau_des_decrypt alignment");
|
CYASSL_MSG("Bad 3ede cau_des_decrypt alignment");
|
||||||
return BAD_ALIGN_E;
|
return BAD_ALIGN_E;
|
||||||
}
|
}
|
||||||
@ -811,7 +811,8 @@ int Des3_SetIV(Des3* des, const byte* iv);
|
|||||||
if(dir == PIC32_ENCRYPTION) {
|
if(dir == PIC32_ENCRYPTION) {
|
||||||
XMEMCPY((void *)iv, (void*)&(out_p[sz-DES_IVLEN]), DES_IVLEN) ;
|
XMEMCPY((void *)iv, (void*)&(out_p[sz-DES_IVLEN]), DES_IVLEN) ;
|
||||||
} else {
|
} else {
|
||||||
ByteReverseWords((word32*)iv, (word32 *)&(in_p[sz-DES_IVLEN]), DES_IVLEN);
|
ByteReverseWords((word32*)iv, (word32 *)&(in_p[sz-DES_IVLEN]),
|
||||||
|
DES_IVLEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1448,7 +1449,7 @@ static int Des3_CaviumSetKey(Des3* des3, const byte* key, const byte* iv)
|
|||||||
static int Des3_CaviumCbcEncrypt(Des3* des3, byte* out, const byte* in,
|
static int Des3_CaviumCbcEncrypt(Des3* des3, byte* out, const byte* in,
|
||||||
word32 length)
|
word32 length)
|
||||||
{
|
{
|
||||||
word offset = 0;
|
cyassl_word offset = 0;
|
||||||
word32 requestId;
|
word32 requestId;
|
||||||
|
|
||||||
while (length > CYASSL_MAX_16BIT) {
|
while (length > CYASSL_MAX_16BIT) {
|
||||||
@ -1483,7 +1484,7 @@ static int Des3_CaviumCbcDecrypt(Des3* des3, byte* out, const byte* in,
|
|||||||
word32 length)
|
word32 length)
|
||||||
{
|
{
|
||||||
word32 requestId;
|
word32 requestId;
|
||||||
word offset = 0;
|
cyassl_word offset = 0;
|
||||||
|
|
||||||
while (length > CYASSL_MAX_16BIT) {
|
while (length > CYASSL_MAX_16BIT) {
|
||||||
word16 slen = (word16)CYASSL_MAX_16BIT;
|
word16 slen = (word16)CYASSL_MAX_16BIT;
|
||||||
|
@ -290,7 +290,7 @@ static INLINE int DoKey(HC128* ctx, const byte* key, const byte* iv)
|
|||||||
int Hc128_SetKey(HC128* ctx, const byte* key, const byte* iv)
|
int Hc128_SetKey(HC128* ctx, const byte* key, const byte* iv)
|
||||||
{
|
{
|
||||||
#ifdef XSTREAM_ALIGN
|
#ifdef XSTREAM_ALIGN
|
||||||
if ((word)key % 4) {
|
if ((cyassl_word)key % 4) {
|
||||||
int alignKey[4];
|
int alignKey[4];
|
||||||
|
|
||||||
/* iv gets aligned in SetIV */
|
/* iv gets aligned in SetIV */
|
||||||
@ -362,7 +362,7 @@ static INLINE int DoProcess(HC128* ctx, byte* output, const byte* input,
|
|||||||
int Hc128_Process(HC128* ctx, byte* output, const byte* input, word32 msglen)
|
int Hc128_Process(HC128* ctx, byte* output, const byte* input, word32 msglen)
|
||||||
{
|
{
|
||||||
#ifdef XSTREAM_ALIGN
|
#ifdef XSTREAM_ALIGN
|
||||||
if ((word)input % 4 || (word)output % 4) {
|
if ((cyassl_word)input % 4 || (cyassl_word)output % 4) {
|
||||||
#ifndef NO_CYASSL_ALLOC_ALIGN
|
#ifndef NO_CYASSL_ALLOC_ALIGN
|
||||||
byte* tmp;
|
byte* tmp;
|
||||||
CYASSL_MSG("Hc128Process unaligned");
|
CYASSL_MSG("Hc128Process unaligned");
|
||||||
|
@ -148,7 +148,7 @@ STATIC INLINE void ByteReverseWords64(word64* out, const word64* in,
|
|||||||
#endif /* WORD64_AVAILABLE */
|
#endif /* WORD64_AVAILABLE */
|
||||||
|
|
||||||
|
|
||||||
STATIC INLINE void XorWords(word* r, const word* a, word32 n)
|
STATIC INLINE void XorWords(cyassl_word* r, const cyassl_word* a, word32 n)
|
||||||
{
|
{
|
||||||
word32 i;
|
word32 i;
|
||||||
|
|
||||||
@ -158,8 +158,9 @@ STATIC INLINE void XorWords(word* r, const word* a, word32 n)
|
|||||||
|
|
||||||
STATIC INLINE void xorbuf(void* buf, const void* mask, word32 count)
|
STATIC INLINE void xorbuf(void* buf, const void* mask, word32 count)
|
||||||
{
|
{
|
||||||
if (((word)buf | (word)mask | count) % CYASSL_WORD_SIZE == 0)
|
if (((cyassl_word)buf | (cyassl_word)mask | count) % CYASSL_WORD_SIZE == 0)
|
||||||
XorWords( (word*)buf, (const word*)mask, count / CYASSL_WORD_SIZE);
|
XorWords( (cyassl_word*)buf,
|
||||||
|
(const cyassl_word*)mask, count / CYASSL_WORD_SIZE);
|
||||||
else {
|
else {
|
||||||
word32 i;
|
word32 i;
|
||||||
byte* b = (byte*)buf;
|
byte* b = (byte*)buf;
|
||||||
|
@ -202,7 +202,7 @@ static INLINE int DoKey(Rabbit* ctx, const byte* key, const byte* iv)
|
|||||||
int RabbitSetKey(Rabbit* ctx, const byte* key, const byte* iv)
|
int RabbitSetKey(Rabbit* ctx, const byte* key, const byte* iv)
|
||||||
{
|
{
|
||||||
#ifdef XSTREAM_ALIGN
|
#ifdef XSTREAM_ALIGN
|
||||||
if ((word)key % 4) {
|
if ((cyassl_word)key % 4) {
|
||||||
int alignKey[4];
|
int alignKey[4];
|
||||||
|
|
||||||
/* iv aligned in SetIV */
|
/* iv aligned in SetIV */
|
||||||
@ -282,7 +282,7 @@ static INLINE int DoProcess(Rabbit* ctx, byte* output, const byte* input,
|
|||||||
int RabbitProcess(Rabbit* ctx, byte* output, const byte* input, word32 msglen)
|
int RabbitProcess(Rabbit* ctx, byte* output, const byte* input, word32 msglen)
|
||||||
{
|
{
|
||||||
#ifdef XSTREAM_ALIGN
|
#ifdef XSTREAM_ALIGN
|
||||||
if ((word)input % 4 || (word)output % 4) {
|
if ((cyassl_word)input % 4 || (cyassl_word)output % 4) {
|
||||||
#ifndef NO_CYASSL_ALLOC_ALIGN
|
#ifndef NO_CYASSL_ALLOC_ALIGN
|
||||||
byte* tmp;
|
byte* tmp;
|
||||||
CYASSL_MSG("RabbitProcess unaligned");
|
CYASSL_MSG("RabbitProcess unaligned");
|
||||||
|
@ -550,8 +550,8 @@ int InitRngCavium(RNG* rng, int devId)
|
|||||||
|
|
||||||
static void CaviumRNG_GenerateBlock(RNG* rng, byte* output, word32 sz)
|
static void CaviumRNG_GenerateBlock(RNG* rng, byte* output, word32 sz)
|
||||||
{
|
{
|
||||||
word offset = 0;
|
cyassl_word offset = 0;
|
||||||
word32 requestId;
|
word32 requestId;
|
||||||
|
|
||||||
while (sz > CYASSL_MAX_16BIT) {
|
while (sz > CYASSL_MAX_16BIT) {
|
||||||
word16 slen = (word16)CYASSL_MAX_16BIT;
|
word16 slen = (word16)CYASSL_MAX_16BIT;
|
||||||
|
@ -88,9 +88,9 @@
|
|||||||
/* These platforms have 64-bit CPU registers. */
|
/* These platforms have 64-bit CPU registers. */
|
||||||
#if (defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || \
|
#if (defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || \
|
||||||
defined(__mips64) || defined(__x86_64__) || defined(_M_X64))
|
defined(__mips64) || defined(__x86_64__) || defined(_M_X64))
|
||||||
typedef word64 word;
|
typedef word64 cyassl_word;
|
||||||
#else
|
#else
|
||||||
typedef word32 word;
|
typedef word32 cyassl_word;
|
||||||
#ifdef WORD64_AVAILABLE
|
#ifdef WORD64_AVAILABLE
|
||||||
#define CTAOCRYPT_SLOW_WORD64
|
#define CTAOCRYPT_SLOW_WORD64
|
||||||
#endif
|
#endif
|
||||||
@ -98,7 +98,7 @@
|
|||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
CYASSL_WORD_SIZE = sizeof(word),
|
CYASSL_WORD_SIZE = sizeof(cyassl_word),
|
||||||
CYASSL_BIT_SIZE = 8,
|
CYASSL_BIT_SIZE = 8,
|
||||||
CYASSL_WORD_BITS = CYASSL_WORD_SIZE * CYASSL_BIT_SIZE
|
CYASSL_WORD_BITS = CYASSL_WORD_SIZE * CYASSL_BIT_SIZE
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user