diff --git a/include/cryb/md4.h b/include/cryb/md4.h index 5801161..1a5ff81 100644 --- a/include/cryb/md4.h +++ b/include/cryb/md4.h @@ -133,8 +133,8 @@ void md4_hmac_final( md4_ctx *ctx, unsigned char output[16] ); * \param output HMAC-MD4 result */ void md4_hmac_complete( unsigned char *key, int keylen, - unsigned char *input, int ilen, - unsigned char output[16] ); + unsigned char *input, int ilen, + unsigned char output[16] ); #ifdef __cplusplus } diff --git a/include/cryb/sha512.h b/include/cryb/sha512.h index 7b18926..e8d0e9c 100644 --- a/include/cryb/sha512.h +++ b/include/cryb/sha512.h @@ -93,7 +93,7 @@ void sha512_final( sha512_ctx *ctx, unsigned char output[64] ); * \param output SHA-384/512 checksum result */ void sha512_complete( const void *input, int ilen, - unsigned char output[64] ); + unsigned char output[64] ); #ifdef __cplusplus } diff --git a/lib/digest/md2.c b/lib/digest/md2.c index 4d32748..2320e5a 100644 --- a/lib/digest/md2.c +++ b/lib/digest/md2.c @@ -86,30 +86,30 @@ static void md2_process( md2_ctx *ctx ) for( i = 0; i < 16; i++ ) { - ctx->state[i + 16] = ctx->buffer[i]; - ctx->state[i + 32] = - (unsigned char)( ctx->buffer[i] ^ ctx->state[i]); + ctx->state[i + 16] = ctx->buffer[i]; + ctx->state[i + 32] = + (unsigned char)( ctx->buffer[i] ^ ctx->state[i]); } for( i = 0; i < 18; i++ ) { - for( j = 0; j < 48; j++ ) - { - ctx->state[j] = (unsigned char) - ( ctx->state[j] ^ PI_SUBST[t] ); - t = ctx->state[j]; - } + for( j = 0; j < 48; j++ ) + { + ctx->state[j] = (unsigned char) + ( ctx->state[j] ^ PI_SUBST[t] ); + t = ctx->state[j]; + } - t = (unsigned char)( t + i ); + t = (unsigned char)( t + i ); } t = ctx->cksum[15]; for( i = 0; i < 16; i++ ) { - ctx->cksum[i] = (unsigned char) - ( ctx->cksum[i] ^ PI_SUBST[ctx->buffer[i] ^ t] ); - t = ctx->cksum[i]; + ctx->cksum[i] = (unsigned char) + ( ctx->cksum[i] ^ PI_SUBST[ctx->buffer[i] ^ t] ); + t = ctx->cksum[i]; } } @@ -122,22 +122,22 @@ void md2_update( md2_ctx *ctx, const void *input, int ilen ) while( ilen > 0 ) { - if( ctx->left + ilen > 16 ) - fill = 16 - ctx->left; - else - fill = ilen; + if( ctx->left + ilen > 16 ) + fill = 16 - ctx->left; + else + fill = ilen; - memcpy( ctx->buffer + ctx->left, input, fill ); + memcpy( ctx->buffer + ctx->left, input, fill ); - ctx->left += fill; - input += fill; - ilen -= fill; + ctx->left += fill; + input += fill; + ilen -= fill; - if( ctx->left == 16 ) - { - ctx->left = 0; - md2_process( ctx ); - } + if( ctx->left == 16 ) + { + ctx->left = 0; + md2_process( ctx ); + } } } @@ -152,7 +152,7 @@ void md2_final( md2_ctx *ctx, unsigned char *output ) x = (unsigned char)( 16 - ctx->left ); for( i = ctx->left; i < 16; i++ ) - ctx->buffer[i] = x; + ctx->buffer[i] = x; md2_process( ctx ); @@ -186,9 +186,9 @@ void md2_hmac_init( md2_ctx *ctx, unsigned char *key, int keylen ) if( keylen > 64 ) { - md2_complete( key, keylen, sum ); - keylen = sizeof sum; - key = sum; + md2_complete( key, keylen, sum ); + keylen = sizeof sum; + key = sum; } memset( ctx->ipad, 0x36, sizeof ctx->ipad ); @@ -196,8 +196,8 @@ void md2_hmac_init( md2_ctx *ctx, unsigned char *key, int keylen ) for( i = 0; i < keylen; i++ ) { - ctx->ipad[i] = (unsigned char)( ctx->ipad[i] ^ key[i] ); - ctx->opad[i] = (unsigned char)( ctx->opad[i] ^ key[i] ); + ctx->ipad[i] = (unsigned char)( ctx->ipad[i] ^ key[i] ); + ctx->opad[i] = (unsigned char)( ctx->opad[i] ^ key[i] ); } md2_init( ctx ); @@ -234,7 +234,7 @@ void md2_hmac_final( md2_ctx *ctx, unsigned char *output ) * output = HMAC-MD2( hmac key, input buffer ) */ void md2_hmac_complete( unsigned char *key, int keylen, unsigned char *input, int ilen, - unsigned char *output ) + unsigned char *output ) { md2_ctx ctx; diff --git a/lib/digest/sha384.c b/lib/digest/sha384.c index 219c31b..0b4cdcc 100644 --- a/lib/digest/sha384.c +++ b/lib/digest/sha384.c @@ -48,13 +48,13 @@ #define GET_UINT64_BE(n,b,i) \ do { \ (n) = ( (uint64_t) (b)[(i) ] << 56 ) \ - | ( (uint64_t) (b)[(i) + 1] << 48 ) \ - | ( (uint64_t) (b)[(i) + 2] << 40 ) \ - | ( (uint64_t) (b)[(i) + 3] << 32 ) \ - | ( (uint64_t) (b)[(i) + 4] << 24 ) \ - | ( (uint64_t) (b)[(i) + 5] << 16 ) \ - | ( (uint64_t) (b)[(i) + 6] << 8 ) \ - | ( (uint64_t) (b)[(i) + 7] ); \ + | ( (uint64_t) (b)[(i) + 1] << 48 ) \ + | ( (uint64_t) (b)[(i) + 2] << 40 ) \ + | ( (uint64_t) (b)[(i) + 3] << 32 ) \ + | ( (uint64_t) (b)[(i) + 4] << 24 ) \ + | ( (uint64_t) (b)[(i) + 5] << 16 ) \ + | ( (uint64_t) (b)[(i) + 6] << 8 ) \ + | ( (uint64_t) (b)[(i) + 7] ); \ } while (0) #endif @@ -167,13 +167,13 @@ static void sha384_process( sha384_ctx *ctx, const unsigned char *data ) for( i = 0; i < 16; i++ ) { - GET_UINT64_BE( W[i], data, i << 3 ); + GET_UINT64_BE( W[i], data, i << 3 ); } for( ; i < 80; i++ ) { - W[i] = S1(W[i - 2]) + W[i - 7] + - S0(W[i - 15]) + W[i - 16]; + W[i] = S1(W[i - 2]) + W[i - 7] + + S0(W[i - 15]) + W[i - 16]; } A = ctx->state[0]; @@ -188,14 +188,14 @@ static void sha384_process( sha384_ctx *ctx, const unsigned char *data ) do { - P( A, B, C, D, E, F, G, H, W[i], K[i] ); i++; - P( H, A, B, C, D, E, F, G, W[i], K[i] ); i++; - P( G, H, A, B, C, D, E, F, W[i], K[i] ); i++; - P( F, G, H, A, B, C, D, E, W[i], K[i] ); i++; - P( E, F, G, H, A, B, C, D, W[i], K[i] ); i++; - P( D, E, F, G, H, A, B, C, W[i], K[i] ); i++; - P( C, D, E, F, G, H, A, B, W[i], K[i] ); i++; - P( B, C, D, E, F, G, H, A, W[i], K[i] ); i++; + P( A, B, C, D, E, F, G, H, W[i], K[i] ); i++; + P( H, A, B, C, D, E, F, G, W[i], K[i] ); i++; + P( G, H, A, B, C, D, E, F, W[i], K[i] ); i++; + P( F, G, H, A, B, C, D, E, W[i], K[i] ); i++; + P( E, F, G, H, A, B, C, D, W[i], K[i] ); i++; + P( D, E, F, G, H, A, B, C, W[i], K[i] ); i++; + P( C, D, E, F, G, H, A, B, W[i], K[i] ); i++; + P( B, C, D, E, F, G, H, A, W[i], K[i] ); i++; } while( i < 80 ); @@ -218,7 +218,7 @@ void sha384_update( sha384_ctx *ctx, const void *input, int ilen ) uint64_t left; if( ilen <= 0 ) - return; + return; left = ctx->total[0] & 0x7F; fill = (int)( 128 - left ); @@ -226,29 +226,29 @@ void sha384_update( sha384_ctx *ctx, const void *input, int ilen ) ctx->total[0] += ilen; if( ctx->total[0] < (uint64_t) ilen ) - ctx->total[1]++; + ctx->total[1]++; if( left && ilen >= fill ) { - memcpy( (void *) (ctx->buffer + left), - (void *) input, fill ); - sha384_process( ctx, ctx->buffer ); - input += fill; - ilen -= fill; - left = 0; + memcpy( (void *) (ctx->buffer + left), + (void *) input, fill ); + sha384_process( ctx, ctx->buffer ); + input += fill; + ilen -= fill; + left = 0; } while( ilen >= 128 ) { - sha384_process( ctx, input ); - input += 128; - ilen -= 128; + sha384_process( ctx, input ); + input += 128; + ilen -= 128; } if( ilen > 0 ) { - memcpy( (void *) (ctx->buffer + left), - (void *) input, ilen ); + memcpy( (void *) (ctx->buffer + left), + (void *) input, ilen ); } } @@ -274,7 +274,7 @@ void sha384_final( sha384_ctx *ctx, unsigned char output[64] ) unsigned char msglen[16]; high = ( ctx->total[0] >> 61 ) - | ( ctx->total[1] << 3 ); + | ( ctx->total[1] << 3 ); low = ( ctx->total[0] << 3 ); PUT_UINT64_BE( high, msglen, 0 ); @@ -298,7 +298,7 @@ void sha384_final( sha384_ctx *ctx, unsigned char output[64] ) * output = SHA-384( input buffer ) */ void sha384_complete( const void *input, int ilen, - unsigned char output[64] ) + unsigned char output[64] ) { sha384_ctx ctx; diff --git a/lib/mac/hmac_sha224.c b/lib/mac/hmac_sha224.c index 0098738..b75f69a 100644 --- a/lib/mac/hmac_sha224.c +++ b/lib/mac/hmac_sha224.c @@ -56,10 +56,10 @@ hmac_sha224_init(hmac_sha224_ctx *ctx, const void *key, size_t keylen) /* prepare key */ memset(keybuf, 0, sizeof keybuf); - if (keylen > sizeof keybuf) - sha224_complete(key, keylen, keybuf); - else - memcpy(keybuf, key, keylen); + if (keylen > sizeof keybuf) + sha224_complete(key, keylen, keybuf); + else + memcpy(keybuf, key, keylen); /* input pad */ for (unsigned int i = 0; i < sizeof pad; ++i) diff --git a/lib/mac/hmac_sha384.c b/lib/mac/hmac_sha384.c index 2aa77f3..78d5dd2 100644 --- a/lib/mac/hmac_sha384.c +++ b/lib/mac/hmac_sha384.c @@ -56,10 +56,10 @@ hmac_sha384_init(hmac_sha384_ctx *ctx, const void *key, size_t keylen) /* prepare key */ memset(keybuf, 0, sizeof keybuf); - if (keylen > sizeof keybuf) - sha384_complete(key, keylen, keybuf); - else - memcpy(keybuf, key, keylen); + if (keylen > sizeof keybuf) + sha384_complete(key, keylen, keybuf); + else + memcpy(keybuf, key, keylen); /* input pad */ for (unsigned int i = 0; i < sizeof pad; ++i) diff --git a/t/t.h b/t/t.h index df77a69..143c4f2 100644 --- a/t/t.h +++ b/t/t.h @@ -46,7 +46,7 @@ typedef int (t_func)(char **, void *); struct t_test { t_func *func; void *arg; - char *desc; + char *desc; }; extern const char *t_progname; diff --git a/t/t_md5.c b/t/t_md5.c index 0a8b570..45cfc2f 100644 --- a/t/t_md5.c +++ b/t/t_md5.c @@ -182,12 +182,12 @@ t_md5_short_updates(char **desc CRYB_UNUSED, void *arg) md5_ctx ctx; int i, len; - md5_init(&ctx); + md5_init(&ctx); len = strlen(vector->msg); for (i = 0; i + 5 < len; i += 5) md5_update(&ctx, vector->msg + i, 5); md5_update(&ctx, vector->msg + i, len - i); - md5_final(&ctx, digest); + md5_final(&ctx, digest); return (memcmp(digest, vector->digest, MD5_DIGEST_LEN) == 0); } #endif diff --git a/t/t_sha1.c b/t/t_sha1.c index 2457f92..c79feb6 100644 --- a/t/t_sha1.c +++ b/t/t_sha1.c @@ -179,12 +179,12 @@ t_sha1_short_updates(char **desc CRYB_UNUSED, void *arg) sha1_ctx ctx; int i, len; - sha1_init(&ctx); + sha1_init(&ctx); len = strlen(vector->msg); for (i = 0; i + 5 < len; i += 5) sha1_update(&ctx, vector->msg + i, 5); sha1_update(&ctx, vector->msg + i, len - i); - sha1_final(&ctx, digest); + sha1_final(&ctx, digest); return (memcmp(digest, vector->digest, SHA1_DIGEST_LEN) == 0); } #endif