Browse Source

global style change (now * is attached to identifier not to type)

master
bg 9 years ago
parent
commit
3a9f9d918f
  1. 4
      a51/A5_1.c
  2. 2
      a51/A5_1.h
  3. 2
      aes/aes128_dec.c
  4. 2
      aes/aes128_dec.h
  5. 2
      aes/aes128_enc.c
  6. 2
      aes/aes128_enc.h
  7. 2
      aes/aes192_dec.c
  8. 2
      aes/aes192_dec.h
  9. 2
      aes/aes192_enc.c
  10. 2
      aes/aes192_enc.h
  11. 2
      aes/aes256_dec.c
  12. 2
      aes/aes256_dec.h
  13. 2
      aes/aes256_enc.c
  14. 2
      aes/aes256_enc.h
  15. 2
      aes/aes_dec-asm.S
  16. 2
      aes/aes_dec-asm_faster.S
  17. 10
      aes/aes_dec.c
  18. 2
      aes/aes_dec.h
  19. 2
      aes/aes_enc-asm.S
  20. 8
      aes/aes_enc.c
  21. 2
      aes/aes_enc.h
  22. 2
      aes/aes_keyschedule-asm.S
  23. 10
      aes/aes_keyschedule.c
  24. 8
      aes/aes_keyschedule.h
  25. 4
      base64/base64_dec.c
  26. 4
      base64/base64_dec.h
  27. 2
      base64/base64_enc.c
  28. 2
      base64/base64_enc.h
  29. 14
      bcal/bcal-basic.c
  30. 14
      bcal/bcal-basic.h
  31. 16
      bcal/bcal-cbc.c
  32. 16
      bcal/bcal-cbc.h
  33. 18
      bcal/bcal-cfb_bit.c
  34. 14
      bcal/bcal-cfb_bit.h
  35. 14
      bcal/bcal-cfb_byte.c
  36. 14
      bcal/bcal-cfb_byte.h
  37. 14
      bcal/bcal-cmac.c
  38. 12
      bcal/bcal-cmac.h
  39. 16
      bcal/bcal-ctr.c
  40. 16
      bcal/bcal-ctr.h
  41. 20
      bcal/bcal-eax.c
  42. 22
      bcal/bcal-eax.h
  43. 10
      bcal/bcal-nessie.c
  44. 4
      bcal/bcal-nessie.h
  45. 14
      bcal/bcal-ofb.c
  46. 14
      bcal/bcal-ofb.h
  47. 8
      bcal/bcal-performance.c
  48. 4
      bcal/bcal-performance.h
  49. 4
      bcal/bcal_des.c
  50. 2
      bcal/bcal_rc5.c
  51. 4
      bcal/bcal_tdes.c
  52. 6
      bcal/bcal_tdes2.c
  53. 2
      bcal/bcal_threefish1024.c
  54. 2
      bcal/bcal_threefish256.c
  55. 2
      bcal/bcal_threefish512.c
  56. 4
      bcal/bcal_xtea.c
  57. 42
      bigint/bigint-stub.c
  58. 54
      bigint/bigint.c
  59. 50
      bigint/bigint.h
  60. 4
      bigint/bigint_adjust.S
  61. 2
      bigint/bigint_asm.S
  62. 4
      bigint/bigint_io.c
  63. 4
      bigint/bigint_io.h
  64. 34
      blake/blake_large.c
  65. 24
      blake/blake_large.h
  66. 32
      blake/blake_small.c
  67. 24
      blake/blake_small.h
  68. 2
      blockcipher_descriptor.h
  69. 8
      bmw/bmw_224-tinyasm.S
  70. 8
      bmw/bmw_256-tinyasm.S
  71. 42
      bmw/bmw_large.c
  72. 24
      bmw/bmw_large.h
  73. 26
      bmw/bmw_small-asm.S
  74. 12
      bmw/bmw_small-tinyasm.S
  75. 42
      bmw/bmw_small.c
  76. 24
      bmw/bmw_small.h
  77. 6
      camellia/camellia-asm.S
  78. 6
      camellia/camellia.h
  79. 14
      camellia/camellia128-stub.c
  80. 16
      camellia/camellia_C.c
  81. 10
      cast5/cast5.c
  82. 18
      cast5/cast5.h
  83. 20
      cast6/cast6.c
  84. 6
      cast6/cast6.h
  85. 6
      cscipher/cscipher.h
  86. 6
      cscipher/cscipher_small.c
  87. 4
      cscipher/cscipher_tiny_asm.S
  88. 26
      cubehash/cubehash.c
  89. 24
      cubehash/cubehash.h
  90. 2
      cubehash/xchg.h
  91. 10
      des/des.c
  92. 20
      des/des.h
  93. 16
      dsa/dsa.h
  94. 2
      dsa/dsa_key_blob.c
  95. 2
      dsa/dsa_key_blob.h
  96. 8
      dsa/dsa_sign.c
  97. 8
      dsa/dsa_verify.c
  98. 16
      ecdsa/ecc.h
  99. 16
      ecdsa/ecc_chudnovsky.c
  100. 16
      ecdsa/ecdsa.h

4
a51/A5_1.c

@ -39,7 +39,7 @@ uint8_t a5_1_clock_core(a5_1_ctx_t *c, uint8_t clockoverride);
* length is length of key in bits!
*/
void a5_1_init(a5_1_ctx_t *c, void* key, uint8_t keylength_b, void* iv, uint8_t ivlength_b){
void a5_1_init(a5_1_ctx_t *c, void *key, uint8_t keylength_b, void *iv, uint8_t ivlength_b){
uint8_t i,t;
memset(c->r1, 0, 3);
memset(c->r2, 0, 3);
@ -65,7 +65,7 @@ void a5_1_init(a5_1_ctx_t *c, void* key, uint8_t keylength_b, void* iv, uint8_t
}
static
void shiftreg(uint8_t* d){
void shiftreg(uint8_t *d){
uint8_t c, c2;
c=d[0]>>7;
d[0] <<= 1;

2
a51/A5_1.h

@ -58,7 +58,7 @@ typedef struct {
} a5_1_ctx_t;
void a5_1_init(a5_1_ctx_t *c, void* key, uint8_t keylength_b, void* iv, uint8_t ivlength_b);
void a5_1_init(a5_1_ctx_t *c, void *key, uint8_t keylength_b, void *iv, uint8_t ivlength_b);
uint8_t a5_1_clock(a5_1_ctx_t *c);
uint8_t a5_1_gen(a5_1_ctx_t *c);

2
aes/aes128_dec.c

@ -28,7 +28,7 @@
#include "aes.h"
#include "aes_dec.h"
void aes128_dec(void* buffer, aes128_ctx_t* ctx){
void aes128_dec(void *buffer, aes128_ctx_t *ctx){
aes_decrypt_core(buffer, (aes_genctx_t*)ctx, 10);
}

2
aes/aes128_dec.h

@ -39,7 +39,7 @@
* \param buffer pointer to the block to decrypt
* \param ctx pointer to the key schedule
*/
void aes128_dec(void* buffer, aes128_ctx_t* ctx);
void aes128_dec(void *buffer, aes128_ctx_t *ctx);

2
aes/aes128_enc.c

@ -28,7 +28,7 @@
#include "aes.h"
#include "aes_enc.h"
void aes128_enc(void* buffer, aes128_ctx_t* ctx){
void aes128_enc(void *buffer, aes128_ctx_t *ctx){
aes_encrypt_core(buffer, (aes_genctx_t*)ctx, 10);
}

2
aes/aes128_enc.h

@ -40,7 +40,7 @@
* \param buffer pointer to the block to encrypt
* \param ctx pointer to the key schedule
*/
void aes128_enc(void* buffer, aes128_ctx_t* ctx);
void aes128_enc(void *buffer, aes128_ctx_t *ctx);

2
aes/aes192_dec.c

@ -28,7 +28,7 @@
#include "aes.h"
#include "aes_dec.h"
void aes192_dec(void* buffer, aes192_ctx_t* ctx){
void aes192_dec(void *buffer, aes192_ctx_t *ctx){
aes_decrypt_core(buffer, (aes_genctx_t*)ctx, 12);
}

2
aes/aes192_dec.h

@ -39,7 +39,7 @@
* \param buffer pointer to the block to decrypt
* \param ctx pointer to the key schedule
*/
void aes192_dec(void* buffer, aes192_ctx_t* ctx);
void aes192_dec(void *buffer, aes192_ctx_t *ctx);

2
aes/aes192_enc.c

@ -28,7 +28,7 @@
#include "aes.h"
#include "aes_enc.h"
void aes192_enc(void* buffer, aes192_ctx_t* ctx){
void aes192_enc(void *buffer, aes192_ctx_t *ctx){
aes_encrypt_core(buffer, (aes_genctx_t*)ctx, 12);
}

2
aes/aes192_enc.h

@ -40,7 +40,7 @@
* \param buffer pointer to the block to encrypt
* \param ctx pointer to the key schedule
*/
void aes192_enc(void* buffer, aes192_ctx_t* ctx);
void aes192_enc(void *buffer, aes192_ctx_t *ctx);

2
aes/aes256_dec.c

@ -28,7 +28,7 @@
#include "aes.h"
#include "aes_dec.h"
void aes256_dec(void* buffer, aes256_ctx_t* ctx){
void aes256_dec(void *buffer, aes256_ctx_t *ctx){
aes_decrypt_core(buffer, (aes_genctx_t*)ctx, 14);
}

2
aes/aes256_dec.h

@ -39,7 +39,7 @@
* \param buffer pointer to the block to decrypt
* \param ctx pointer to the key schedule
*/
void aes256_dec(void* buffer, aes256_ctx_t* ctx);
void aes256_dec(void *buffer, aes256_ctx_t *ctx);

2
aes/aes256_enc.c

@ -28,7 +28,7 @@
#include "aes.h"
#include "aes_enc.h"
void aes256_enc(void* buffer, aes256_ctx_t* ctx){
void aes256_enc(void *buffer, aes256_ctx_t *ctx){
aes_encrypt_core(buffer, (aes_genctx_t*)ctx, 14);
}

2
aes/aes256_enc.h

@ -40,7 +40,7 @@
* \param buffer pointer to the block to encrypt
* \param ctx pointer to the key schedule
*/
void aes256_enc(void* buffer, aes256_ctx_t* ctx);
void aes256_enc(void *buffer, aes256_ctx_t *ctx);

2
aes/aes_dec-asm.S

@ -65,7 +65,7 @@ aes128_dec:
/*
void aes_decrypt_core(aes_cipher_state_t* state, const aes_genctx_t* ks, uint8_t rounds)
void aes_decrypt_core(aes_cipher_state_t *state, const aes_genctx_t *ks, uint8_t rounds)
*/
T0= 2
T1= 3

2
aes/aes_dec-asm_faster.S

@ -47,7 +47,7 @@ aes128_dec:
/*
void aes_decrypt_core(aes_cipher_state_t* state, const aes_genctx_t* ks, uint8_t rounds)
void aes_decrypt_core(aes_cipher_state_t *state, const aes_genctx_t *ks, uint8_t rounds)
*/
T0= 2
T1= 3

10
aes/aes_dec.c

@ -25,7 +25,7 @@
#include "aes_dec.h"
#include <avr/pgmspace.h>
void aes_invshiftrow(void* data, uint8_t shift){
void aes_invshiftrow(void *data, uint8_t shift){
uint8_t tmp[4];
tmp[0] = ((uint8_t*)data)[(4+0-shift)&3];
tmp[1] = ((uint8_t*)data)[(4+1-shift)&3];
@ -34,7 +34,7 @@ void aes_invshiftrow(void* data, uint8_t shift){
memcpy(data, tmp, 4);
}
void aes_invshiftcol(void* data, uint8_t shift){
void aes_invshiftcol(void *data, uint8_t shift){
uint8_t tmp[4];
tmp[0] = ((uint8_t*)data)[ 0];
tmp[1] = ((uint8_t*)data)[ 4];
@ -46,7 +46,7 @@ void aes_invshiftcol(void* data, uint8_t shift){
((uint8_t*)data)[12] = tmp[(4-shift+3)&3];
}
static
void aes_dec_round(aes_cipher_state_t* state, const aes_roundkey_t* k){
void aes_dec_round(aes_cipher_state_t *state, const aes_roundkey_t *k){
uint8_t tmp[16];
uint8_t i;
uint8_t t,u,v,w;
@ -102,7 +102,7 @@ void aes_dec_round(aes_cipher_state_t* state, const aes_roundkey_t* k){
static
void aes_dec_firstround(aes_cipher_state_t* state, const aes_roundkey_t* k){
void aes_dec_firstround(aes_cipher_state_t *state, const aes_roundkey_t *k){
uint8_t i;
/* keyAdd */
for(i=0; i<16; ++i){
@ -118,7 +118,7 @@ void aes_dec_firstround(aes_cipher_state_t* state, const aes_roundkey_t* k){
}
}
void aes_decrypt_core(aes_cipher_state_t* state, const aes_genctx_t* ks, uint8_t rounds){
void aes_decrypt_core(aes_cipher_state_t *state, const aes_genctx_t *ks, uint8_t rounds){
uint8_t i;
aes_dec_firstround(state, &(ks->key[i=rounds]));
for(;rounds>1;--rounds){

2
aes/aes_dec.h

@ -30,7 +30,7 @@
#include <stdint.h>
void aes_decrypt_core(aes_cipher_state_t* state,const aes_genctx_t* ks, uint8_t rounds);
void aes_decrypt_core(aes_cipher_state_t *state,const aes_genctx_t *ks, uint8_t rounds);
#endif

2
aes/aes_enc-asm.S

@ -54,7 +54,7 @@ aes128_enc:
/*
void aes_encrypt_core(aes_cipher_state_t* state, const aes_genctx_t* ks, uint8_t rounds)
void aes_encrypt_core(aes_cipher_state_t *state, const aes_genctx_t *ks, uint8_t rounds)
*/
T0= 2
T1= 3

8
aes/aes_enc.c

@ -33,7 +33,7 @@
#include "aes_enc.h"
#include <avr/pgmspace.h>
void aes_shiftcol(void* data, uint8_t shift){
void aes_shiftcol(void *data, uint8_t shift){
uint8_t tmp[4];
tmp[0] = ((uint8_t*)data)[ 0];
tmp[1] = ((uint8_t*)data)[ 4];
@ -50,7 +50,7 @@ void aes_shiftcol(void* data, uint8_t shift){
#define GF256MUL_3(a) (gf256mul(3, (a), 0x1b))
static
void aes_enc_round(aes_cipher_state_t* state, const aes_roundkey_t* k){
void aes_enc_round(aes_cipher_state_t *state, const aes_roundkey_t *k){
uint8_t tmp[16], t;
uint8_t i;
/* subBytes */
@ -90,7 +90,7 @@ void aes_enc_round(aes_cipher_state_t* state, const aes_roundkey_t* k){
static
void aes_enc_lastround(aes_cipher_state_t* state,const aes_roundkey_t* k){
void aes_enc_lastround(aes_cipher_state_t *state,const aes_roundkey_t *k){
uint8_t i;
/* subBytes */
for(i=0; i<16; ++i){
@ -106,7 +106,7 @@ void aes_enc_lastround(aes_cipher_state_t* state,const aes_roundkey_t* k){
}
}
void aes_encrypt_core(aes_cipher_state_t* state, const aes_genctx_t* ks, uint8_t rounds){
void aes_encrypt_core(aes_cipher_state_t *state, const aes_genctx_t *ks, uint8_t rounds){
uint8_t i;
for(i=0; i<16; ++i){
state->s[i] ^= ks->key[0].ks[i];

2
aes/aes_enc.h

@ -30,7 +30,7 @@
#include <stdint.h>
void aes_encrypt_core(aes_cipher_state_t* state, const aes_genctx_t* ks, uint8_t rounds);
void aes_encrypt_core(aes_cipher_state_t *state, const aes_genctx_t *ks, uint8_t rounds);
#endif

2
aes/aes_keyschedule-asm.S

@ -48,7 +48,7 @@ aes128_init:
ldi r22, 128
/*
void aes_init(const void* key, uint16_t keysize_b, aes_genctx_t* ctx){
void aes_init(const void *key, uint16_t keysize_b, aes_genctx_t *ctx){
uint8_t hi,i,nk, next_nk;
uint8_t rc=1;
uint8_t tmp[4];

10
aes/aes_keyschedule.c

@ -33,7 +33,7 @@
#include <avr/pgmspace.h>
static
void aes_rotword(void* a){
void aes_rotword(void *a){
uint8_t t;
t=((uint8_t*)a)[0];
((uint8_t*)a)[0] = ((uint8_t*)a)[1];
@ -46,7 +46,7 @@ const uint8_t rc_tab[] PROGMEM = { 0x01, 0x02, 0x04, 0x08,
0x10, 0x20, 0x40, 0x80,
0x1b, 0x36 };
void aes_init(const void* key, uint16_t keysize_b, aes_genctx_t* ctx){
void aes_init(const void *key, uint16_t keysize_b, aes_genctx_t *ctx){
uint8_t hi,i,nk, next_nk;
uint8_t rc=0;
union {
@ -81,14 +81,14 @@ void aes_init(const void* key, uint16_t keysize_b, aes_genctx_t* ctx){
}
}
void aes128_init(const void* key, aes128_ctx_t* ctx){
void aes128_init(const void *key, aes128_ctx_t *ctx){
aes_init(key, 128, (aes_genctx_t*)ctx);
}
void aes192_init(const void* key, aes192_ctx_t* ctx){
void aes192_init(const void *key, aes192_ctx_t *ctx){
aes_init(key, 192, (aes_genctx_t*)ctx);
}
void aes256_init(const void* key, aes256_ctx_t* ctx){
void aes256_init(const void *key, aes256_ctx_t *ctx){
aes_init(key, 256, (aes_genctx_t*)ctx);
}

8
aes/aes_keyschedule.h

@ -39,7 +39,7 @@
* \param keysize_b length of the key in bits (valid are 128, 192 and 256)
* \param ctx pointer to the context where the keyschedule should be stored
*/
void aes_init(const void* key, uint16_t keysize_b, aes_genctx_t* ctx);
void aes_init(const void *key, uint16_t keysize_b, aes_genctx_t *ctx);
/**
* \brief initialize the keyschedule for 128 bit key
@ -49,7 +49,7 @@ void aes_init(const void* key, uint16_t keysize_b, aes_genctx_t* ctx);
* \param key pointer to the key material
* \param ctx pointer to the context where the keyschedule should be stored
*/
void aes128_init(const void* key, aes128_ctx_t* ctx);
void aes128_init(const void *key, aes128_ctx_t *ctx);
/**
* \brief initialize the keyschedule for 192 bit key
@ -59,7 +59,7 @@ void aes128_init(const void* key, aes128_ctx_t* ctx);
* \param key pointer to the key material
* \param ctx pointer to the context where the keyschedule should be stored
*/
void aes192_init(const void* key, aes192_ctx_t* ctx);
void aes192_init(const void *key, aes192_ctx_t *ctx);
/**
* \brief initialize the keyschedule for 256 bit key
@ -69,7 +69,7 @@ void aes192_init(const void* key, aes192_ctx_t* ctx);
* \param key pointer to the key material
* \param ctx pointer to the context where the keyschedule should be stored
*/
void aes256_init(const void* key, aes256_ctx_t* ctx);
void aes256_init(const void *key, aes256_ctx_t *ctx);
#endif /* AES_KEYSCHEDULE_H_ */

4
base64/base64_dec.c

@ -131,7 +131,7 @@ uint8_t ascii2bit6(uint8_t a){
#endif
int base64_binlength(char* str, uint8_t strict){
int base64_binlength(char *str, uint8_t strict){
int l=0;
uint8_t term=0;
for(;;){
@ -187,7 +187,7 @@ int base64_binlength(char* str, uint8_t strict){
*/
int base64dec(void* dest, const char* b64str, uint8_t strict){
int base64dec(void *dest, const char *b64str, uint8_t strict){
uint8_t buffer[4];
uint8_t idx=0;
uint8_t term=0;

4
base64/base64_dec.h

@ -23,7 +23,7 @@
#include <stdint.h>
int base64_binlength(char* str, uint8_t strict);
int base64dec(void* dest, const char* b64str, uint8_t strict);
int base64_binlength(char *str, uint8_t strict);
int base64dec(void *dest, const char *b64str, uint8_t strict);
#endif /*BASE64_DEC_H_*/

2
base64/base64_enc.c

@ -75,7 +75,7 @@ char bit6toAscii(uint8_t a){
#endif
void base64enc(char* dest,const void* src, uint16_t length){
void base64enc(char *dest,const void *src, uint16_t length){
uint16_t i,j;
uint8_t a[4];
for(i=0; i<length/3; ++i){

2
base64/base64_enc.h

@ -23,6 +23,6 @@
#include <stdint.h>
void base64enc(char* dest, const void* src, uint16_t length);
void base64enc(char *dest, const void *src, uint16_t length);
#endif /*BASE64_ENC_H_*/

14
bcal/bcal-basic.c

@ -24,8 +24,8 @@
#include "blockcipher_descriptor.h"
#include "keysize_descriptor.h"
uint8_t bcal_cipher_init(const bcdesc_t* cipher_descriptor,
const void* key, uint16_t keysize_b, bcgen_ctx_t* ctx){
uint8_t bcal_cipher_init(const bcdesc_t *cipher_descriptor,
const void *key, uint16_t keysize_b, bcgen_ctx_t *ctx){
if(!is_valid_keysize_P((PGM_VOID_P)pgm_read_word(&(cipher_descriptor->valid_keysize_desc)),
keysize_b)){
return 1;
@ -52,7 +52,7 @@ uint8_t bcal_cipher_init(const bcdesc_t* cipher_descriptor,
return 0;
}
void bcal_cipher_free(bcgen_ctx_t* ctx){
void bcal_cipher_free(bcgen_ctx_t *ctx){
if(!ctx)
return;
bc_free_fpt free_fpt;
@ -62,7 +62,7 @@ void bcal_cipher_free(bcgen_ctx_t* ctx){
free(ctx->ctx);
}
void bcal_cipher_enc(void* block, const bcgen_ctx_t* ctx){
void bcal_cipher_enc(void *block, const bcgen_ctx_t *ctx){
bc_enc_fpt enc_fpt;
enc_fpt.encvoid = (void_fpt)pgm_read_word(&(ctx->desc_ptr->enc.encvoid));
if(!enc_fpt.encvoid){
@ -73,7 +73,7 @@ void bcal_cipher_enc(void* block, const bcgen_ctx_t* ctx){
}
void bcal_cipher_dec(void* block, const bcgen_ctx_t* ctx){
void bcal_cipher_dec(void *block, const bcgen_ctx_t *ctx){
bc_dec_fpt dec_fpt;
dec_fpt.decvoid = (void_fpt)pgm_read_word(&(ctx->desc_ptr->dec.decvoid));
if(!dec_fpt.decvoid){
@ -83,11 +83,11 @@ void bcal_cipher_dec(void* block, const bcgen_ctx_t* ctx){
dec_fpt.dec1(block, (ctx->ctx));
}
uint16_t bcal_cipher_getBlocksize_b(const bcdesc_t* desc){
uint16_t bcal_cipher_getBlocksize_b(const bcdesc_t *desc){
return pgm_read_word(&(desc->blocksize_b));
}
PGM_VOID_P bcal_cipher_getKeysizeDesc(const bcdesc_t* desc){
PGM_VOID_P bcal_cipher_getKeysizeDesc(const bcdesc_t *desc){
return (PGM_VOID_P)pgm_read_word(&(desc->valid_keysize_desc));
}

14
bcal/bcal-basic.h

@ -26,11 +26,11 @@
#include "keysize_descriptor.h"
#include <avr/pgmspace.h>
uint8_t bcal_cipher_init(const bcdesc_t* cipher_descriptor,
const void* key, uint16_t keysize_b, bcgen_ctx_t* ctx);
void bcal_cipher_free(bcgen_ctx_t* ctx);
void bcal_cipher_enc(void* block, const bcgen_ctx_t* ctx);
void bcal_cipher_dec(void* block, const bcgen_ctx_t* ctx);
uint16_t bcal_cipher_getBlocksize_b(const bcdesc_t* desc);
PGM_VOID_P bcal_cipher_getKeysizeDesc(const bcdesc_t* desc);
uint8_t bcal_cipher_init(const bcdesc_t *cipher_descriptor,
const void *key, uint16_t keysize_b, bcgen_ctx_t *ctx);
void bcal_cipher_free(bcgen_ctx_t *ctx);
void bcal_cipher_enc(void *block, const bcgen_ctx_t *ctx);
void bcal_cipher_dec(void *block, const bcgen_ctx_t *ctx);
uint16_t bcal_cipher_getBlocksize_b(const bcdesc_t *desc);
PGM_VOID_P bcal_cipher_getKeysizeDesc(const bcdesc_t *desc);
#endif /* BCAL_BASIC_H_ */

16
bcal/bcal-cbc.c

@ -23,7 +23,7 @@
#include "bcal-basic.h"
#include "memxor.h"
uint8_t bcal_cbc_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b, bcal_cbc_ctx_t* ctx){
uint8_t bcal_cbc_init(const bcdesc_t *desc, const void *key, uint16_t keysize_b, bcal_cbc_ctx_t *ctx){
ctx->desc = (bcdesc_t*)desc;
ctx->blocksize_B = (bcal_cipher_getBlocksize_b(desc)+7)/8;
ctx->prev_block = malloc(ctx->blocksize_B);
@ -34,37 +34,37 @@ uint8_t bcal_cbc_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b,
return bcal_cipher_init(desc, key, keysize_b, &(ctx->cctx));
}
void bcal_cbc_free(bcal_cbc_ctx_t* ctx){
void bcal_cbc_free(bcal_cbc_ctx_t *ctx){
bcal_cipher_free(&(ctx->cctx));
free(ctx->prev_block);
}
void bcal_cbc_loadIV(const void* iv, bcal_cbc_ctx_t* ctx){
void bcal_cbc_loadIV(const void *iv, bcal_cbc_ctx_t *ctx){
if(iv){
memcpy(ctx->prev_block, iv, ctx->blocksize_B);
}
}
void bcal_cbc_encNext(void* block, bcal_cbc_ctx_t* ctx){
void bcal_cbc_encNext(void *block, bcal_cbc_ctx_t *ctx){
memxor(block, ctx->prev_block, ctx->blocksize_B);
bcal_cipher_enc(block, &(ctx->cctx));
memcpy(ctx->prev_block, block, ctx->blocksize_B);
}
void bcal_cbc_decNext(void* block, bcal_cbc_ctx_t* ctx){
void bcal_cbc_decNext(void *block, bcal_cbc_ctx_t *ctx){
uint8_t tmp[ctx->blocksize_B];
memcpy(tmp, block, ctx->blocksize_B);
bcal_cipher_dec(block, &(ctx->cctx));
memxor(block, ctx->prev_block, ctx->blocksize_B);
memcpy(ctx->prev_block, tmp, ctx->blocksize_B);
}
void bcal_cbc_decRand(void* block, const void* prev_block, bcal_cbc_ctx_t* ctx){
void bcal_cbc_decRand(void *block, const void *prev_block, bcal_cbc_ctx_t *ctx){
bcal_cipher_dec(block, &(ctx->cctx));
memxor(block, prev_block, ctx->blocksize_B);
}
void bcal_cbc_encMsg(const void* iv, void* msg, uint16_t msg_blocks, bcal_cbc_ctx_t* ctx){
void bcal_cbc_encMsg(const void *iv, void *msg, uint16_t msg_blocks, bcal_cbc_ctx_t *ctx){
bcal_cbc_loadIV(iv, ctx);
while(msg_blocks--){
bcal_cbc_encNext(msg, ctx);
@ -72,7 +72,7 @@ void bcal_cbc_encMsg(const void* iv, void* msg, uint16_t msg_blocks, bcal_cbc_ct
}
}
void bcal_cbc_decMsg(const void* iv, void* msg, uint16_t msg_blocks, bcal_cbc_ctx_t* ctx){
void bcal_cbc_decMsg(const void *iv, void *msg, uint16_t msg_blocks, bcal_cbc_ctx_t *ctx){
msg=(uint8_t*)msg + (msg_blocks-1)*ctx->blocksize_B;
while(msg_blocks > 1){
bcal_cbc_decRand(msg, (uint8_t*)msg-ctx->blocksize_B, ctx);

16
bcal/bcal-cbc.h

@ -31,14 +31,14 @@ typedef struct{
uint8_t blocksize_B;
} bcal_cbc_ctx_t;
uint8_t bcal_cbc_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b, bcal_cbc_ctx_t* ctx);
void bcal_cbc_free(bcal_cbc_ctx_t* ctx);
void bcal_cbc_loadIV(const void* iv, bcal_cbc_ctx_t* ctx);
void bcal_cbc_encNext(void* block, bcal_cbc_ctx_t* ctx);
void bcal_cbc_decNext(void* block, bcal_cbc_ctx_t* ctx);
void bcal_cbc_decRand(void* block, const void* prev_block, bcal_cbc_ctx_t* ctx);
void bcal_cbc_encMsg(const void* iv, void* msg, uint16_t msg_blocks, bcal_cbc_ctx_t* ctx);
void bcal_cbc_decMsg(const void* iv, void* msg, uint16_t msg_blocks, bcal_cbc_ctx_t* ctx);
uint8_t bcal_cbc_init(const bcdesc_t *desc, const void *key, uint16_t keysize_b, bcal_cbc_ctx_t *ctx);
void bcal_cbc_free(bcal_cbc_ctx_t *ctx);
void bcal_cbc_loadIV(const void *iv, bcal_cbc_ctx_t *ctx);
void bcal_cbc_encNext(void *block, bcal_cbc_ctx_t *ctx);
void bcal_cbc_decNext(void *block, bcal_cbc_ctx_t *ctx);
void bcal_cbc_decRand(void *block, const void *prev_block, bcal_cbc_ctx_t *ctx);
void bcal_cbc_encMsg(const void *iv, void *msg, uint16_t msg_blocks, bcal_cbc_ctx_t *ctx);
void bcal_cbc_decMsg(const void *iv, void *msg, uint16_t msg_blocks, bcal_cbc_ctx_t *ctx);
#endif /* BCALCBC_H_ */

18
bcal/bcal-cfb_bit.c

@ -23,14 +23,14 @@
#include "bcal-cfb_bit.h"
#include "bcal-basic.h"
static uint8_t read_bit(void* block, uint32_t index){
static uint8_t read_bit(void *block, uint32_t index){
uint8_t r;
r=((uint8_t*)block)[index/8];
r=(r&(0x80>>(index&7)))?0xff:0x00;
return r;
}
static void write_bit(void* block, uint32_t index, uint8_t value){
static void write_bit(void *block, uint32_t index, uint8_t value){
if(value){
/* set bit */
((uint8_t*)block)[index/8] |= 0x80>>(index&7);
@ -40,7 +40,7 @@ static void write_bit(void* block, uint32_t index, uint8_t value){
}
}
uint8_t bcal_cfb_b_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b, uint16_t size_b, bcal_cfb_b_ctx_t* ctx){
uint8_t bcal_cfb_b_init(const bcdesc_t *desc, const void *key, uint16_t keysize_b, uint16_t size_b, bcal_cfb_b_ctx_t *ctx){
ctx->desc = (bcdesc_t*)desc;
ctx->blocksize_B = (bcal_cipher_getBlocksize_b(desc)+7)/8;
ctx->in_block=malloc(ctx->blocksize_B);
@ -54,18 +54,18 @@ uint8_t bcal_cfb_b_init(const bcdesc_t* desc, const void* key, uint16_t keysize_
return bcal_cipher_init(desc, key, keysize_b, &(ctx->cctx));
}
void bcal_cfb_b_free(bcal_cfb_b_ctx_t* ctx){
void bcal_cfb_b_free(bcal_cfb_b_ctx_t *ctx){
free(ctx->in_block);
bcal_cipher_free(&(ctx->cctx));
}
void bcal_cfb_b_loadIV(const void* iv, bcal_cfb_b_ctx_t* ctx){
void bcal_cfb_b_loadIV(const void *iv, bcal_cfb_b_ctx_t *ctx){
if(iv){
memcpy(ctx->in_block, iv, ctx->blocksize_B);
}
}
void bcal_cfb_b_encNext(void* block, uint8_t offset, bcal_cfb_b_ctx_t* ctx){
void bcal_cfb_b_encNext(void *block, uint8_t offset, bcal_cfb_b_ctx_t *ctx){
uint8_t tmp[ctx->blocksize_B];
offset &= 7;
memcpy(tmp, ctx->in_block, ctx->blocksize_B);
@ -83,7 +83,7 @@ void bcal_cfb_b_encNext(void* block, uint8_t offset, bcal_cfb_b_ctx_t* ctx){
}
}
void bcal_cfb_b_decNext(void* block, uint8_t offset, bcal_cfb_b_ctx_t* ctx){
void bcal_cfb_b_decNext(void *block, uint8_t offset, bcal_cfb_b_ctx_t *ctx){
uint8_t tmp[ctx->blocksize_B];
offset &= 7;
memcpy(tmp, ctx->in_block, ctx->blocksize_B);
@ -103,7 +103,7 @@ void bcal_cfb_b_decNext(void* block, uint8_t offset, bcal_cfb_b_ctx_t* ctx){
}
}
void bcal_cfb_b_encMsg(const void* iv, void* msg, uint8_t offset, uint32_t msg_blocks, bcal_cfb_b_ctx_t* ctx){
void bcal_cfb_b_encMsg(const void *iv, void *msg, uint8_t offset, uint32_t msg_blocks, bcal_cfb_b_ctx_t *ctx){
bcal_cfb_b_loadIV(iv, ctx);
uint32_t addr;
addr = ((uint16_t)msg)*8+offset;
@ -115,7 +115,7 @@ void bcal_cfb_b_encMsg(const void* iv, void* msg, uint8_t offset, uint32_t msg_b
}
}
void bcal_cfb_b_decMsg(const void* iv, void* msg, uint8_t offset, uint32_t msg_blocks, bcal_cfb_b_ctx_t* ctx){
void bcal_cfb_b_decMsg(const void *iv, void *msg, uint8_t offset, uint32_t msg_blocks, bcal_cfb_b_ctx_t *ctx){
bcal_cfb_b_loadIV(iv, ctx);
uint32_t addr;
addr = ((uint16_t)msg)*8+offset;

14
bcal/bcal-cfb_bit.h

@ -35,13 +35,13 @@ typedef struct{
} bcal_cfb_b_ctx_t;
uint8_t bcal_cfb_b_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b, uint16_t size_b, bcal_cfb_b_ctx_t* ctx);
void bcal_cfb_b_free(bcal_cfb_b_ctx_t* ctx);
void bcal_cfb_b_loadIV(const void* iv, bcal_cfb_b_ctx_t* ctx);
void bcal_cfb_b_encNext(void* block, uint8_t offset, bcal_cfb_b_ctx_t* ctx);
void bcal_cfb_b_decNext(void* block, uint8_t offset, bcal_cfb_b_ctx_t* ctx);
void bcal_cfb_b_encMsg(const void* iv, void* msg, uint8_t offset, uint32_t msg_blocks, bcal_cfb_b_ctx_t* ctx);
void bcal_cfb_b_decMsg(const void* iv, void* msg, uint8_t offset, uint32_t msg_blocks, bcal_cfb_b_ctx_t* ctx);
uint8_t bcal_cfb_b_init(const bcdesc_t *desc, const void *key, uint16_t keysize_b, uint16_t size_b, bcal_cfb_b_ctx_t *ctx);
void bcal_cfb_b_free(bcal_cfb_b_ctx_t *ctx);
void bcal_cfb_b_loadIV(const void *iv, bcal_cfb_b_ctx_t *ctx);
void bcal_cfb_b_encNext(void *block, uint8_t offset, bcal_cfb_b_ctx_t *ctx);
void bcal_cfb_b_decNext(void *block, uint8_t offset, bcal_cfb_b_ctx_t *ctx);
void bcal_cfb_b_encMsg(const void *iv, void *msg, uint8_t offset, uint32_t msg_blocks, bcal_cfb_b_ctx_t *ctx);
void bcal_cfb_b_decMsg(const void *iv, void *msg, uint8_t offset, uint32_t msg_blocks, bcal_cfb_b_ctx_t *ctx);
#endif /* BCALCFB_BIT_H_ */

14
bcal/bcal-cfb_byte.c

@ -25,7 +25,7 @@
#include "memxor.h"
uint8_t bcal_cfb_B_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b, uint16_t size_b, bcal_cfb_B_ctx_t* ctx){
uint8_t bcal_cfb_B_init(const bcdesc_t *desc, const void *key, uint16_t keysize_b, uint16_t size_b, bcal_cfb_B_ctx_t *ctx){
ctx->desc = (bcdesc_t*)desc;
ctx->blocksize_B = (bcal_cipher_getBlocksize_b(desc)+7)/8;
ctx->in_block=malloc(ctx->blocksize_B);
@ -39,18 +39,18 @@ uint8_t bcal_cfb_B_init(const bcdesc_t* desc, const void* key, uint16_t keysize_
return bcal_cipher_init(desc, key, keysize_b, &(ctx->cctx));
}
void bcal_cfb_B_free(bcal_cfb_B_ctx_t* ctx){
void bcal_cfb_B_free(bcal_cfb_B_ctx_t *ctx){
free(ctx->in_block);
bcal_cipher_free(&(ctx->cctx));
}
void bcal_cfb_B_loadIV(const void* iv, bcal_cfb_B_ctx_t* ctx){
void bcal_cfb_B_loadIV(const void *iv, bcal_cfb_B_ctx_t *ctx){
if(iv){
memcpy(ctx->in_block, iv, ctx->blocksize_B);
}
}
void bcal_cfb_B_encNext(void* block, bcal_cfb_B_ctx_t* ctx){
void bcal_cfb_B_encNext(void *block, bcal_cfb_B_ctx_t *ctx){
uint8_t tmp[ctx->blocksize_B];
memcpy(tmp, ctx->in_block, ctx->blocksize_B);
bcal_cipher_enc(tmp, &(ctx->cctx));
@ -59,7 +59,7 @@ void bcal_cfb_B_encNext(void* block, bcal_cfb_B_ctx_t* ctx){
memcpy(ctx->in_block+ctx->blocksize_B-ctx->size_B, block, ctx->size_B);
}
void bcal_cfb_B_decNext(void* block, bcal_cfb_B_ctx_t* ctx){
void bcal_cfb_B_decNext(void *block, bcal_cfb_B_ctx_t *ctx){
uint8_t tmp[ctx->blocksize_B];
uint8_t xblock[ctx->size_B];
memcpy(xblock, block, ctx->size_B);
@ -70,7 +70,7 @@ void bcal_cfb_B_decNext(void* block, bcal_cfb_B_ctx_t* ctx){
memcpy(ctx->in_block+ctx->blocksize_B-ctx->size_B, xblock, ctx->size_B);
}
void bcal_cfb_B_encMsg(const void* iv, void* msg, uint16_t msg_blocks, bcal_cfb_B_ctx_t* ctx){
void bcal_cfb_B_encMsg(const void *iv, void *msg, uint16_t msg_blocks, bcal_cfb_B_ctx_t *ctx){
bcal_cfb_B_loadIV(iv, ctx);
while(msg_blocks--){
bcal_cfb_B_encNext(msg, ctx);
@ -78,7 +78,7 @@ void bcal_cfb_B_encMsg(const void* iv, void* msg, uint16_t msg_blocks, bcal_cfb_
}
}
void bcal_cfb_B_decMsg(const void* iv, void* msg, uint16_t msg_blocks, bcal_cfb_B_ctx_t* ctx){
void bcal_cfb_B_decMsg(const void *iv, void *msg, uint16_t msg_blocks, bcal_cfb_B_ctx_t *ctx){
bcal_cfb_B_loadIV(iv, ctx);
while(msg_blocks--){
bcal_cfb_B_decNext(msg, ctx);

14
bcal/bcal-cfb_byte.h

@ -34,13 +34,13 @@ typedef struct{
} bcal_cfb_B_ctx_t;
uint8_t bcal_cfb_B_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b, uint16_t size_b, bcal_cfb_B_ctx_t* ctx);
void bcal_cfb_B_free(bcal_cfb_B_ctx_t* ctx);
void bcal_cfb_B_loadIV(const void* iv, bcal_cfb_B_ctx_t* ctx);
void bcal_cfb_B_encNext(void* block, bcal_cfb_B_ctx_t* ctx);
void bcal_cfb_B_decNext(void* block, bcal_cfb_B_ctx_t* ctx);
void bcal_cfb_B_encMsg(const void* iv, void* msg, uint16_t msg_blocks, bcal_cfb_B_ctx_t* ctx);
void bcal_cfb_B_decMsg(const void* iv, void* msg, uint16_t msg_blocks, bcal_cfb_B_ctx_t* ctx);
uint8_t bcal_cfb_B_init(const bcdesc_t *desc, const void *key, uint16_t keysize_b, uint16_t size_b, bcal_cfb_B_ctx_t *ctx);
void bcal_cfb_B_free(bcal_cfb_B_ctx_t *ctx);
void bcal_cfb_B_loadIV(const void *iv, bcal_cfb_B_ctx_t *ctx);
void bcal_cfb_B_encNext(void *block, bcal_cfb_B_ctx_t *ctx);
void bcal_cfb_B_decNext(void *block, bcal_cfb_B_ctx_t *ctx);
void bcal_cfb_B_encMsg(const void *iv, void *msg, uint16_t msg_blocks, bcal_cfb_B_ctx_t *ctx);
void bcal_cfb_B_decMsg(const void *iv, void *msg, uint16_t msg_blocks, bcal_cfb_B_ctx_t *ctx);
#endif /* BCALCFB_BYTE_H_ */

14
bcal/bcal-cmac.c

@ -25,7 +25,7 @@
#include "memxor.h"
static uint8_t left_shift_be_block(void* block, uint8_t blocksize_B){
static uint8_t left_shift_be_block(void *block, uint8_t blocksize_B){
uint8_t c1=0, c2;
do{
--blocksize_B;
@ -40,7 +40,7 @@ static uint8_t left_shift_be_block(void* block, uint8_t blocksize_B){
static const uint8_t const_128 = 0x87;
static const uint8_t const_64 = 0x1b;
uint8_t bcal_cmac_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b, bcal_cmac_ctx_t* ctx){
uint8_t bcal_cmac_init(const bcdesc_t *desc, const void *key, uint16_t keysize_b, bcal_cmac_ctx_t *ctx){
uint8_t r;
ctx->desc = (bcdesc_t*)desc;
ctx->blocksize_B = bcal_cipher_getBlocksize_b(desc)/8;
@ -87,14 +87,14 @@ uint8_t bcal_cmac_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b
return 0;
}
void bcal_cmac_free(bcal_cmac_ctx_t* ctx){
void bcal_cmac_free(bcal_cmac_ctx_t *ctx){
free(ctx->accu);
free(ctx->k1);
free(ctx->k2);
bcal_cipher_free(&(ctx->cctx));
}
void bcal_cmac_nextBlock (bcal_cmac_ctx_t* ctx, const void* block){
void bcal_cmac_nextBlock (bcal_cmac_ctx_t *ctx, const void *block){
if(ctx->last_set){
memxor(ctx->accu, ctx->lastblock, ctx->blocksize_B);
bcal_cipher_enc(ctx->accu, &(ctx->cctx));
@ -104,7 +104,7 @@ void bcal_cmac_nextBlock (bcal_cmac_ctx_t* ctx, const void* block){
}
void bcal_cmac_lastBlock(bcal_cmac_ctx_t* ctx, const void* block, uint16_t length_b){
void bcal_cmac_lastBlock(bcal_cmac_ctx_t *ctx, const void *block, uint16_t length_b){
uint16_t blocksize_b;
blocksize_b = ctx->blocksize_B*8;
while(length_b>=blocksize_b){
@ -131,7 +131,7 @@ void bcal_cmac_lastBlock(bcal_cmac_ctx_t* ctx, const void* block, uint16_t lengt
bcal_cipher_enc(ctx->accu, &(ctx->cctx));
}
void bcal_cmac_ctx2mac(void* dest, uint16_t length_b, const bcal_cmac_ctx_t* ctx){
void bcal_cmac_ctx2mac(void *dest, uint16_t length_b, const bcal_cmac_ctx_t *ctx){
memcpy(dest, ctx->accu, length_b/8);
if(length_b&7){
((uint8_t*)dest)[length_b/8] &= 0xff>>(length_b&7);
@ -139,7 +139,7 @@ void bcal_cmac_ctx2mac(void* dest, uint16_t length_b, const bcal_cmac_ctx_t* ctx
}
}
void bcal_cmac(void* dest, uint16_t out_length_b, const void* block, uint32_t length_b, bcal_cmac_ctx_t* ctx){
void bcal_cmac(void *dest, uint16_t out_length_b, const void *block, uint32_t length_b, bcal_cmac_ctx_t *ctx){
uint16_t blocksize_b;
blocksize_b = ctx->blocksize_B*8;
while(length_b>blocksize_b){

12
bcal/bcal-cmac.h

@ -35,11 +35,11 @@ typedef struct{
uint8_t blocksize_B;
} bcal_cmac_ctx_t;
uint8_t bcal_cmac_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b, bcal_cmac_ctx_t* ctx);
void bcal_cmac_free(bcal_cmac_ctx_t* ctx);
void bcal_cmac_nextBlock(bcal_cmac_ctx_t* ctx, const void* block);
void bcal_cmac_lastBlock(bcal_cmac_ctx_t* ctx, const void* block, uint16_t length_b);
void bcal_cmac_ctx2mac(void* dest, uint16_t length_b, const bcal_cmac_ctx_t* ctx);
void bcal_cmac(void* dest, uint16_t out_length_b, const void* block, uint32_t length_b, bcal_cmac_ctx_t* ctx);
uint8_t bcal_cmac_init(const bcdesc_t *desc, const void *key, uint16_t keysize_b, bcal_cmac_ctx_t *ctx);
void bcal_cmac_free(bcal_cmac_ctx_t *ctx);
void bcal_cmac_nextBlock(bcal_cmac_ctx_t *ctx, const void *block);
void bcal_cmac_lastBlock(bcal_cmac_ctx_t *ctx, const void *block, uint16_t length_b);
void bcal_cmac_ctx2mac(void *dest, uint16_t length_b, const bcal_cmac_ctx_t *ctx);
void bcal_cmac(void *dest, uint16_t out_length_b, const void *block, uint32_t length_b, bcal_cmac_ctx_t *ctx);
#endif /* BCALCMAC_H_ */

16
bcal/bcal-ctr.c

@ -24,7 +24,7 @@
#include "bcal-ctr.h"
#include "memxor.h"
static void increment_be(void* block, uint8_t size_B){
static void increment_be(void *block, uint8_t size_B){
uint16_t c=1;
do{
--size_B;
@ -34,7 +34,7 @@ static void increment_be(void* block, uint8_t size_B){
}while(size_B);
}
uint8_t bcal_ctr_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b, inc_fp_t inc_func, bcal_ctr_ctx_t* ctx){
uint8_t bcal_ctr_init(const bcdesc_t *desc, const void *key, uint16_t keysize_b, inc_fp_t inc_func, bcal_ctr_ctx_t *ctx){
ctx->desc = (bcdesc_t*)desc;
if(inc_func){
ctx->inc_func = inc_func;
@ -49,18 +49,18 @@ uint8_t bcal_ctr_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b,
return bcal_cipher_init(desc, key, keysize_b, &(ctx->cctx));
}
void bcal_ctr_free(bcal_ctr_ctx_t* ctx){
void bcal_ctr_free(bcal_ctr_ctx_t *ctx){
free(ctx->in_block);
bcal_cipher_free(&(ctx->cctx));
}
void bcal_ctr_loadIV(const void* iv, bcal_ctr_ctx_t* ctx){
void bcal_ctr_loadIV(const void *iv, bcal_ctr_ctx_t *ctx){
if(iv){
memcpy(ctx->in_block, iv, ctx->blocksize_B);
}
}
void bcal_ctr_encNext(void* block, bcal_ctr_ctx_t* ctx){
void bcal_ctr_encNext(void *block, bcal_ctr_ctx_t *ctx){
uint8_t tmp[ctx->blocksize_B];
memcpy(tmp, ctx->in_block, ctx->blocksize_B);
bcal_cipher_enc(tmp, &(ctx->cctx));
@ -68,11 +68,11 @@ void bcal_ctr_encNext(void* block, bcal_ctr_ctx_t* ctx){
ctx->inc_func(ctx->in_block, ctx->blocksize_B);
}
void bcal_ctr_decNext(void* block, bcal_ctr_ctx_t* ctx){
void bcal_ctr_decNext(void *block, bcal_ctr_ctx_t *ctx){
bcal_ctr_encNext(block, ctx);
}
void bcal_ctr_encMsg(const void* iv, void* msg, uint32_t msg_len_b, bcal_ctr_ctx_t* ctx){
void bcal_ctr_encMsg(const void *iv, void *msg, uint32_t msg_len_b, bcal_ctr_ctx_t *ctx){
bcal_ctr_loadIV(iv, ctx);
uint16_t blocksize_b;
blocksize_b = ctx->blocksize_B*8;
@ -89,7 +89,7 @@ void bcal_ctr_encMsg(const void* iv, void* msg, uint32_t msg_len_b, bcal_ctr_ctx
memxor(msg, tmp, (msg_len_b+7)/8);
}
void bcal_ctr_decMsg(const void* iv, void* msg, uint32_t msg_len_b, bcal_ctr_ctx_t* ctx){
void bcal_ctr_decMsg(const void *iv, void *msg, uint32_t msg_len_b, bcal_ctr_ctx_t *ctx){
bcal_ctr_encMsg(iv, msg, msg_len_b, ctx);
}

16
bcal/bcal-ctr.h

@ -24,7 +24,7 @@
#include "bcal-basic.h"
#include "blockcipher_descriptor.h"
typedef void(*inc_fp_t)(void* block, uint8_t size_B);
typedef void(*inc_fp_t)(void *block, uint8_t size_B);
typedef struct{
bcdesc_t* desc;
@ -34,12 +34,12 @@ typedef struct{
uint8_t blocksize_B;
} bcal_ctr_ctx_t;
uint8_t bcal_ctr_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b, inc_fp_t inc_func, bcal_ctr_ctx_t* ctx);
void bcal_ctr_free(bcal_ctr_ctx_t* ctx);
void bcal_ctr_loadIV(const void* iv, bcal_ctr_ctx_t* ctx);
void bcal_ctr_encNext(void* block, bcal_ctr_ctx_t* ctx);
void bcal_ctr_decNext(void* block, bcal_ctr_ctx_t* ctx);
void bcal_ctr_encMsg(const void* iv, void* msg, uint32_t msg_len_b, bcal_ctr_ctx_t* ctx);
void bcal_ctr_decMsg(const void* iv, void* msg, uint32_t msg_len_b, bcal_ctr_ctx_t* ctx);
uint8_t bcal_ctr_init(const bcdesc_t *desc, const void *key, uint16_t keysize_b, inc_fp_t inc_func, bcal_ctr_ctx_t *ctx);
void bcal_ctr_free(bcal_ctr_ctx_t *ctx);
void bcal_ctr_loadIV(const void *iv, bcal_ctr_ctx_t *ctx);
void bcal_ctr_encNext(void *block, bcal_ctr_ctx_t *ctx);
void bcal_ctr_decNext(void *block, bcal_ctr_ctx_t *ctx);
void bcal_ctr_encMsg(const void *iv, void *msg, uint32_t msg_len_b, bcal_ctr_ctx_t *ctx);
void bcal_ctr_decMsg(const void *iv, void *msg, uint32_t msg_len_b, bcal_ctr_ctx_t *ctx);
#endif /* BCALCTR_H_ */

20
bcal/bcal-eax.c

@ -26,7 +26,7 @@
#include "bcal-eax.h"
#include "memxor.h"
uint8_t bcal_eax_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b, bcal_eax_ctx_t* ctx){
uint8_t bcal_eax_init(const bcdesc_t *desc, const void *key, uint16_t keysize_b, bcal_eax_ctx_t *ctx){
uint8_t r;
ctx->blocksize_B = (bcal_cipher_getBlocksize_b(desc)+7)/8;
ctx->nonce = malloc(ctx->blocksize_B);
@ -60,7 +60,7 @@ uint8_t bcal_eax_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b,
return 0;
}
void bcal_eax_free(bcal_eax_ctx_t* ctx){
void bcal_eax_free(bcal_eax_ctx_t *ctx){
bcal_ctr_free(&(ctx->cipher));
bcal_cmac_free(&(ctx->ctag));
bcal_cmac_free(&(ctx->htag));
@ -68,42 +68,42 @@ void bcal_eax_free(bcal_eax_ctx_t* ctx){
free(ctx->nonce);
}
void bcal_eax_loadNonce(const void* nonce, uint16_t length_b, bcal_eax_ctx_t* ctx){
void bcal_eax_loadNonce(const void *nonce, uint16_t length_b, bcal_eax_ctx_t *ctx){
bcal_cmac_lastBlock(&(ctx->ntag), nonce, length_b);
bcal_cmac_ctx2mac(ctx->nonce, ctx->blocksize_B*8, &(ctx->ntag));
bcal_ctr_loadIV(ctx->nonce, &(ctx->cipher));
}
void bcal_eax_addNextHeader(const void* header, bcal_eax_ctx_t* ctx){
void bcal_eax_addNextHeader(const void *header, bcal_eax_ctx_t *ctx){
bcal_cmac_nextBlock(&(ctx->htag), header);
}
void bcal_eax_addLastHeader(const void* header, uint16_t length_b, bcal_eax_ctx_t* ctx){
void bcal_eax_addLastHeader(const void *header, uint16_t length_b, bcal_eax_ctx_t *ctx){
bcal_cmac_lastBlock(&(ctx->htag), header, length_b);
ctx->header_set = 1;
}
void bcal_eax_encNextBlock(void* block, bcal_eax_ctx_t* ctx){
void bcal_eax_encNextBlock(void *block, bcal_eax_ctx_t *ctx){
bcal_ctr_encNext(block, &(ctx->cipher));
bcal_cmac_nextBlock(&(ctx->ctag), block);
}
void bcal_eax_encLastBlock(void* block, uint16_t length_b, bcal_eax_ctx_t* ctx){
void bcal_eax_encLastBlock(void *block, uint16_t length_b, bcal_eax_ctx_t *ctx){
bcal_ctr_encMsg(NULL, block, length_b, &(ctx->cipher));
bcal_cmac_lastBlock(&(ctx->ctag), block, length_b);
}
void bcal_eax_decNextBlock(void* block, bcal_eax_ctx_t* ctx){
void bcal_eax_decNextBlock(void *block, bcal_eax_ctx_t *ctx){
bcal_cmac_nextBlock(&(ctx->ctag), block);
bcal_ctr_decNext(block, &(ctx->cipher));
}
void bcal_eax_decLastBlock(void* block, uint16_t length_b, bcal_eax_ctx_t* ctx){
void bcal_eax_decLastBlock(void *block, uint16_t length_b, bcal_eax_ctx_t *ctx){
bcal_cmac_lastBlock(&(ctx->ctag), block, length_b);
bcal_ctr_decMsg(NULL, block, length_b, &(ctx->cipher));
}
void bcal_eax_ctx2tag(void* dest, uint16_t length_b, bcal_eax_ctx_t* ctx){
void bcal_eax_ctx2tag(void *dest, uint16_t length_b, bcal_eax_ctx_t *ctx){
uint8_t tmp[ctx->blocksize_B];
if(ctx->header_set==0){
bcal_cmac_lastBlock(&(ctx->htag), NULL, 0);

22
bcal/bcal-eax.h

@ -37,17 +37,17 @@ typedef struct{
uint8_t header_set;
} bcal_eax_ctx_t;
uint8_t bcal_eax_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b, bcal_eax_ctx_t* ctx);
void bcal_eax_free(bcal_eax_ctx_t* ctx);
void bcal_eax_loadNonce(const void* nonce, uint16_t length_b, bcal_eax_ctx_t* ctx);
void bcal_eax_addNextHeader(const void* header, bcal_eax_ctx_t* ctx);
void bcal_eax_addLastHeader(const void* header, uint16_t length_b, bcal_eax_ctx_t* ctx);
void bcal_eax_encNextBlock(void* block, bcal_eax_ctx_t* ctx);
void bcal_eax_encLastBlock(void* block, uint16_t length_b, bcal_eax_ctx_t* ctx);
void bcal_eax_decNextBlock(void* block, bcal_eax_ctx_t* ctx);
void bcal_eax_decLastBlock(void* block, uint16_t length_b, bcal_eax_ctx_t* ctx);
void bcal_eax_ctx2tag(void* dest, uint16_t length_b, bcal_eax_ctx_t* ctx);
//void bcal_eax(void* dest, uint16_t out_length_b, const void* block, uint32_t length_b, bcal_eax_ctx_t* ctx);
uint8_t bcal_eax_init(const bcdesc_t *desc, const void *key, uint16_t keysize_b, bcal_eax_ctx_t *ctx);
void bcal_eax_free(bcal_eax_ctx_t *ctx);
void bcal_eax_loadNonce(const void *nonce, uint16_t length_b, bcal_eax_ctx_t *ctx);
void bcal_eax_addNextHeader(const void *header, bcal_eax_ctx_t *ctx);
void bcal_eax_addLastHeader(const void *header, uint16_t length_b, bcal_eax_ctx_t *ctx);
void bcal_eax_encNextBlock(void *block, bcal_eax_ctx_t *ctx);
void bcal_eax_encLastBlock(void *block, uint16_t length_b, bcal_eax_ctx_t *ctx);
void bcal_eax_decNextBlock(void *block, bcal_eax_ctx_t *ctx);
void bcal_eax_decLastBlock(void *block, uint16_t length_b, bcal_eax_ctx_t *ctx);
void bcal_eax_ctx2tag(void *dest, uint16_t length_b, bcal_eax_ctx_t *ctx);
//void bcal_eax(void *dest, uint16_t out_length_b, const void *block, uint32_t length_b, bcal_eax_ctx_t *ctx);
#endif /* BCALEAX_H_ */

10
bcal/bcal-nessie.c

@ -26,9 +26,9 @@
#include <avr/pgmspace.h>
void(*bcal_nessie_dummy_init_fpt)(const void* key, void* ctx)=NULL;
void(*bcal_nessie_dummy_init_fpt)(const void *key, void *ctx)=NULL;
void bcal_nessie_dummy_init(const void* key, uint16_t keysize, void* ctx){
void bcal_nessie_dummy_init(const void *key, uint16_t keysize, void *ctx){
if(bcal_nessie_dummy_init_fpt){
bcal_nessie_dummy_init_fpt(key, ctx);
}else{
@ -36,7 +36,7 @@ void bcal_nessie_dummy_init(const void* key, uint16_t keysize, void* ctx){
}
}
void bcal_nessie(const bcdesc_t* bcd){
void bcal_nessie(const bcdesc_t *bcd){
if(pgm_read_byte(&(bcd->type))!=BCDESC_TYPE_BLOCKCIPHER)
return;
char name[1+strlen_P((void*)pgm_read_word(&(bcd->name)))];
@ -69,8 +69,8 @@ void bcal_nessie(const bcdesc_t* bcd){
}
void bcal_nessie_multiple(const bcdesc_t* const* bcd_list){
const bcdesc_t* bcd;
void bcal_nessie_multiple(const bcdesc_t *const *bcd_list){
const bcdesc_t *bcd;
for(;;){
bcd = (void*)pgm_read_word(bcd_list);
if(!bcd)

4
bcal/bcal-nessie.h

@ -30,8 +30,8 @@
#include "blockcipher_descriptor.h"
void bcal_nessie(const bcdesc_t* bcd);
void bcal_nessie_multiple(const bcdesc_t* const* bcd_list);
void bcal_nessie(const bcdesc_t *bcd);
void bcal_nessie_multiple(const bcdesc_t *const *bcd_list);
#endif /* BCALNESSIE_H_ */

14
bcal/bcal-ofb.c

@ -24,7 +24,7 @@
#include "memxor.h"
uint8_t bcal_ofb_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b, bcal_ofb_ctx_t* ctx){
uint8_t bcal_ofb_init(const bcdesc_t *desc, const void *key, uint16_t keysize_b, bcal_ofb_ctx_t *ctx){
ctx->desc = (bcdesc_t*)desc;
ctx->blocksize_B = (bcal_cipher_getBlocksize_b(desc)+7)/8;
ctx->in_block=malloc(ctx->blocksize_B);
@ -34,29 +34,29 @@ uint8_t bcal_ofb_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b,
return bcal_cipher_init(desc, key, keysize_b, &(ctx->cctx));
}
void bcal_ofb_free(bcal_ofb_ctx_t* ctx){
void bcal_ofb_free(bcal_ofb_ctx_t *ctx){
free(ctx->in_block);
bcal_cipher_free(&(ctx->cctx));
}
void bcal_ofb_loadIV(const void* iv, bcal_ofb_ctx_t* ctx){
void bcal_ofb_loadIV(const void *iv, bcal_ofb_ctx_t *ctx){
if(iv){
memcpy(ctx->in_block, iv, ctx->blocksize_B);
}
}
void bcal_ofb_encNext(void* block, bcal_ofb_ctx_t* ctx){
void bcal_ofb_encNext(void *block, bcal_ofb_ctx_t *ctx){
bcal_cipher_enc(ctx->in_block , &(ctx->cctx));
memxor(block, ctx->in_block, ctx->blocksize_B);
}
void bcal_ofb_decNext(void* block, bcal_ofb_ctx_t* ctx){
void bcal_ofb_decNext(void *block, bcal_ofb_ctx_t *ctx){
bcal_cipher_enc(ctx->in_block , &(ctx->cctx));
memxor(block, ctx->in_block, ctx->blocksize_B);
}