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

This commit is contained in:
bg 2013-02-17 10:44:36 +01:00
parent 33d65e8032
commit 3a9f9d918f
393 changed files with 1878 additions and 1878 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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){

View File

@ -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

View File

@ -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

View File

@ -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];

View File

@ -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

View File

@ -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];

View File

@ -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);
}

View File

@ -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_ */

View File

@ -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;

View File

@ -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_*/

View File

@ -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){

View File

@ -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_*/

View File

@ -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));
}

View File

@ -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_ */

View File

@ -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);

View File

@ -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_ */

View File

@ -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;

View File

@ -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_ */

View File

@ -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);

View File

@ -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_ */

View File

@ -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){

View File

@ -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_ */

View File

@ -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);
}

View File

@ -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_ */

View File

@ -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);

View File

@ -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_ */

View File

@ -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)

View File

@ -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_ */

View File

@ -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);
}
void bcal_ofb_encMsg(const void* iv, void* msg, uint32_t msg_len_b, bcal_ofb_ctx_t* ctx){
void bcal_ofb_encMsg(const void *iv, void *msg, uint32_t msg_len_b, bcal_ofb_ctx_t *ctx){
uint16_t block_len_b;
block_len_b = ctx->blocksize_B*8;
bcal_ofb_loadIV(iv, ctx);
@ -70,7 +70,7 @@ void bcal_ofb_encMsg(const void* iv, void* msg, uint32_t msg_len_b, bcal_ofb_ctx
memxor(msg, ctx->in_block, (msg_len_b+7)/8);
}
void bcal_ofb_decMsg(const void* iv, void* msg, uint32_t msg_len_b, bcal_ofb_ctx_t* ctx){
void bcal_ofb_decMsg(const void *iv, void *msg, uint32_t msg_len_b, bcal_ofb_ctx_t *ctx){
bcal_ofb_encMsg(iv, msg, msg_len_b, ctx);
}

View File

@ -34,13 +34,13 @@ typedef struct{
} bcal_ofb_ctx_t;
uint8_t bcal_ofb_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b, bcal_ofb_ctx_t* ctx);
void bcal_ofb_free(bcal_ofb_ctx_t* ctx);
void bcal_ofb_loadIV(const void* iv, bcal_ofb_ctx_t* ctx);
void bcal_ofb_encNext(void* block, bcal_ofb_ctx_t* ctx);
void bcal_ofb_decNext(void* block, bcal_ofb_ctx_t* ctx);
void bcal_ofb_encMsg(const void* iv, void* msg, uint32_t msg_len_b, bcal_ofb_ctx_t* ctx);
void bcal_ofb_decMsg(const void* iv, void* msg, uint32_t msg_len_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);
void bcal_ofb_free(bcal_ofb_ctx_t *ctx);
void bcal_ofb_loadIV(const void *iv, bcal_ofb_ctx_t *ctx);
void bcal_ofb_encNext(void *block, bcal_ofb_ctx_t *ctx);
void bcal_ofb_decNext(void *block, bcal_ofb_ctx_t *ctx);
void bcal_ofb_encMsg(const void *iv, void *msg, uint32_t msg_len_b, bcal_ofb_ctx_t *ctx);
void bcal_ofb_decMsg(const void *iv, void *msg, uint32_t msg_len_b, bcal_ofb_ctx_t *ctx);
#endif /* BCALOFB_H_ */

View File

@ -55,7 +55,7 @@ void printvalue(unsigned long v){
}
*/
void bcal_performance(const bcdesc_t* bcd){
void bcal_performance(const bcdesc_t *bcd){
bcdesc_t bc;
memcpy_P(&bc, bcd, sizeof(bcdesc_t));
uint8_t ctx[bc.ctxsize_B];
@ -136,7 +136,7 @@ void bcal_performance(const bcdesc_t* bcd){
}
}
void bcal_stacksize(const bcdesc_t* bcd){
void bcal_stacksize(const bcdesc_t *bcd){
bcdesc_t bc;
stack_measuring_ctx_t smctx;
memcpy_P(&bc, bcd, sizeof(bcdesc_t));
@ -205,8 +205,8 @@ void bcal_stacksize(const bcdesc_t* bcd){
}
}
void bcal_performance_multiple(const bcdesc_t* const* bcd_list){
const bcdesc_t* bcd;
void bcal_performance_multiple(const bcdesc_t *const *bcd_list){
const bcdesc_t *bcd;
for(;;){
bcd = (void*)pgm_read_word(bcd_list);
if(!bcd){

View File

@ -31,8 +31,8 @@
#include "blockcipher_descriptor.h"
void bcal_performance(const bcdesc_t* hd);
void bcal_performance_multiple(const bcdesc_t* const* hd_list);
void bcal_performance(const bcdesc_t *hd);
void bcal_performance_multiple(const bcdesc_t *const *hd_list);
#endif /* BCAL_PERFORMANCE_H_ */

View File

@ -36,12 +36,12 @@ const char des_str[] PROGMEM = "DES";
const uint8_t des_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(64),
KS_TYPE_TERMINATOR };
static
void des_dummy_enc(void* block, void* key){
void des_dummy_enc(void *block, void *key){
des_enc(block, block, key);
}
static
void des_dummy_dec(void* block, void* key){
void des_dummy_dec(void *block, void *key){
des_dec(block, block, key);
}

View File

@ -39,7 +39,7 @@ const uint8_t rc5_keysize_desc[] PROGMEM = { KS_TYPE_RANGE, KS_INT(1), KS_INT(20
KS_TYPE_TERMINATOR };
static
void rc5_dummy_init(void* key, uint16_t keysize_b, void* ctx){
void rc5_dummy_init(void *key, uint16_t keysize_b, void *ctx){
rc5_init(key, keysize_b, RC5_ROUNDS, ctx);
}

View File

@ -37,12 +37,12 @@ const uint8_t tdes_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(192),
KS_TYPE_TERMINATOR };
static
void tdes_dummy_enc(void* block, void* key){
void tdes_dummy_enc(void *block, void *key){
tdes_enc(block, block, key);
}
static
void tdes_dummy_dec(void* block, void* key){
void tdes_dummy_dec(void *block, void *key){
tdes_dec(block, block, key);
}

View File

@ -38,17 +38,17 @@ const uint8_t tdes2_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(128),
KS_TYPE_TERMINATOR };
static
void tdes_dummy_enc(void* block, void* key){
void tdes_dummy_enc(void *block, void *key){
tdes_enc(block, block, key);
}
static
void tdes_dummy_dec(void* block, void* key){
void tdes_dummy_dec(void *block, void *key){
tdes_dec(block, block, key);
}
static
void tdes2_init(void* key, void* ctx){
void tdes2_init(void *key, void *ctx){
memcpy(ctx, key, 16);
memcpy((uint8_t*)ctx+16, key, 8);
}

View File

@ -36,7 +36,7 @@ const char threefish1024_str[] PROGMEM = "Threefish-1024";
const uint8_t threefish1024_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(1024),
KS_TYPE_TERMINATOR };
static void threefish1024_dummy_init(void* key, void* ctx){
static void threefish1024_dummy_init(void *key, void *ctx){
threefish1024_init(key, NULL, ctx);
}

View File

@ -36,7 +36,7 @@ const char threefish256_str[] PROGMEM = "Threefish-256";
const uint8_t threefish256_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(256),
KS_TYPE_TERMINATOR };
static void threefish256_dummy_init(void* key, void* ctx){
static void threefish256_dummy_init(void *key, void *ctx){
threefish256_init(key, NULL, ctx);
}

View File

@ -36,7 +36,7 @@ const char threefish512_str[] PROGMEM = "Threefish-512";
const uint8_t threefish512_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(512),
KS_TYPE_TERMINATOR };
static void threefish512_dummy_init(void* key, void* ctx){
static void threefish512_dummy_init(void *key, void *ctx){
threefish512_init(key, NULL, ctx);
}

View File

@ -37,12 +37,12 @@ const uint8_t xtea_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(128),
KS_TYPE_TERMINATOR };
static
void xtea_dummy_enc(void* block, void* key){
void xtea_dummy_enc(void *block, void *key){
xtea_enc(block, block, key);
}
static
void xtea_dummy_dec(void* block, void* key){
void xtea_dummy_dec(void *block, void *key){
xtea_dec(block, block, key);
}

View File

@ -58,7 +58,7 @@
/******************************************************************************/
/*
void bigint_copy(bigint_t* dest, const bigint_t* src){
void bigint_copy(bigint_t *dest, const bigint_t *src){
memcpy(dest->wordv, src->wordv, src->length_W);
dest->length_W = src->length_W;
dest->info = src->info;
@ -68,7 +68,7 @@ void bigint_copy(bigint_t* dest, const bigint_t* src){
/* this should be implemented in assembly */
/*
void bigint_add_u(bigint_t* dest, const bigint_t* a, const bigint_t* b){
void bigint_add_u(bigint_t *dest, const bigint_t *a, const bigint_t *b){
uint16_t t=0, i;
if(a->length_W < b->length_W){
XCHG_PTR(a,b);
@ -92,7 +92,7 @@ void bigint_add_u(bigint_t* dest, const bigint_t* a, const bigint_t* b){
/* this should be implemented in assembly */
/*
void bigint_add_scale_u(bigint_t* dest, const bigint_t* a, uint16_t scale){
void bigint_add_scale_u(bigint_t *dest, const bigint_t *a, uint16_t scale){
uint16_t i,j=0;
uint16_t t=0;
if(scale>dest->length_W)
@ -122,7 +122,7 @@ void bigint_add_scale_u(bigint_t* dest, const bigint_t* a, uint16_t scale){
/******************************************************************************/
/* this should be implemented in assembly */
void bigint_sub_u(bigint_t* dest, const bigint_t* a, const bigint_t* b){
void bigint_sub_u(bigint_t *dest, const bigint_t *a, const bigint_t *b){
int8_t borrow=0;
int8_t r;
int16_t t;
@ -183,7 +183,7 @@ void bigint_sub_u(bigint_t* dest, const bigint_t* a, const bigint_t* b){
/******************************************************************************/
int8_t bigint_cmp_u(const bigint_t* a, const bigint_t* b){
int8_t bigint_cmp_u(const bigint_t *a, const bigint_t *b){
if(a->length_W > b->length_W){
return 1;
}
@ -209,7 +209,7 @@ int8_t bigint_cmp_u(const bigint_t* a, const bigint_t* b){
/******************************************************************************/
void bigint_add_s(bigint_t* dest, const bigint_t* a, const bigint_t* b){
void bigint_add_s(bigint_t *dest, const bigint_t *a, const bigint_t *b){
uint8_t s;
s = GET_SIGN(a)?2:0;
s |= GET_SIGN(b)?1:0;
@ -235,7 +235,7 @@ void bigint_add_s(bigint_t* dest, const bigint_t* a, const bigint_t* b){
/******************************************************************************/
void bigint_sub_s(bigint_t* dest, const bigint_t* a, const bigint_t* b){
void bigint_sub_s(bigint_t *dest, const bigint_t *a, const bigint_t *b){
uint8_t s;
s = GET_SIGN(a)?2:0;
s |= GET_SIGN(b)?1:0;
@ -262,7 +262,7 @@ void bigint_sub_s(bigint_t* dest, const bigint_t* a, const bigint_t* b){
/******************************************************************************/
int8_t bigint_cmp_s(const bigint_t* a, const bigint_t* b){
int8_t bigint_cmp_s(const bigint_t *a, const bigint_t *b){
uint8_t s;
if(a->length_W==0 && b->length_W==0){
return 0;
@ -290,7 +290,7 @@ int8_t bigint_cmp_s(const bigint_t* a, const bigint_t* b){
/******************************************************************************/
void bigint_shiftleft(bigint_t* a, uint16_t shift){
void bigint_shiftleft(bigint_t *a, uint16_t shift){
uint16_t byteshift;
uint16_t i;
uint8_t bitshift;
@ -324,7 +324,7 @@ void bigint_shiftleft(bigint_t* a, uint16_t shift){
/******************************************************************************/
void bigint_shiftright(bigint_t* a, uint16_t shift){
void bigint_shiftright(bigint_t *a, uint16_t shift){
uint16_t byteshift;
uint16_t i;
uint8_t bitshift;
@ -359,7 +359,7 @@ void bigint_shiftright(bigint_t* a, uint16_t shift){
/******************************************************************************/
void bigint_xor(bigint_t* dest, const bigint_t* a){
void bigint_xor(bigint_t *dest, const bigint_t *a){
uint16_t i;
for(i=0; i<a->length_W; ++i){
dest->wordv[i] ^= a->wordv[i];
@ -369,7 +369,7 @@ void bigint_xor(bigint_t* dest, const bigint_t* a){
/******************************************************************************/
void bigint_set_zero(bigint_t* a){
void bigint_set_zero(bigint_t *a){
a->length_W=0;
}
@ -377,7 +377,7 @@ void bigint_set_zero(bigint_t* a){
/* using the Karatsuba-Algorithm */
/* x*y = (xh*yh)*b**2n + ((xh+xl)*(yh+yl) - xh*yh - xl*yl)*b**n + yh*yl */
void bigint_mul_u(bigint_t* dest, const bigint_t* a, const bigint_t* b){
void bigint_mul_u(bigint_t *dest, const bigint_t *a, const bigint_t *b){
if(a->length_W==0 || b->length_W==0){
bigint_set_zero(dest);
return;
@ -470,7 +470,7 @@ void bigint_mul_u(bigint_t* dest, const bigint_t* a, const bigint_t* b){
/******************************************************************************/
void bigint_mul_s(bigint_t* dest, const bigint_t* a, const bigint_t* b){
void bigint_mul_s(bigint_t *dest, const bigint_t *a, const bigint_t *b){
uint8_t s;
s = GET_SIGN(a)?2:0;
s |= GET_SIGN(b)?1:0;
@ -500,7 +500,7 @@ void bigint_mul_s(bigint_t* dest, const bigint_t* a, const bigint_t* b){
/* square */
/* (xh*b^n+xl)^2 = xh^2*b^2n + 2*xh*xl*b^n + xl^2 */
void bigint_square(bigint_t* dest, const bigint_t* a){
void bigint_square(bigint_t *dest, const bigint_t *a){
if(a->length_W<=4){
uint64_t r=0;
memcpy(&r, a->wordv, a->length_W);
@ -538,7 +538,7 @@ void bigint_square(bigint_t* dest, const bigint_t* a){
/******************************************************************************/
void bigint_sub_u_bitscale(bigint_t* a, const bigint_t* b, uint16_t bitscale){
void bigint_sub_u_bitscale(bigint_t *a, const bigint_t *b, uint16_t bitscale){
bigint_t tmp;
uint8_t tmp_b[b->length_W+1];
uint16_t i,j,byteshift=bitscale/8;
@ -579,7 +579,7 @@ void bigint_sub_u_bitscale(bigint_t* a, const bigint_t* b, uint16_t bitscale){
/******************************************************************************/
void bigint_reduce(bigint_t* a, const bigint_t* r){
void bigint_reduce(bigint_t *a, const bigint_t *r){
// bigint_adjust(r);
uint8_t rfbs = GET_FBS(r);
@ -602,7 +602,7 @@ void bigint_reduce(bigint_t* a, const bigint_t* r){
/* calculate dest = a**exp % r */
/* using square&multiply */
void bigint_expmod_u(bigint_t* dest, const bigint_t* a, const bigint_t* exp, const bigint_t* r){
void bigint_expmod_u(bigint_t *dest, const bigint_t *a, const bigint_t *exp, const bigint_t *r){
if(a->length_W==0 || r->length_W==0){
return;
}
@ -647,7 +647,7 @@ void bigint_expmod_u(bigint_t* dest, const bigint_t* a, const bigint_t* exp, con
/******************************************************************************/
/* gcd <-- gcd(x,y) a*x+b*y=gcd */
void bigint_gcdext(bigint_t* gcd, bigint_t* a, bigint_t* b, const bigint_t* x, const bigint_t* y){
void bigint_gcdext(bigint_t *gcd, bigint_t *a, bigint_t *b, const bigint_t *x, const bigint_t *y){
bigint_t g, x_, y_, u, v, a_, b_, c_, d_;
volatile uint16_t i=0;
if(x->length_W==0 || y->length_W==0){
@ -744,7 +744,7 @@ void bigint_gcdext(bigint_t* gcd, bigint_t* a, bigint_t* b, const bigint_t* x, c
/******************************************************************************/
void bigint_inverse(bigint_t* dest, const bigint_t* a, const bigint_t* m){
void bigint_inverse(bigint_t *dest, const bigint_t *a, const bigint_t *m){
bigint_gcdext(NULL, dest, NULL, a, m);
while(dest->info&BIGINT_NEG_MASK){
bigint_add_s(dest, dest, m);
@ -753,7 +753,7 @@ void bigint_inverse(bigint_t* dest, const bigint_t* a, const bigint_t* m){
/******************************************************************************/
void bigint_changeendianess(bigint_t* a){
void bigint_changeendianess(bigint_t *a){
uint8_t t, *p, *q;
p = a->wordv;
q = p+a->length_W-1;

View File

@ -61,7 +61,7 @@
#define GET_SIGN(a) ((a)->info&BIGINT_NEG_MASK)
/******************************************************************************/
void bigint_adjust(bigint_t* a){
void bigint_adjust(bigint_t *a){
while(a->length_W!=0 && a->wordv[a->length_W-1]==0){
a->length_W--;
}
@ -81,7 +81,7 @@ void bigint_adjust(bigint_t* a){
/******************************************************************************/
uint16_t bigint_length_b(const bigint_t* a){
uint16_t bigint_length_b(const bigint_t *a){
if(!a->length_W || a->length_W==0){
return 0;
}
@ -90,13 +90,13 @@ uint16_t bigint_length_b(const bigint_t* a){
/******************************************************************************/
uint16_t bigint_length_B(const bigint_t* a){
uint16_t bigint_length_B(const bigint_t *a){
return a->length_W * sizeof(bigint_word_t);
}
/******************************************************************************/
uint32_t bigint_get_first_set_bit(const bigint_t* a){
uint32_t bigint_get_first_set_bit(const bigint_t *a){
if(a->length_W==0){
return (uint32_t)(-1);
}
@ -106,7 +106,7 @@ uint32_t bigint_get_first_set_bit(const bigint_t* a){
/******************************************************************************/
uint32_t bigint_get_last_set_bit(const bigint_t* a){
uint32_t bigint_get_last_set_bit(const bigint_t *a){
uint32_t r=0;
uint8_t b=0;
bigint_word_t x=1;
@ -128,7 +128,7 @@ uint32_t bigint_get_last_set_bit(const bigint_t* a){
/******************************************************************************/
void bigint_copy(bigint_t* dest, const bigint_t* src){
void bigint_copy(bigint_t *dest, const bigint_t *src){
if(dest->wordv != src->wordv){
memcpy(dest->wordv, src->wordv, src->length_W * sizeof(bigint_word_t));
}
@ -139,7 +139,7 @@ void bigint_copy(bigint_t* dest, const bigint_t* src){
/******************************************************************************/
/* this should be implemented in assembly */
void bigint_add_u(bigint_t* dest, const bigint_t* a, const bigint_t* b){
void bigint_add_u(bigint_t *dest, const bigint_t *a, const bigint_t *b){
uint16_t i;
bigint_wordplus_t t = 0LL;
if(a->length_W < b->length_W){
@ -167,7 +167,7 @@ void bigint_add_u(bigint_t* dest, const bigint_t* a, const bigint_t* b){
/******************************************************************************/
/* this should be implemented in assembly */
void bigint_add_scale_u(bigint_t* dest, const bigint_t* a, uint16_t scale){
void bigint_add_scale_u(bigint_t *dest, const bigint_t *a, uint16_t scale){
if(a->length_W == 0){
return;
}
@ -218,7 +218,7 @@ void bigint_add_scale_u(bigint_t* dest, const bigint_t* a, uint16_t scale){
/******************************************************************************/
/* this should be implemented in assembly */
void bigint_sub_u(bigint_t* dest, const bigint_t* a, const bigint_t* b){
void bigint_sub_u(bigint_t *dest, const bigint_t *a, const bigint_t *b){
int8_t borrow=0;
int8_t r;
bigint_wordplus_signed_t t=0LL;
@ -263,7 +263,7 @@ void bigint_sub_u(bigint_t* dest, const bigint_t* a, const bigint_t* b){
/******************************************************************************/
int8_t bigint_cmp_u(const bigint_t* a, const bigint_t* b){
int8_t bigint_cmp_u(const bigint_t *a, const bigint_t *b){
if(a->length_W > b->length_W){
return 1;
}
@ -289,7 +289,7 @@ int8_t bigint_cmp_u(const bigint_t* a, const bigint_t* b){
/******************************************************************************/
void bigint_add_s(bigint_t* dest, const bigint_t* a, const bigint_t* b){
void bigint_add_s(bigint_t *dest, const bigint_t *a, const bigint_t *b){
uint8_t s;
s = GET_SIGN(a)?2:0;
s |= GET_SIGN(b)?1:0;
@ -315,7 +315,7 @@ void bigint_add_s(bigint_t* dest, const bigint_t* a, const bigint_t* b){
/******************************************************************************/
void bigint_sub_s(bigint_t* dest, const bigint_t* a, const bigint_t* b){
void bigint_sub_s(bigint_t *dest, const bigint_t *a, const bigint_t *b){
uint8_t s;
s = GET_SIGN(a)?2:0;
s |= GET_SIGN(b)?1:0;
@ -342,7 +342,7 @@ void bigint_sub_s(bigint_t* dest, const bigint_t* a, const bigint_t* b){
/******************************************************************************/
int8_t bigint_cmp_s(const bigint_t* a, const bigint_t* b){
int8_t bigint_cmp_s(const bigint_t *a, const bigint_t *b){
uint8_t s;
if(a->length_W==0 && b->length_W==0){
return 0;
@ -370,7 +370,7 @@ int8_t bigint_cmp_s(const bigint_t* a, const bigint_t* b){
/******************************************************************************/
void bigint_shiftleft(bigint_t* a, uint16_t shift){
void bigint_shiftleft(bigint_t *a, uint16_t shift){
uint16_t byteshift, words_to_shift;
int16_t i;
uint8_t bitshift;
@ -408,7 +408,7 @@ void bigint_shiftleft(bigint_t* a, uint16_t shift){
/******************************************************************************/
void bigint_shiftright(bigint_t* a, uint16_t shift){
void bigint_shiftright(bigint_t *a, uint16_t shift){
uint16_t byteshift;
uint16_t i;
uint8_t bitshift;
@ -445,7 +445,7 @@ void bigint_shiftright(bigint_t* a, uint16_t shift){
/******************************************************************************/
void bigint_xor(bigint_t* dest, const bigint_t* a){
void bigint_xor(bigint_t *dest, const bigint_t *a){
uint16_t i;
for(i=0; i<a->length_W; ++i){
dest->wordv[i] ^= a->wordv[i];
@ -455,7 +455,7 @@ void bigint_xor(bigint_t* dest, const bigint_t* a){
/******************************************************************************/
void bigint_set_zero(bigint_t* a){
void bigint_set_zero(bigint_t *a){
a->length_W=0;
}
@ -463,7 +463,7 @@ void bigint_set_zero(bigint_t* a){
/* using the Karatsuba-Algorithm */
/* x*y = (xh*yh)*b**2n + ((xh+xl)*(yh+yl) - xh*yh - xl*yl)*b**n + yh*yl */
void bigint_mul_u(bigint_t* dest, const bigint_t* a, const bigint_t* b){
void bigint_mul_u(bigint_t *dest, const bigint_t *a, const bigint_t *b){
if(a->length_W == 0 || b->length_W == 0){
bigint_set_zero(dest);
return;
@ -564,7 +564,7 @@ void bigint_mul_u(bigint_t* dest, const bigint_t* a, const bigint_t* b){
/******************************************************************************/
void bigint_mul_s(bigint_t* dest, const bigint_t* a, const bigint_t* b){
void bigint_mul_s(bigint_t *dest, const bigint_t *a, const bigint_t *b){
uint8_t s;
s = GET_SIGN(a)?2:0;
s |= GET_SIGN(b)?1:0;
@ -599,7 +599,7 @@ unsigned square_depth = 0;
/* square */
/* (xh*b^n+xl)^2 = xh^2*b^2n + 2*xh*xl*b^n + xl^2 */
void bigint_square(bigint_t* dest, const bigint_t* a){
void bigint_square(bigint_t *dest, const bigint_t *a){
if(a->length_W * sizeof(bigint_word_t) <= 4){
uint64_t r = 0;
memcpy(&r, a->wordv, a->length_W * sizeof(bigint_word_t));
@ -684,7 +684,7 @@ void bigint_square(bigint_t* dest, const bigint_t* a){
/******************************************************************************/
void bigint_sub_u_bitscale(bigint_t* a, const bigint_t* b, uint16_t bitscale){
void bigint_sub_u_bitscale(bigint_t *a, const bigint_t *b, uint16_t bitscale){
bigint_t tmp, x;
bigint_word_t tmp_b[b->length_W + 1];
const uint16_t word_shift = bitscale / BIGINT_WORD_SIZE;
@ -711,7 +711,7 @@ void bigint_sub_u_bitscale(bigint_t* a, const bigint_t* b, uint16_t bitscale){
/******************************************************************************/
void bigint_reduce(bigint_t* a, const bigint_t* r){
void bigint_reduce(bigint_t *a, const bigint_t *r){
// bigint_adjust((bigint_t*)r);
uint8_t rfbs = GET_FBS(r);
#if DEBUG
@ -772,7 +772,7 @@ void bigint_reduce(bigint_t* a, const bigint_t* r){
/* calculate dest = a**exp % r */
/* using square&multiply */
void bigint_expmod_u_sam(bigint_t* dest, const bigint_t* a, const bigint_t* exp, const bigint_t* r){
void bigint_expmod_u_sam(bigint_t *dest, const bigint_t *a, const bigint_t *exp, const bigint_t *r){
if(a->length_W==0 || r->length_W==0){
return;
}
@ -835,7 +835,7 @@ void bigint_expmod_u_sam(bigint_t* dest, const bigint_t* a, const bigint_t* exp,
#define printf_P(...)
#endif
/* gcd <-- gcd(x,y) a*x+b*y=gcd */
void bigint_gcdext(bigint_t* gcd, bigint_t* a, bigint_t* b, const bigint_t* x, const bigint_t* y){
void bigint_gcdext(bigint_t *gcd, bigint_t *a, bigint_t *b, const bigint_t *x, const bigint_t *y){
uint16_t i = 0;
printf_P(PSTR("\nDBG: gcdext( "));
bigint_print_hex(x);
@ -1009,7 +1009,7 @@ void bigint_gcdext(bigint_t* gcd, bigint_t* a, bigint_t* b, const bigint_t* x, c
/******************************************************************************/
void bigint_inverse(bigint_t* dest, const bigint_t* a, const bigint_t* m){
void bigint_inverse(bigint_t *dest, const bigint_t *a, const bigint_t *m){
bigint_gcdext(NULL, dest, NULL, a, m);
while(dest->info&BIGINT_NEG_MASK){
bigint_add_s(dest, dest, m);
@ -1018,7 +1018,7 @@ void bigint_inverse(bigint_t* dest, const bigint_t* a, const bigint_t* m){
/******************************************************************************/
void bigint_changeendianess(bigint_t* a){
void bigint_changeendianess(bigint_t *a){
uint8_t t, *p, *q;
p = (uint8_t*)(a->wordv);
q = p + a->length_W * sizeof(bigint_word_t) - 1;
@ -1037,7 +1037,7 @@ void bigint_changeendianess(bigint_t* a){
/******************************************************************************/
void bigint_expmod_u(bigint_t* dest, const bigint_t* a, const bigint_t* exp, const bigint_t* r){
void bigint_expmod_u(bigint_t *dest, const bigint_t *a, const bigint_t *exp, const bigint_t *r){
bigint_expmod_u_sam(dest, a, exp, r);
}

View File

@ -47,32 +47,32 @@ typedef struct{
/******************************************************************************/
void bigint_adjust(bigint_t* a);
uint32_t bigint_get_first_set_bit(const bigint_t* a);
uint32_t bigint_get_last_set_bit(const bigint_t* a);
uint16_t bigint_length_b(const bigint_t* a);
uint16_t bigint_length_B(const bigint_t* a);
void bigint_copy(bigint_t* dest, const bigint_t* src);
void bigint_add_u(bigint_t* dest, const bigint_t* a, const bigint_t* b);
void bigint_add_scale_u(bigint_t* dest, const bigint_t* a, uint16_t scale);
void bigint_sub_u(bigint_t* dest, const bigint_t* a, const bigint_t* b);
void bigint_adjust(bigint_t *a);
uint32_t bigint_get_first_set_bit(const bigint_t *a);
uint32_t bigint_get_last_set_bit(const bigint_t *a);
uint16_t bigint_length_b(const bigint_t *a);
uint16_t bigint_length_B(const bigint_t *a);
void bigint_copy(bigint_t *dest, const bigint_t *src);
void bigint_add_u(bigint_t *dest, const bigint_t *a, const bigint_t *b);
void bigint_add_scale_u(bigint_t *dest, const bigint_t *a, uint16_t scale);
void bigint_sub_u(bigint_t *dest, const bigint_t *a, const bigint_t *b);
int8_t bigint_cmp_u(const bigint_t * a, const bigint_t * b);
void bigint_add_s(bigint_t* dest, const bigint_t* a, const bigint_t* b);
void bigint_sub_s(bigint_t* dest, const bigint_t* a, const bigint_t* b);
int8_t bigint_cmp_s(const bigint_t* a, const bigint_t* b);
void bigint_shiftleft(bigint_t* a, uint16_t shift);
void bigint_shiftright(bigint_t* a, uint16_t shift);
void bigint_xor(bigint_t* dest, const bigint_t* a);
void bigint_set_zero(bigint_t* a);
void bigint_mul_u(bigint_t* dest, const bigint_t* a, const bigint_t* b);
void bigint_mul_s(bigint_t* dest, const bigint_t* a, const bigint_t* b);
void bigint_square(bigint_t* dest, const bigint_t* a);
void bigint_sub_u_bitscale(bigint_t* a, const bigint_t* b, uint16_t bitscale);
void bigint_reduce(bigint_t* a, const bigint_t* r);
void bigint_expmod_u(bigint_t* dest, const bigint_t* a, const bigint_t* exp, const bigint_t* r);
void bigint_gcdext(bigint_t* gcd, bigint_t* a, bigint_t* b, const bigint_t* x, const bigint_t* y);
void bigint_inverse(bigint_t* dest, const bigint_t* a, const bigint_t* m);
void bigint_changeendianess(bigint_t* a);
void bigint_add_s(bigint_t *dest, const bigint_t *a, const bigint_t *b);
void bigint_sub_s(bigint_t *dest, const bigint_t *a, const bigint_t *b);
int8_t bigint_cmp_s(const bigint_t *a, const bigint_t *b);
void bigint_shiftleft(bigint_t *a, uint16_t shift);
void bigint_shiftright(bigint_t *a, uint16_t shift);
void bigint_xor(bigint_t *dest, const bigint_t *a);
void bigint_set_zero(bigint_t *a);
void bigint_mul_u(bigint_t *dest, const bigint_t *a, const bigint_t *b);
void bigint_mul_s(bigint_t *dest, const bigint_t *a, const bigint_t *b);
void bigint_square(bigint_t *dest, const bigint_t *a);
void bigint_sub_u_bitscale(bigint_t *a, const bigint_t *b, uint16_t bitscale);
void bigint_reduce(bigint_t *a, const bigint_t *r);
void bigint_expmod_u(bigint_t *dest, const bigint_t *a, const bigint_t *exp, const bigint_t *r);
void bigint_gcdext(bigint_t *gcd, bigint_t *a, bigint_t *b, const bigint_t *x, const bigint_t *y);
void bigint_inverse(bigint_t *dest, const bigint_t *a, const bigint_t *m);
void bigint_changeendianess(bigint_t *a);
/******************************************************************************/
#endif /*BIGINT_H_*/

View File

@ -18,7 +18,7 @@
*/
/*
void bigint_adjust(bigint_t* a){
void bigint_adjust(bigint_t *a){
while(a->length_B!=0 && a->wordv[a->length_B-1]==0){
a->length_B--;
}
@ -76,7 +76,7 @@ bigint_adjust_ret:
ret
/*
void bigint_copy(bigint_t* dest, const bigint_t* src){
void bigint_copy(bigint_t *dest, const bigint_t *src){
memcpy(dest->wordv, src->wordv, src->length_B);
dest->length_B = src->length_B;
dest->info = src->info;

View File

@ -24,7 +24,7 @@
/******************************************************************************/
/*
void bigint_add_scale_u(bigint_t* dest, const bigint_t* a, uint16_t scale){
void bigint_add_scale_u(bigint_t *dest, const bigint_t *a, uint16_t scale){
uint16_t i,j=0;
uint16_t t=0;
if(scale>dest->length_B)

View File

@ -23,7 +23,7 @@
#include <stdlib.h>
#include <string.h>
void bigint_print_hex(const bigint_t* a){
void bigint_print_hex(const bigint_t *a){
if(a->length_W==0){
cli_putc('0');
return;
@ -94,7 +94,7 @@ static uint16_t read_byte(void){
return (t1<<4)|t2;
}
uint8_t bigint_read_hex_echo(bigint_t* a){
uint8_t bigint_read_hex_echo(bigint_t *a){
uint16_t allocated=0;
uint8_t shift4=0;
uint16_t t, idx = 0;

View File

@ -22,7 +22,7 @@
#include "bigint.h"
void bigint_print_hex(const bigint_t* a);
uint8_t bigint_read_hex_echo(bigint_t* a);
void bigint_print_hex(const bigint_t *a);
uint8_t bigint_read_hex_echo(bigint_t *a);
#endif /* BIGINT_IO_H_ */

View File

@ -33,7 +33,7 @@
#include "blake_common.h"
static
uint64_t pgm_read_qword(const void* p){
uint64_t pgm_read_qword(const void *p){
union{
uint64_t v64;
uint32_t v32[2];
@ -65,7 +65,7 @@ const uint64_t blake_c[] PROGMEM = {
(a)>>24 )
static
void blake_large_expand(uint64_t* v, const blake_large_ctx_t* ctx){
void blake_large_expand(uint64_t *v, const blake_large_ctx_t *ctx){
uint8_t i;
memcpy(v, ctx->h, 8*8);
for(i=0; i<8; ++i){
@ -76,7 +76,7 @@ void blake_large_expand(uint64_t* v, const blake_large_ctx_t* ctx){
}
static
void blake_large_changeendian(void* dest, const void* src){
void blake_large_changeendian(void *dest, const void *src){
uint8_t i;
uint32_t tmp;
for(i=0; i<32; i+=2){
@ -87,7 +87,7 @@ void blake_large_changeendian(void* dest, const void* src){
}
static
void blake_large_compress(uint64_t* v,const void* m){
void blake_large_compress(uint64_t *v,const void *m){
uint8_t r,i;
uint8_t a,b,c,d, s0, s1, sigma_idx=0;
for(r=0; r<16; ++r){
@ -116,14 +116,14 @@ void blake_large_compress(uint64_t* v,const void* m){
}
static
void blake_large_collapse(blake_large_ctx_t* ctx, uint64_t* v){
void blake_large_collapse(blake_large_ctx_t *ctx, uint64_t *v){
uint8_t i;
for(i=0; i<8; ++i){
ctx->h[i] ^= ctx->s[i%4] ^ v[i] ^ v[8+i];
}
}
void blake_large_nextBlock(blake_large_ctx_t* ctx, const void* msg){
void blake_large_nextBlock(blake_large_ctx_t *ctx, const void *msg){
uint64_t v[16];
uint64_t m[16];
union {
@ -140,7 +140,7 @@ void blake_large_nextBlock(blake_large_ctx_t* ctx, const void* msg){
blake_large_collapse(ctx, v);
}
void blake_large_lastBlock(blake_large_ctx_t* ctx, const void* msg, uint16_t length_b){
void blake_large_lastBlock(blake_large_ctx_t *ctx, const void *msg, uint16_t length_b){
while(length_b>=BLAKE_LARGE_BLOCKSIZE){
blake_large_nextBlock(ctx, msg);
msg = (uint8_t*)msg + BLAKE_LARGE_BLOCKSIZE_B;
@ -186,7 +186,7 @@ const uint64_t blake512_iv[] PROGMEM = {
0x1F83D9ABFB41BD6BLL, 0x5BE0CD19137E2179LL
};
void blake512_init(blake512_ctx_t* ctx){
void blake512_init(blake512_ctx_t *ctx){
uint8_t i;
for(i=0; i<8; ++i){
ctx->h[i] = pgm_read_qword(&(blake512_iv[i]));
@ -203,7 +203,7 @@ const uint64_t blake384_iv[] PROGMEM = {
0xDB0C2E0D64F98FA7LL, 0x47B5481DBEFA4FA4LL
};
void blake384_init(blake384_ctx_t* ctx){
void blake384_init(blake384_ctx_t *ctx){
uint8_t i;
for(i=0; i<8; ++i){
ctx->h[i] = pgm_read_qword(&(blake384_iv[i]));
@ -213,7 +213,7 @@ void blake384_init(blake384_ctx_t* ctx){
ctx->appendone = 0;
}
void blake512_ctx2hash(void* dest, const blake512_ctx_t* ctx){
void blake512_ctx2hash(void *dest, const blake512_ctx_t *ctx){
uint8_t i;
for(i=0; i<8; ++i){
((uint32_t*)dest)[2*i+0] = CHANGE_ENDIAN32((ctx->h[i])>>32);
@ -221,7 +221,7 @@ void blake512_ctx2hash(void* dest, const blake512_ctx_t* ctx){
}
}
void blake384_ctx2hash(void* dest, const blake384_ctx_t* ctx){
void blake384_ctx2hash(void *dest, const blake384_ctx_t *ctx){
uint8_t i;
for(i=0; i<6; ++i){
((uint32_t*)dest)[2*i+0] = CHANGE_ENDIAN32((ctx->h[i])>>32);
@ -229,23 +229,23 @@ void blake384_ctx2hash(void* dest, const blake384_ctx_t* ctx){
}
}
void blake512_nextBlock(blake512_ctx_t* ctx, const void* block){
void blake512_nextBlock(blake512_ctx_t *ctx, const void *block){
blake_large_nextBlock(ctx, block);
}
void blake384_nextBlock(blake384_ctx_t* ctx, const void* block){
void blake384_nextBlock(blake384_ctx_t *ctx, const void *block){
blake_large_nextBlock(ctx, block);
}
void blake512_lastBlock(blake512_ctx_t* ctx, const void* block, uint16_t length_b){
void blake512_lastBlock(blake512_ctx_t *ctx, const void *block, uint16_t length_b){
blake_large_lastBlock(ctx, block, length_b);
}
void blake384_lastBlock(blake384_ctx_t* ctx, const void* block, uint16_t length_b){
void blake384_lastBlock(blake384_ctx_t *ctx, const void *block, uint16_t length_b){
blake_large_lastBlock(ctx, block, length_b);
}
void blake512(void* dest, const void* msg, uint32_t length_b){
void blake512(void *dest, const void *msg, uint32_t length_b){
blake_large_ctx_t ctx;
blake512_init(&ctx);
while(length_b>=BLAKE_LARGE_BLOCKSIZE){
@ -257,7 +257,7 @@ void blake512(void* dest, const void* msg, uint32_t length_b){
blake512_ctx2hash(dest, &ctx);
}
void blake384(void* dest, const void* msg, uint32_t length_b){
void blake384(void *dest, const void *msg, uint32_t length_b){
blake_large_ctx_t ctx;
blake384_init(&ctx);
while(length_b>=BLAKE_LARGE_BLOCKSIZE){

View File

@ -46,22 +46,22 @@ typedef struct {
typedef blake_large_ctx_t blake384_ctx_t;
typedef blake_large_ctx_t blake512_ctx_t;
void blake384_init(blake384_ctx_t* ctx);
void blake512_init(blake512_ctx_t* ctx);
void blake384_init(blake384_ctx_t *ctx);
void blake512_init(blake512_ctx_t *ctx);
void blake_large_nextBlock(blake_large_ctx_t* ctx, const void* block);
void blake_large_lastBlock(blake_large_ctx_t* ctx, const void* block, uint16_t length_b);
void blake_large_nextBlock(blake_large_ctx_t *ctx, const void *block);
void blake_large_lastBlock(blake_large_ctx_t *ctx, const void *block, uint16_t length_b);
void blake384_nextBlock(blake384_ctx_t* ctx, const void* block);
void blake384_lastBlock(blake384_ctx_t* ctx, const void* block, uint16_t length_b);
void blake384_nextBlock(blake384_ctx_t *ctx, const void *block);
void blake384_lastBlock(blake384_ctx_t *ctx, const void *block, uint16_t length_b);
void blake512_nextBlock(blake512_ctx_t* ctx, const void* block);
void blake512_lastBlock(blake512_ctx_t* ctx, const void* block, uint16_t length_b);
void blake512_nextBlock(blake512_ctx_t *ctx, const void *block);
void blake512_lastBlock(blake512_ctx_t *ctx, const void *block, uint16_t length_b);
void blake384_ctx2hash(void* dest, const blake384_ctx_t* ctx);
void blake512_ctx2hash(void* dest, const blake512_ctx_t* ctx);
void blake384_ctx2hash(void *dest, const blake384_ctx_t *ctx);
void blake512_ctx2hash(void *dest, const blake512_ctx_t *ctx);
void blake384(void* dest, const void* msg, uint32_t length_b);
void blake512(void* dest, const void* msg, uint32_t length_b);
void blake384(void *dest, const void *msg, uint32_t length_b);
void blake512(void *dest, const void *msg, uint32_t length_b);
#endif /* BLAKE_LARGE_H_ */

View File

@ -51,7 +51,7 @@ const uint32_t blake_c[] PROGMEM = {
((0x00ff0000&(a))>>8)| \
(a)>>24 )
static
void blake_small_expand(uint32_t* v, const blake_small_ctx_t* ctx){
void blake_small_expand(uint32_t *v, const blake_small_ctx_t *ctx){
uint8_t i;
memcpy(v, ctx->h, 8*4);
for(i=0; i<8; ++i){
@ -62,7 +62,7 @@ void blake_small_expand(uint32_t* v, const blake_small_ctx_t* ctx){
}
static
void blake_small_changeendian(void* dest, const void* src){
void blake_small_changeendian(void *dest, const void *src){
uint8_t i;
for(i=0; i<16; ++i){
((uint32_t*)dest)[i] = CHANGE_ENDIAN32(((uint32_t*)src)[i]);
@ -70,7 +70,7 @@ void blake_small_changeendian(void* dest, const void* src){
}
static
void blake_small_compress(uint32_t* v,const void* m){
void blake_small_compress(uint32_t *v,const void *m){
uint8_t r,i;
uint8_t a,b,c,d, s0, s1, sigma_idx=0;
uint32_t lv[4];
@ -109,14 +109,14 @@ void blake_small_compress(uint32_t* v,const void* m){
}
static
void blake_small_collapse(blake_small_ctx_t* ctx, uint32_t* v){
void blake_small_collapse(blake_small_ctx_t *ctx, uint32_t *v){
uint8_t i;
for(i=0; i<8; ++i){
ctx->h[i] ^= ctx->s[i%4] ^ v[i] ^ v[8+i];
}
}
void blake_small_nextBlock(blake_small_ctx_t* ctx, const void* msg){
void blake_small_nextBlock(blake_small_ctx_t *ctx, const void *msg){
uint32_t v[16];
uint32_t m[16];
union {
@ -135,7 +135,7 @@ void blake_small_nextBlock(blake_small_ctx_t* ctx, const void* msg){
blake_small_collapse(ctx, v);
}
void blake_small_lastBlock(blake_small_ctx_t* ctx, const void* msg, uint16_t length_b){
void blake_small_lastBlock(blake_small_ctx_t *ctx, const void *msg, uint16_t length_b){
while(length_b>=BLAKE_SMALL_BLOCKSIZE){
blake_small_nextBlock(ctx, msg);
msg = (uint8_t*)msg + BLAKE_SMALL_BLOCKSIZE_B;
@ -189,7 +189,7 @@ const uint32_t blake256_iv[] PROGMEM = {
0x1F83D9ABL, 0x5BE0CD19
};
void blake256_init(blake256_ctx_t* ctx){
void blake256_init(blake256_ctx_t *ctx){
uint8_t i;
for(i=0; i<8; ++i){
ctx->h[i] = pgm_read_dword(&(blake256_iv[i]));
@ -206,7 +206,7 @@ const uint32_t blake224_iv[] PROGMEM = {
0x64F98FA7, 0xBEFA4FA4
};
void blake224_init(blake224_ctx_t* ctx){
void blake224_init(blake224_ctx_t *ctx){
uint8_t i;
for(i=0; i<8; ++i){
ctx->h[i] = pgm_read_dword(&(blake224_iv[i]));
@ -216,37 +216,37 @@ void blake224_init(blake224_ctx_t* ctx){
ctx->appendone = 0;
}
void blake256_ctx2hash(void* dest, const blake256_ctx_t* ctx){
void blake256_ctx2hash(void *dest, const blake256_ctx_t *ctx){
uint8_t i;
for(i=0; i<8; ++i){
((uint32_t*)dest)[i] = CHANGE_ENDIAN32(ctx->h[i]);
}
}
void blake224_ctx2hash(void* dest, const blake224_ctx_t* ctx){
void blake224_ctx2hash(void *dest, const blake224_ctx_t *ctx){
uint8_t i;
for(i=0; i<7; ++i){
((uint32_t*)dest)[i] = CHANGE_ENDIAN32(ctx->h[i]);
}
}
void blake256_nextBlock(blake256_ctx_t* ctx, const void* block){
void blake256_nextBlock(blake256_ctx_t *ctx, const void *block){
blake_small_nextBlock(ctx, block);
}
void blake224_nextBlock(blake224_ctx_t* ctx, const void* block){
void blake224_nextBlock(blake224_ctx_t *ctx, const void *block){
blake_small_nextBlock(ctx, block);
}
void blake256_lastBlock(blake256_ctx_t* ctx, const void* block, uint16_t length_b){
void blake256_lastBlock(blake256_ctx_t *ctx, const void *block, uint16_t length_b){
blake_small_lastBlock(ctx, block, length_b);
}
void blake224_lastBlock(blake224_ctx_t* ctx, const void* block, uint16_t length_b){
void blake224_lastBlock(blake224_ctx_t *ctx, const void *block, uint16_t length_b){
blake_small_lastBlock(ctx, block, length_b);
}
void blake256(void* dest, const void* msg, uint32_t length_b){
void blake256(void *dest, const void *msg, uint32_t length_b){
blake_small_ctx_t ctx;
blake256_init(&ctx);
while(length_b>=BLAKE_SMALL_BLOCKSIZE){
@ -258,7 +258,7 @@ void blake256(void* dest, const void* msg, uint32_t length_b){
blake256_ctx2hash(dest, &ctx);
}
void blake224(void* dest, const void* msg, uint32_t length_b){
void blake224(void *dest, const void *msg, uint32_t length_b){
blake_small_ctx_t ctx;
blake224_init(&ctx);
while(length_b>=BLAKE_SMALL_BLOCKSIZE){

View File

@ -46,22 +46,22 @@ typedef struct {
typedef blake_small_ctx_t blake224_ctx_t;
typedef blake_small_ctx_t blake256_ctx_t;
void blake224_init(blake224_ctx_t* ctx);
void blake256_init(blake256_ctx_t* ctx);
void blake224_init(blake224_ctx_t *ctx);
void blake256_init(blake256_ctx_t *ctx);
void blake_small_nextBlock(blake_small_ctx_t* ctx, const void* block);
void blake_small_lastBlock(blake_small_ctx_t* ctx, const void* block, uint16_t length_b);
void blake_small_nextBlock(blake_small_ctx_t *ctx, const void *block);
void blake_small_lastBlock(blake_small_ctx_t *ctx, const void *block, uint16_t length_b);
void blake224_nextBlock(blake224_ctx_t* ctx, const void* block);
void blake224_lastBlock(blake224_ctx_t* ctx, const void* block, uint16_t length_b);
void blake224_nextBlock(blake224_ctx_t *ctx, const void *block);
void blake224_lastBlock(blake224_ctx_t *ctx, const void *block, uint16_t length_b);
void blake256_nextBlock(blake256_ctx_t* ctx, const void* block);
void blake256_lastBlock(blake256_ctx_t* ctx, const void* block, uint16_t length_b);
void blake256_nextBlock(blake256_ctx_t *ctx, const void *block);
void blake256_lastBlock(blake256_ctx_t *ctx, const void *block, uint16_t length_b);
void blake224_ctx2hash(void* dest, const blake224_ctx_t* ctx);
void blake256_ctx2hash(void* dest, const blake256_ctx_t* ctx);
void blake224_ctx2hash(void *dest, const blake224_ctx_t *ctx);
void blake256_ctx2hash(void *dest, const blake256_ctx_t *ctx);
void blake224(void* dest, const void* msg, uint32_t length_b);
void blake256(void* dest, const void* msg, uint32_t length_b);
void blake224(void *dest, const void *msg, uint32_t length_b);
void blake256(void *dest, const void *msg, uint32_t length_b);
#endif /* BLAKE_SMALL_H_ */

View File

@ -90,7 +90,7 @@ typedef struct {
} bcdesc_t; /* blockcipher descriptor type */
typedef struct{
bcdesc_t* desc_ptr;
bcdesc_t *desc_ptr;
uint16_t keysize;
void* ctx;
} bcgen_ctx_t;

View File

@ -279,7 +279,7 @@ f0_hacktable:
/*******************************************************************************
* uint32_t addelment(uint8_t j, const uint32_t* m, const uint32_t* h){
* uint32_t addelment(uint8_t j, const uint32_t *m, const uint32_t *h){
* uint32_t r;
* r = pgm_read_dword(k_lut+j);
* r += rotl_addel(((uint32_t*)m)[j&0xf], j+0);
@ -1017,7 +1017,7 @@ bmw256_lastBlock:
/*******************************************************************************
* void bmw224_ctx2hash(void* dest, const bmw224_ctx_t* ctx){
* void bmw224_ctx2hash(void *dest, const bmw224_ctx_t *ctx){
* memcpy(dest, &(ctx->h[9]), 224/8);
* }
*
@ -1038,7 +1038,7 @@ bmw224_ctx2hash:
/*******************************************************************************
* void bmw224(void* dest, const void* msg, uint32_t length_b){
* void bmw224(void *dest, const void *msg, uint32_t length_b){
* bmw_small_ctx_t ctx;
* bmw224_init(&ctx);
* while(length_b>=BMW_SMALL_BLOCKSIZE){
@ -1102,7 +1102,7 @@ bmw224:
rjmp pop9
/*******************************************************************************
* void bmw224_init(bmw224_ctx_t* ctx){
* void bmw224_init(bmw224_ctx_t *ctx){
* uint8_t i;
* ctx->h[0] = 0x00010203;
* for(i=1; i<16; ++i){

View File

@ -279,7 +279,7 @@ f0_hacktable:
/*******************************************************************************
* uint32_t addelment(uint8_t j, const uint32_t* m, const uint32_t* h){
* uint32_t addelment(uint8_t j, const uint32_t *m, const uint32_t *h){
* uint32_t r;
* r = pgm_read_dword(k_lut+j);
* r += rotl_addel(((uint32_t*)m)[j&0xf], j+0);
@ -1019,7 +1019,7 @@ bmw256_lastBlock:
/*******************************************************************************
* void bmw256_ctx2hash(void* dest, const bmw256_ctx_t* ctx){
* void bmw256_ctx2hash(void *dest, const bmw256_ctx_t *ctx){
* memcpy(dest, &(ctx->h[8]), 256/8);
* }
*
@ -1039,7 +1039,7 @@ bmw256_ctx2hash:
ret
/*******************************************************************************
* void bmw256(void* dest, const void* msg, uint32_t length_b){
* void bmw256(void *dest, const void *msg, uint32_t length_b){
* bmw_small_ctx_t ctx;
* bmw256_init(&ctx);
* while(length_b>=BMW_SMALL_BLOCKSIZE){
@ -1068,7 +1068,7 @@ dst1 = 11
/*******************************************************************************
* void bmw224(void* dest, const void* msg, uint32_t length_b){
* void bmw224(void *dest, const void *msg, uint32_t length_b){
* bmw_small_ctx_t ctx;
* bmw224_init(&ctx);
* while(length_b>=BMW_SMALL_BLOCKSIZE){

View File

@ -43,7 +43,7 @@
#if DEBUG
#include "cli.h"
void ctx_dump(const bmw_large_ctx_t* ctx){
void ctx_dump(const bmw_large_ctx_t *ctx){
uint8_t i;
cli_putstr_P(PSTR("\r\n==== ctx dump ===="));
for(i=0; i<16;++i){
@ -56,7 +56,7 @@
cli_hexdump(&(ctx->counter), 4);
}
void dump_x(const uint64_t* q, uint8_t elements, char x){
void dump_x(const uint64_t *q, uint8_t elements, char x){
uint8_t i;
cli_putstr_P(PSTR("\r\n==== "));
cli_putc(x);
@ -220,7 +220,7 @@ const uint64_t k_lut[] PROGMEM = {
0xa55555555555554bLL };
static
uint64_t bmw_large_expand1(uint8_t j, const uint64_t* q, const void* m, const void* h){
uint64_t bmw_large_expand1(uint8_t j, const uint64_t *q, const void *m, const void *h){
uint64_t(*s[])(uint64_t) = {bmw_large_s1, bmw_large_s2, bmw_large_s3, bmw_large_s0};
uint64_t a = 0;
union{
@ -250,7 +250,7 @@ uint64_t bmw_large_expand1(uint8_t j, const uint64_t* q, const void* m, const vo
}
static
uint64_t bmw_large_expand2(uint8_t j, const uint64_t* q, const void* m, const void* h){
uint64_t bmw_large_expand2(uint8_t j, const uint64_t *q, const void *m, const void *h){
uint64_t(*rf[])(uint64_t) = {bmw_large_r1, bmw_large_r2, bmw_large_r3,
bmw_large_r4, bmw_large_r5, bmw_large_r6,
bmw_large_r7};
@ -313,7 +313,7 @@ static const uint8_t offset_table[5] PROGMEM = { 4+16, 6+16, 9+16, 12+16, 13+16
static
void bmw_large_f0(uint64_t* q, const uint64_t* h, const void* m){
void bmw_large_f0(uint64_t *q, const uint64_t *h, const void *m){
uint16_t hack_reg;
uint8_t i,j,c;
uint64_t(*s[])(uint64_t)={ bmw_large_s0, bmw_large_s1, bmw_large_s2,
@ -375,7 +375,7 @@ const uint8_t f0_lut[] PROGMEM ={
};
static
void bmw_large_f0(uint64_t* q, const uint64_t* h, const void* m){
void bmw_large_f0(uint64_t *q, const uint64_t *h, const void *m){
uint8_t i,j=-1,v,sign,l=0;
uint64_t(*s[])(uint64_t)={ bmw_large_s0, bmw_large_s1, bmw_large_s2,
bmw_large_s3, bmw_large_s4 };
@ -417,7 +417,7 @@ void bmw_large_f0(uint64_t* q, const uint64_t* h, const void* m){
#if F0_HACK==0
static
void bmw_large_f0(uint64_t* q, const uint64_t* h, const void* m){
void bmw_large_f0(uint64_t *q, const uint64_t *h, const void *m){
uint8_t i;
uint64_t(*s[])(uint64_t)={ bmw_large_s0, bmw_large_s1, bmw_large_s2,
bmw_large_s3, bmw_large_s4 };
@ -458,7 +458,7 @@ void bmw_large_f0(uint64_t* q, const uint64_t* h, const void* m){
#endif /* F0_HACK==0 */
static
void bmw_large_f1(uint64_t* q, const void* m, const uint64_t* h){
void bmw_large_f1(uint64_t *q, const void *m, const uint64_t *h){
uint8_t i;
q[16] = bmw_large_expand1(0, q, m, h);
q[17] = bmw_large_expand1(1, q, m, h);
@ -468,7 +468,7 @@ void bmw_large_f1(uint64_t* q, const void* m, const uint64_t* h){
}
static
void bmw_large_f2(uint64_t* h, const uint64_t* q, const void* m){
void bmw_large_f2(uint64_t *h, const uint64_t *q, const void *m){
uint64_t xl=0, xh;
uint8_t i;
for(i=16;i<24;++i){
@ -510,7 +510,7 @@ void bmw_large_f2(uint64_t* h, const uint64_t* q, const void* m){
h[15] += SHR64(xl, 2) ^ q[22] ^ q[15];
}
void bmw_large_nextBlock(bmw_large_ctx_t* ctx, const void* block){
void bmw_large_nextBlock(bmw_large_ctx_t *ctx, const void *block){
uint64_t q[32];
dump_x(block, 16, 'M');
bmw_large_f0(q, ctx->h, block);
@ -522,7 +522,7 @@ void bmw_large_nextBlock(bmw_large_ctx_t* ctx, const void* block){
ctx_dump(ctx);
}
void bmw_large_lastBlock(bmw_large_ctx_t* ctx, const void* block, uint16_t length_b){
void bmw_large_lastBlock(bmw_large_ctx_t *ctx, const void *block, uint16_t length_b){
union {
uint8_t v8[128];
uint64_t v64[ 16];
@ -556,7 +556,7 @@ void bmw_large_lastBlock(bmw_large_ctx_t* ctx, const void* block, uint16_t lengt
#endif
}
void bmw384_init(bmw384_ctx_t* ctx){
void bmw384_init(bmw384_ctx_t *ctx){
uint8_t i;
ctx->h[0] = 0x0001020304050607LL;
for(i=1; i<16; ++i){
@ -569,7 +569,7 @@ void bmw384_init(bmw384_ctx_t* ctx){
ctx_dump(ctx);
}
void bmw512_init(bmw512_ctx_t* ctx){
void bmw512_init(bmw512_ctx_t *ctx){
uint8_t i;
ctx->h[0] = 0x8081828384858687LL;
for(i=1; i<16; ++i){
@ -579,31 +579,31 @@ void bmw512_init(bmw512_ctx_t* ctx){
ctx_dump(ctx);
}
void bmw384_nextBlock(bmw384_ctx_t* ctx, const void* block){
void bmw384_nextBlock(bmw384_ctx_t *ctx, const void *block){
bmw_large_nextBlock(ctx, block);
}
void bmw512_nextBlock(bmw512_ctx_t* ctx, const void* block){
void bmw512_nextBlock(bmw512_ctx_t *ctx, const void *block){
bmw_large_nextBlock(ctx, block);
}
void bmw384_lastBlock(bmw384_ctx_t* ctx, const void* block, uint16_t length_b){
void bmw384_lastBlock(bmw384_ctx_t *ctx, const void *block, uint16_t length_b){
bmw_large_lastBlock(ctx, block, length_b);
}
void bmw512_lastBlock(bmw512_ctx_t* ctx, const void* block, uint16_t length_b){
void bmw512_lastBlock(bmw512_ctx_t *ctx, const void *block, uint16_t length_b){
bmw_large_lastBlock(ctx, block, length_b);
}
void bmw384_ctx2hash(void* dest, const bmw384_ctx_t* ctx){
void bmw384_ctx2hash(void *dest, const bmw384_ctx_t *ctx){
memcpy(dest, &(ctx->h[10]), 384/8);
}
void bmw512_ctx2hash(void* dest, const bmw512_ctx_t* ctx){
void bmw512_ctx2hash(void *dest, const bmw512_ctx_t *ctx){
memcpy(dest, &(ctx->h[8]), 512/8);
}
void bmw384(void* dest, const void* msg, uint32_t length_b){
void bmw384(void *dest, const void *msg, uint32_t length_b){
bmw_large_ctx_t ctx;
bmw384_init(&ctx);
while(length_b>=BMW_LARGE_BLOCKSIZE){
@ -615,7 +615,7 @@ void bmw384(void* dest, const void* msg, uint32_t length_b){
bmw384_ctx2hash(dest, &ctx);
}
void bmw512(void* dest, const void* msg, uint32_t length_b){
void bmw512(void *dest, const void *msg, uint32_t length_b){
bmw_large_ctx_t ctx;
bmw512_init(&ctx);
while(length_b>=BMW_LARGE_BLOCKSIZE){

View File

@ -44,22 +44,22 @@ typedef struct {
typedef bmw_large_ctx_t bmw384_ctx_t;
typedef bmw_large_ctx_t bmw512_ctx_t;
void bmw384_init(bmw384_ctx_t* ctx);
void bmw512_init(bmw512_ctx_t* ctx);
void bmw384_init(bmw384_ctx_t *ctx);
void bmw512_init(bmw512_ctx_t *ctx);
void bmw_large_nextBlock(bmw_large_ctx_t* ctx, const void* block);
void bmw_large_lastBlock(bmw_large_ctx_t* ctx, const void* block, uint16_t length_b);
void bmw_large_nextBlock(bmw_large_ctx_t *ctx, const void *block);
void bmw_large_lastBlock(bmw_large_ctx_t *ctx, const void *block, uint16_t length_b);
void bmw384_nextBlock(bmw384_ctx_t* ctx, const void* block);
void bmw384_lastBlock(bmw384_ctx_t* ctx, const void* block, uint16_t length_b);
void bmw384_nextBlock(bmw384_ctx_t *ctx, const void *block);
void bmw384_lastBlock(bmw384_ctx_t *ctx, const void *block, uint16_t length_b);
void bmw512_nextBlock(bmw512_ctx_t* ctx, const void* block);
void bmw512_lastBlock(bmw512_ctx_t* ctx, const void* block, uint16_t length_b);
void bmw512_nextBlock(bmw512_ctx_t *ctx, const void *block);
void bmw512_lastBlock(bmw512_ctx_t *ctx, const void *block, uint16_t length_b);
void bmw384_ctx2hash(void* dest, const bmw384_ctx_t* ctx);
void bmw512_ctx2hash(void* dest, const bmw512_ctx_t* ctx);
void bmw384_ctx2hash(void *dest, const bmw384_ctx_t *ctx);
void bmw512_ctx2hash(void *dest, const bmw512_ctx_t *ctx);
void bmw384(void* dest, const void* msg, uint32_t length_b);
void bmw512(void* dest, const void* msg, uint32_t length_b);
void bmw384(void *dest, const void *msg, uint32_t length_b);
void bmw512(void *dest, const void *msg, uint32_t length_b);
#endif /* BMW_LARGE_H_ */

View File

@ -510,7 +510,7 @@ const_lut:
.long 0x9555554c, 0x9aaaaaa1, 0x9ffffff6, 0xa555554b
/*******************************************************************************
* uint32_t addelment(uint8_t j, const uint32_t* m, const uint32_t* h){
* uint32_t addelment(uint8_t j, const uint32_t *m, const uint32_t *h){
* uint32_t r;
* r = pgm_read_dword(k_lut+j);
* r += rotl_addel(((uint32_t*)m)[j&0xf], j+0);
@ -625,7 +625,7 @@ addelement:
ret
/*******************************************************************************
* uint32_t bmw_small_expand1(uint8_t j, const void* m, const void* h, const uint32_t* q){
* uint32_t bmw_small_expand1(uint8_t j, const void *m, const void *h, const uint32_t *q){
* uint32_t(*s[])(uint32_t) = {bmw_small_s1, bmw_small_s2, bmw_small_s3, bmw_small_s0};
* uint32_t r;
* uint8_t i;
@ -708,7 +708,7 @@ expand1_exit:
ret
/*******************************************************************************
* uint32_t bmw_small_expand2(uint8_t j, const void* m, const void* h, const uint32_t* q){
* uint32_t bmw_small_expand2(uint8_t j, const void *m, const void *h, const uint32_t *q){
* uint32_t(*rf[])(uint32_t) = {bmw_small_r1, bmw_small_r2, bmw_small_r3,
* bmw_small_r4, bmw_small_r5, bmw_small_r6,
* bmw_small_r7};
@ -781,7 +781,7 @@ bmw_small_expand2:
rjmp expand1_exit
/*******************************************************************************
* void bmw_small_f1(uint32_t* q, const void* m, const void* h){
* void bmw_small_f1(uint32_t *q, const void *m, const void *h){
* uint8_t i;
* q[16] = bmw_small_expand1(0, m, h, q);
* q[17] = bmw_small_expand1(1, m, h, q);
@ -849,7 +849,7 @@ bmw_small_f1:
* uint16_t hack_table[5] PROGMEM = { 0x0311, 0xDDB3, 0x2A79, 0x07AA, 0x51C2 };
* uint8_t offset_table[5] PROGMEM = { 4+16, 6+16, 9+16, 12+16, 13+16 };
*
* void bmw_small_f0(uint32_t* h, const void* m, uint32_t* q){
* void bmw_small_f0(uint32_t *h, const void *m, uint32_t *q){
* uint16_t hack_reg;
* uint8_t c,i,j;
* uint32_t(*s[])(uint32_t)={ bmw_small_s0, bmw_small_s1, bmw_small_s2,
@ -1109,7 +1109,7 @@ bmw_small_f0:
ret
/*******************************************************************************
* void bmw_small_f2(uint32_t* h, const uint32_t* q, const void* m){
* void bmw_small_f2(uint32_t *h, const uint32_t *q, const void *m){
* uint32_t xl=0, xh;
* uint8_t i;
* for(i=16;i<24;++i){
@ -1699,7 +1699,7 @@ cli_putchar:
#endif
/*******************************************************************************
* void bmw_small_nextBlock(bmw_small_ctx_t* ctx, const void* block){
* void bmw_small_nextBlock(bmw_small_ctx_t *ctx, const void *block){
* uint32_t q[32];
* dump_x(block, 16, 'M');
* bmw_small_f0(ctx->h, block, q);
@ -1769,7 +1769,7 @@ bmw256_nextBlock:
/*******************************************************************************
* void bmw224_init(bmw224_ctx_t* ctx){
* void bmw224_init(bmw224_ctx_t *ctx){
* uint8_t i;
* ctx->h[0] = 0x00010203;
* for(i=1; i<16; ++i){
@ -1821,7 +1821,7 @@ bmw256_init:
rjmp bmw_small_init
/*******************************************************************************
* void bmw_small_lastBlock(bmw_small_ctx_t* ctx, const void* block, uint16_t length_b){
* void bmw_small_lastBlock(bmw_small_ctx_t *ctx, const void *block, uint16_t length_b){
* struct {
* uint8_t buffer[64];
* uint32_t ctr;
@ -2041,7 +2041,7 @@ bmw256_lastBlock:
ret
/*******************************************************************************
* void bmw224_ctx2hash(void* dest, const bmw224_ctx_t* ctx){
* void bmw224_ctx2hash(void *dest, const bmw224_ctx_t *ctx){
* memcpy(dest, &(ctx->h[9]), 224/8);
* }
*
@ -2057,7 +2057,7 @@ bmw224_ctx2hash:
rjmp 1f
/*******************************************************************************
* void bmw256_ctx2hash(void* dest, const bmw256_ctx_t* ctx){
* void bmw256_ctx2hash(void *dest, const bmw256_ctx_t *ctx){
* memcpy(dest, &(ctx->h[8]), 256/8);
* }
*
@ -2078,7 +2078,7 @@ bmw256_ctx2hash:
ret
/*******************************************************************************
* void bmw256(void* dest, const void* msg, uint32_t length_b){
* void bmw256(void *dest, const void *msg, uint32_t length_b){
* bmw_small_ctx_t ctx;
* bmw256_init(&ctx);
* while(length_b>=BMW_SMALL_BLOCKSIZE){
@ -2111,7 +2111,7 @@ bmw256:
rjmp bmw_small_all
/*******************************************************************************
* void bmw224(void* dest, const void* msg, uint32_t length_b){
* void bmw224(void *dest, const void *msg, uint32_t length_b){
* bmw_small_ctx_t ctx;
* bmw224_init(&ctx);
* while(length_b>=BMW_SMALL_BLOCKSIZE){

View File

@ -279,7 +279,7 @@ f0_hacktable:
/*******************************************************************************
* uint32_t addelment(uint8_t j, const uint32_t* m, const uint32_t* h){
* uint32_t addelment(uint8_t j, const uint32_t *m, const uint32_t *h){
* uint32_t r;
* r = pgm_read_dword(k_lut+j);
* r += rotl_addel(((uint32_t*)m)[j&0xf], j+0);
@ -1021,7 +1021,7 @@ bmw256_lastBlock:
/*******************************************************************************
* void bmw224_ctx2hash(void* dest, const bmw224_ctx_t* ctx){
* void bmw224_ctx2hash(void *dest, const bmw224_ctx_t *ctx){
* memcpy(dest, &(ctx->h[9]), 224/8);
* }
*
@ -1036,7 +1036,7 @@ bmw224_ctx2hash:
rjmp 1f
/*******************************************************************************
* void bmw256_ctx2hash(void* dest, const bmw256_ctx_t* ctx){
* void bmw256_ctx2hash(void *dest, const bmw256_ctx_t *ctx){
* memcpy(dest, &(ctx->h[8]), 256/8);
* }
*
@ -1056,7 +1056,7 @@ bmw256_ctx2hash:
ret
/*******************************************************************************
* void bmw256(void* dest, const void* msg, uint32_t length_b){
* void bmw256(void *dest, const void *msg, uint32_t length_b){
* bmw_small_ctx_t ctx;
* bmw256_init(&ctx);
* while(length_b>=BMW_SMALL_BLOCKSIZE){
@ -1089,7 +1089,7 @@ bmw256:
/*******************************************************************************
* void bmw224(void* dest, const void* msg, uint32_t length_b){
* void bmw224(void *dest, const void *msg, uint32_t length_b){
* bmw_small_ctx_t ctx;
* bmw224_init(&ctx);
* while(length_b>=BMW_SMALL_BLOCKSIZE){
@ -1177,7 +1177,7 @@ c2h_lut:
rjmp bmw256_ctx2hash
/*******************************************************************************
* void bmw224_init(bmw224_ctx_t* ctx){
* void bmw224_init(bmw224_ctx_t *ctx){
* uint8_t i;
* ctx->h[0] = 0x00010203;
* for(i=1; i<16; ++i){

View File

@ -56,7 +56,7 @@
#if DEBUG
#include "cli.h"
void ctx_dump(const bmw_small_ctx_t* ctx){
void ctx_dump(const bmw_small_ctx_t *ctx){
uint8_t i;
cli_putstr_P(PSTR("\r\n==== ctx dump ===="));
for(i=0; i<16;++i){
@ -69,7 +69,7 @@
cli_hexdump(&(ctx->counter), 4);
}
void dump_x(const uint32_t* q, uint8_t elements, char x){
void dump_x(const uint32_t *q, uint8_t elements, char x){
uint8_t i;
cli_putstr_P(PSTR("\r\n==== "));
cli_putc(x);
@ -212,7 +212,7 @@ const uint32_t k_lut[] PROGMEM = {
0xa555554bL };
static
uint32_t bmw_small_expand1(uint8_t j, const uint32_t* q, const void* m, const void* h){
uint32_t bmw_small_expand1(uint8_t j, const uint32_t *q, const void *m, const void *h){
uint32_t(*s[])(uint32_t) = {bmw_small_s1, bmw_small_s2, bmw_small_s3, bmw_small_s0};
uint32_t r;
uint8_t i;
@ -237,7 +237,7 @@ uint32_t bmw_small_expand1(uint8_t j, const uint32_t* q, const void* m, const vo
}
static
uint32_t bmw_small_expand2(uint8_t j, const uint32_t* q, const void* m, const void* h){
uint32_t bmw_small_expand2(uint8_t j, const uint32_t *q, const void *m, const void *h){
uint32_t(*rf[])(uint32_t) = {bmw_small_r1, bmw_small_r2, bmw_small_r3,
bmw_small_r4, bmw_small_r5, bmw_small_r6,
bmw_small_r7};
@ -277,7 +277,7 @@ static const uint16_t hack_table[5] PROGMEM = { 0x0311, 0xDDB3, 0x2A79, 0x07AA,
static const uint8_t offset_table[5] PROGMEM = { 4+16, 6+16, 9+16, 12+16, 13+16 };
static
void bmw_small_f0(uint32_t* q, uint32_t* h, const void* m){
void bmw_small_f0(uint32_t *q, uint32_t *h, const void *m){
uint16_t hack_reg;
uint8_t c,i,j;
uint32_t(*s[])(uint32_t)={ bmw_small_s0, bmw_small_s1, bmw_small_s2,
@ -339,7 +339,7 @@ const uint8_t f0_lut[] PROGMEM = {
};
static
void bmw_small_f0(uint32_t* q, uint32_t* h, const void* m){
void bmw_small_f0(uint32_t *q, uint32_t *h, const void *m){
uint8_t i,j=-1,v,sign,l=0;
uint32_t(*s[])(uint32_t)={ bmw_small_s0, bmw_small_s1, bmw_small_s2,
bmw_small_s3, bmw_small_s4 };
@ -381,7 +381,7 @@ void bmw_small_f0(uint32_t* q, uint32_t* h, const void* m){
#if F0_HACK==0
static
void bmw_small_f0(uint32_t* q, uint32_t* h, const void* m){
void bmw_small_f0(uint32_t *q, uint32_t *h, const void *m){
uint8_t i;
uint32_t(*s[])(uint32_t)={ bmw_small_s0, bmw_small_s1, bmw_small_s2,
bmw_small_s3, bmw_small_s4 };
@ -421,7 +421,7 @@ void bmw_small_f0(uint32_t* q, uint32_t* h, const void* m){
#endif /* F0_HACK==0 */
static
void bmw_small_f1(uint32_t* q, const void* m, const void* h){
void bmw_small_f1(uint32_t *q, const void *m, const void *h){
uint8_t i;
q[16] = bmw_small_expand1(0, q, m, h);
q[17] = bmw_small_expand1(1, q, m, h);
@ -431,7 +431,7 @@ void bmw_small_f1(uint32_t* q, const void* m, const void* h){
}
static
void bmw_small_f2(uint32_t* h, uint32_t* q, const void* m){
void bmw_small_f2(uint32_t *h, uint32_t *q, const void *m){
uint32_t xl=0, xh;
uint8_t i;
for(i=16;i<24;++i){
@ -486,7 +486,7 @@ void bmw_small_f2(uint32_t* h, uint32_t* q, const void* m){
}
void bmw_small_nextBlock(bmw_small_ctx_t* ctx, const void* block){
void bmw_small_nextBlock(bmw_small_ctx_t *ctx, const void *block){
uint32_t q[32];
dump_x(block, 16, 'M');
bmw_small_f0(q, ctx->h, block);
@ -498,7 +498,7 @@ void bmw_small_nextBlock(bmw_small_ctx_t* ctx, const void* block){
ctx_dump(ctx);
}
void bmw_small_lastBlock(bmw_small_ctx_t* ctx, const void* block, uint16_t length_b){
void bmw_small_lastBlock(bmw_small_ctx_t *ctx, const void *block, uint16_t length_b){
union {
uint8_t v8[64];
uint32_t v32[16];
@ -538,7 +538,7 @@ void bmw_small_lastBlock(bmw_small_ctx_t* ctx, const void* block, uint16_t lengt
#endif
}
void bmw224_init(bmw224_ctx_t* ctx){
void bmw224_init(bmw224_ctx_t *ctx){
uint8_t i;
ctx->h[0] = 0x00010203;
for(i=1; i<16; ++i){
@ -551,7 +551,7 @@ void bmw224_init(bmw224_ctx_t* ctx){
ctx_dump(ctx);
}
void bmw256_init(bmw256_ctx_t* ctx){
void bmw256_init(bmw256_ctx_t *ctx){
uint8_t i;
ctx->h[0] = 0x40414243;
for(i=1; i<16; ++i){
@ -561,31 +561,31 @@ void bmw256_init(bmw256_ctx_t* ctx){
ctx_dump(ctx);
}
void bmw224_nextBlock(bmw224_ctx_t* ctx, const void* block){
void bmw224_nextBlock(bmw224_ctx_t *ctx, const void *block){
bmw_small_nextBlock(ctx, block);
}
void bmw256_nextBlock(bmw256_ctx_t* ctx, const void* block){
void bmw256_nextBlock(bmw256_ctx_t *ctx, const void *block){
bmw_small_nextBlock(ctx, block);
}
void bmw224_lastBlock(bmw224_ctx_t* ctx, const void* block, uint16_t length_b){
void bmw224_lastBlock(bmw224_ctx_t *ctx, const void *block, uint16_t length_b){
bmw_small_lastBlock(ctx, block, length_b);
}
void bmw256_lastBlock(bmw256_ctx_t* ctx, const void* block, uint16_t length_b){
void bmw256_lastBlock(bmw256_ctx_t *ctx, const void *block, uint16_t length_b){
bmw_small_lastBlock(ctx, block, length_b);
}
void bmw224_ctx2hash(void* dest, const bmw224_ctx_t* ctx){
void bmw224_ctx2hash(void *dest, const bmw224_ctx_t *ctx){
memcpy(dest, &(ctx->h[9]), 224/8);
}
void bmw256_ctx2hash(void* dest, const bmw256_ctx_t* ctx){
void bmw256_ctx2hash(void *dest, const bmw256_ctx_t *ctx){
memcpy(dest, &(ctx->h[8]), 256/8);
}
void bmw224(void* dest, const void* msg, uint32_t length_b){
void bmw224(void *dest, const void *msg, uint32_t length_b){
bmw_small_ctx_t ctx;
bmw224_init(&ctx);
while(length_b>=BMW_SMALL_BLOCKSIZE){
@ -597,7 +597,7 @@ void bmw224(void* dest, const void* msg, uint32_t length_b){
bmw224_ctx2hash(dest, &ctx);
}
void bmw256(void* dest, const void* msg, uint32_t length_b){
void bmw256(void *dest, const void *msg, uint32_t length_b){
bmw_small_ctx_t ctx;
bmw256_init(&ctx);
while(length_b>=BMW_SMALL_BLOCKSIZE){

View File

@ -44,22 +44,22 @@ typedef struct {
typedef bmw_small_ctx_t bmw224_ctx_t;
typedef bmw_small_ctx_t bmw256_ctx_t;
void bmw224_init(bmw224_ctx_t* ctx);
void bmw256_init(bmw256_ctx_t* ctx);
void bmw224_init(bmw224_ctx_t *ctx);
void bmw256_init(bmw256_ctx_t *ctx);
void bmw_small_nextBlock(bmw_small_ctx_t* ctx, const void* block);
void bmw_small_lastBlock(bmw_small_ctx_t* ctx, const void* block, uint16_t length_b);
void bmw_small_nextBlock(bmw_small_ctx_t *ctx, const void *block);
void bmw_small_lastBlock(bmw_small_ctx_t *ctx, const void *block, uint16_t length_b);
void bmw224_nextBlock(bmw224_ctx_t* ctx, const void* block);
void bmw224_lastBlock(bmw224_ctx_t* ctx, const void* block, uint16_t length_b);
void bmw224_nextBlock(bmw224_ctx_t *ctx, const void *block);
void bmw224_lastBlock(bmw224_ctx_t *ctx, const void *block, uint16_t length_b);
void bmw256_nextBlock(bmw256_ctx_t* ctx, const void* block);
void bmw256_lastBlock(bmw256_ctx_t* ctx, const void* block, uint16_t length_b);
void bmw256_nextBlock(bmw256_ctx_t *ctx, const void *block);
void bmw256_lastBlock(bmw256_ctx_t *ctx, const void *block, uint16_t length_b);
void bmw224_ctx2hash(void* dest, const bmw224_ctx_t* ctx);
void bmw256_ctx2hash(void* dest, const bmw256_ctx_t* ctx);
void bmw224_ctx2hash(void *dest, const bmw224_ctx_t *ctx);
void bmw256_ctx2hash(void *dest, const bmw256_ctx_t *ctx);
void bmw224(void* dest, const void* msg, uint32_t length_b);
void bmw256(void* dest, const void* msg, uint32_t length_b);
void bmw224(void *dest, const void *msg, uint32_t length_b);
void bmw256(void *dest, const void *msg, uint32_t length_b);
#endif /* BMW_SMALL_H_ */

View File

@ -646,9 +646,9 @@ change_endian:
#define KEY_ROL17 0x08
#define KEY_ROL15 0x00
/*
void camellia_6rounds(camellia128_ctx_t* s, uint64_t* bl, uint64_t* br, uint8_t roundop, uint8_t keychoice){
void camellia_6rounds(camellia128_ctx_t *s, uint64_t *bl, uint64_t *br, uint8_t roundop, uint8_t keychoice){
uint8_t i;
uint64_t* k[4];
uint64_t *k[4];
k[0] = &(s->kll);
k[1] = &(s->klr);
k[2] = &(s->kal);
@ -827,7 +827,7 @@ main_loop:
;##############################################################################
/*
void camellia128_init(camellia128_ctx_t* s, uint8_t* key){
void camellia128_init(camellia128_ctx_t *s, uint8_t *key){
uint8_t i;
s->kll = 0; //((uint64_t*)key)[0];

View File

@ -29,9 +29,9 @@ typedef struct camellia128_ctx_s{
}camellia128_ctx_t;
void camellia128_init(const void* key, camellia128_ctx_t* s);
void camellia128_enc(void* block, const camellia128_ctx_t* s);
void camellia128_dec(void* block, const camellia128_ctx_t* s);
void camellia128_init(const void *key, camellia128_ctx_t *s);
void camellia128_enc(void *block, const camellia128_ctx_t *s);
void camellia128_dec(void *block, const camellia128_ctx_t *s);
#endif /*CAMELLIA_H_*/

View File

@ -39,7 +39,7 @@ uint64_t camellia_fl(uint64_t x, uint64_t k);
/*****************************************************************************/
uint64_t camellia_fl_inv(uint64_t y, uint64_t k);
/*****************************************************************************/
void change_endian(void* data, uint8_t length);
void change_endian(void *data, uint8_t length);
/*
uint64_t PROGMEM camellia_sigma[6]={ / * 64 byte table * /
0xA09E667F3BCC908BLL,
@ -83,7 +83,7 @@ void camellia128_ctx_dump(camellia128_ctx_t *s){
/*****************************************************************************/
/* extern uint64_t camellia_sigma[6]; */
void camellia128_init(const void* key, camellia128_ctx_t* s){
void camellia128_init(const void *key, camellia128_ctx_t *s){
uint8_t i;
s->kll = 0; /* ((uint64_t*)key)[0]; */
@ -113,9 +113,9 @@ void camellia128_init(const void* key, camellia128_ctx_t* s){
}
/*****************************************************************************/
void camellia128_keyop(camellia128_ctx_t* s, int8_t q);
void camellia128_keyop(camellia128_ctx_t *s, int8_t q);
/*****************************************************************************/
void camellia128_keyop_inv(camellia128_ctx_t* s, int8_t q);
void camellia128_keyop_inv(camellia128_ctx_t *s, int8_t q);
/*****************************************************************************/
#define SEL_KA 1
@ -133,12 +133,12 @@ void camellia128_keyop_inv(camellia128_ctx_t* s, int8_t q);
#define KEY_ROL17 0x08
#define KEY_ROL15 0x00
void camellia_6rounds(const camellia128_ctx_t* s, uint64_t* bl, uint64_t* br,
void camellia_6rounds(const camellia128_ctx_t *s, uint64_t *bl, uint64_t *br,
uint8_t roundop, uint8_t keychoice);
/*****************************************************************************/
void camellia128_enc(void* block, const camellia128_ctx_t* s){
void camellia128_enc(void *block, const camellia128_ctx_t *s){
#define BL (((uint64_t*)block)[0])
#define BR (((uint64_t*)block)[1])
@ -192,7 +192,7 @@ void camellia128_enc(void* block, const camellia128_ctx_t* s){
/*****************************************************************************/
void camellia128_dec(void* block, const camellia128_ctx_t* s){
void camellia128_dec(void *block, const camellia128_ctx_t *s){
#define BL (((uint64_t*)block)[1])
#define BR (((uint64_t*)block)[0])

View File

@ -272,7 +272,7 @@ uint64_t camellia_sigma(uint8_t idx){
}
/*****************************************************************************/
void camellia128_init(const void* key, camellia128_ctx_t* s){
void camellia128_init(const void *key, camellia128_ctx_t *s){
uint8_t i;
s->kll = 0; //((uint64_t*)key)[0];
@ -306,7 +306,7 @@ void camellia128_init(const void* key, camellia128_ctx_t* s){
/*****************************************************************************/
static
void camellia128_keyop(camellia128_ctx_t* s, int8_t q){
void camellia128_keyop(camellia128_ctx_t *s, int8_t q){
/* first we do 16 bit left-rols for kl and ka (128bit each) */
uint32_t temp;
@ -323,7 +323,7 @@ void camellia128_keyop(camellia128_ctx_t* s, int8_t q){
/*****************************************************************************/
static
void camellia128_keyop_inv(camellia128_ctx_t* s, int8_t q){
void camellia128_keyop_inv(camellia128_ctx_t *s, int8_t q){
/* first we do 16 bit right-rols for kl and ka (128bit each) */
uint32_t temp;
@ -355,9 +355,9 @@ void camellia128_keyop_inv(camellia128_ctx_t* s, int8_t q){
#define KEY_ROL15 0x00
static
void camellia_6rounds(const camellia128_ctx_t* s, uint64_t* bl, uint64_t* br, uint8_t roundop, uint8_t keychoice){
void camellia_6rounds(const camellia128_ctx_t *s, uint64_t *bl, uint64_t *br, uint8_t roundop, uint8_t keychoice){
uint8_t i;
uint64_t* k[4];
uint64_t *k[4];
k[0] = &(((camellia128_ctx_t*)s)->kll);
k[1] = &(((camellia128_ctx_t*)s)->klr);
k[2] = &(((camellia128_ctx_t*)s)->kal);
@ -384,7 +384,7 @@ void camellia_6rounds(const camellia128_ctx_t* s, uint64_t* bl, uint64_t* br, ui
/*****************************************************************************/
static
void change_endian(void* data, uint8_t length){
void change_endian(void *data, uint8_t length){
uint8_t i,a;
for(i=0; i<length/2; ++i){
a = ((uint8_t*)data)[i];
@ -395,7 +395,7 @@ void change_endian(void* data, uint8_t length){
/*****************************************************************************/
void camellia128_enc(void* block, const camellia128_ctx_t* s){
void camellia128_enc(void *block, const camellia128_ctx_t *s){
#define BL (((uint64_t*)block)[0])
#define BR (((uint64_t*)block)[1])
@ -449,7 +449,7 @@ void camellia128_enc(void* block, const camellia128_ctx_t* s){
/*****************************************************************************/
void camellia128_dec(void* block, const camellia128_ctx_t* s){
void camellia128_dec(void *block, const camellia128_ctx_t *s){
#define BL (((uint64_t*)block)[1])
#define BR (((uint64_t*)block)[0])

View File

@ -129,7 +129,7 @@ void cast5_init_rM(uint8_t *klo, uint8_t *khi, uint8_t offset, uint8_t *src, boo
void cast5_init(const void* key, uint16_t keylength_b, cast5_ctx_t* s){
void cast5_init(const void *key, uint16_t keylength_b, cast5_ctx_t *s){
/* we migth return if the key is valid and if setup was successful */
uint32_t x[4], z[4];
#define BPX ((uint8_t*)&(x[0]))
@ -291,10 +291,10 @@ uint32_t cast5_f3(uint32_t d, uint32_t m, uint8_t r){
/******************************************************************************/
void cast5_enc(void* block, const cast5_ctx_t *s){
void cast5_enc(void *block, const cast5_ctx_t *s){
uint32_t l,r, x, y;
uint8_t i;
cast5_f_t* f[]={cast5_f1,cast5_f2,cast5_f3};
cast5_f_t *f[]={cast5_f1,cast5_f2,cast5_f3};
l=((uint32_t*)block)[0];
r=((uint32_t*)block)[1];
// cli_putstr("\r\n round[-1] = ");
@ -315,10 +315,10 @@ void cast5_enc(void* block, const cast5_ctx_t *s){
/******************************************************************************/
void cast5_dec(void* block, const cast5_ctx_t *s){
void cast5_dec(void *block, const cast5_ctx_t *s){
uint32_t l,r, x, y;
int8_t i, rounds;
cast5_f_t* f[]={cast5_f1,cast5_f2,cast5_f3};
cast5_f_t *f[]={cast5_f1,cast5_f2,cast5_f3};
l=((uint32_t*)block)[0];
r=((uint32_t*)block)[1];
rounds = (s->shortkey?12:16);

View File

@ -46,7 +46,7 @@
*
* A variable of this type may hold a keyschedule for the CAST-5 cipher.
* This context is regulary generated by the
* cast5_init(uint8_t* key, uint8_t keylength_b, cast5_ctx_t* s) function.
* cast5_init(uint8_t *key, uint8_t keylength_b, cast5_ctx_t *s) function.
*/
typedef struct cast5_ctx_st{
uint32_t mask[16];
@ -56,7 +56,7 @@ typedef struct cast5_ctx_st{
} cast5_ctx_t;
/** \fn void cast5_init(const void* key, uint16_t keylength_b, cast5_ctx_t* s);
/** \fn void cast5_init(const void *key, uint16_t keylength_b, cast5_ctx_t *s);
* \brief generate keyschedule/contex for CAST-5
*
* This function generates the keyschedule from the supplied key for the
@ -65,29 +65,29 @@ typedef struct cast5_ctx_st{
* \param keylength_b length of the key in bits (maximum 128 bits)
* \param s pointer to the context
*/
void cast5_init(const void* key, uint16_t keylength_b, cast5_ctx_t* s);
void cast5_init(const void *key, uint16_t keylength_b, cast5_ctx_t *s);
/** \fn void cast5_enc(void* block, const cast5_ctx_t* s);
/** \fn void cast5_enc(void *block, const cast5_ctx_t *s);
* \brief encrypt a block with the CAST-5 algorithm
*
* This function encrypts a block of 64 bits (8 bytes) with the CAST-5 algorithm.
* It uses a keyschedule as generated by the
* cast5_init(void* key, uint8_t keylength_b, cast5_ctx_t* s) function.
* cast5_init(void *key, uint8_t keylength_b, cast5_ctx_t *s) function.
* \param block pointer to the block which gets encrypted
* \param s pointer to the keyschedule/context
*/
void cast5_enc(void* block, const cast5_ctx_t* s);
void cast5_enc(void *block, const cast5_ctx_t *s);
/** \fn void cast5_dec(void* block, const cast5_ctx_t* s);
/** \fn void cast5_dec(void *block, const cast5_ctx_t *s);
* \brief decrypt a block with the CAST-5 algorithm
*
* This function decrypts a block of 64 bits (8 bytes) with the CAST-5 algorithm.
* It uses a keyschedule as generated by the
* cast5_init(void* key, uint8_t keylength_b, cast5_ctx_t* s) function.
* cast5_init(void *key, uint8_t keylength_b, cast5_ctx_t *s) function.
* \param block pointer to the block which gets decrypted
* \param s pointer to the keyschedule/context
*/
void cast5_dec(void* block, const cast5_ctx_t* s);
void cast5_dec(void *block, const cast5_ctx_t *s);

View File

@ -17,7 +17,7 @@
static
uint8_t kr(uint8_t i, const cast6_ctx_t* ctx){
uint8_t kr(uint8_t i, const cast6_ctx_t *ctx){
uint8_t ret;
ret = ctx->krx[i/2];
if(i&1){
@ -31,7 +31,7 @@ uint8_t kr(uint8_t i, const cast6_ctx_t* ctx){
}
static
void set_kr(uint8_t value, uint8_t i, cast6_ctx_t* ctx){
void set_kr(uint8_t value, uint8_t i, cast6_ctx_t *ctx){
value &= 0x1F;
(ctx->krx[i/2]) &= 0xF0>>((i&1)*4); /* clear the location where v should go */
@ -103,7 +103,7 @@ uint32_t f3(uint32_t v, uint8_t kri, uint32_t kmi){
#define D (((uint32_t*)buffer)[3])
static
void q(void* buffer, uint8_t i, const cast6_ctx_t* ctx){
void q(void *buffer, uint8_t i, const cast6_ctx_t *ctx){
C ^= f1(D, kr(i*4+0, ctx), ctx->km[i][0]);
B ^= f2(C, kr(i*4+1, ctx), ctx->km[i][1]);
A ^= f3(B, kr(i*4+2, ctx), ctx->km[i][2]);
@ -111,14 +111,14 @@ void q(void* buffer, uint8_t i, const cast6_ctx_t* ctx){
}
static
void qbar(void* buffer, uint8_t i, const cast6_ctx_t* ctx){
void qbar(void *buffer, uint8_t i, const cast6_ctx_t *ctx){
D ^= f1(A, kr(i*4+3, ctx), ctx->km[i][3]);
A ^= f3(B, kr(i*4+2, ctx), ctx->km[i][2]);
B ^= f2(C, kr(i*4+1, ctx), ctx->km[i][1]);
C ^= f1(D, kr(i*4+0, ctx), ctx->km[i][0]);
}
void cast6_enc(void* buffer, const cast6_ctx_t* ctx){
void cast6_enc(void *buffer, const cast6_ctx_t *ctx){
uint8_t i;
for(i=0; i<32/4; ++i){
((uint32_t*)buffer)[i] = CHANGE_ENDIAN32(((uint32_t*)buffer)[i]);
@ -134,7 +134,7 @@ void cast6_enc(void* buffer, const cast6_ctx_t* ctx){
}
}
void cast6_dec(void* buffer, const cast6_ctx_t* ctx){
void cast6_dec(void *buffer, const cast6_ctx_t *ctx){
uint8_t i;
for(i=0; i<32/4; ++i){
((uint32_t*)buffer)[i] = CHANGE_ENDIAN32(((uint32_t*)buffer)[i]);
@ -168,7 +168,7 @@ void cast6_dec(void* buffer, const cast6_ctx_t* ctx){
/*
* we might later make it optional to use this small thing
static
void w(void* buffer, uint8_t* tr, uint32_t* tm){
void w(void *buffer, uint8_t *tr, uint32_t *tm){
G ^= f1(H, (tr[0]&0x0f)+(tr[5]&0x01)?0x10:0x00, tm[0]);
F ^= f2(G, (tr[0]>>4) +(tr[5]&0x02)?0x10:0x00, tm[1]);
E ^= f3(F, (tr[1]&0x0f)+(tr[5]&0x04)?0x10:0x00, tm[2]);
@ -180,7 +180,7 @@ void w(void* buffer, uint8_t* tr, uint32_t* tm){
}
*/
static
void w(void* buffer, uint8_t* tr, uint32_t* tm){
void w(void *buffer, uint8_t *tr, uint32_t *tm){
G ^= f1(H, tr[0], tm[0]);
F ^= f2(G, tr[1], tm[1]);
E ^= f3(F, tr[2], tm[2]);
@ -192,7 +192,7 @@ void w(void* buffer, uint8_t* tr, uint32_t* tm){
}
/*
void dump_ctx(const cast6_ctx_t* ctx){
void dump_ctx(const cast6_ctx_t *ctx){
uint8_t i,t;
cli_putstr_P(PSTR("\r\n DBG:"));
for(i=0; i<12; ++i){
@ -228,7 +228,7 @@ void dump_ctx(const cast6_ctx_t* ctx){
#define MR 17
#define MM 0x6ED9EBA1
void cast6_init(const void* key, uint16_t keysize_b, cast6_ctx_t* ctx){
void cast6_init(const void *key, uint16_t keysize_b, cast6_ctx_t *ctx){
uint8_t buffer[32];
uint8_t cr=CR, tr[8];
uint32_t cm=CM, tm[8];

View File

@ -13,9 +13,9 @@ typedef struct cast6_ctx_st{
void cast6_enc(void* buffer, const cast6_ctx_t* ctx);
void cast6_dec(void* buffer, const cast6_ctx_t* ctx);
void cast6_init(const void* key, uint16_t keysize_b, cast6_ctx_t* ctx);
void cast6_enc(void *buffer, const cast6_ctx_t *ctx);
void cast6_dec(void *buffer, const cast6_ctx_t *ctx);
void cast6_init(const void *key, uint16_t keysize_b, cast6_ctx_t *ctx);
#endif /*CAST6_H_*/

View File

@ -24,9 +24,9 @@ typedef struct {
uint8_t keys[9][8];
} cscipher_ctx_t;
void cscipher_enc(void* buffer, const cscipher_ctx_t* ctx);
void cscipher_dec(void* buffer, const cscipher_ctx_t* ctx);
void cscipher_init(const void* key, cscipher_ctx_t* ctx);
void cscipher_enc(void *buffer, const cscipher_ctx_t *ctx);
void cscipher_dec(void *buffer, const cscipher_ctx_t *ctx);
void cscipher_init(const void *key, cscipher_ctx_t *ctx);
#endif /* CSCIPHER_H_ */

View File

@ -95,7 +95,7 @@ static uint16_t m_inv(uint16_t a){
}
void cscipher_enc(void* buffer, const cscipher_ctx_t* ctx){
void cscipher_enc(void *buffer, const cscipher_ctx_t *ctx){
uint8_t i,j,k;
uint8_t tmp[8];
for(i=0; i<8; ++i){
@ -123,7 +123,7 @@ void cscipher_enc(void* buffer, const cscipher_ctx_t* ctx){
memxor(buffer, ctx->keys[8], 8);
}
void cscipher_dec(void* buffer, const cscipher_ctx_t* ctx){
void cscipher_dec(void *buffer, const cscipher_ctx_t *ctx){
uint8_t i=7,j,k;
uint8_t tmp[8];
memxor(buffer, ctx->keys[8], 8);
@ -146,7 +146,7 @@ void cscipher_dec(void* buffer, const cscipher_ctx_t* ctx){
}while(i--);
}
void cscipher_init(const void* key, cscipher_ctx_t* ctx){
void cscipher_init(const void *key, cscipher_ctx_t *ctx){
uint8_t tmp_key[16], tmp[8];
uint8_t i,j,k,t=0;
memcpy(tmp_key, key, 16);

View File

@ -164,7 +164,7 @@ round_const:
.byte 0xbf, 0x71, 0x58, 0x80, 0x9c, 0xf4, 0xf3, 0xc7
/*
void cscipher_enc(void* buffer, const cscipher_ctx_t* ctx){
void cscipher_enc(void *buffer, const cscipher_ctx_t *ctx){
uint8_t i,j,k;
uint8_t tmp[8];
for(i=0; i<8; ++i){
@ -288,7 +288,7 @@ cscipher_enc:
rjmp memxor
/*
void cscipher_dec(void* buffer, const cscipher_ctx_t* ctx){
void cscipher_dec(void *buffer, const cscipher_ctx_t *ctx){
uint8_t i=7,j,k;
uint8_t tmp[8];
memxor(buffer, ctx->keys[8], 8);

View File

@ -46,7 +46,7 @@
Swap x_1jkl0 with x_1jkl1 , for each (j, k, l).
*/
static void cubehash_round(cubehash_ctx_t* ctx){
static void cubehash_round(cubehash_ctx_t *ctx){
uint8_t i;
uint32_t t, t2;
for(i=0; i<16; ++i){
@ -79,7 +79,7 @@ static void cubehash_round(cubehash_ctx_t* ctx){
}
}
void cubehash_init(uint8_t r, uint8_t b, uint16_t h, cubehash_ctx_t* ctx){
void cubehash_init(uint8_t r, uint8_t b, uint16_t h, cubehash_ctx_t *ctx){
memset(ctx->a, 0, 32*4);
ctx->a[0] = h/8;
ctx->a[1] = b;
@ -91,7 +91,7 @@ void cubehash_init(uint8_t r, uint8_t b, uint16_t h, cubehash_ctx_t* ctx){
}
}
void cubehash_nextBlock(cubehash_ctx_t* ctx, void* block){
void cubehash_nextBlock(cubehash_ctx_t *ctx, void *block){
uint8_t i;
memxor(ctx->a, block, ctx->blocksize_B);
for(i=0; i<ctx->rounds; ++i){
@ -99,7 +99,7 @@ void cubehash_nextBlock(cubehash_ctx_t* ctx, void* block){
}
}
void cubehash_lastBlock(cubehash_ctx_t* ctx, void* block, uint16_t length_b){
void cubehash_lastBlock(cubehash_ctx_t *ctx, void *block, uint16_t length_b){
while(length_b>=ctx->blocksize_B*8){
cubehash_nextBlock(ctx, block);
block = (uint8_t*)block + ctx->blocksize_B;
@ -117,46 +117,46 @@ void cubehash_lastBlock(cubehash_ctx_t* ctx, void* block, uint16_t length_b){
}
}
void cubehash_ctx2hash(void* dest, uint16_t length_b, cubehash_ctx_t* ctx){
void cubehash_ctx2hash(void *dest, uint16_t length_b, cubehash_ctx_t *ctx){
memcpy(dest, ctx->a, (length_b+7)/8);
}
/******************************************************************************/
void cubehash224_init(cubehash_ctx_t* ctx){
void cubehash224_init(cubehash_ctx_t *ctx){
cubehash_init(16, 32, 224, ctx);
}
void cubehash224_ctx2hash(void* dest, cubehash_ctx_t* ctx){
void cubehash224_ctx2hash(void *dest, cubehash_ctx_t *ctx){
cubehash_ctx2hash(dest, 224, ctx);
}
/******************************************************************************/
void cubehash256_init(cubehash_ctx_t* ctx){
void cubehash256_init(cubehash_ctx_t *ctx){
cubehash_init(16, 32, 256, ctx);
}
void cubehash256_ctx2hash(void* dest, cubehash_ctx_t* ctx){
void cubehash256_ctx2hash(void *dest, cubehash_ctx_t *ctx){
cubehash_ctx2hash(dest, 256, ctx);
}
/******************************************************************************/
void cubehash384_init(cubehash_ctx_t* ctx){
void cubehash384_init(cubehash_ctx_t *ctx){
cubehash_init(16, 32, 384, ctx);
}
void cubehash384_ctx2hash(void* dest, cubehash_ctx_t* ctx){
void cubehash384_ctx2hash(void *dest, cubehash_ctx_t *ctx){
cubehash_ctx2hash(dest, 384, ctx);
}
/******************************************************************************/
void cubehash512_init(cubehash_ctx_t* ctx){
void cubehash512_init(cubehash_ctx_t *ctx){
cubehash_init(16, 32, 512, ctx);
}
void cubehash512_ctx2hash(void* dest, cubehash_ctx_t* ctx){
void cubehash512_ctx2hash(void *dest, cubehash_ctx_t *ctx){
cubehash_ctx2hash(dest, 512, ctx);
}

View File

@ -37,21 +37,21 @@ typedef struct {
uint8_t blocksize_B;
} cubehash_ctx_t;
void cubehash_init(uint8_t r, uint8_t b, uint16_t h, cubehash_ctx_t* ctx);
void cubehash_nextBlock(cubehash_ctx_t* ctx, void* block);
void cubehash_lastBlock(cubehash_ctx_t* ctx, void* block, uint16_t length_b);
void cubehash_ctx2hash(void* dest, uint16_t length_b, cubehash_ctx_t* ctx);
void cubehash_init(uint8_t r, uint8_t b, uint16_t h, cubehash_ctx_t *ctx);
void cubehash_nextBlock(cubehash_ctx_t *ctx, void *block);
void cubehash_lastBlock(cubehash_ctx_t *ctx, void *block, uint16_t length_b);
void cubehash_ctx2hash(void *dest, uint16_t length_b, cubehash_ctx_t *ctx);
void cubehash224_init(cubehash_ctx_t* ctx);
void cubehash224_ctx2hash(void* dest, cubehash_ctx_t* ctx);
void cubehash224_init(cubehash_ctx_t *ctx);
void cubehash224_ctx2hash(void *dest, cubehash_ctx_t *ctx);
void cubehash256_init(cubehash_ctx_t* ctx);
void cubehash256_ctx2hash(void* dest, cubehash_ctx_t* ctx);
void cubehash256_init(cubehash_ctx_t *ctx);
void cubehash256_ctx2hash(void *dest, cubehash_ctx_t *ctx);
void cubehash384_init(cubehash_ctx_t* ctx);
void cubehash384_ctx2hash(void* dest, cubehash_ctx_t* ctx);
void cubehash384_init(cubehash_ctx_t *ctx);
void cubehash384_ctx2hash(void *dest, cubehash_ctx_t *ctx);
void cubehash512_init(cubehash_ctx_t* ctx);
void cubehash512_ctx2hash(void* dest, cubehash_ctx_t* ctx);
void cubehash512_init(cubehash_ctx_t *ctx);
void cubehash512_ctx2hash(void *dest, cubehash_ctx_t *ctx);
#endif /* CUBEHASH_H_ */

View File

@ -22,6 +22,6 @@
#include <stdint.h>
void xchg32_array(void* a, void* b, uint8_t n);
void xchg32_array(void *a, void *b, uint8_t n);
#endif /* XCHG_H_ */

View File

@ -269,7 +269,7 @@ uint8_t substitute(uint8_t a, uint8_t * sbp){
/******************************************************************************/
uint32_t des_f(uint32_t r, uint8_t* kr){
uint32_t des_f(uint32_t r, uint8_t *kr){
uint8_t i;
uint32_t t=0,ret;
uint64_t data;
@ -297,7 +297,7 @@ uint32_t des_f(uint32_t r, uint8_t* kr){
/******************************************************************************/
void des_enc(void* out, const void* in, const void* key){
void des_enc(void *out, const void *in, const void *key){
#define R (data.v32[1])
#define L (data.v32[0])
@ -333,7 +333,7 @@ void des_enc(void* out, const void* in, const void* key){
/******************************************************************************/
void des_dec(void* out, const void* in, const uint8_t* key){
void des_dec(void *out, const void *in, const uint8_t *key){
uint8_t kr[6],k[7];
union {
uint8_t v8[8];
@ -368,7 +368,7 @@ void des_dec(void* out, const void* in, const uint8_t* key){
/******************************************************************************/
void tdes_enc(void* out, void* in, const void* key){
void tdes_enc(void *out, void *in, const void *key){
des_enc(out, in, (uint8_t*)key + 0);
des_dec(out, out, (uint8_t*)key + 8);
des_enc(out, out, (uint8_t*)key +16);
@ -376,7 +376,7 @@ void tdes_enc(void* out, void* in, const void* key){
/******************************************************************************/
void tdes_dec(void* out, void* in, const uint8_t* key){
void tdes_dec(void *out, void *in, const uint8_t *key){
des_dec(out, in, (uint8_t*)key +16);
des_enc(out, out, (uint8_t*)key + 8);
des_dec(out, out, (uint8_t*)key + 0);

View File

@ -31,17 +31,17 @@
* Also we only implement the three key mode */
/** \def tdea_enc
* \brief defining an alias for void tdes_enc(void* out, const void* in, const void* key)
* \brief defining an alias for void tdes_enc(void *out, const void *in, const void *key)
*/
/** \def tdea_dec
* \brief defining an alias for void tdes_dec(void* out, const void* in, const void* key)
* \brief defining an alias for void tdes_dec(void *out, const void *in, const void *key)
*/
#define tdea_enc tdes_enc
#define tdea_dec tdes_dec
/** \fn void des_enc(void* out, const void* in, const void* key)
/** \fn void des_enc(void *out, const void *in, const void *key)
* \brief encrypt a block with DES
*
* This function encrypts a block of 64 bits (8 bytes) with the DES algorithm.
@ -53,9 +53,9 @@
* \param in pointer to the block (64 bit = 8 byte) where the plaintext is read from
* \param key pointer to the key (64 bit = 8 byte)
*/
void des_enc(void* out, const void* in, const void* key);
void des_enc(void *out, const void *in, const void *key);
/** \fn void des_dec(void* out, const void* in, const void* key)
/** \fn void des_dec(void *out, const void *in, const void *key)
* \brief decrypt a block with DES
*
* This function decrypts a block of 64 bits (8 bytes) with the DES algorithm.
@ -67,9 +67,9 @@ void des_enc(void* out, const void* in, const void* key);
* \param in pointer to the block (64 bit = 8 byte) where the ciphertext is read from
* \param key pointer to the key (64 bit = 8 byte)
*/
void des_dec(void* out, const void* in, const void* key);
void des_dec(void *out, const void *in, const void *key);
/** \fn void tdes_enc(void* out, const void* in, const void* key)
/** \fn void tdes_enc(void *out, const void *in, const void *key)
* \brief encrypt a block with Tripple-DES
*
* This function encrypts a block of 64 bits (8 bytes) with the Tripple-DES (EDE)
@ -81,9 +81,9 @@ void des_dec(void* out, const void* in, const void* key);
* \param in pointer to the block (64 bit = 8 byte) where the plaintext is read from
* \param key pointer to the key (192 bit = 24 byte)
*/
void tdes_enc(void* out, const void* in, const void* key);
void tdes_enc(void *out, const void *in, const void *key);
/** \fn void tdes_dec(void* out, const void* in, const void* key)
/** \fn void tdes_dec(void *out, const void *in, const void *key)
* \brief decrypt a block with Tripple-DES
*
* This function decrypts a block of 64 bits (8 bytes) with the Tripple-DES (EDE)
@ -95,6 +95,6 @@ void tdes_enc(void* out, const void* in, const void* key);
* \param in pointer to the block (64 bit = 8 byte) where the ciphertext is read from
* \param key pointer to the key (192 bit = 24 byte)
*/
void tdes_dec(void* out, const void* in, const void* key);
void tdes_dec(void *out, const void *in, const void *key);
#endif /*DES_H_*/

View File

@ -49,14 +49,14 @@ typedef uint8_t(*rand_func_ptr_t)(void);
#define DSA_SIGNATURE_OK 1
#define DSA_SIGNATURE_FAIL 0
uint8_t dsa_sign_bigint(dsa_signature_t* s, const bigint_t* m,
const dsa_ctx_t* ctx, const bigint_t* k);
uint8_t dsa_sign_message(dsa_signature_t* s, const void* m, uint16_t m_len_b,
const hfdesc_t* hash_desc, const dsa_ctx_t* ctx,
uint8_t dsa_sign_bigint(dsa_signature_t *s, const bigint_t *m,
const dsa_ctx_t *ctx, const bigint_t *k);
uint8_t dsa_sign_message(dsa_signature_t *s, const void *m, uint16_t m_len_b,
const hfdesc_t *hash_desc, const dsa_ctx_t *ctx,
const rand_func_ptr_t rand_in);
uint8_t dsa_verify_bigint(const dsa_signature_t* s, const bigint_t* m,
const dsa_ctx_t* ctx);
uint8_t dsa_verify_message(const dsa_signature_t* s, const void* m, uint16_t m_len_b,
const hfdesc_t* hash_desc, const dsa_ctx_t* ctx);
uint8_t dsa_verify_bigint(const dsa_signature_t *s, const bigint_t *m,
const dsa_ctx_t *ctx);
uint8_t dsa_verify_message(const dsa_signature_t *s, const void *m, uint16_t m_len_b,
const hfdesc_t *hash_desc, const dsa_ctx_t *ctx);
#endif /* DSA_H_ */

View File

@ -270,7 +270,7 @@ static const uint8_t dsa_key_blob[] PROGMEM = {
};
#endif
void load_dsa_key_blob(dsa_ctx_t* ctx){
void load_dsa_key_blob(dsa_ctx_t *ctx){
if(ctx->priv.wordv){
free(ctx->priv.wordv);
}

View File

@ -20,6 +20,6 @@
#ifndef DSA_KEY_BLOB_H_
#define DSA_KEY_BLOB_H_
void load_dsa_key_blob(dsa_ctx_t* ctx);
void load_dsa_key_blob(dsa_ctx_t *ctx);
#endif /* DSA_KEY_BLOB_H_ */

View File

@ -24,8 +24,8 @@
#include "hashfunction_descriptor.h"
#include "hfal-basic.h"
uint8_t dsa_sign_bigint(dsa_signature_t* s, const bigint_t* m,
const dsa_ctx_t* ctx, const bigint_t* k){
uint8_t dsa_sign_bigint(dsa_signature_t *s, const bigint_t *m,
const dsa_ctx_t *ctx, const bigint_t *k){
bigint_t tmp, tmp2;
uint8_t tmp_b[ctx->domain.p.length_W+5], tmp2_b[ctx->domain.q.length_W+5];
tmp.wordv= tmp_b;
@ -47,8 +47,8 @@ uint8_t dsa_sign_bigint(dsa_signature_t* s, const bigint_t* m,
return 0;
}
uint8_t dsa_sign_message(dsa_signature_t* s, const void* m, uint16_t m_len_b,
const hfdesc_t* hash_desc, const dsa_ctx_t* ctx,
uint8_t dsa_sign_message(dsa_signature_t *s, const void *m, uint16_t m_len_b,
const hfdesc_t *hash_desc, const dsa_ctx_t *ctx,
const rand_func_ptr_t rand_in){
bigint_t z, k;
uint8_t i, n_B = ctx->domain.q.length_W;

View File

@ -22,8 +22,8 @@
#include "dsa.h"
#include "hfal-basic.h"
uint8_t dsa_verify_bigint(const dsa_signature_t* s, const bigint_t* m,
const dsa_ctx_t* ctx){
uint8_t dsa_verify_bigint(const dsa_signature_t *s, const bigint_t *m,
const dsa_ctx_t *ctx){
if(s->r.length_W==0 || s->s.length_W==0){
return DSA_SIGNATURE_FAIL;
}
@ -54,8 +54,8 @@ uint8_t dsa_verify_bigint(const dsa_signature_t* s, const bigint_t* m,
return DSA_SIGNATURE_FAIL;
}
uint8_t dsa_verify_message(const dsa_signature_t* s, const void* m, uint16_t m_len_b,
const hfdesc_t* hash_desc, const dsa_ctx_t* ctx){
uint8_t dsa_verify_message(const dsa_signature_t *s, const void *m, uint16_t m_len_b,
const hfdesc_t *hash_desc, const dsa_ctx_t *ctx){
bigint_t z;
uint8_t n_B = ctx->domain.q.length_W;
uint8_t hash_value[(hfal_hash_getHashsize(hash_desc)+7)/8];

View File

@ -41,15 +41,15 @@ typedef union __attribute__((packed)){
} ecc_combi_point_t;
typedef struct {
bigint_t* p;
bigint_t* b;
bigint_t *p;
bigint_t *b;
int (*reduce_p)(bigint_t*);
} ecc_curve_sp_t;
uint8_t ecc_chudnovsky_point_alloc(ecc_chudnovsky_point_t* p, size_t length_B);
uint8_t ecc_chudnovsky_point_alloc(ecc_chudnovsky_point_t *p, size_t length_B);
void ecc_chudnovsky_point_free(ecc_chudnovsky_point_t* p);
void ecc_chudnovsky_point_free(ecc_chudnovsky_point_t *p);
void ecc_chudnovsky_point_print(const ecc_chudnovsky_point_t *p);
@ -71,15 +71,15 @@ uint8_t ecc_chudnovsky_point_add_sp(ecc_chudnovsky_point_t *dest,
uint8_t ecc_chudnovsky_double_and_add(ecc_chudnovsky_point_t *dest,
const bigint_t *k,
const ecc_chudnovsky_point_t *p,
const ecc_curve_sp_t* curve);
uint8_t bigint_to_naf(uint8_t* dest, uint16_t *length, const bigint_t *src);
const ecc_curve_sp_t *curve);
uint8_t bigint_to_naf(uint8_t *dest, uint16_t *length, const bigint_t *src);
uint8_t ecc_chudnovsky_naf_multiplication(ecc_chudnovsky_point_t *dest,
const bigint_t *k,
const ecc_chudnovsky_point_t *p,
const ecc_curve_sp_t* curve);
const ecc_curve_sp_t *curve);
uint8_t ecc_chudnovsky_multiplication(ecc_chudnovsky_point_t *dest,
const bigint_t *k,
const ecc_chudnovsky_point_t *p,
const ecc_curve_sp_t* curve);
const ecc_curve_sp_t *curve);
#endif /* ECC_H_ */

View File

@ -38,7 +38,7 @@
#define putchar(a)
#endif
uint8_t ecc_chudnovsky_point_alloc(ecc_chudnovsky_point_t* p, size_t length_B){
uint8_t ecc_chudnovsky_point_alloc(ecc_chudnovsky_point_t *p, size_t length_B){
if(!(p->x.wordv = malloc(length_B))){
printf_P(PSTR("DBG: XXX <%S %s %d>\n"), PSTR(__FILE__), __func__, __LINE__);
return 1;
@ -77,7 +77,7 @@ uint8_t ecc_chudnovsky_point_alloc(ecc_chudnovsky_point_t* p, size_t length_B){
return 0;
}
void ecc_chudnovsky_point_free(ecc_chudnovsky_point_t* p){
void ecc_chudnovsky_point_free(ecc_chudnovsky_point_t *p){
free(p->x.wordv);
free(p->y.wordv);
free(p->z1.wordv);
@ -378,7 +378,7 @@ uint8_t ecc_chudnovsky_point_add_sp(ecc_chudnovsky_point_t *dest,
uint8_t ecc_chudnovsky_double_and_add(ecc_chudnovsky_point_t *dest,
const bigint_t *k,
const ecc_chudnovsky_point_t *p,
const ecc_curve_sp_t* curve){
const ecc_curve_sp_t *curve){
uint16_t i;
uint8_t s = 0;
bigint_word_t v, t;
@ -404,7 +404,7 @@ uint8_t ecc_chudnovsky_double_and_add(ecc_chudnovsky_point_t *dest,
return 0;
}
uint8_t bigint_to_naf(uint8_t* dest, uint16_t *length, const bigint_t *src){
uint8_t bigint_to_naf(uint8_t *dest, uint16_t *length, const bigint_t *src){
if(src->length_W == 0){
*dest = 0;
*length = 2;
@ -443,7 +443,7 @@ uint8_t bigint_to_naf(uint8_t* dest, uint16_t *length, const bigint_t *src){
return 0;
}
void print_naf(uint8_t* naf, uint16_t length){
void print_naf(uint8_t *naf, uint16_t length){
if(!length){
return;
}
@ -466,7 +466,7 @@ void print_naf(uint8_t* naf, uint16_t length){
uint8_t ecc_chudnovsky_naf_multiplication(ecc_chudnovsky_point_t *dest,
const bigint_t *k,
const ecc_chudnovsky_point_t *p,
const ecc_curve_sp_t* curve){
const ecc_curve_sp_t *curve){
if(k->length_W == 0 || p->y.length_W == 0){
bigint_set_zero(&dest->y);
return 0;
@ -515,7 +515,7 @@ uint8_t ecc_chudnovsky_naf_multiplication(ecc_chudnovsky_point_t *dest,
uint8_t ecc_chudnovsky_multiplication(ecc_chudnovsky_point_t *dest,
const bigint_t *k,
const ecc_chudnovsky_point_t *p,
const ecc_curve_sp_t* curve){
const ecc_curve_sp_t *curve){
return ecc_chudnovsky_naf_multiplication(dest, k, p, curve);
}
@ -526,6 +526,6 @@ uint8_t ecc_chudnovsky_multipy_and_sum(ecc_chudnovsky_point_t *dest,
const ecc_chudnovsky_point_t *p,
const bigint_t *l,
const ecc_chudnovsky_point_t *q,
const ecc_curve_sp_t* curve){
const ecc_curve_sp_t *curve){
return ecc_chudnovsky_naf_multiplication(dest, k, p, curve);
}

View File

@ -43,15 +43,15 @@ typedef uint8_t(*rand_func_ptr_t)(void);
#define ECDSA_SIGNATURE_OK 1
#define ECDSA_SIGNATURE_FAIL 0
uint8_t ecdsa_sign_bigint(ecdsa_signature_t* s, const bigint_t* m,
const ecdsa_ctx_t* ctx, const bigint_t* k);
uint8_t ecdsa_sign_message(ecdsa_signature_t* s, const void* m, uint16_t m_len_b,
const hfdesc_t* hash_desc, const ecdsa_ctx_t* ctx,
uint8_t ecdsa_sign_bigint(ecdsa_signature_t *s, const bigint_t *m,
const ecdsa_ctx_t *ctx, const bigint_t *k);
uint8_t ecdsa_sign_message(ecdsa_signature_t *s, const void *m, uint16_t m_len_b,
const hfdesc_t *hash_desc, const ecdsa_ctx_t *ctx,
const void *rand_in);
uint8_t ecdsa_verify_bigint(const ecdsa_signature_t* s, const bigint_t* m,
const ecdsa_ctx_t* ctx);
uint8_t ecdsa_verify_message(const ecdsa_signature_t* s, const void* m, uint16_t m_len_b,
const hfdesc_t* hash_desc, const ecdsa_ctx_t* ctx);
uint8_t ecdsa_verify_bigint(const ecdsa_signature_t *s, const bigint_t *m,
const ecdsa_ctx_t *ctx);
uint8_t ecdsa_verify_message(const ecdsa_signature_t *s, const void *m, uint16_t m_len_b,
const hfdesc_t *hash_desc, const ecdsa_ctx_t *ctx);
#endif /* ECDSA_H_ */

Some files were not shown because too many files have changed in this diff Show More