- Moved from unsigned long to uint32_t throughout code

This commit is contained in:
Paul Bakker 2012-10-01 14:41:15 +00:00
parent 6adff7497a
commit 5c2364c2ba
34 changed files with 539 additions and 454 deletions

View file

@ -38,18 +38,18 @@
/*
* 32-bit integer manipulation macros (big endian)
*/
#ifndef GET_ULONG_BE
#define GET_ULONG_BE(n,b,i) \
#ifndef GET_UINT32_BE
#define GET_UINT32_BE(n,b,i) \
{ \
(n) = ( (unsigned long) (b)[(i) ] << 24 ) \
| ( (unsigned long) (b)[(i) + 1] << 16 ) \
| ( (unsigned long) (b)[(i) + 2] << 8 ) \
| ( (unsigned long) (b)[(i) + 3] ); \
(n) = ( (uint32_t) (b)[(i) ] << 24 ) \
| ( (uint32_t) (b)[(i) + 1] << 16 ) \
| ( (uint32_t) (b)[(i) + 2] << 8 ) \
| ( (uint32_t) (b)[(i) + 3] ); \
}
#endif
#ifndef PUT_ULONG_BE
#define PUT_ULONG_BE(n,b,i) \
#ifndef PUT_UINT32_BE
#define PUT_UINT32_BE(n,b,i) \
{ \
(b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
(b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
@ -342,8 +342,8 @@ int camellia_setkey_enc( camellia_context *ctx, const unsigned char *key, unsign
* Prepare SIGMA values
*/
for (i = 0; i < 6; i++) {
GET_ULONG_BE(SIGMA[i][0], SIGMA_CHARS[i], 0);
GET_ULONG_BE(SIGMA[i][1], SIGMA_CHARS[i], 4);
GET_UINT32_BE(SIGMA[i][0], SIGMA_CHARS[i], 0);
GET_UINT32_BE(SIGMA[i][1], SIGMA_CHARS[i], 4);
}
/*
@ -354,7 +354,7 @@ int camellia_setkey_enc( camellia_context *ctx, const unsigned char *key, unsign
/* Store KL, KR */
for (i = 0; i < 8; i++)
GET_ULONG_BE(KC[i], t, i * 4);
GET_UINT32_BE(KC[i], t, i * 4);
/* Generate KA */
for( i = 0; i < 4; ++i)
@ -475,10 +475,10 @@ int camellia_crypt_ecb( camellia_context *ctx,
NR = ctx->nr;
RK = ctx->rk;
GET_ULONG_BE( X[0], input, 0 );
GET_ULONG_BE( X[1], input, 4 );
GET_ULONG_BE( X[2], input, 8 );
GET_ULONG_BE( X[3], input, 12 );
GET_UINT32_BE( X[0], input, 0 );
GET_UINT32_BE( X[1], input, 4 );
GET_UINT32_BE( X[2], input, 8 );
GET_UINT32_BE( X[3], input, 12 );
X[0] ^= *RK++;
X[1] ^= *RK++;
@ -513,10 +513,10 @@ int camellia_crypt_ecb( camellia_context *ctx,
X[0] ^= *RK++;
X[1] ^= *RK++;
PUT_ULONG_BE( X[2], output, 0 );
PUT_ULONG_BE( X[3], output, 4 );
PUT_ULONG_BE( X[0], output, 8 );
PUT_ULONG_BE( X[1], output, 12 );
PUT_UINT32_BE( X[2], output, 0 );
PUT_UINT32_BE( X[3], output, 4 );
PUT_UINT32_BE( X[0], output, 8 );
PUT_UINT32_BE( X[1], output, 12 );
return( 0 );
}