* 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);
}
static
-void shiftreg(uint8_t* d){
+void shiftreg(uint8_t *d){
uint8_t c, c2;
c=d[0]>>7;
d[0] <<= 1;
} 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);
#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);
}
* \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);
#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);
}
* \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);
#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);
}
* \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);
#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);
}
* \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);
#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);
}
* \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);
#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);
}
* \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);
/*
- 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
/*
- 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
#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];
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];
((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;
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){
}
}
-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){
#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
/*
- 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
#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];
#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 */
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){
}
}
-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];
#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
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];
#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];
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 {
}
}
-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);
}
* \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
* \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
* \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
* \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_ */
#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(;;){
*/
-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;
#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_*/
#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){
#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_*/
#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;
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;
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){
}
-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){
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));
}
#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_ */
#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);
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);
}
}
-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);
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_ */
#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);
}
}
-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);
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);
}
}
-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);
}
}
-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;
}
}
-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;
} 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_ */
#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);
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));
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);
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);
}
}
-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);
} 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_ */
#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;
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;
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));
}
-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){
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);
}
}
-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){
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_ */
#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;
}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;
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));
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;
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);
}
#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;
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_ */
#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);
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));
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);
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_ */
#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{
}
}
-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)))];
}
-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)
#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_ */
#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);
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);
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);
}
} 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_ */
}
*/
-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];
}
}
-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));
}
}
-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){
#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_ */
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
/******************************************************************************/
/*
-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;
/* 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);
/* 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)
/******************************************************************************/
/* 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;
/******************************************************************************/
-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;
}
/******************************************************************************/
-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;
/******************************************************************************/
-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;
/******************************************************************************/
-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;
/******************************************************************************/
-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;
/******************************************************************************/
-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;
/******************************************************************************/
-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];
/******************************************************************************/
-void bigint_set_zero(bigint_t* a){
+void bigint_set_zero(bigint_t *a){
a->length_W=0;
}
/* 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;
/******************************************************************************/
-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;
/* 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);
/******************************************************************************/
-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;
/******************************************************************************/
-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);
/* 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;
}
/******************************************************************************/
/* 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){
/******************************************************************************/
-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);
/******************************************************************************/
-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;
#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--;
}
/******************************************************************************/
-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;
}
/******************************************************************************/
-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);
}
/******************************************************************************/
-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;
/******************************************************************************/
-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));
}
/******************************************************************************/
/* 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){
/******************************************************************************/
/* 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;
}
/******************************************************************************/
/* 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;
/******************************************************************************/
-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;
}
/******************************************************************************/
-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;
/******************************************************************************/
-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;
/******************************************************************************/
-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;
/******************************************************************************/
-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;
/******************************************************************************/
-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;
/******************************************************************************/
-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];
/******************************************************************************/
-void bigint_set_zero(bigint_t* a){
+void bigint_set_zero(bigint_t *a){
a->length_W=0;
}
/* 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;
/******************************************************************************/
-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;
/* 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));
/******************************************************************************/
-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;
/******************************************************************************/
-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
/* 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;
}
#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);
/******************************************************************************/
-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);
/******************************************************************************/
-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;
/******************************************************************************/
-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);
}
/******************************************************************************/
-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_*/
*/
/*
-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--;
}
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;
/******************************************************************************/
/*
-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)
#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;
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;
#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_ */
#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];
(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){
}
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){
}
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){
}
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 {
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;
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]));
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]));
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);
}
}
-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);
}
}
-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){
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){
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_ */
((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){
}
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]);
}
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];
}
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 {
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;
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]));
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]));
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){
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){
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_ */
} bcdesc_t; /* blockcipher descriptor type */
typedef struct{
- bcdesc_t* desc_ptr;
+ bcdesc_t *desc_ptr;
uint16_t keysize;
void* ctx;
} bcgen_ctx_t;
/*******************************************************************************
-* 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);
/*******************************************************************************
-* 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 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){
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){
/*******************************************************************************
-* 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);
/*******************************************************************************
-* 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);
* }
*
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){
/*******************************************************************************
-* 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){
#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){
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);
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{
}
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};
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,
};
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 };
#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 };
#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);
}
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){
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);
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];
#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){
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){
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){
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){
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_ */
.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);
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;
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};
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);
* 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,
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){
#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);
/*******************************************************************************
-* 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){
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;
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);
* }
*
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);
* }
*
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){
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){
/*******************************************************************************
-* 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);
/*******************************************************************************
-* 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);
* }
*
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);
* }
*
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){
/*******************************************************************************
-* 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){
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){
#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){
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);
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;
}
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};
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,
};
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 };
#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 };
#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);
}
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){
}
-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);
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];
#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){
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){
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){
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){
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_ */
#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);
;##############################################################################
/*
-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];
}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_*/
/*****************************************************************************/
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,
/*****************************************************************************/
/* 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]; */
}
/*****************************************************************************/
-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
#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])
/*****************************************************************************/
-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])
}
/*****************************************************************************/
-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];
/*****************************************************************************/
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;
/*****************************************************************************/
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;
#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);
/*****************************************************************************/
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];
/*****************************************************************************/
-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])
/*****************************************************************************/
-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])
-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]))
/******************************************************************************/
-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] = ");
/******************************************************************************/
-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);
*
* 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];
} 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
* \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);
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){
}
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 */
#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]);
}
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]);
}
}
-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]);
/*
* 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]);
}
*/
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]);
}
/*
-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){
#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];
-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_*/
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_ */
}
-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){
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);
}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);
.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){
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);
• 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){
}
}
-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;
}
}
-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){
}
}
-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;
}
}
-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);
}
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_ */
#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_ */
/******************************************************************************/
-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;
/******************************************************************************/
-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])
/******************************************************************************/
-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];
/******************************************************************************/
-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);
/******************************************************************************/
-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);
* 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.
* \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.
* \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)
* \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)
* \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_*/
#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_ */
};
#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);
}
#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_ */
#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;
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;
#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;
}
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];
} 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);
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_ */
#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;
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);
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;
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;
return 0;
}
-void print_naf(uint8_t* naf, uint16_t length){
+void print_naf(uint8_t *naf, uint16_t length){
if(!length){
return;
}
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;
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);
}
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);
}
#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_ */
#include "bigint_io.h"
-uint8_t ecdsa_signature_alloc(ecdsa_signature_t* s, size_t length_B){
+uint8_t ecdsa_signature_alloc(ecdsa_signature_t *s, size_t length_B){
if(!(s->r.wordv = malloc(length_B))){
printf_P(PSTR("DBG: XXX <%S %s %d>\n"), PSTR(__FILE__), __func__, __LINE__);
return 1;
return 0;
}
-void ecdsa_signature_free(ecdsa_signature_t* s){
+void ecdsa_signature_free(ecdsa_signature_t *s){
free(s->r.wordv);
free(s->s.wordv);
}
-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_bigint(ecdsa_signature_t *s, const bigint_t *m,
+ const ecdsa_ctx_t *ctx, const bigint_t *k){
bigint_t t;
ecc_combi_point_t q;
return 0;
}
-uint8_t ecdsa_sign_hash(ecdsa_signature_t* s, const void* hash,
- size_t hash_len_B, const ecdsa_ctx_t* ctx,
+uint8_t ecdsa_sign_hash(ecdsa_signature_t *s, const void *hash,
+ size_t hash_len_B, const ecdsa_ctx_t *ctx,
const void *rand_in){
bigint_t m_int;
bigint_t r_int;
return r;
}
-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_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 *hash;
#include "ecdsa.h"
#include "hfal-basic.h"
-uint8_t ecdsa_signature_alloc(ecdsa_signature_t* s, size_t length_B);
+uint8_t ecdsa_signature_alloc(ecdsa_signature_t *s, size_t length_B);
-void ecdsa_signature_free(ecdsa_signature_t* s);
+void ecdsa_signature_free(ecdsa_signature_t *s);
-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_bigint(ecdsa_signature_t *s, const bigint_t *m,
+ const ecdsa_ctx_t *ctx, const bigint_t *k);
-uint8_t ecdsa_sign_hash(ecdsa_signature_t* s, const void* hash,
- size_t hash_len_B, const ecdsa_ctx_t* ctx,
+uint8_t ecdsa_sign_hash(ecdsa_signature_t *s, const void *hash,
+ size_t hash_len_B, const ecdsa_ctx_t *ctx,
const void *rand_in);
-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_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);
#endif /* ECDSA_SIGN_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)
*/
T0= 2
T1= 3
uint8_t ks[16];
} aes_roundkey_t;
-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);
#endif /* AES_ENC_ROUND_H_ */
#define GF256MUL_2(a) (gf256mul(2, (a), 0x1b))
#define GF256MUL_3(a) (gf256mul(3, (a), 0x1b))
-static void mixcol(uint8_t* s){
+static void mixcol(uint8_t *s){
uint8_t t, tmp[4];
tmp[0] = *(s+16*0);
tmp[1] = *(s+16*1);
}
#if DEBUG
-static void dump_state(void* s){
+static void dump_state(void *s){
uint8_t row, col;
for(col=0; col<4; col++){
for(row=0; row<4; row++){
}
#endif
-static void echo_compress(uint8_t* s, uint8_t iterations, uint64_t* c, void* salt){
+static void echo_compress(uint8_t *s, uint8_t iterations, uint64_t *c, void *salt){
uint8_t i, j;
union {
uint8_t v8[16];
/******************************************************************************/
-static void compress512(void* v, void* m, uint64_t* c, void* salt){
+static void compress512(void *v, void *m, uint64_t *c, void *salt){
uint8_t s[16*16];
uint8_t i;
memcpy(s, v, 16*4); /* load v into state */
}
}
-static void compress1024(void* v, void* m, uint64_t* c, void* salt){
+static void compress1024(void *v, void *m, uint64_t *c, void *salt){
uint8_t s[16*16];
memcpy(s, v, 16*8); /* load v into state */
memcpy(s+16*8, m, 16*8); /* load m into state */
/******************************************************************************/
-void echo_small_nextBlock(echo_small_ctx_t* ctx, void* block){
+void echo_small_nextBlock(echo_small_ctx_t *ctx, void *block){
ctx->counter += ECHO_SMALL_BLOCKSIZE;
compress512(ctx->v, block, &(ctx->counter), ctx->salt);
}
-void echo_small_lastBlock(echo_small_ctx_t* ctx, void* block, uint16_t length_b){
+void echo_small_lastBlock(echo_small_ctx_t *ctx, void *block, uint16_t length_b){
while(length_b>=ECHO_SMALL_BLOCKSIZE){
echo_small_nextBlock(ctx, block);
block = (uint8_t*)block + ECHO_SMALL_BLOCKSIZE_B;
/******************************************************************************/
-void echo_large_nextBlock(echo_large_ctx_t* ctx, void* block){
+void echo_large_nextBlock(echo_large_ctx_t *ctx, void *block){
ctx->counter += ECHO_LARGE_BLOCKSIZE;
compress1024(ctx->v, block, &(ctx->counter), ctx->salt);
}
-void echo_large_lastBlock(echo_large_ctx_t* ctx, void* block, uint16_t length_b){
+void echo_large_lastBlock(echo_large_ctx_t *ctx, void *block, uint16_t length_b){
while(length_b>=ECHO_LARGE_BLOCKSIZE){
echo_large_nextBlock(ctx, block);
block = (uint8_t*)block + ECHO_LARGE_BLOCKSIZE_B;
}
/******************************************************************************/
-void echo_ctx2hash(void* dest, uint16_t length_b, echo_small_ctx_t* ctx){
+void echo_ctx2hash(void *dest, uint16_t length_b, echo_small_ctx_t *ctx){
memcpy(dest, ctx->v, (length_b+7)/8);
}
-void echo224_ctx2hash(void* dest, echo_small_ctx_t* ctx){
+void echo224_ctx2hash(void *dest, echo_small_ctx_t *ctx){
memcpy(dest, ctx->v, 224/8);
}
-void echo256_ctx2hash(void* dest, echo_small_ctx_t* ctx){
+void echo256_ctx2hash(void *dest, echo_small_ctx_t *ctx){
memcpy(dest, ctx->v, 256/8);
}
/******************************************************************************/
-void echo384_ctx2hash(void* dest, echo_large_ctx_t* ctx){
+void echo384_ctx2hash(void *dest, echo_large_ctx_t *ctx){
memcpy(dest, ctx->v, 384/8);
}
-void echo512_ctx2hash(void* dest, echo_large_ctx_t* ctx){
+void echo512_ctx2hash(void *dest, echo_large_ctx_t *ctx){
memcpy(dest, ctx->v, 512/8);
}
/******************************************************************************/
-void echo224_init(echo_small_ctx_t* ctx){
+void echo224_init(echo_small_ctx_t *ctx){
memset(ctx->v, 0, 4*16);
ctx->counter = 0;
memset(ctx->salt, 0, 16);
ctx->v[0+16*3] = 0xE0;
}
-void echo256_init(echo_small_ctx_t* ctx){
+void echo256_init(echo_small_ctx_t *ctx){
memset(ctx->v, 0, 4*16);
ctx->counter = 0;
memset(ctx->salt, 0, 16);
/******************************************************************************/
-void echo384_init(echo_large_ctx_t* ctx){
+void echo384_init(echo_large_ctx_t *ctx){
uint8_t i;
memset(ctx->v, 0, 8*16);
ctx->counter = 0;
}
}
-void echo512_init(echo_large_ctx_t* ctx){
+void echo512_init(echo_large_ctx_t *ctx){
uint8_t i;
memset(ctx->v, 0, 8*16);
ctx->counter = 0;
uint16_t id;
}echo_large_ctx_t;
-void echo_small_nextBlock(echo_small_ctx_t* ctx, void* block);
-void echo_small_lastBlock(echo_small_ctx_t* ctx, void* block, uint16_t length_b);
-void echo_small_ctx2hash(void* dest, uint16_t length_b, echo_small_ctx_t* ctx);
-void echo224_ctx2hash(void* dest, echo_small_ctx_t* ctx);
-void echo256_ctx2hash(void* dest, echo_small_ctx_t* ctx);
-void echo224_init(echo_small_ctx_t* ctx);
-void echo256_init(echo_small_ctx_t* ctx);
+void echo_small_nextBlock(echo_small_ctx_t *ctx, void *block);
+void echo_small_lastBlock(echo_small_ctx_t *ctx, void *block, uint16_t length_b);
+void echo_small_ctx2hash(void *dest, uint16_t length_b, echo_small_ctx_t *ctx);
+void echo224_ctx2hash(void *dest, echo_small_ctx_t *ctx);
+void echo256_ctx2hash(void *dest, echo_small_ctx_t *ctx);
+void echo224_init(echo_small_ctx_t *ctx);
+void echo256_init(echo_small_ctx_t *ctx);
-void echo_large_nextBlock(echo_large_ctx_t* ctx, void* block);
-void echo_large_lastBlock(echo_large_ctx_t* ctx, void* block, uint16_t length_b);
-void echo_large_ctx2hash(void* dest, uint16_t length_b, echo_large_ctx_t* ctx);
-void echo384_ctx2hash(void* dest, echo_large_ctx_t* ctx);
-void echo512_ctx2hash(void* dest, echo_large_ctx_t* ctx);
-void echo384_init(echo_large_ctx_t* ctx);
-void echo512_init(echo_large_ctx_t* ctx);
+void echo_large_nextBlock(echo_large_ctx_t *ctx, void *block);
+void echo_large_lastBlock(echo_large_ctx_t *ctx, void *block, uint16_t length_b);
+void echo_large_ctx2hash(void *dest, uint16_t length_b, echo_large_ctx_t *ctx);
+void echo384_ctx2hash(void *dest, echo_large_ctx_t *ctx);
+void echo512_ctx2hash(void *dest, echo_large_ctx_t *ctx);
+void echo384_init(echo_large_ctx_t *ctx);
+void echo512_init(echo_large_ctx_t *ctx);
#endif /* ECHO_H_ */
*
* we simply first "hash" rndCore, then entropy.
*/
-void entropium_addEntropy(unsigned length_b, const void* data){
+void entropium_addEntropy(unsigned length_b, const void *data){
sha256_ctx_t s;
static uint8_t offset=0; /* selects if higher or lower half gets updated */
sha256_init(&s);
return block[i++];
}
-void entropium_fillBlockRandom(void* block, unsigned length_B){
+void entropium_fillBlockRandom(void *block, unsigned length_B){
while(length_B>ENTROPIUM_RANDOMBLOCK_SIZE){
entropium_getRandomBlock(block);
block = (uint8_t*)block + ENTROPIUM_RANDOMBLOCK_SIZE;
*/
#define ENTROPIUM_RANDOMBLOCK_SIZE 32 /* bytes */
-/** \fn void entropium_addEntropy(unsigned length_b, const void* data)
+/** \fn void entropium_addEntropy(unsigned length_b, const void *data)
* \brief add entropy to the prng
*
* This function adds data to the internal entropy pool
* \param length_b length of the data block in bits
* \param data pointer to the data
*/
-void entropium_addEntropy(unsigned length_b, const void* data);
+void entropium_addEntropy(unsigned length_b, const void *data);
-/** \fn void entropium_getRandomBlock(void* b)
+/** \fn void entropium_getRandomBlock(void *b)
* \brief generate a fixed size block of random data
*
* This function writes 32 bytes of random extracted from the entropy pool
* in the supplied buffer.
* \param b buffer where the random data gets written
*/
-void entropium_getRandomBlock(void* b);
+void entropium_getRandomBlock(void *b);
/** \fn uint8_t entropium_getRandomByte(void)
* \brief get a single byte of random data
*/
uint8_t entropium_getRandomByte(void);
-/** \fn void entropium_fillBlockRandom(void* block, unsigned length_B)
+/** \fn void entropium_fillBlockRandom(void *block, unsigned length_B)
* \brief get a block of random data
*
* This function writes random data extracted from the entropy pool in the
* \param block pointer to the buffer where the random data goes
* \param length_B number of bytes to be written to the buffer
*/
-void entropium_fillBlockRandom(void* block, unsigned length_B);
+void entropium_fillBlockRandom(void *block, unsigned length_B);
#endif /*PRNG_H_*/
0xF3, 0x2E, 0xF3, 0x2E, 0x0C, 0xD1, 0x0C, 0x2E, 0xAC, 0x71, 0xAC, 0x71, 0x53, 0x71, 0xA3, 0xD4 };
#endif
-uint8_t grain_enc(grain_ctx_t* ctx){
+uint8_t grain_enc(grain_ctx_t *ctx){
uint8_t s80, s0, c1, c2;
uint8_t i;
/* clock the LFSR */
return (h&1);
}
-uint8_t grain_getbyte(grain_ctx_t* ctx){
+uint8_t grain_getbyte(grain_ctx_t *ctx){
uint8_t i=0;
uint8_t r=0;
do{
#endif
-void grain_init(const void* key, const void* iv, grain_ctx_t* ctx){
+void grain_init(const void *key, const void *iv, grain_ctx_t *ctx){
uint8_t i,t;
/* load the 80bit key */
uint8_t nfsr[10];
} grain_ctx_t;
-uint8_t grain_getbyte(grain_ctx_t* ctx);
-uint8_t grain_enc(grain_ctx_t* ctx);
-void grain_init(const void* key, const void* iv, grain_ctx_t* ctx);
+uint8_t grain_getbyte(grain_ctx_t *ctx);
+uint8_t grain_enc(grain_ctx_t *ctx);
+void grain_init(const void *key, const void *iv, grain_ctx_t *ctx);
#endif /*GRAIN_H_*/
#if DEBUG
#include "cli.h"
- void dump_m(const uint8_t* m){
+ void dump_m(const uint8_t *m){
uint8_t i,j;
for(i=0; i<16; ++i){
cli_putstr_P(PSTR("\r\n"));
}
}
-void groestl384_init(groestl384_ctx_t* ctx){
+void groestl384_init(groestl384_ctx_t *ctx){
memset(ctx->h, 0, 16*8);
ctx->h[8*16-1] = (uint8_t)384;
ctx->h[8*16-2] = (uint8_t)(384>>8);
ctx->counter = 0;
}
-void groestl512_init(groestl512_ctx_t* ctx){
+void groestl512_init(groestl512_ctx_t *ctx){
memset(ctx->h, 0, 16*8);
ctx->h[8*16-2] = 2;
ctx->counter = 0;
}
-void groestl_large_nextBlock(groestl_large_ctx_t* ctx, const void* block){
+void groestl_large_nextBlock(groestl_large_ctx_t *ctx, const void *block){
uint8_t tmp1[128], tmp2[128];
/*
for(i=0; i<8; ++i){
ctx->counter++;
}
-void groestl_large_lastBlock(groestl_large_ctx_t* ctx, const void* block, uint16_t length_b){
+void groestl_large_lastBlock(groestl_large_ctx_t *ctx, const void *block, uint16_t length_b){
uint8_t buffer[128];
while(length_b>=GROESTL_LARGE_BLOCKSIZE){
groestl_large_nextBlock(ctx, block);
groestl_large_nextBlock(ctx, buffer);
}
-void groestl_large_ctx2hash(void* dest, const groestl_large_ctx_t* ctx, uint16_t outlength_b){
+void groestl_large_ctx2hash(void *dest, const groestl_large_ctx_t *ctx, uint16_t outlength_b){
uint8_t tmp[128];
memcpy(tmp, ctx->h, 128);
groestl_large_rounds(tmp, 0);
memcpy(dest, tmp+128-outlength_b/8, outlength_b/8);
}
-void groestl384_ctx2hash(void* dest, const groestl384_ctx_t* ctx){
+void groestl384_ctx2hash(void *dest, const groestl384_ctx_t *ctx){
groestl_large_ctx2hash(dest, ctx, 384);
}
-void groestl512_ctx2hash(void* dest, const groestl512_ctx_t* ctx){
+void groestl512_ctx2hash(void *dest, const groestl512_ctx_t *ctx){
groestl_large_ctx2hash(dest, ctx, 512);
}
-void groestl384_nextBlock(groestl384_ctx_t* ctx, const void* block){
+void groestl384_nextBlock(groestl384_ctx_t *ctx, const void *block){
groestl_large_nextBlock(ctx, block);
}
-void groestl512_nextBlock(groestl512_ctx_t* ctx, const void* block){
+void groestl512_nextBlock(groestl512_ctx_t *ctx, const void *block){
groestl_large_nextBlock(ctx, block);
}
-void groestl384_lastBlock(groestl384_ctx_t* ctx, const void* block, uint16_t length_b){
+void groestl384_lastBlock(groestl384_ctx_t *ctx, const void *block, uint16_t length_b){
groestl_large_lastBlock(ctx, block, length_b);
}
-void groestl512_lastBlock(groestl512_ctx_t* ctx, const void* block, uint16_t length_b){
+void groestl512_lastBlock(groestl512_ctx_t *ctx, const void *block, uint16_t length_b){
groestl_large_lastBlock(ctx, block, length_b);
}
-void groestl384(void* dest, const void* msg, uint32_t length_b){
+void groestl384(void *dest, const void *msg, uint32_t length_b){
groestl_large_ctx_t ctx;
groestl384_init(&ctx);
while(length_b>=GROESTL_LARGE_BLOCKSIZE){
groestl_large_ctx2hash(dest, &ctx, 384);
}
-void groestl512(void* dest, const void* msg, uint32_t length_b){
+void groestl512(void *dest, const void *msg, uint32_t length_b){
groestl_large_ctx_t ctx;
groestl512_init(&ctx);
while(length_b>=GROESTL_LARGE_BLOCKSIZE){
typedef groestl_large_ctx_t groestl384_ctx_t;
typedef groestl_large_ctx_t groestl512_ctx_t;
-void groestl384_init(groestl384_ctx_t* ctx);
-void groestl512_init(groestl512_ctx_t* ctx);
+void groestl384_init(groestl384_ctx_t *ctx);
+void groestl512_init(groestl512_ctx_t *ctx);
-void groestl_large_nextBlock(groestl_large_ctx_t* ctx, const void* block);
-void groestl_large_lastBlock(groestl_large_ctx_t* ctx, const void* block, uint16_t length_b);
+void groestl_large_nextBlock(groestl_large_ctx_t *ctx, const void *block);
+void groestl_large_lastBlock(groestl_large_ctx_t *ctx, const void *block, uint16_t length_b);
-void groestl384_nextBlock(groestl384_ctx_t* ctx, const void* block);
-void groestl384_lastBlock(groestl384_ctx_t* ctx, const void* block, uint16_t length_b);
+void groestl384_nextBlock(groestl384_ctx_t *ctx, const void *block);
+void groestl384_lastBlock(groestl384_ctx_t *ctx, const void *block, uint16_t length_b);
-void groestl512_nextBlock(groestl512_ctx_t* ctx, const void* block);
-void groestl512_lastBlock(groestl512_ctx_t* ctx, const void* block, uint16_t length_b);
+void groestl512_nextBlock(groestl512_ctx_t *ctx, const void *block);
+void groestl512_lastBlock(groestl512_ctx_t *ctx, const void *block, uint16_t length_b);
-void groestl384_ctx2hash(void* dest, const groestl384_ctx_t* ctx);
-void groestl512_ctx2hash(void* dest, const groestl512_ctx_t* ctx);
+void groestl384_ctx2hash(void *dest, const groestl384_ctx_t *ctx);
+void groestl512_ctx2hash(void *dest, const groestl512_ctx_t *ctx);
-void groestl384(void* dest, const void* msg, uint32_t length_b);
-void groestl512(void* dest, const void* msg, uint32_t length_b);
+void groestl384(void *dest, const void *msg, uint32_t length_b);
+void groestl512(void *dest, const void *msg, uint32_t length_b);
#endif /* GROESTL_GROESTL_H_ */
#if DEBUG
#include "cli.h"
- void dump_m(const uint8_t* m){
+ void dump_m(const uint8_t *m){
uint8_t i,j;
for(i=0; i<8; ++i){
cli_putstr_P(PSTR("\r\n"));
}
}
-void groestl224_init(groestl224_ctx_t* ctx){
+void groestl224_init(groestl224_ctx_t *ctx){
memset(ctx->h, 0, 8*8);
ctx->h[8*8-1] = 224;
ctx->counter = 1;
}
-void groestl256_init(groestl256_ctx_t* ctx){
+void groestl256_init(groestl256_ctx_t *ctx){
memset(ctx->h, 0, 8*8);
ctx->h[8*8-2] = 1;
ctx->counter = 1;
}
-void groestl_small_nextBlock(groestl_small_ctx_t* ctx, const void* block){
+void groestl_small_nextBlock(groestl_small_ctx_t *ctx, const void *block){
uint8_t tmp1[64], tmp2[64];
/* for(i=0; i<8; ++i){
for(j=0; j<8; ++j){
ctx->counter++;
}
-void groestl_small_lastBlock(groestl_small_ctx_t* ctx, const void* block, uint16_t length_b){
+void groestl_small_lastBlock(groestl_small_ctx_t *ctx, const void *block, uint16_t length_b){
uint8_t buffer[64];
while(length_b>=GROESTL_SMALL_BLOCKSIZE){
groestl_small_nextBlock(ctx, block);
groestl_small_nextBlock(ctx, buffer);
}
-void groestl_small_ctx2hash(void* dest, const groestl_small_ctx_t* ctx, uint16_t outlength_b){
+void groestl_small_ctx2hash(void *dest, const groestl_small_ctx_t *ctx, uint16_t outlength_b){
uint8_t tmp[64];
memcpy(tmp, ctx->h, 64);
groestl_small_rounds(tmp, 0);
memcpy(dest, tmp+64-outlength_b/8, outlength_b/8);
}
-void groestl224_ctx2hash(void* dest, const groestl224_ctx_t* ctx){
+void groestl224_ctx2hash(void *dest, const groestl224_ctx_t *ctx){
groestl_small_ctx2hash(dest, ctx, 224);
}
-void groestl256_ctx2hash(void* dest, const groestl256_ctx_t* ctx){
+void groestl256_ctx2hash(void *dest, const groestl256_ctx_t *ctx){
groestl_small_ctx2hash(dest, ctx, 256);
}
-void groestl224_nextBlock(groestl224_ctx_t* ctx, const void* block){
+void groestl224_nextBlock(groestl224_ctx_t *ctx, const void *block){
groestl_small_nextBlock(ctx, block);
}
-void groestl256_nextBlock(groestl256_ctx_t* ctx, const void* block){
+void groestl256_nextBlock(groestl256_ctx_t *ctx, const void *block){
groestl_small_nextBlock(ctx, block);
}
-void groestl224_lastBlock(groestl224_ctx_t* ctx, const void* block, uint16_t length_b){
+void groestl224_lastBlock(groestl224_ctx_t *ctx, const void *block, uint16_t length_b){
groestl_small_lastBlock(ctx, block, length_b);
}
-void groestl256_lastBlock(groestl256_ctx_t* ctx, const void* block, uint16_t length_b){
+void groestl256_lastBlock(groestl256_ctx_t *ctx, const void *block, uint16_t length_b){
groestl_small_lastBlock(ctx, block, length_b);
}
-void groestl224(void* dest, const void* msg, uint32_t length_b){
+void groestl224(void *dest, const void *msg, uint32_t length_b){
groestl_small_ctx_t ctx;
groestl224_init(&ctx);
while(length_b>=GROESTL_SMALL_BLOCKSIZE){
groestl_small_ctx2hash(dest, &ctx, 224);
}
-void groestl256(void* dest, const void* msg, uint32_t length_b){
+void groestl256(void *dest, const void *msg, uint32_t length_b){
groestl_small_ctx_t ctx;
groestl256_init(&ctx);
while(length_b>=GROESTL_SMALL_BLOCKSIZE){
typedef groestl_small_ctx_t groestl224_ctx_t;
typedef groestl_small_ctx_t groestl256_ctx_t;
-void groestl224_init(groestl224_ctx_t* ctx);
-void groestl256_init(groestl256_ctx_t* ctx);
+void groestl224_init(groestl224_ctx_t *ctx);
+void groestl256_init(groestl256_ctx_t *ctx);
-void groestl_small_nextBlock(groestl_small_ctx_t* ctx, const void* block);
-void groestl_small_lastBlock(groestl_small_ctx_t* ctx, const void* block, uint16_t length_b);
+void groestl_small_nextBlock(groestl_small_ctx_t *ctx, const void *block);
+void groestl_small_lastBlock(groestl_small_ctx_t *ctx, const void *block, uint16_t length_b);
-void groestl224_nextBlock(groestl224_ctx_t* ctx, const void* block);
-void groestl224_lastBlock(groestl224_ctx_t* ctx, const void* block, uint16_t length_b);
+void groestl224_nextBlock(groestl224_ctx_t *ctx, const void *block);
+void groestl224_lastBlock(groestl224_ctx_t *ctx, const void *block, uint16_t length_b);
-void groestl256_nextBlock(groestl256_ctx_t* ctx, const void* block);
-void groestl256_lastBlock(groestl256_ctx_t* ctx, const void* block, uint16_t length_b);
+void groestl256_nextBlock(groestl256_ctx_t *ctx, const void *block);
+void groestl256_lastBlock(groestl256_ctx_t *ctx, const void *block, uint16_t length_b);
-void groestl224_ctx2hash(void* dest, const groestl224_ctx_t* ctx);
-void groestl256_ctx2hash(void* dest, const groestl256_ctx_t* ctx);
+void groestl224_ctx2hash(void *dest, const groestl224_ctx_t *ctx);
+void groestl256_ctx2hash(void *dest, const groestl256_ctx_t *ctx);
-void groestl224(void* dest, const void* msg, uint32_t length_b);
-void groestl256(void* dest, const void* msg, uint32_t length_b);
+void groestl224(void *dest, const void *msg, uint32_t length_b);
+void groestl256(void *dest, const void *msg, uint32_t length_b);
#endif /* GROESTL_GROESTL_H_ */
} hfdesc_t; /* hashfunction descriptor type */
typedef struct{
- hfdesc_t* desc_ptr;
+ hfdesc_t *desc_ptr;
void* ctx;
} hfgen_ctx_t;
#include "hfal-basic.h"
#include <stdlib.h>
-uint8_t hfal_hash_init(const hfdesc_t* hash_descriptor, hfgen_ctx_t* ctx){
+uint8_t hfal_hash_init(const hfdesc_t *hash_descriptor, hfgen_ctx_t *ctx){
hf_init_fpt f;
uint16_t tmp;
ctx->desc_ptr = (hfdesc_t*)hash_descriptor;
return 0;
}
-void hfal_hash_nextBlock(hfgen_ctx_t* ctx, const void* block){
+void hfal_hash_nextBlock(hfgen_ctx_t *ctx, const void *block){
hf_nextBlock_fpt f;
- hfdesc_t* x=(ctx->desc_ptr);
+ hfdesc_t *x=(ctx->desc_ptr);
f =(hf_nextBlock_fpt)pgm_read_word(&(x->nextBlock));
f(ctx->ctx, block);
}
-void hfal_hash_lastBlock(hfgen_ctx_t* ctx, const void* block, uint16_t length_b){
+void hfal_hash_lastBlock(hfgen_ctx_t *ctx, const void *block, uint16_t length_b){
hf_lastBlock_fpt f;
- hfdesc_t* x=ctx->desc_ptr;
+ hfdesc_t *x=ctx->desc_ptr;
f =(hf_lastBlock_fpt)pgm_read_word(&(x->lastBlock));
f(ctx->ctx, block, length_b);
}
-void hfal_hash_ctx2hash(void* dest, hfgen_ctx_t* ctx){
+void hfal_hash_ctx2hash(void *dest, hfgen_ctx_t *ctx){
hf_ctx2hash_fpt f;
- hfdesc_t* x=ctx->desc_ptr;
+ hfdesc_t *x=ctx->desc_ptr;
f =(hf_ctx2hash_fpt)pgm_read_word(&(x->ctx2hash));
f(dest, ctx->ctx);
}
-void hfal_hash_free(hfgen_ctx_t* ctx){
+void hfal_hash_free(hfgen_ctx_t *ctx){
hf_free_fpt f;
- hfdesc_t* x=ctx->desc_ptr;
+ hfdesc_t *x=ctx->desc_ptr;
f =(hf_free_fpt)pgm_read_word(&(x->free));
if(f)
f(ctx->ctx);
free(ctx->ctx);
}
-void hfal_hash_mem(const hfdesc_t* hash_descriptor, void* dest, const void* msg, uint32_t length_b){
+void hfal_hash_mem(const hfdesc_t *hash_descriptor, void *dest, const void *msg, uint32_t length_b){
void_fpt f;
f = (void_fpt)pgm_read_word(&(hash_descriptor->mem));
if(f){
}
}
-uint16_t hfal_hash_getBlocksize(const hfdesc_t* hash_descriptor){
+uint16_t hfal_hash_getBlocksize(const hfdesc_t *hash_descriptor){
uint16_t ret;
ret = pgm_read_word(&(hash_descriptor->blocksize_b));
return ret;
}
-uint16_t hfal_hash_getHashsize(const hfdesc_t* hash_descriptor){
+uint16_t hfal_hash_getHashsize(const hfdesc_t *hash_descriptor){
uint16_t ret;
ret = pgm_read_word(&(hash_descriptor->hashsize_b));
return ret;
}
-uint16_t hfal_hash_getCtxsize_B(const hfdesc_t* hash_descriptor){
+uint16_t hfal_hash_getCtxsize_B(const hfdesc_t *hash_descriptor){
uint16_t ret;
ret = pgm_read_word(&(hash_descriptor->ctxsize_B));
return ret;
#include <avr/pgmspace.h>
#include "hashfunction_descriptor.h"
-uint8_t hfal_hash_init(const hfdesc_t* hash_descriptor, hfgen_ctx_t* ctx);
-void hfal_hash_nextBlock(hfgen_ctx_t* ctx, const void* block);
-void hfal_hash_lastBlock(hfgen_ctx_t* ctx, const void* block, uint16_t length_b);
-void hfal_hash_ctx2hash(void* dest, hfgen_ctx_t* ctx);
-void hfal_hash_free(hfgen_ctx_t* ctx);
-void hfal_hash_mem(const hfdesc_t* hash_descriptor, void* dest, const void* msg, uint32_t length_b);
-uint16_t hfal_hash_getBlocksize(const hfdesc_t* hash_descriptor);
-uint16_t hfal_hash_getHashsize(const hfdesc_t* hash_descriptor);
-uint16_t hfal_hash_getCtxsize_B(const hfdesc_t* hash_descriptor);
+uint8_t hfal_hash_init(const hfdesc_t *hash_descriptor, hfgen_ctx_t *ctx);
+void hfal_hash_nextBlock(hfgen_ctx_t *ctx, const void *block);
+void hfal_hash_lastBlock(hfgen_ctx_t *ctx, const void *block, uint16_t length_b);
+void hfal_hash_ctx2hash(void *dest, hfgen_ctx_t *ctx);
+void hfal_hash_free(hfgen_ctx_t *ctx);
+void hfal_hash_mem(const hfdesc_t *hash_descriptor, void *dest, const void *msg, uint32_t length_b);
+uint16_t hfal_hash_getBlocksize(const hfdesc_t *hash_descriptor);
+uint16_t hfal_hash_getHashsize(const hfdesc_t *hash_descriptor);
+uint16_t hfal_hash_getCtxsize_B(const hfdesc_t *hash_descriptor);
#endif /* HFAL_BASIC_H_ */
#define IPAD 0x36
#define OPAD 0x5C
-uint8_t hfal_hmac_init(const hfdesc_t* hash_descriptor,
- hfhmacgen_ctx_t* ctx,
- const void* key, uint16_t keylength_b){
+uint8_t hfal_hmac_init(const hfdesc_t *hash_descriptor,
+ hfhmacgen_ctx_t *ctx,
+ const void *key, uint16_t keylength_b){
uint16_t bs = hfal_hash_getBlocksize();
uint8_t buffer[bs/8];
uint8_t i;
memset(buffer, 0, bs/8);
}
-void hfal_hmac_nextBlock(hfhmacgen_ctx_t* ctx, const void* block){
+void hfal_hmac_nextBlock(hfhmacgen_ctx_t *ctx, const void *block){
hf_nextBlock_fpt nextBlock;
nextBlock = pgm_read_word(&(hash_descriptor->nextBlock));
nextBlock(ctx->ctx, block);
}
-void hfal_hmac_lastBlock(hfhmacgen_ctx_t* ctx, const void* block, uint16_t length_b){
+void hfal_hmac_lastBlock(hfhmacgen_ctx_t *ctx, const void *block, uint16_t length_b){
hf_lastBlock_fpt lastBlock;
hf_ctx2hash_fpt ctx2hash;
uint16_t hs = pgm_read_word(&(hash_descriptor->hashsize_b));
lastBlock(ctx->finctx, buffer, hs);
}
-void hfal_hmac_ctx2mac(void* dest, hfhmacgen_ctx_t* ctx){
+void hfal_hmac_ctx2mac(void *dest, hfhmacgen_ctx_t *ctx){
hf_ctx2hash_fpt ctx2hash;
ctx2hash = pgm_read_word(&(hash_descriptor->ctx2hash));
ctx2hash(dest, ctx->finctx);
}
-void hfal_hmac_free(hfhmacgen_ctx_t* ctx){
+void hfal_hmac_free(hfhmacgen_ctx_t *ctx){
hf_free_fpt free_fpt;
free_fpt = pgm_read_word(&(hash_descriptor->free));
if(free_fpt){
free(ctx->finctx)
}
-void hfal_hmac_mem(const hfdesc_t* hash_descriptor, const void* key, uint16_t keylength_b, void* dest, const void* msg, uint32_t length_b){
+void hfal_hmac_mem(const hfdesc_t *hash_descriptor, const void *key, uint16_t keylength_b, void *dest, const void *msg, uint32_t length_b){
hfhmacgen_ctx_t ctx;
uint16_t bs = hfal_hash_getBlocksize();
hfal_hmac_init(hash_descriptor, &ctx, key, keylength_b);
hfal_free(&ctx);
}
-uint16_t hfal_hmac_getBlocksize(const hfdesc_t* hash_descriptor){
+uint16_t hfal_hmac_getBlocksize(const hfdesc_t *hash_descriptor){
return hfal_hash_getBlocksize(hash_descriptor);
}
-uint16_t hfal_hmac_getMACsize(const hfdesc_t* hash_descriptor){
+uint16_t hfal_hmac_getMACsize(const hfdesc_t *hash_descriptor){
return hfal_hash_getHashsize(hash_descriptor);
}
#include "hashfunction_descriptor.h"
typedef struct {
- hfdesc_t* desc;
+ hfdesc_t *desc;
void* ctx;
void* finctx;
} hfhmacgen_ctx_t;
-uint8_t hfal_hmac_init(const hfdesc_t* hash_descriptor, hfhmacgen_ctx_t* ctx, const void* key, uint16_t keylength_b);
-void hfal_hmac_nextBlock(hfhmacgen_ctx_t* ctx, const void* block);
-void hfal_hmac_lastBlock(hfhmacgen_ctx_t* ctx, const void* block, uint16_t length_b);
-void hfal_hmac_ctx2mac(void* dest, hfhmacgen_ctx_t* ctx);
-void hfal_hmac_free(hfhmacgen_ctx_t* ctx);
-void hfal_hmac_mem(const hfdesc_t* hash_descriptor, const void* key, uint16_t keylength_b, void* dest, const void* msg, uint32_t length_b);
-uint16_t hfal_hmac_getBlocksize(const hfdesc_t* hash_descriptor);
-uint16_t hfal_hmac_getMACsize(const hfdesc_t* hash_descriptor);
+uint8_t hfal_hmac_init(const hfdesc_t *hash_descriptor, hfhmacgen_ctx_t *ctx, const void *key, uint16_t keylength_b);
+void hfal_hmac_nextBlock(hfhmacgen_ctx_t *ctx, const void *block);
+void hfal_hmac_lastBlock(hfhmacgen_ctx_t *ctx, const void *block, uint16_t length_b);
+void hfal_hmac_ctx2mac(void *dest, hfhmacgen_ctx_t *ctx);
+void hfal_hmac_free(hfhmacgen_ctx_t *ctx);
+void hfal_hmac_mem(const hfdesc_t *hash_descriptor, const void *key, uint16_t keylength_b, void *dest, const void *msg, uint32_t length_b);
+uint16_t hfal_hmac_getBlocksize(const hfdesc_t *hash_descriptor);
+uint16_t hfal_hmac_getMACsize(const hfdesc_t *hash_descriptor);
#endif /* HFAL_HMAC_H_ */
#include <stdint.h>
#include <avr/pgmspace.h>
-void hfal_nessie(const hfdesc_t* hd){
+void hfal_nessie(const hfdesc_t *hd){
if(pgm_read_byte(&(hd->type))!=HFDESC_TYPE_HASHFUNCTION)
return;
char name[1+strlen_P((void*)pgm_read_word(&(hd->name)))];
nessie_hash_run();
}
-void hfal_nessie_multiple(const hfdesc_t* const* hd_list){
- const hfdesc_t* hd;
+void hfal_nessie_multiple(const hfdesc_t *const *hd_list){
+ const hfdesc_t *hd;
for(;;){
hd = (void*)pgm_read_word(hd_list);
if(!hd)
#include "hashfunction_descriptor.h"
-void hfal_nessie(const hfdesc_t* hd);
-void hfal_nessie_multiple(const hfdesc_t* const* hd_list);
+void hfal_nessie(const hfdesc_t *hd);
+void hfal_nessie_multiple(const hfdesc_t *const *hd_list);
#endif /* HFAL_NESSIE_H_ */
cli_putstr(str);
}
-void hfal_performance(const hfdesc_t* hd){
+void hfal_performance(const hfdesc_t *hd){
hfdesc_t hf;
memcpy_P(&hf, hd, sizeof(hfdesc_t));
uint8_t ctx[hf.ctxsize_B];
}
}
-void hfal_stacksize(const hfdesc_t* hd){
+void hfal_stacksize(const hfdesc_t *hd){
hfdesc_t hf;
stack_measuring_ctx_t smctx;
memcpy_P(&hf, hd, sizeof(hfdesc_t));
}
}
-void hfal_performance_multiple(const hfdesc_t* const* hd_list){
- const hfdesc_t* hd;
+void hfal_performance_multiple(const hfdesc_t *const *hd_list){
+ const hfdesc_t *hd;
for(;;){
hd = (void*)pgm_read_word(hd_list);
if(!hd){
#include "hashfunction_descriptor.h"
-void hfal_performance(const hfdesc_t* hd);
-void hfal_performance_multiple(const hfdesc_t* const* hd_list);
+void hfal_performance(const hfdesc_t *hd);
+void hfal_performance_multiple(const hfdesc_t *const *hd_list);
#endif /* HFAL_PERFORMANCE_H_ */
#include <stdint.h>
#include <avr/pgmspace.h>
-void hfal_test(const hfdesc_t* hd, void* msg, uint32_t length_b){
+void hfal_test(const hfdesc_t *hd, void *msg, uint32_t length_b){
if(pgm_read_byte(&(hd->type))!=HFDESC_TYPE_HASHFUNCTION)
return;
uint16_t dlen = (pgm_read_word(&(hd->hashsize_b))+7)/8;
#include "hashfunction_descriptor.h"
#include <stdint.h>
-void hfal_test(const hfdesc_t* hd, void* msg, uint32_t length_b);
+void hfal_test(const hfdesc_t *hd, void *msg, uint32_t length_b);
#endif /* HFAL_TEST_H_ */
static const char skein1024_512_str[] PROGMEM = "Skein-1024-512";
static const char skein1024_1024_str[] PROGMEM = "Skein-1024-1024";
-void skein1024_128_init(skein1024_ctx_t* ctx){
+void skein1024_128_init(skein1024_ctx_t *ctx){
skein1024_init(ctx, 128);
}
-void skein1024_160_init(skein1024_ctx_t* ctx){
+void skein1024_160_init(skein1024_ctx_t *ctx){
skein1024_init(ctx, 160);
}
-void skein1024_224_init(skein1024_ctx_t* ctx){
+void skein1024_224_init(skein1024_ctx_t *ctx){
skein1024_init(ctx, 224);
}
-void skein1024_256_init(skein1024_ctx_t* ctx){
+void skein1024_256_init(skein1024_ctx_t *ctx){
skein1024_init(ctx, 256);
}
-void skein1024_384_init(skein1024_ctx_t* ctx){
+void skein1024_384_init(skein1024_ctx_t *ctx){
skein1024_init(ctx, 384);
}
-void skein1024_512_init(skein1024_ctx_t* ctx){
+void skein1024_512_init(skein1024_ctx_t *ctx){
skein1024_init(ctx, 512);
}
-void skein1024_1024_init(skein1024_ctx_t* ctx){
+void skein1024_1024_init(skein1024_ctx_t *ctx){
skein1024_init(ctx, 1024);
}
static const char skein256_384_str[] PROGMEM = "Skein-256-384";
static const char skein256_512_str[] PROGMEM = "Skein-256-512";
-void skein256_128_init(skein256_ctx_t* ctx){
+void skein256_128_init(skein256_ctx_t *ctx){
skein256_init(ctx, 128);
}
-void skein256_160_init(skein256_ctx_t* ctx){
+void skein256_160_init(skein256_ctx_t *ctx){
skein256_init(ctx, 160);
}
-void skein256_224_init(skein256_ctx_t* ctx){
+void skein256_224_init(skein256_ctx_t *ctx){
skein256_init(ctx, 224);
}
-void skein256_256_init(skein256_ctx_t* ctx){
+void skein256_256_init(skein256_ctx_t *ctx){
skein256_init(ctx, 256);
}
-void skein256_384_init(skein256_ctx_t* ctx){
+void skein256_384_init(skein256_ctx_t *ctx){
skein256_init(ctx, 384);
}
-void skein256_512_init(skein256_ctx_t* ctx){
+void skein256_512_init(skein256_ctx_t *ctx){
skein256_init(ctx, 512);
}
static const char skein512_512_str[] PROGMEM = "Skein-512-512";
static const char skein512_1024_str[] PROGMEM = "Skein-512-1024";
-void skein512_128_init(skein512_ctx_t* ctx){
+void skein512_128_init(skein512_ctx_t *ctx){
skein512_init(ctx, 128);
}
-void skein512_160_init(skein512_ctx_t* ctx){
+void skein512_160_init(skein512_ctx_t *ctx){
skein512_init(ctx, 160);
}
-void skein512_224_init(skein512_ctx_t* ctx){
+void skein512_224_init(skein512_ctx_t *ctx){
skein512_init(ctx, 224);
}
-void skein512_256_init(skein512_ctx_t* ctx){
+void skein512_256_init(skein512_ctx_t *ctx){
skein512_init(ctx, 256);
}
-void skein512_384_init(skein512_ctx_t* ctx){
+void skein512_384_init(skein512_ctx_t *ctx){
skein512_init(ctx, 384);
}
-void skein512_512_init(skein512_ctx_t* ctx){
+void skein512_512_init(skein512_ctx_t *ctx){
skein512_init(ctx, 512);
}
-void skein512_1024_init(skein512_ctx_t* ctx){
+void skein512_1024_init(skein512_ctx_t *ctx){
skein512_init(ctx, 1024);
}
#ifndef HMAC_SHORTONLY
-void hmac_md5_init(hmac_md5_ctx_t *s, void* key, uint16_t keylength_b){
+void hmac_md5_init(hmac_md5_ctx_t *s, void *key, uint16_t keylength_b){
uint8_t buffer[MD5_BLOCK_BYTES];
uint8_t i;
#endif
}
-void hmac_md5_nextBlock(hmac_md5_ctx_t *s, const void* block){
+void hmac_md5_nextBlock(hmac_md5_ctx_t *s, const void *block){
md5_nextBlock(&(s->a), block);
}
-void hmac_md5_lastBlock(hmac_md5_ctx_t *s, const void* block, uint16_t length_b){
+void hmac_md5_lastBlock(hmac_md5_ctx_t *s, const void *block, uint16_t length_b){
md5_lastBlock(&(s->a), block, length_b);
}
-void hmac_md5_final(void* dest, hmac_md5_ctx_t *s){
+void hmac_md5_final(void *dest, hmac_md5_ctx_t *s){
md5_ctx2hash((md5_hash_t*)dest, &(s->a));
md5_lastBlock(&(s->b), dest, MD5_HASH_BITS);
md5_ctx2hash((md5_hash_t*)dest, &(s->b));
* keylength in bits!
* message length in bits!
*/
-void hmac_md5(void* dest, void* key, uint16_t keylength_b, void* msg, uint32_t msglength_b){ /* a one-shot*/
+void hmac_md5(void *dest, void *key, uint16_t keylength_b, void *msg, uint32_t msglength_b){ /* a one-shot*/
md5_ctx_t s;
uint8_t i;
uint8_t buffer[MD5_BLOCK_BYTES];
} hmac_md5_ctx_t;
-void hmac_md5_init(hmac_md5_ctx_t *s, void* key, uint16_t keylength_b);
-void hmac_md5_nextBlock(hmac_md5_ctx_t *s, const void* block);
-void hmac_md5_lastBlock(hmac_md5_ctx_t *s, const void* block, uint16_t length_b);
-void hmac_md5_final(void* dest, hmac_md5_ctx_t *s);
+void hmac_md5_init(hmac_md5_ctx_t *s, void *key, uint16_t keylength_b);
+void hmac_md5_nextBlock(hmac_md5_ctx_t *s, const void *block);
+void hmac_md5_lastBlock(hmac_md5_ctx_t *s, const void *block, uint16_t length_b);
+void hmac_md5_final(void *dest, hmac_md5_ctx_t *s);
-void hmac_md5(void* dest, void* key, uint16_t keylength_b, void* msg, uint32_t msglength_b);
+void hmac_md5(void *dest, void *key, uint16_t keylength_b, void *msg, uint32_t msglength_b);
#endif /*HMACMD5_H_*/
#ifndef HMAC_SHORTONLY
-void hmac_sha1_init(hmac_sha1_ctx_t *s, const void* key, uint16_t keylength_b){
+void hmac_sha1_init(hmac_sha1_ctx_t *s, const void *key, uint16_t keylength_b){
uint8_t buffer[SHA1_BLOCK_BYTES];
uint8_t i;
#endif
}
-void hmac_sha1_nextBlock(hmac_sha1_ctx_t *s, const void* block){
+void hmac_sha1_nextBlock(hmac_sha1_ctx_t *s, const void *block){
sha1_nextBlock(&(s->a), block);
}
-void hmac_sha1_lastBlock(hmac_sha1_ctx_t *s, const void* block, uint16_t length_b){
+void hmac_sha1_lastBlock(hmac_sha1_ctx_t *s, const void *block, uint16_t length_b){
while(length_b>=SHA1_BLOCK_BITS){
sha1_nextBlock(&s->a, block);
block = (uint8_t*)block + SHA1_BLOCK_BYTES;
sha1_lastBlock(&s->a, block, length_b);
}
-void hmac_sha1_final(void* dest, hmac_sha1_ctx_t *s){
+void hmac_sha1_final(void *dest, hmac_sha1_ctx_t *s){
sha1_ctx2hash(dest, &s->a);
sha1_lastBlock(&s->b, dest, SHA1_HASH_BITS);
sha1_ctx2hash(dest, &(s->b));
* keylength in bits!
* message length in bits!
*/
-void hmac_sha1(void* dest, const void* key, uint16_t keylength_b, const void* msg, uint32_t msglength_b){ /* a one-shot*/
+void hmac_sha1(void *dest, const void *key, uint16_t keylength_b, const void *msg, uint32_t msglength_b){ /* a one-shot*/
sha1_ctx_t s;
uint8_t i;
uint8_t buffer[SHA1_BLOCK_BYTES];
} hmac_sha1_ctx_t;
-void hmac_sha1_init(hmac_sha1_ctx_t *s, const void* key, uint16_t keylength_b);
-void hmac_sha1_nextBlock(hmac_sha1_ctx_t *s, const void* block);
-void hmac_sha1_lastBlock(hmac_sha1_ctx_t *s, const void* block, uint16_t length_b);
-void hmac_sha1_final(void* dest, hmac_sha1_ctx_t *s);
+void hmac_sha1_init(hmac_sha1_ctx_t *s, const void *key, uint16_t keylength_b);
+void hmac_sha1_nextBlock(hmac_sha1_ctx_t *s, const void *block);
+void hmac_sha1_lastBlock(hmac_sha1_ctx_t *s, const void *block, uint16_t length_b);
+void hmac_sha1_final(void *dest, hmac_sha1_ctx_t *s);
-void hmac_sha1(void* dest, const void* key, uint16_t keylength_b, const void* msg, uint32_t msglength_b);
+void hmac_sha1(void *dest, const void *key, uint16_t keylength_b, const void *msg, uint32_t msglength_b);
#endif /*HMACSHA1_H_*/
#ifndef HMAC_SHA256_SHORTONLY
-void hmac_sha256_init(hmac_sha256_ctx_t *s, const void* key, uint16_t keylength_b){
+void hmac_sha256_init(hmac_sha256_ctx_t *s, const void *key, uint16_t keylength_b){
uint8_t buffer[HMAC_SHA256_BLOCK_BYTES];
uint8_t i;
#endif
}
-void hmac_sha256_nextBlock(hmac_sha256_ctx_t *s, const void* block){
+void hmac_sha256_nextBlock(hmac_sha256_ctx_t *s, const void *block){
sha256_nextBlock(&(s->a), block);
}
-void hmac_sha256_lastBlock(hmac_sha256_ctx_t *s, const void* block, uint16_t length_b){
+void hmac_sha256_lastBlock(hmac_sha256_ctx_t *s, const void *block, uint16_t length_b){
/* while(length_b>=SHA256_BLOCK_BITS){
sha256_nextBlock(&(s->a), block);
block = (uint8_t*)block + SHA256_BLOCK_BYTES;
*/ sha256_lastBlock(&(s->a), block, length_b);
}
-void hmac_sha256_final(void* dest, hmac_sha256_ctx_t *s){
+void hmac_sha256_final(void *dest, hmac_sha256_ctx_t *s){
sha256_ctx2hash((sha256_hash_t*)dest, &(s->a));
sha256_lastBlock(&(s->b), dest, SHA256_HASH_BITS);
sha256_ctx2hash((sha256_hash_t*)dest, &(s->b));
* keylength in bits!
* message length in bits!
*/
-void hmac_sha256(void* dest, const void* key, uint16_t keylength_b, const void* msg, uint32_t msglength_b){ /* a one-shot*/
+void hmac_sha256(void *dest, const void *key, uint16_t keylength_b, const void *msg, uint32_t msglength_b){ /* a one-shot*/
sha256_ctx_t s;
uint8_t i;
uint8_t buffer[HMAC_SHA256_BLOCK_BYTES];
} hmac_sha256_ctx_t;
-void hmac_sha256_init(hmac_sha256_ctx_t *s, const void* key, uint16_t keylength_b);
-void hmac_sha256_nextBlock(hmac_sha256_ctx_t *s, const void* block);
-void hmac_sha256_lastBlock(hmac_sha256_ctx_t *s, const void* block, uint16_t length_b);
-void hmac_sha256_final(void* dest, hmac_sha256_ctx_t *s);
+void hmac_sha256_init(hmac_sha256_ctx_t *s, const void *key, uint16_t keylength_b);
+void hmac_sha256_nextBlock(hmac_sha256_ctx_t *s, const void *block);
+void hmac_sha256_lastBlock(hmac_sha256_ctx_t *s, const void *block, uint16_t length_b);
+void hmac_sha256_final(void *dest, hmac_sha256_ctx_t *s);
-void hmac_sha256(void* dest, const void* key, uint16_t keylength_b, const void* msg, uint32_t msglength_b);
+void hmac_sha256(void *dest, const void *key, uint16_t keylength_b, const void *msg, uint32_t msglength_b);
#endif /*HMACSHA256_H_*/
print_align = 1,
print_prefix = 1;
-char* fmt_strings[]={"%d", "%3d",
+char *fmt_strings[]={"%d", "%3d",
"%X", "%2.2X",
"%o", "%3o",
"%d", "%3d",
int i,j;
int c;
int option_index=0;
- char* fmt=NULL;
+ char *fmt=NULL;
static struct option long_options[] =
{
/* These options set a flag. */
unsigned long ul_reducer=0x00, max=0xff, min=0x00;
uint8_t reducer, a;
char** eptr;
- FILE* of = stdout;
+ FILE *of = stdout;
while(c!=-1){
c = getopt_long(argc, argv,"cCbBdh8aApPr:l:u:f:",
long_options, &option_index);
} jh_ctx_t;
-void jh_init(uint16_t hashlen_b, jh_ctx_t* ctx);
-void jh_nextBlock(jh_ctx_t* ctx, void* block);
-void jh_lastBlock(jh_ctx_t* ctx, void* block, uint16_t length_b);
-void jh_ctx2hash(void* dest, uint16_t length_b, jh_ctx_t* ctx);
+void jh_init(uint16_t hashlen_b, jh_ctx_t *ctx);
+void jh_nextBlock(jh_ctx_t *ctx, void *block);
+void jh_lastBlock(jh_ctx_t *ctx, void *block, uint16_t length_b);
+void jh_ctx2hash(void *dest, uint16_t length_b, jh_ctx_t *ctx);
-void jh224_init(jh_ctx_t* ctx);
-void jh224_ctx2hash(void* dest, jh_ctx_t* ctx);
+void jh224_init(jh_ctx_t *ctx);
+void jh224_ctx2hash(void *dest, jh_ctx_t *ctx);
-void jh256_init(jh_ctx_t* ctx);
-void jh256_ctx2hash(void* dest, jh_ctx_t* ctx);
+void jh256_init(jh_ctx_t *ctx);
+void jh256_ctx2hash(void *dest, jh_ctx_t *ctx);
-void jh384_init(jh_ctx_t* ctx);
-void jh384_ctx2hash(void* dest, jh_ctx_t* ctx);
+void jh384_init(jh_ctx_t *ctx);
+void jh384_ctx2hash(void *dest, jh_ctx_t *ctx);
-void jh512_init(jh_ctx_t* ctx);
-void jh512_ctx2hash(void* dest, jh_ctx_t* ctx);
+void jh512_init(jh_ctx_t *ctx);
+void jh512_ctx2hash(void *dest, jh_ctx_t *ctx);
#endif /* JH_SIMPLE_H_ */
void jh_encrypt(uint8_t *a);
-void jh_init(uint16_t hashlen_b, jh_ctx_t* ctx){
+void jh_init(uint16_t hashlen_b, jh_ctx_t *ctx){
memset(ctx->a, 0, 128);
ctx->a[0] = hashlen_b>>8;
ctx->a[1] = hashlen_b&0xff;
ctx->block_hashed=0;
}
-void jh_nextBlock(jh_ctx_t* ctx, void* block){
+void jh_nextBlock(jh_ctx_t *ctx, void *block){
memxor(ctx->a, block, 64);
jh_encrypt(ctx->a);
memxor(ctx->a+64, block, 64);
ctx->block_hashed++;
}
-void jh_lastBlock(jh_ctx_t* ctx, void* block, uint16_t length_b){
+void jh_lastBlock(jh_ctx_t *ctx, void *block, uint16_t length_b){
while(length_b>=64*8){
jh_nextBlock(ctx, block);
block = (uint8_t*)block + 64;
jh_nextBlock(ctx, buffer);
}
-void jh_ctx2hash(void* dest, uint16_t length_b, jh_ctx_t* ctx){
+void jh_ctx2hash(void *dest, uint16_t length_b, jh_ctx_t *ctx){
memcpy(dest, ctx->a+128-(length_b+7)/8, (length_b+7)/8);
}
-void jh224_init(jh_ctx_t* ctx){
+void jh224_init(jh_ctx_t *ctx){
jh_init(224, ctx);
}
-void jh224_ctx2hash(void* dest, jh_ctx_t* ctx){
+void jh224_ctx2hash(void *dest, jh_ctx_t *ctx){
jh_ctx2hash(dest, 224, ctx);
}
-void jh256_init(jh_ctx_t* ctx){
+void jh256_init(jh_ctx_t *ctx){
jh_init(256, ctx);
}
-void jh256_ctx2hash(void* dest, jh_ctx_t* ctx){
+void jh256_ctx2hash(void *dest, jh_ctx_t *ctx){
jh_ctx2hash(dest, 256, ctx);
}
-void jh384_init(jh_ctx_t* ctx){
+void jh384_init(jh_ctx_t *ctx){
jh_init(384, ctx);
}
-void jh384_ctx2hash(void* dest, jh_ctx_t* ctx){
+void jh384_ctx2hash(void *dest, jh_ctx_t *ctx){
jh_ctx2hash(dest, 384, ctx);
}
-void jh512_init(jh_ctx_t* ctx){
+void jh512_init(jh_ctx_t *ctx){
jh_init(512, ctx);
}
-void jh512_ctx2hash(void* dest, jh_ctx_t* ctx){
+void jh512_ctx2hash(void *dest, jh_ctx_t *ctx){
jh_ctx2hash(dest, 512, ctx);
}
}
static
-void jh_round(uint8_t* a, const uint8_t* rc){
+void jh_round(uint8_t *a, const uint8_t *rc){
uint8_t b[128];
uint8_t i,r=0,x,y;
for(i=0; i<128; ++i){
}
static
-void jh_next_round_const(uint8_t* a){
+void jh_next_round_const(uint8_t *a){
uint8_t b[32];
uint8_t i,x,y;
for(i=0; i<32; ++i){
memcpy(a,b,128);
}
-void jh_encrypt(uint8_t* a){
+void jh_encrypt(uint8_t *a){
uint8_t i;
uint8_t rc[32];
/* grouping */
#endif
static
-void jh_round(uint8_t* a, uint8_t roundno){
+void jh_round(uint8_t *a, uint8_t roundno){
uint8_t b[128];
uint8_t i,r=0,u,v,x,y;
uint8_t *pr;
memcpy(a,b,128);
}
-void jh_encrypt(uint8_t* a){
+void jh_encrypt(uint8_t *a){
uint8_t i;
/* grouping */
#if DEBUG
-- or --
- const uint8_t* rot_code = (const uint8_t*)keccak_rotate_codes;
- const uint8_t* idx_idx = (const uint8_t*)rho_pi_idx_table;
+ const uint8_t *rot_code = (const uint8_t*)keccak_rotate_codes;
+ const uint8_t *idx_idx = (const uint8_t*)rho_pi_idx_table;
uint64_t *a_tmp = (uint64_t*)a;
for(i = 0; i < 25; ++i){
*((uint64_t*)(((uint8_t*)b) + pgm_read_byte(idx_idx++))) =
.endfunc
/*
-void keccak_ctx2hash(void* dest, uint16_t length_b, keccak_ctx_t* ctx){
+void keccak_ctx2hash(void *dest, uint16_t length_b, keccak_ctx_t *ctx){
while(length_b>=ctx->r){
memcpy(dest, ctx->a, ctx->bs);
dest = (uint8_t*)dest + ctx->bs;
ldi r25, hi8(1088)
.endfunc
/*
-void keccak_init(uint16_t r, keccak_ctx_t* ctx){
+void keccak_init(uint16_t r, keccak_ctx_t *ctx){
memset(ctx->a, 0x00, 5 * 5 * 8);
ctx->r = r;
ctx->bs = (uint8_t)(r / 8);
.endfunc
/*
-void keccak_lastBlock(keccak_ctx_t* ctx, const void* block, uint16_t length_b){
+void keccak_lastBlock(keccak_ctx_t *ctx, const void *block, uint16_t length_b){
uint8_t length_B;
uint8_t t;
while(length_b >= ctx->r){
}
}
-void keccak_dump_ctx(keccak_ctx_t* ctx){
+void keccak_dump_ctx(keccak_ctx_t *ctx){
keccak_dump_state(ctx->a);
cli_putstr_P(PSTR("\r\nDBG: r: "));
cli_hexdump_rev(&(ctx->r), 2);
#endif
}
-void keccak_f1600(void* a){
+void keccak_f1600(void *a){
uint8_t i = 0;
do {
#if DEBUG
} while (++i < 24);
}
-void keccak_nextBlock(keccak_ctx_t* ctx, const void* block){
+void keccak_nextBlock(keccak_ctx_t *ctx, const void *block){
memxor(ctx->a, block, ctx->bs);
keccak_f1600(ctx->a);
}
-void keccak_lastBlock(keccak_ctx_t* ctx, const void* block, uint16_t length_b){
+void keccak_lastBlock(keccak_ctx_t *ctx, const void *block, uint16_t length_b){
uint8_t length_B;
uint8_t t;
while(length_b >= ctx->r){
keccak_f1600(ctx->a);
}
-void keccak_ctx2hash(void* dest, uint16_t length_b, keccak_ctx_t* ctx){
+void keccak_ctx2hash(void *dest, uint16_t length_b, keccak_ctx_t *ctx){
while(length_b >= ctx->r){
memcpy(dest, ctx->a, ctx->bs);
dest = (uint8_t*)dest + ctx->bs;
memcpy(dest, ctx->a, (length_b+7)/8);
}
-void keccak224_ctx2hash(void* dest, keccak_ctx_t* ctx){
+void keccak224_ctx2hash(void *dest, keccak_ctx_t *ctx){
keccak_ctx2hash(dest, 224, ctx);
}
-void keccak256_ctx2hash(void* dest, keccak_ctx_t* ctx){
+void keccak256_ctx2hash(void *dest, keccak_ctx_t *ctx){
keccak_ctx2hash(dest, 256, ctx);
}
-void keccak384_ctx2hash(void* dest, keccak_ctx_t* ctx){
+void keccak384_ctx2hash(void *dest, keccak_ctx_t *ctx){
keccak_ctx2hash(dest, 384, ctx);
}
-void keccak512_ctx2hash(void* dest, keccak_ctx_t* ctx){
+void keccak512_ctx2hash(void *dest, keccak_ctx_t *ctx){
keccak_ctx2hash(dest, 512, ctx);
}
3. SHA3-384: ⌊Keccak[r = 832, c = 768, d = 48]⌋384
4. SHA3-512: ⌊Keccak[r = 576, c = 1024, d = 64]⌋512
*/
-void keccak_init(uint16_t r, keccak_ctx_t* ctx){
+void keccak_init(uint16_t r, keccak_ctx_t *ctx){
memset(ctx->a, 0x00, 5 * 5 * 8);
ctx->r = r;
ctx->bs = (uint8_t)(r / 8);
}
-void keccak224_init(keccak_ctx_t* ctx){
+void keccak224_init(keccak_ctx_t *ctx){
keccak_init(1152, ctx);
}
-void keccak256_init(keccak_ctx_t* ctx){
+void keccak256_init(keccak_ctx_t *ctx){
keccak_init(1088, ctx);
}
-void keccak384_init(keccak_ctx_t* ctx){
+void keccak384_init(keccak_ctx_t *ctx){
keccak_init( 832, ctx);
}
-void keccak512_init(keccak_ctx_t* ctx){
+void keccak512_init(keccak_ctx_t *ctx){
keccak_init( 576, ctx);
}
} keccak_ctx_t;
-void keccak_init(uint16_t r, keccak_ctx_t* ctx);
-void keccak224_init(keccak_ctx_t* ctx);
-void keccak256_init(keccak_ctx_t* ctx);
-void keccak384_init(keccak_ctx_t* ctx);
-void keccak512_init(keccak_ctx_t* ctx);
-
-void keccak_nextBlock(keccak_ctx_t* ctx, const void* block);
-void keccak_lastBlock(keccak_ctx_t* ctx, const void* block, uint16_t length_b);
-
-void keccak_ctx2hash(void* dest, uint16_t length_b, keccak_ctx_t* ctx);
-void keccak224_ctx2hash(void* dest, keccak_ctx_t* ctx);
-void keccak256_ctx2hash(void* dest, keccak_ctx_t* ctx);
-void keccak384_ctx2hash(void* dest, keccak_ctx_t* ctx);
-void keccak512_ctx2hash(void* dest, keccak_ctx_t* ctx);
+void keccak_init(uint16_t r, keccak_ctx_t *ctx);
+void keccak224_init(keccak_ctx_t *ctx);
+void keccak256_init(keccak_ctx_t *ctx);
+void keccak384_init(keccak_ctx_t *ctx);
+void keccak512_init(keccak_ctx_t *ctx);
+
+void keccak_nextBlock(keccak_ctx_t *ctx, const void *block);
+void keccak_lastBlock(keccak_ctx_t *ctx, const void *block, uint16_t length_b);
+
+void keccak_ctx2hash(void *dest, uint16_t length_b, keccak_ctx_t *ctx);
+void keccak224_ctx2hash(void *dest, keccak_ctx_t *ctx);
+void keccak256_ctx2hash(void *dest, keccak_ctx_t *ctx);
+void keccak384_ctx2hash(void *dest, keccak_ctx_t *ctx);
+void keccak512_ctx2hash(void *dest, keccak_ctx_t *ctx);
#endif /* KECCAK_H_ */
return b|c;
}
-static void gamma_1(uint8_t* a){
+static void gamma_1(uint8_t *a){
uint8_t i;
for(i=0; i<8; ++i){
*a = khazad_sbox(*a);
{ 0x7B, 0x86, 0x54, 0x31 }
};
-static void theta(uint8_t* a){
+static void theta(uint8_t *a){
uint8_t i,j,x,accu;
uint8_t c[8];
uint8_t *hp;
/******************************************************************************/
-static void khazad_round(uint8_t* a, const uint8_t* k){
+static void khazad_round(uint8_t *a, const uint8_t *k){
gamma_1(a);
theta(a);
memxor(a, k, 8);
/******************************************************************************/
-void khazad_init(const void* key, khazad_ctx_t* ctx){
+void khazad_init(const void *key, khazad_ctx_t *ctx){
uint8_t c[8];
uint8_t i,r=0;
for(i=0; i<8; ++i){
/******************************************************************************/
-void khazad_enc(void* buffer, const khazad_ctx_t* ctx){
+void khazad_enc(void *buffer, const khazad_ctx_t *ctx){
uint8_t r;
memxor(buffer, ctx->k[0], 8);
for(r=1; r<8; ++r){
/******************************************************************************/
-void khazad_dec(void* buffer, const khazad_ctx_t* ctx){
+void khazad_dec(void *buffer, const khazad_ctx_t *ctx){
uint8_t r=7;
memxor(buffer, ctx->k[8], 8);
gamma_1(buffer);
uint8_t k[9][8];
}khazad_ctx_t;
-void khazad_enc(void* buffer, const khazad_ctx_t* ctx);
-void khazad_dec(void* buffer, const khazad_ctx_t* ctx);
-void khazad_init(const void* key, khazad_ctx_t* ctx);
+void khazad_enc(void *buffer, const khazad_ctx_t *ctx);
+void khazad_dec(void *buffer, const khazad_ctx_t *ctx);
+void khazad_init(const void *key, khazad_ctx_t *ctx);
uint8_t khazad_sbox(uint8_t);
#endif /* KHAZAD_H_ */
mov r18, r14
; rjmp md5_core_asm
/*
-void md5_core(uint32_t* a, void* block, uint8_t as, uint8_t s, uint8_t i, uint8_t fi){
+void md5_core(uint32_t *a, void *block, uint8_t as, uint8_t s, uint8_t i, uint8_t fi){
uint32_t t;
- md5_func_t* funcs[]={md5_F, md5_G, md5_H, md5_I};
+ md5_func_t *funcs[]={md5_F, md5_G, md5_H, md5_I};
as &= 0x3;
/ * a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). * /
t = a[as] + funcs[fi](a[(as+1)&3], a[(as+2)&3], a[(as+3)&3]) + *((uint32_t*)block) + md5_T[i] ;
;###################################################################
/*
-void md5_nextBlock(md5_ctx_t *state, void* block){
+void md5_nextBlock(md5_ctx_t *state, void *block){
uint32_t a[4];
uint8_t m,n,i=0;
;###############################################################################
/*
-void md5_lastBlock(md5_ctx_t *state, const void* block, uint16_t length_b){
+void md5_lastBlock(md5_ctx_t *state, const void *block, uint16_t length_b){
uint16_t l;
uint8_t b[64];
while (length_b >= 512){
#define ROTL32(x,n) (((x)<<(n)) | ((x)>>(32-(n))))
static
-void md5_core(uint32_t* a, void* block, uint8_t as, uint8_t s, uint8_t i, uint8_t fi){
+void md5_core(uint32_t *a, void *block, uint8_t as, uint8_t s, uint8_t i, uint8_t fi){
uint32_t t;
- md5_func_t* funcs[]={md5_F, md5_G, md5_H, md5_I};
+ md5_func_t *funcs[]={md5_F, md5_G, md5_H, md5_I};
as &= 0x3;
/* a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
#ifdef DEBUG
a[as]=a[(as+1)&3] + ROTL32(t, s);
}
-void md5_nextBlock(md5_ctx_t *state, const void* block){
+void md5_nextBlock(md5_ctx_t *state, const void *block){
uint32_t a[4];
uint8_t m,n,i=0;
/* this requires other mixed sboxes */
state->counter++;
}
-void md5_lastBlock(md5_ctx_t *state, const void* block, uint16_t length_b){
+void md5_lastBlock(md5_ctx_t *state, const void *block, uint16_t length_b){
uint16_t l;
union {
uint8_t v8[64];
md5_nextBlock(state, buffer.v8);
}
-void md5_ctx2hash(md5_hash_t* dest, const md5_ctx_t* state){
+void md5_ctx2hash(md5_hash_t *dest, const md5_ctx_t *state){
memcpy(dest, state->a, MD5_HASH_BYTES);
}
-void md5(md5_hash_t* dest, const void* msg, uint32_t length_b){
+void md5(md5_hash_t *dest, const void *msg, uint32_t length_b){
md5_ctx_t ctx;
md5_init(&ctx);
while(length_b>=MD5_BLOCK_BITS){
void md5_init(md5_ctx_t *s);
-void md5_nextBlock(md5_ctx_t *state, const void* block);
-void md5_lastBlock(md5_ctx_t *state, const void* block, uint16_t length);
-void md5_ctx2hash(md5_hash_t* dest, const md5_ctx_t* state);
-void md5(md5_hash_t* dest, const void* msg, uint32_t length_b);
+void md5_nextBlock(md5_ctx_t *state, const void *block);
+void md5_lastBlock(md5_ctx_t *state, const void *block, uint16_t length);
+void md5_ctx2hash(md5_hash_t *dest, const md5_ctx_t *state);
+void md5(md5_hash_t *dest, const void *msg, uint32_t length_b);
#endif /*MD5_H_*/
*/
/*
- * void memxor(void* dest, const void* src, uint16_t n);
+ * void memxor(void *dest, const void *src, uint16_t n);
*/
/*
* param dest is passed in r24:r25
#define MEMXOR_H_
#include <stdint.h>
-void memxor(void* dest, const void* src, uint16_t n);
-void memxor_P(void* dest, const void* src, uint16_t n);
+void memxor(void *dest, const void *src, uint16_t n);
+void memxor_P(void *dest, const void *src, uint16_t n);
#endif
#include "memxor.h"
-void memxor(void* dest, const void* src, uint16_t n){
+void memxor(void *dest, const void *src, uint16_t n){
while(n--){
*((uint8_t*)dest) ^= *((uint8_t*)src);
dest = (uint8_t*)dest +1;
*/
/*
- * void memxor(void* dest, const void* src, uint16_t n);
+ * void memxor(void *dest, const void *src, uint16_t n);
*/
/*
* param dest is passed in r24:r25
*/
-void mgf1_short_seed(void* dest, const void* seed, uint8_t seed_len_B, uint16_t out_length_B, const mgf1_parameter_t* p){
+void mgf1_short_seed(void *dest, const void *seed, uint8_t seed_len_B, uint16_t out_length_B, const mgf1_parameter_t *p){
uint8_t buffer[seed_len_B+4];
uint32_t counter=1;
uint8_t hv_len = hfal_hash_getHashsize(p->hashfunction)/8;
}
}
-void mgf1(void* dest, const void* seed, uint16_t seed_len_B, uint16_t out_length_B, const mgf1_parameter_t* p){
+void mgf1(void *dest, const void *seed, uint16_t seed_len_B, uint16_t out_length_B, const mgf1_parameter_t *p){
mgf1_short_seed(dest, seed, seed_len_B, out_length_B, p);
}
#include "hfal-basic.h"
typedef struct {
- const hfdesc_t* hashfunction;
+ const hfdesc_t *hashfunction;
} mgf1_parameter_t;
/*
* MGF1 as defined in PKCS #1 v2.1 B.2.1
*/
-void mgf1(void* dest, const void* seed, uint16_t seed_len_B, uint16_t out_length_B, const mgf1_parameter_t* p);
+void mgf1(void *dest, const void *seed, uint16_t seed_len_B, uint16_t out_length_B, const mgf1_parameter_t *p);
#endif /* MGF1_H_ */
};
static
-void memxor_P(void* d, PGM_VOID_P s, uint8_t length_B){
+void memxor_P(void *d, PGM_VOID_P s, uint8_t length_B){
while(length_B--){
*((uint8_t*)d) ^= pgm_read_byte(s);
d = (uint8_t*)d +1;
#define SHLX1(a) c0=((a)>>7); (a)^=(((a)<<1)|c1)
static
-void clock_r(uint8_t* r, uint8_t ibit, uint8_t cbit){
+void clock_r(uint8_t *r, uint8_t ibit, uint8_t cbit){
uint8_t i,c0=0,c1=0; /* carry */
ibit ^= ((r[159/8])>>(159%8))&1; /* ibit is now the same as feedback_bit */
if(cbit){
};
static
-void clock_s(uint8_t* s, uint8_t ibit, uint8_t cbit){
+void clock_s(uint8_t *s, uint8_t ibit, uint8_t cbit){
uint8_t s0[20], s1[20];
uint8_t i,c=0, c2=0;
ibit ^= (s[19])>>7;
}
static
-void clock_kg(uint8_t* r, uint8_t* s, uint8_t mixing, uint8_t input){
+void clock_kg(uint8_t *r, uint8_t *s, uint8_t mixing, uint8_t input){
uint8_t rb, sb;
rb = ((s[ 54/8])>>(( 54%8))) ^ ((r[106/8])>>(((106%8))));
sb = ((s[106/8])>>((106%8))) ^ ((r[ 53/8])>>((( 53%8))));
clock_s(s, input, sb);
}
-void mickey128_init(void* key, uint16_t keysize_b,
- void* iv, uint16_t ivsize_b,
- mickey128_ctx_t* ctx){
+void mickey128_init(void *key, uint16_t keysize_b,
+ void *iv, uint16_t ivsize_b,
+ mickey128_ctx_t *ctx){
uint16_t i;
memset(ctx->r, 0, 20);
memset(ctx->s, 0, 20);
}
}
-uint8_t mickey128_getbit(mickey128_ctx_t* ctx){
+uint8_t mickey128_getbit(mickey128_ctx_t *ctx){
uint8_t ret;
ret = 1&(*(ctx->r) ^ *(ctx->s));
clock_kg(ctx->r, ctx->s, 0, 0);
return ret;
}
-uint8_t mickey128_getbyte(mickey128_ctx_t* ctx){
+uint8_t mickey128_getbyte(mickey128_ctx_t *ctx){
uint8_t i,ret=0;
for(i=0; i<8; ++i){
ret<<=1;
void debug_clock_r(void);
void debug_clock_s(void);
-void mickey128_init(void* key, uint16_t keysize_b,
- void* iv, uint16_t ivsize_b,
- mickey128_ctx_t* ctx);
-uint8_t mickey128_getbit(mickey128_ctx_t* ctx);
-uint8_t mickey128_getbyte(mickey128_ctx_t* ctx);
+void mickey128_init(void *key, uint16_t keysize_b,
+ void *iv, uint16_t ivsize_b,
+ mickey128_ctx_t *ctx);
+uint8_t mickey128_getbit(mickey128_ctx_t *ctx);
+uint8_t mickey128_getbyte(mickey128_ctx_t *ctx);
#endif /*MICKEY128_H_*/
#include "avr-asm-macros.S"
#if 0
-static void mqq_inv_affine_transformation(uint8_t* input_bytes, uint8_t* result, const mqq160_sign_key_t* key){
+static void mqq_inv_affine_transformation(uint8_t *input_bytes, uint8_t *result, const mqq160_sign_key_t *key){
/* The matrix SInv is given as two permutations of 160 elements. */
uint8_t j, byteindex, bitindex, bitindex_d, byteindex_d, rp1, rp5;
uint8_t *r1_ptr, *r5_ptr;
8, 9, 10, 11, 12, 13, 14, 15,
};
-static void memxor_idx(void* dest, const void* src, uint16_t length, uint8_t dist){
+static void memxor_idx(void *dest, const void *src, uint16_t length, uint8_t dist){
while(length--){
*((uint8_t*)dest) ^= *((uint8_t*)src);
dest = (uint8_t*)dest + 1;
in the MQQ160-SIGN C Library.
*/
-static void mqq_inv_affine_transformation(const uint8_t* input_bytes, uint8_t* result, const mqq160_sign_key_t* key){
+static void mqq_inv_affine_transformation(const uint8_t *input_bytes, uint8_t *result, const mqq160_sign_key_t *key){
/* The matrix SInv is given as two permutations of 160 elements. */
uint8_t j, byteindex, bitindex, bitindex_d, byteindex_d, rp1, rp5;
const uint8_t *rp1_ptr, *rp5_ptr;
static uint16_t MaskShort[8] = {0x8000, 0x4000, 0x2000, 0x1000, 0x0800, 0x0400, 0x0200, 0x0100};
-static uint8_t mqq_q(uint8_t i, uint8_t b1, uint8_t b2, const mqq160_sign_key_t* key){
+static uint8_t mqq_q(uint8_t i, uint8_t b1, uint8_t b2, const mqq160_sign_key_t *key){
uint8_t e[9];
uint16_t a[8];
uint8_t result, column, row, k;
return(result);
}
-void mqq160_sign(void* dest, const void* hash, const mqq160_sign_key_t* key){
+void mqq160_sign(void *dest, const void *hash, const mqq160_sign_key_t *key){
uint8_t i, r1[20], byteindex;
mqq_inv_affine_transformation((uint8_t*)hash, (uint8_t*)dest, key);
r1[0]=((uint8_t*)dest)[0];
const uint8_t *rp5;
} mqq160_sign_key_t;
-void mqq160_sign(void* dest, const void* hash, const mqq160_sign_key_t* key);
+void mqq160_sign(void *dest, const void *hash, const mqq160_sign_key_t *key);
#endif /* MQQ160SIGN_H_ */
#include "avr-asm-macros.S"
#if 0
-static void mqq_inv_affine_transformation(uint8_t* input_bytes, uint8_t* result, const mqq160_sign_key_t* key){
+static void mqq_inv_affine_transformation(uint8_t *input_bytes, uint8_t *result, const mqq160_sign_key_t *key){
/* The matrix SInv is given as two permutations of 160 elements. */
uint8_t j, byteindex, bitindex, bitindex_d, byteindex_d, rp1, rp5;
uint8_t *r1_ptr, *r5_ptr;
*/
-void mqq_inv_affine_transformation(uint8_t* input_bytes, uint8_t* result, const mqq160_sign_key_t* key);
-uint8_t mqq_q(uint8_t i, uint8_t b1, uint8_t b2, const mqq160_sign_key_t* key);
+void mqq_inv_affine_transformation(uint8_t *input_bytes, uint8_t *result, const mqq160_sign_key_t *key);
+uint8_t mqq_q(uint8_t i, uint8_t b1, uint8_t b2, const mqq160_sign_key_t *key);
#if 0
static uint16_t MaskShort[8] = {0x8000, 0x4000, 0x2000, 0x1000, 0x0800, 0x0400, 0x0200, 0x0100};
-static uint8_t mqq_q(uint8_t i, uint8_t b1, uint8_t b2, const mqq160_sign_key_t* key){
+static uint8_t mqq_q(uint8_t i, uint8_t b1, uint8_t b2, const mqq160_sign_key_t *key){
uint8_t e[9];
uint16_t a[8];
uint8_t result, column, row, k;
#endif
-void mqq160_sign_P(void* dest, const void* hash, const mqq160_sign_key_t* key_P){
+void mqq160_sign_P(void *dest, const void *hash, const mqq160_sign_key_t *key_P){
uint8_t i, r1[20], byteindex;
mqq160_sign_key_t key;
8, 9, 10, 11, 12, 13, 14, 15,
};
-static void memxor_idx_P(uint8_t* dest, const uint8_t* src, uint16_t length, uint8_t dist){
+static void memxor_idx_P(uint8_t *dest, const uint8_t *src, uint16_t length, uint8_t dist){
while(length--){
*((uint8_t*)dest) ^= pgm_read_byte((uint8_t*)src);
dest = (uint8_t*)dest + 1;
in the MQQ160-SIGN C Library.
*/
-static void mqq_inv_affine_transformation(uint8_t* input_bytes, uint8_t* result, const mqq160_sign_key_t* key){
+static void mqq_inv_affine_transformation(uint8_t *input_bytes, uint8_t *result, const mqq160_sign_key_t *key){
/* The matrix SInv is given as two permutations of 160 elements. */
uint8_t j, byteindex, bitindex, bitindex_d, byteindex_d, rp1, rp5;
const uint8_t *r1_ptr, *r5_ptr;
static uint16_t MaskShort[8] = {0x8000, 0x4000, 0x2000, 0x1000, 0x0800, 0x0400, 0x0200, 0x0100};
-static uint8_t mqq_q(uint8_t i, uint8_t b1, uint8_t b2, const mqq160_sign_key_t* key){
+static uint8_t mqq_q(uint8_t i, uint8_t b1, uint8_t b2, const mqq160_sign_key_t *key){
uint8_t e[9];
uint16_t a[8];
uint8_t result, column, row, k;
return(result);
}
-void mqq160_sign_P(void* dest, const void* hash, const mqq160_sign_key_t* key_P){
+void mqq160_sign_P(void *dest, const void *hash, const mqq160_sign_key_t *key_P){
uint8_t i, r1[20], byteindex;
mqq160_sign_key_t key;
memcpy_P(&key, key_P, sizeof(mqq160_sign_key_t));
#include "mqq160-sign.h"
-void mqq160_sign_P(void* dest, const void* hash, const mqq160_sign_key_t* key_P);
+void mqq160_sign_P(void *dest, const void *hash, const mqq160_sign_key_t *key_P);
#endif /* MQQ160SIGN_P_H_ */
const mqq160_sign_key_t testkey_P PROGMEM = {a, cc1, cc2, rp1, rp5 };
-void mqq_load_pgm_key(void* buffer, mqq160_sign_key_t* key, const mqq160_sign_key_t* key_P){
+void mqq_load_pgm_key(void *buffer, mqq160_sign_key_t *key, const mqq160_sign_key_t *key_P){
uint8_t *buf_ptr;
buf_ptr = buffer;
memcpy_P(key, key_P, sizeof(mqq160_sign_key_t));
*/
extern const mqq160_sign_key_t testkey_P;
-void mqq_load_pgm_key(void* buffer, mqq160_sign_key_t* key, const mqq160_sign_key_t* key_P);
+void mqq_load_pgm_key(void *buffer, mqq160_sign_key_t *key, const mqq160_sign_key_t *key_P);
#endif /* MQQ160SIGN_TESTKEY_H_ */
/*
#include "cli.h" / * only for debugging * /
-void dump_mugi_ctx(mugi_ctx_t* ctx){
+void dump_mugi_ctx(mugi_ctx_t *ctx){
uint8_t i;
cli_putstr_P(PSTR("\r\n== MUGI CTX DUMP==\r\n a:"));
cli_hexdump(&(ctx->a[0]), 8);
#define T(x) (((uint8_t*)&t)[(x)])
#define D(y) (((uint8_t*)dest)[(y)])
-static void mugi_f(uint64_t* dest, uint64_t* a, uint64_t* b){
+static void mugi_f(uint64_t *dest, uint64_t *a, uint64_t *b){
uint64_t t;
uint8_t i,x;
t = (*a);
}
static
-void mugi_rho(mugi_ctx_t* ctx){
+void mugi_rho(mugi_ctx_t *ctx){
uint64_t t,bx;
t = ctx->a[1];
ctx->a[1] = ctx->a[2];
}
static
-void mugi_rho_init(uint64_t* a){
+void mugi_rho_init(uint64_t *a){
uint64_t t;
t = a[1];
a[1] = a[2];
}
static
-void mugi_lambda(uint64_t* b, uint64_t *a){
+void mugi_lambda(uint64_t *b, uint64_t *a){
uint8_t i;
uint64_t t;
t=b[15];
b[10] ^= rotl64(b[14], 32);
}
-void mugi_init(const void* key, const void* iv, mugi_ctx_t* ctx){
+void mugi_init(const void *key, const void *iv, mugi_ctx_t *ctx){
uint8_t i;
uint64_t a0;
memcpy(ctx->a, key, 128/8);
a0=0x00;
}
-uint64_t mugi_gen(mugi_ctx_t* ctx){
+uint64_t mugi_gen(mugi_ctx_t *ctx){
uint64_t r;
r=ctx->a[0];
mugi_rho(ctx);
uint64_t b[16];
}mugi_ctx_t; /* 152 bytes in total */
-void mugi_init(const void* key, const void* iv, mugi_ctx_t* ctx);
-uint64_t mugi_gen(mugi_ctx_t* ctx);
+void mugi_init(const void *key, const void *iv, mugi_ctx_t *ctx);
+uint64_t mugi_gen(mugi_ctx_t *ctx);
#endif /* MUGI_H_ */
#define RC_POS 0
static
-void gamma_1(uint32_t* a){
+void gamma_1(uint32_t *a){
uint32_t tmp;
a[1] ^= ~((a[3]) | (a[2]));
#define ROTR32(a,n) (((a)>>n)|((a)<<(32-n)))
static
-void pi1(uint32_t* a){
+void pi1(uint32_t *a){
a[1] = ROTL32(a[1], 1);
a[2] = ROTL32(a[2], 5);
a[3] = ROTL32(a[3], 2);
}
static
-void pi2(uint32_t* a){
+void pi2(uint32_t *a){
a[1] = ROTR32(a[1], 1);
a[2] = ROTR32(a[2], 5);
a[3] = ROTR32(a[3], 2);
}
static
-void theta(const uint32_t* k, uint32_t* a){
+void theta(const uint32_t *k, uint32_t *a){
uint32_t temp;
temp = a[0] ^ a[2]; temp ^= ROTR32(temp, 8) ^ ROTL32(temp, 8);
}
static
-void noekeon_round(uint32_t* key, uint32_t* state, uint8_t const1, uint8_t const2){
+void noekeon_round(uint32_t *key, uint32_t *state, uint8_t const1, uint8_t const2){
((uint8_t*)state)[RC_POS] ^= const1;
theta(key, state);
((uint8_t*)state)[RC_POS] ^= const2;
*/
static
-void changendian32(void* a){
+void changendian32(void *a){
((uint8_t*)a)[0] ^= ((uint8_t*)a)[3];
((uint8_t*)a)[3] ^= ((uint8_t*)a)[0];
((uint8_t*)a)[0] ^= ((uint8_t*)a)[3];
}
static
-void changendian(void* a){
+void changendian(void *a){
changendian32((uint32_t*)(&(((uint32_t*)a)[0])));
changendian32((uint32_t*)(&(((uint32_t*)a)[1])));
changendian32((uint32_t*)(&(((uint32_t*)a)[2])));
/******************************************************************************/
-void noekeon_enc(void* buffer, const void* key){
+void noekeon_enc(void *buffer, const void *key){
uint8_t rc=0x80;
uint8_t keyb[16];
int8_t i;
}
-void noekeon_dec(void* buffer, const void* key){
+void noekeon_dec(void *buffer, const void *key){
uint8_t rc;
int8_t i;
uint8_t nullv[16];
changendian(buffer);
}
-void noekeon_init(const void* key, noekeon_ctx_t* ctx){
+void noekeon_init(const void *key, noekeon_ctx_t *ctx){
uint8_t nullv[16];
memset(nullv, 0, 16);
*/
typedef uint8_t noekeon_ctx_t[16];
-/** \fn void noekeon_enc(void* buffer, const void* key)
+/** \fn void noekeon_enc(void *buffer, const void *key)
* \brief noekeon encrytion funtion
*
* This function encrypts a block (64 bit = 8 byte) with the noekeon encrytion
* \param key pointer to either the key (128 bit = 16 byte; direct mode) or
* to the context (indirect mode)
*/
-void noekeon_enc(void* buffer, const void* key);
+void noekeon_enc(void *buffer, const void *key);
-/** \fn void noekeon_dec(void* buffer, const void* key)
+/** \fn void noekeon_dec(void *buffer, const void *key)
* \brief noekeon encrytion funtion
*
* This function decrypts a block (64 bit = 8 byte) encrypted with the noekeon
* \param key pointer to either the key (128 bit = 16 byte; direct mode) or
* to the context (indirect mode)
*/
-void noekeon_dec(void* buffer, const void* key);
+void noekeon_dec(void *buffer, const void *key);
-/** \fn void noekeon_init(const void* key, noekeon_ctx_t* ctx)
+/** \fn void noekeon_init(const void *key, noekeon_ctx_t *ctx)
* \brief noekeon context generation function for indirect mode
*
* This function generates a context from the supplied key for using
* \param ctx pointer to the context to fill with key material
* to the context (indirect mode)
*/
-void noekeon_init(const void* key, noekeon_ctx_t* ctx);
+void noekeon_init(const void *key, noekeon_ctx_t *ctx);
#endif /*NOEKEON_H_*/
/******************************************************************************/
/*
-void theta(uint32_t* k, uint32_t* a){
+void theta(uint32_t *k, uint32_t *a){
uint32_t temp;
temp = a[0] ^ a[2]; temp ^= ROTR32(temp, 8) ^ ROTL32(temp, 8);
a[1] ^= temp;
/******************************************************************************/
/*
-void noekeon_init(void* key, noekeon_ctx_t* ctx){
+void noekeon_init(void *key, noekeon_ctx_t *ctx){
uint8_t nullv[16];
memset(nullv, 0, 16);
.extern noekeon_enc
/*
- * void noekeon_cbc_enc(void* buffer, uint8_t block_cnt, const void* key)
+ * void noekeon_cbc_enc(void *buffer, uint8_t block_cnt, const void *key)
*/
/* param buffer is passed in r24:r25
#include <stdint.h>
#include "noekeon.h"
-void noekeon_cbc_enc(void* buffer, uint8_t block_cnt, const void* key);
+void noekeon_cbc_enc(void *buffer, uint8_t block_cnt, const void *key);
#endif /*NOEKEON_CBC_ENC_H_*/
.extern noekeon_enc
/*
- * void noekeon_ctr_next(void* buffer, const noekeon_ctr_ctx_t* ctx);
+ * void noekeon_ctr_next(void *buffer, const noekeon_ctr_ctx_t *ctx);
*/
.global noekeon_ctr_next
/*
uint8_t key[16];
}noekeon_ctr_ctx_t;
-void noekeon_ctr_next(void* buffer, const noekeon_ctr_ctx_t* ctx);
+void noekeon_ctr_next(void *buffer, const noekeon_ctr_ctx_t *ctx);
#endif /*NOEKEON_CTR_H_*/
return sr[i];
}
-void random_block(void* dest){
+void random_block(void *dest){
i=0;
noekeon_enc(random_state, random_key);
memcpy(dest, random_state, 16);
memcpy(random_key, &seed, 4);
}
-void random_seed(const void* buffer){
+void random_seed(const void *buffer){
memcpy(random_key, buffer, 16);
}
-void random_add(const void* buffer){
+void random_add(const void *buffer){
memxor(random_key, buffer, 16);
}
#include <stdint.h>
uint8_t random8(void);
-void random_block(void* dest);
+void random_block(void *dest);
void srandom32(uint32_t seed);
-void random_seed(const void* buffer);
-void random_add(const void* buffer);
+void random_seed(const void *buffer);
+void random_add(const void *buffer);
#endif /* PRNG_H_*/
/******************************************************************************/
/*
- * void noekeon_omac_init(noekeon_omac_ctx_t* ctx){
+ * void noekeon_omac_init(noekeon_omac_ctx_t *ctx){
* memset(ctx, 0, 16);
* }
*/
/******************************************************************************/
/*
- * void omac_noekeon_tweak(uint8_t t, const void* key, noekeon_omac_ctx_t* ctx){
+ * void omac_noekeon_tweak(uint8_t t, const void *key, noekeon_omac_ctx_t *ctx){
* *ctx[15] = t;
* noekeon_enc(ctx, key);
* }
/******************************************************************************/
/*
- * void noekeon_omac_next(const void* buffer, const void* key, noekeon_omac_ctx_t* ctx){
+ * void noekeon_omac_next(const void *buffer, const void *key, noekeon_omac_ctx_t *ctx){
* memxor(ctx, buffer, 16);
* noekeon_enc(ctx, key);
* }
/******************************************************************************/
/*
- * void omac_noekeon_comppad(uint8_t* pad, const void* key, uint8_t length_b){
+ * void omac_noekeon_comppad(uint8_t *pad, const void *key, uint8_t length_b){
* uint8_t c1,c2,r,j;
* memset(pad, 0, 16);
* noekeon_enc(pad, key);
/******************************************************************************/
/*
- * void omac_noekeon_last(const void* buffer, uint8_t length_b, const void* key, noekeon_omac_ctx_t* ctx){
+ * void omac_noekeon_last(const void *buffer, uint8_t length_b, const void *key, noekeon_omac_ctx_t *ctx){
* while(length_b>128){
* omac_noekeon_next(buffer, key, ctx);
* buffer = (uint8_t*)buffer +16;
/******************************************************************************/
/*
- *void omac_noekeon(void* dest, const void* msg, uint16_t msglength_b,
- * const void* key, uint8_t t){
+ *void omac_noekeon(void *dest, const void *msg, uint16_t msglength_b,
+ * const void *key, uint8_t t){
* omac_noekeon_init(dest);
* if(t!=0xff)
* omac_noekeon_tweak(t,key,dest);
typedef uint8_t omac_noekeon_ctx_t[16];
-void omac_noekeon_init(omac_noekeon_ctx_t* ctx);
-void omac_noekeon_tweak(uint8_t t, const void* key, omac_noekeon_ctx_t* ctx);
-void omac_noekeon_next(const void* buffer, const void* key,
- omac_noekeon_ctx_t* ctx);
-void omac_noekeon_last(const void* buffer, uint8_t length_b, const void* key,
- omac_noekeon_ctx_t* ctx);
-void omac_noekeon(void* dest, const void* msg, uint16_t msglength_b,
- const void* key, uint8_t t);
+void omac_noekeon_init(omac_noekeon_ctx_t *ctx);
+void omac_noekeon_tweak(uint8_t t, const void *key, omac_noekeon_ctx_t *ctx);
+void omac_noekeon_next(const void *buffer, const void *key,
+ omac_noekeon_ctx_t *ctx);
+void omac_noekeon_last(const void *buffer, uint8_t length_b, const void *key,
+ omac_noekeon_ctx_t *ctx);
+void omac_noekeon(void *dest, const void *msg, uint16_t msglength_b,
+ const void *key, uint8_t t);
#endif /*NOEKEON_OMAC_H_*/
#include <stdint.h>
-void omac_noekeon_init(omac_noekeon_ctx_t* ctx){
+void omac_noekeon_init(omac_noekeon_ctx_t *ctx){
memset(ctx, 0, 16);
}
-void omac_noekeon_tweak(uint8_t t, const void* key, omac_noekeon_ctx_t* ctx){
+void omac_noekeon_tweak(uint8_t t, const void *key, omac_noekeon_ctx_t *ctx){
*ctx[15] = t;
noekeon_enc(ctx, key);
}
-void omac_noekeon_next(const void* buffer, const void* key, omac_noekeon_ctx_t* ctx){
+void omac_noekeon_next(const void *buffer, const void *key, omac_noekeon_ctx_t *ctx){
memxor(ctx, buffer, 16);
noekeon_enc(ctx, key);
}
static
-void omac_noekeon_comppad(uint8_t* pad, const void* key, uint8_t length_b){
+void omac_noekeon_comppad(uint8_t *pad, const void *key, uint8_t length_b){
uint8_t c1,c2,r,j;
memset(pad, 0, 16);
noekeon_enc(pad, key);
}
}
-void omac_noekeon_last(const void* buffer, uint8_t length_b, const void* key, omac_noekeon_ctx_t* ctx){
+void omac_noekeon_last(const void *buffer, uint8_t length_b, const void *key, omac_noekeon_ctx_t *ctx){
while(length_b>128){
omac_noekeon_next(buffer, key, ctx);
buffer = (uint8_t*)buffer +16;
}
-void omac_noekeon(void* dest, const void* msg, uint16_t msglength_b,
- const void* key, uint8_t t){
+void omac_noekeon(void *dest, const void *msg, uint16_t msglength_b,
+ const void *key, uint8_t t){
omac_noekeon_init(dest);
if(t!=0xff)
omac_noekeon_tweak(t,key,dest);
#include "present128.h"
static
-void key_update_128(uint8_t* buffer, uint8_t round){
+void key_update_128(uint8_t *buffer, uint8_t round){
uint8_t j;
uint8_t t8;
union __attribute__((packed)){
static
-void key_update_128_inv(uint8_t* buffer, uint8_t round){
+void key_update_128_inv(uint8_t *buffer, uint8_t round){
uint8_t j;
uint8_t t8;
union __attribute__((packed)){
}while(j--);
}
-void present128_init(const uint8_t* key, uint8_t keysize_b, present128_ctx_t* ctx){
+void present128_init(const uint8_t *key, uint8_t keysize_b, present128_ctx_t *ctx){
uint8_t i;
memcpy(ctx->fwd_key, key, 16);
memcpy(ctx->rev_key, key, 16);
}
}
-void present128_enc(void* buffer, present128_ctx_t* ctx){
+void present128_enc(void *buffer, present128_ctx_t *ctx){
present_generic_enc(buffer, (uint8_t*)ctx, 16, key_update_128);
}
-void present128_dec(void* buffer, present128_ctx_t* ctx){
+void present128_dec(void *buffer, present128_ctx_t *ctx){
present_generic_dec(buffer, (uint8_t*)ctx, 16, key_update_128_inv);
}
/*
-void present128_enc(void* buffer, present128_ctx_t* ctx){
+void present128_enc(void *buffer, present128_ctx_t *ctx){
uint8_t i,j,tmp[8], k[16];
memcpy(k, ctx->fwd_key, 16);
memxor(buffer, k, 8);
}
}
-void present128_dec(void* buffer, present128_ctx_t* ctx){
+void present128_dec(void *buffer, present128_ctx_t *ctx){
uint8_t j,tmp[8], k[16];
uint8_t i;
memcpy(k, ctx->rev_key, 16);
} present128_ctx_t;
-void present128_init(const uint8_t* key, uint8_t keysize_b, present128_ctx_t* ctx);
-void present128_enc(void* buffer, present128_ctx_t* ctx);
-void present128_dec(void* buffer, present128_ctx_t* ctx);
+void present128_init(const uint8_t *key, uint8_t keysize_b, present128_ctx_t *ctx);
+void present128_enc(void *buffer, present128_ctx_t *ctx);
+void present128_dec(void *buffer, present128_ctx_t *ctx);
#endif /*PRESENT128_H_*/
#include "present80.h"
static
-void key_update(uint8_t* buffer, uint8_t round){
+void key_update(uint8_t *buffer, uint8_t round){
uint8_t j;
union __attribute__((packed)){
uint8_t v8[2];
}
static
-void key_update_inv(uint8_t* buffer, uint8_t round){
+void key_update_inv(uint8_t *buffer, uint8_t round){
uint8_t j;
union __attribute__((packed)){
uint8_t v8[2];
}while(j--);
}
-void present80_init(const uint8_t* key, uint8_t keysize_b, present80_ctx_t* ctx){
+void present80_init(const uint8_t *key, uint8_t keysize_b, present80_ctx_t *ctx){
uint8_t i;
memcpy(ctx->fwd_key, key, 10);
memcpy(ctx->rev_key, key, 10);
}
}
-void present80_enc(void* buffer, present80_ctx_t* ctx){
+void present80_enc(void *buffer, present80_ctx_t *ctx){
present_generic_enc(buffer, (uint8_t*)ctx, 10, key_update);
}
-void present80_dec(void* buffer, present80_ctx_t* ctx){
+void present80_dec(void *buffer, present80_ctx_t *ctx){
present_generic_dec(buffer, (uint8_t*)ctx, 10, key_update_inv);
}
/*
-void present80_enc(void* buffer, present80_ctx_t* ctx){
+void present80_enc(void *buffer, present80_ctx_t *ctx){
uint8_t i,j,tmp[8], k[10];
memcpy(k, ctx->fwd_key, 10);
memxor(buffer, k, 8);
}
}
-void present80_dec(void* buffer, present80_ctx_t* ctx){
+void present80_dec(void *buffer, present80_ctx_t *ctx){
uint8_t j,tmp[8], k[10];
uint8_t i;
memcpy(k, ctx->rev_key, 10);
} present80_ctx_t;
-void present80_init(const uint8_t* key, uint8_t keysize_b, present80_ctx_t* ctx);
-void present80_enc(void* buffer, present80_ctx_t* ctx);
-void present80_dec(void* buffer, present80_ctx_t* ctx);
+void present80_init(const uint8_t *key, uint8_t keysize_b, present80_ctx_t *ctx);
+void present80_enc(void *buffer, present80_ctx_t *ctx);
+void present80_dec(void *buffer, present80_ctx_t *ctx);
#endif /*PRESENT80_H_*/
return (pgm_read_byte(&sb[b >> 4]) << 4) | pgm_read_byte(&sb[b & 0xf]);
}
-void present_p(uint8_t* o, uint8_t* i){
+void present_p(uint8_t *o, uint8_t *i){
uint8_t m,n=0,idx=0;
for(m=0; m<64; ++m){
o[idx] <<= 1;
}
-void present_generic_enc(void* buffer, uint8_t* ctx, uint8_t ksize_B,
+void present_generic_enc(void *buffer, uint8_t *ctx, uint8_t ksize_B,
void(*update)(uint8_t*, uint8_t)){
uint8_t i,j,tmp[8], k[ksize_B];
memcpy(k, ctx, ksize_B);
}
}
-void present_generic_dec(void* buffer, uint8_t* ctx, uint8_t ksize_B,
+void present_generic_dec(void *buffer, uint8_t *ctx, uint8_t ksize_B,
void(*update)(uint8_t*, uint8_t)){
uint8_t j,tmp[8], k[ksize_B];
uint8_t i;
uint8_t present_sbox(uint8_t b);
uint8_t present_sbox_inv(uint8_t b);
-void present_p(uint8_t* o, uint8_t* i);
+void present_p(uint8_t *o, uint8_t *i);
-void present_generic_enc(void* buffer, uint8_t* ctx, uint8_t ksize_B,
+void present_generic_enc(void *buffer, uint8_t *ctx, uint8_t ksize_B,
void(*update)(uint8_t*, uint8_t));
-void present_generic_dec(void* buffer, uint8_t* ctx, uint8_t ksize_B,
+void present_generic_dec(void *buffer, uint8_t *ctx, uint8_t ksize_B,
void(*update)(uint8_t*, uint8_t));
#endif /*PRESENT_H_*/
#include "present_speed.h"
static
-void key_update(uint8_t* buffer, uint8_t round){
+void key_update(uint8_t *buffer, uint8_t round){
uint8_t j;
union __attribute__((packed)){
uint8_t v8[2];
buffer[7] ^= round >> 1;
}
-void present_init(const uint8_t* key, uint8_t keysize_b, present_ctx_t* ctx){
+void present_init(const uint8_t *key, uint8_t keysize_b, present_ctx_t *ctx){
uint8_t i,key_buffer[10];
memcpy(key_buffer, key, 10);
memcpy(&(ctx->k[0]), key_buffer, 8);
}
-void present_enc(void* buffer, present_ctx_t* ctx){
+void present_enc(void *buffer, present_ctx_t *ctx){
uint8_t i,j,tmp[8];
for(i=0; i<31; ++i){
*((uint64_t*)buffer) ^= ctx->k[i];
}
-void present_dec(void* buffer, present_ctx_t* ctx){
+void present_dec(void *buffer, present_ctx_t *ctx){
uint8_t j,tmp[8];
uint8_t i;
memxor(buffer, &ctx->k[31], 8);
} present_ctx_t;
-void present_init(const uint8_t* key, uint8_t keysize_b, present_ctx_t* ctx);
-void present_enc(void* buffer, present_ctx_t* ctx);
-void present_dec(void* buffer, present_ctx_t* ctx);
+void present_init(const uint8_t *key, uint8_t keysize_b, present_ctx_t *ctx);
+void present_enc(void *buffer, present_ctx_t *ctx);
+void present_dec(void *buffer, present_ctx_t *ctx);
#endif /*PRESENT_H_*/
uint8_t buffer_idx;
} rabbit_ctx_t;
-void dump_ctx(rabbit_ctx_t* ctx);
+void dump_ctx(rabbit_ctx_t *ctx);
-uint8_t rabbit_gen(rabbit_ctx_t* ctx);
-void rabbit_init(const void* key, uint16_t keysize_b,
- const void* iv,
- rabbit_ctx_t* ctx);
+uint8_t rabbit_gen(rabbit_ctx_t *ctx);
+void rabbit_init(const void *key, uint16_t keysize_b,
+ const void *iv,
+ rabbit_ctx_t *ctx);
#endif /* RABBIT_H_ */
#endif
/*
-void dump_ctx(rabbit_ctx_t* ctx){
+void dump_ctx(rabbit_ctx_t *ctx){
uint8_t i=0;
cli_putstr_P(PSTR("\r\n --- ctx dump ---\r\n b = "));
cli_hexdump_byte(ctx->carry);
};
static
-void gen_g(uint32_t* dest, rabbit_ctx_t* ctx){
+void gen_g(uint32_t *dest, rabbit_ctx_t *ctx){
uint8_t i=0;
uint64_t a;
uint32_t t, *x, *c;
}
static
-void update_c(rabbit_ctx_t* ctx){
+void update_c(rabbit_ctx_t *ctx){
uint8_t i=0;
uint64_t a;
uint32_t *c;
#define ROT8(a) (((a)<< 8) | ((a)>>24))
static
-void step(rabbit_ctx_t* ctx){
+void step(rabbit_ctx_t *ctx){
uint32_t g[8];
uint8_t i=0;
update_c(ctx);
}
static
-void keysetup(rabbit_ctx_t* ctx, const void* key){
+void keysetup(rabbit_ctx_t *ctx, const void *key){
uint16_t *x, *c;
uint8_t i=0;
x = (uint16_t*)(ctx->x);
}
static
-void ivsetup(rabbit_ctx_t* ctx, const void* iv){
+void ivsetup(rabbit_ctx_t *ctx, const void *iv){
uint8_t i;
uint32_t t;
union __attribute__((packed)){
}
static
-void extract(rabbit_ctx_t* ctx){
+void extract(rabbit_ctx_t *ctx){
int8_t i=0;
uint8_t *t;
uint16_t v;
static const uint8_t key80_pad[] PROGMEM = { 0xDE, 0x05, 0x6E, 0xAC, 0x8A, 0x11 };
-void rabbit_init(const void* key, uint16_t keysize_b,
- const void* iv,
- rabbit_ctx_t* ctx){
+void rabbit_init(const void *key, uint16_t keysize_b,
+ const void *iv,
+ rabbit_ctx_t *ctx){
uint8_t t_key[16];
if(keysize_b==80){
memcpy(t_key, key, 10);
ctx->buffer_idx = 16;
}
-uint8_t rabbit_gen(rabbit_ctx_t* ctx){
+uint8_t rabbit_gen(rabbit_ctx_t *ctx){
if(ctx->buffer_idx==16){
step(ctx);
extract(ctx);
#define ROTL32(v,n) (((v)<<(n))|((v)>>(32-(n))))
#define ROTR32(v,n) (((v)>>(n))|((v)<<(32-(n))))
-void rc5_enc(void* buffer, const rc5_ctx_t* ctx){
+void rc5_enc(void *buffer, const rc5_ctx_t *ctx){
uint8_t i;
A += ctx->s[0];
B += ctx->s[1];
}
}
-void rc5_dec(void* buffer, const rc5_ctx_t* ctx){
+void rc5_dec(void *buffer, const rc5_ctx_t *ctx){
uint8_t i;
for(i=ctx->rounds; i>0; --i){
B = ROTR32(B - ctx->s[i*2+1], A&31) ^ A;
#define Q32 0x9e3779b9
-void rc5_init(void* key, uint16_t keysize_b, uint8_t rounds, rc5_ctx_t* ctx){
+void rc5_init(void *key, uint16_t keysize_b, uint8_t rounds, rc5_ctx_t *ctx){
uint16_t c,n,m,j,i,t;
uint32_t a,b,l[(keysize_b+31)/32];
ctx->rounds = rounds;
}
}
-void rc5_free(rc5_ctx_t* ctx){
+void rc5_free(rc5_ctx_t *ctx){
if(ctx->s)
free(ctx->s);
}
uint32_t *s;
}rc5_ctx_t;
-void rc5_enc(void* buffer, const rc5_ctx_t* ctx);
-void rc5_dec(void* buffer, const rc5_ctx_t* ctx);
-void rc5_init(void* key, uint16_t keysize_b, uint8_t rounds, rc5_ctx_t* ctx);
-void rc5_free(rc5_ctx_t* ctx);
+void rc5_enc(void *buffer, const rc5_ctx_t *ctx);
+void rc5_dec(void *buffer, const rc5_ctx_t *ctx);
+void rc5_init(void *key, uint16_t keysize_b, uint8_t rounds, rc5_ctx_t *ctx);
+void rc5_free(rc5_ctx_t *ctx);
#endif /*RC5_H_*/
return ( (a>>n)| (a<<(32-n)) );
}
-uint8_t rc6_init(void* key, uint16_t keylength_b, rc6_ctx_t *s){
+uint8_t rc6_init(void *key, uint16_t keylength_b, rc6_ctx_t *s){
return rc6_initl(key, keylength_b, 20, s);
}
-uint8_t rc6_initl(void* key, uint16_t keylength_b, uint8_t rounds, rc6_ctx_t *s){
+uint8_t rc6_initl(void *key, uint16_t keylength_b, uint8_t rounds, rc6_ctx_t *s){
uint8_t i,j;
uint16_t v,p,c;
uint32_t a,b, l=0;
#define C (((uint32_t*)block)[2])
#define D (((uint32_t*)block)[3])
-void rc6_enc(void* block, rc6_ctx_t *s){
+void rc6_enc(void *block, rc6_ctx_t *s){
uint8_t i;
uint32_t t,u,x; /* greetings to Linux? */
B += s->S[0];
C += s->S[2*s->rounds+3];
}
-void rc6_dec(void* block, rc6_ctx_t *s){
+void rc6_dec(void *block, rc6_ctx_t *s){
uint8_t i;
uint32_t t,u,x; /* greetings to Linux? */
} rc6_ctx_t;
-uint8_t rc6_init(void* key, uint16_t keylength_b, rc6_ctx_t *s);
+uint8_t rc6_init(void *key, uint16_t keylength_b, rc6_ctx_t *s);
-uint8_t rc6_initl(void* key, uint16_t keylength_b, uint8_t rounds, rc6_ctx_t *s);
+uint8_t rc6_initl(void *key, uint16_t keylength_b, uint8_t rounds, rc6_ctx_t *s);
-void rc6_enc(void* block, rc6_ctx_t *s);
+void rc6_enc(void *block, rc6_ctx_t *s);
-void rc6_dec(void* block, rc6_ctx_t *s);
+void rc6_dec(void *block, rc6_ctx_t *s);
void rc6_free(rc6_ctx_t *s);
#include "cli.h"
#endif
-void rsa_enc(bigint_t* data, const rsa_publickey_t* key){
+void rsa_enc(bigint_t *data, const rsa_publickey_t *key){
/*
cli_putstr_P(PSTR("\r\n -->rsa_enc()\r\n m = "));
bigint_print_hex(data);
m = m2 + q * h
*/
-uint8_t rsa_dec_crt_mono(bigint_t* data, const rsa_privatekey_t* key){
+uint8_t rsa_dec_crt_mono(bigint_t *data, const rsa_privatekey_t *key){
bigint_t m1, m2;
m1.wordv = malloc((key->components[0].length_W /* + 1 */) * sizeof(bigint_word_t));
m2.wordv = malloc((key->components[1].length_W /* + 1 */) * sizeof(bigint_word_t));
return 0;
}
-uint8_t rsa_dec(bigint_t* data, const rsa_privatekey_t* key){
+uint8_t rsa_dec(bigint_t *data, const rsa_privatekey_t *key){
if(key->n == 1){
bigint_expmod_u(data, data, &(key->components[0]), &key->modulus);
return 0;
return 2;
}
-void rsa_os2ip(bigint_t* dest, const void* data, uint32_t length_B){
+void rsa_os2ip(bigint_t *dest, const void *data, uint32_t length_B){
#if BIGINT_WORD_SIZE == 8
if(data){
memcpy(dest->wordv, data, length_B);
bigint_adjust(dest);
}
-void rsa_i2osp(void* dest, bigint_t* src, uint16_t* out_length_B){
+void rsa_i2osp(void *dest, bigint_t *src, uint16_t *out_length_B){
#if BIGINT_WORD_SIZE == 8
if(dest){
uint8_t *e = src->wordv + src->length_W;
typedef struct {
uint8_t n;
bigint_t modulus;
- bigint_t* components;
+ bigint_t *components;
} rsa_privatekey_t;
} rsa_fullkey_t;
-void rsa_enc(bigint_t* data, const rsa_publickey_t* key);
-uint8_t rsa_dec(bigint_t* data, const rsa_privatekey_t* key);
-void rsa_os2ip(bigint_t* dest, const void* data, uint32_t length_B);
-void rsa_i2osp(void* dest, bigint_t* src, uint16_t* out_length_B);
+void rsa_enc(bigint_t *data, const rsa_publickey_t *key);
+uint8_t rsa_dec(bigint_t *data, const rsa_privatekey_t *key);
+void rsa_os2ip(bigint_t *dest, const void *data, uint32_t length_B);
+void rsa_i2osp(void *dest, bigint_t *src, uint16_t *out_length_B);
#endif /* RSA_BASIC_H_ */
0, NULL
};
-uint8_t rsa_encrypt_oaep(void* dest, uint16_t* out_length,
- const void* src, uint16_t length_B,
- rsa_publickey_t* key, const rsa_oaep_parameter_t *p,
- const rsa_label_t* label, const void* seed){
+uint8_t rsa_encrypt_oaep(void *dest, uint16_t *out_length,
+ const void *src, uint16_t length_B,
+ rsa_publickey_t *key, const rsa_oaep_parameter_t *p,
+ const rsa_label_t *label, const void *seed){
if(!p){
p = &rsa_oaep_default_parameter;
cli_putstr("\r\n modulus_len = ");
cli_hexdump_rev(&key->modulus.length_W, 2);
#endif
- uint8_t* buffer = (uint8_t*)dest;
+ uint8_t *buffer = (uint8_t*)dest;
uint8_t off;
/* the following needs some explanation:
* off is the offset which is used for compensating the effect of
% (sizeof(bigint_word_t));
buffer += off;
buffer_len -= off;
- uint8_t* seed_buffer = buffer + 1;
+ uint8_t *seed_buffer = buffer + 1;
uint16_t db_len = buffer_len - hv_len - 1;
- uint8_t* db = seed_buffer + hv_len;
+ uint8_t *db = seed_buffer + hv_len;
uint16_t maskbuffer_len = db_len>hv_len?db_len:hv_len;
uint8_t maskbuffer[maskbuffer_len];
bigint_t x;
return 0;
}
-uint8_t rsa_decrypt_oaep(void* dest, uint16_t* out_length,
- const void* src, uint16_t length_B,
- rsa_privatekey_t* key, const rsa_oaep_parameter_t *p,
- const rsa_label_t* label, void* seed){
+uint8_t rsa_decrypt_oaep(void *dest, uint16_t *out_length,
+ const void *src, uint16_t length_B,
+ rsa_privatekey_t *key, const rsa_oaep_parameter_t *p,
+ const rsa_label_t *label, void *seed){
// cli_putstr("\r\n -->rsa_decrypt_oaep()"); uart_flush(0);
if(!label){
#include "mgf1.h"
-void mgf1(void* dest, const void* seed, uint16_t seed_len_B, uint16_t out_length_B, const mgf1_parameter_t* p);
+void mgf1(void *dest, const void *seed, uint16_t seed_len_B, uint16_t out_length_B, const mgf1_parameter_t *p);
typedef struct {
- void (*mgf)(void* dst, const void* seed, uint16_t slen_B, uint16_t dstlen_B, const mgf1_parameter_t* p);
- const hfdesc_t* hf;
- mgf1_parameter_t* mgf_parameter;
+ void (*mgf)(void *dst, const void *seed, uint16_t slen_B, uint16_t dstlen_B, const mgf1_parameter_t *p);
+ const hfdesc_t *hf;
+ mgf1_parameter_t *mgf_parameter;
} rsa_oaep_parameter_t;
typedef struct {
uint16_t length_b;
- const void* label;
+ const void *label;
} rsa_label_t;
extern rsa_oaep_parameter_t rsa_oaep_default_parameter;
extern rsa_label_t rsa_oaep_default_label;
-uint8_t rsa_encrypt_oaep(void* dest, uint16_t* out_length,
- const void* src, uint16_t length_B,
- rsa_publickey_t* key, const rsa_oaep_parameter_t *p,
- const rsa_label_t* label, const void* seed);
+uint8_t rsa_encrypt_oaep(void *dest, uint16_t *out_length,
+ const void *src, uint16_t length_B,
+ rsa_publickey_t *key, const rsa_oaep_parameter_t *p,
+ const rsa_label_t *label, const void *seed);
-uint8_t rsa_decrypt_oaep(void* dest, uint16_t* out_length,
- const void* src, uint16_t length_B,
- rsa_privatekey_t* key, const rsa_oaep_parameter_t *p,
- const rsa_label_t* label, void* seed);
+uint8_t rsa_decrypt_oaep(void *dest, uint16_t *out_length,
+ const void *src, uint16_t length_B,
+ rsa_privatekey_t *key, const rsa_oaep_parameter_t *p,
+ const rsa_label_t *label, void *seed);
#endif /* RSA_OAEP_H_ */
#include "random_dummy.h"
-uint16_t rsa_pkcs1v15_compute_padlength_B(bigint_t* modulus, uint16_t msg_length_B){
+uint16_t rsa_pkcs1v15_compute_padlength_B(bigint_t *modulus, uint16_t msg_length_B){
return bigint_get_first_set_bit(modulus) / 8 + 1 - msg_length_B - 3;
}
-uint8_t rsa_encrypt_pkcs1v15(void* dest, uint16_t* out_length, const void* src,
- uint16_t length_B, rsa_publickey_t* key, const void* pad){
+uint8_t rsa_encrypt_pkcs1v15(void *dest, uint16_t *out_length, const void *src,
+ uint16_t length_B, rsa_publickey_t *key, const void *pad){
int16_t pad_length;
bigint_t x;
pad_length = rsa_pkcs1v15_compute_padlength_B(&key->modulus, length_B);
return 0;
}
-uint8_t rsa_decrypt_pkcs1v15(void* dest, uint16_t* out_length, const void* src,
- uint16_t length_B, rsa_privatekey_t* key, void* pad){
+uint8_t rsa_decrypt_pkcs1v15(void *dest, uint16_t *out_length, const void *src,
+ uint16_t length_B, rsa_privatekey_t *key, void *pad){
bigint_t x;
uint16_t m_length, pad_length=0, idx=0;
x.wordv = dest;
#include <stdint.h>
#include "bigint.h"
-uint16_t rsa_pkcs1v15_compute_padlength_B(bigint_t* modulus, uint16_t msg_length_B);
+uint16_t rsa_pkcs1v15_compute_padlength_B(bigint_t *modulus, uint16_t msg_length_B);
-uint8_t rsa_encrypt_pkcs1v15(void* dest, uint16_t* out_length, const void* src,
- uint16_t length_B, rsa_publickey_t* key, const void* pad);
+uint8_t rsa_encrypt_pkcs1v15(void *dest, uint16_t *out_length, const void *src,
+ uint16_t length_B, rsa_publickey_t *key, const void *pad);
-uint8_t rsa_decrypt_pkcs1v15(void* dest, uint16_t* out_length, const void* src,
- uint16_t length_B, rsa_privatekey_t* key, void* pad);
+uint8_t rsa_decrypt_pkcs1v15(void *dest, uint16_t *out_length, const void *src,
+ uint16_t length_B, rsa_privatekey_t *key, void *pad);
#endif /* RSA_PKCS1V15_H_ */
#define ROTL32(a,n) (((a)<<(n))|((a)>>(32-(n))))
static
-void quaterround(uint32_t* a, uint32_t* b, uint32_t* c, uint32_t* d){
+void quaterround(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d){
*b ^= ROTL32(*a + *d, 7);
*c ^= ROTL32(*b + *a, 9);
*d ^= ROTL32(*c + *b, 13);
}
static
-void rowround(uint32_t* a){
+void rowround(uint32_t *a){
quaterround(a+ 0, a+ 1, a+ 2, a+ 3);
quaterround(a+ 5, a+ 6, a+ 7, a+ 4);
quaterround(a+10, a+11, a+ 8, a+ 9);
}
static
-void columnround(uint32_t* a){
+void columnround(uint32_t *a){
quaterround(a+ 0, a+ 4, a+ 8, a+12);
quaterround(a+ 5, a+ 9, a+13, a+ 1);
quaterround(a+10, a+14, a+ 2, a+ 6);
}
static
-void doubleround(uint32_t* a){
+void doubleround(uint32_t *a){
columnround(a);
rowround(a);
}
-void salsa20_hash(uint32_t* a){
+void salsa20_hash(uint32_t *a){
uint8_t i;
uint32_t b[16];
memcpy(b, a, 64);
const uint8_t sigma[] PROGMEM = {'e','x','p','a','n','d',' ','3','2','-','b','y','t','e',' ','k'};
const uint8_t theta[] PROGMEM = {'e','x','p','a','n','d',' ','1','6','-','b','y','t','e',' ','k'};
-void salsa_k32(uint32_t* dest, const uint32_t* k, const uint32_t* n){
+void salsa_k32(uint32_t *dest, const uint32_t *k, const uint32_t *n){
memcpy_P(dest+ 0, sigma+ 0, 4);
memcpy( dest+ 4, k+ 0, 16);
memcpy_P(dest+20, sigma+ 4, 4);
salsa20_hash(dest);
}
-void salsa_k16(uint32_t* dest, const uint32_t* k, const uint32_t* n){
+void salsa_k16(uint32_t *dest, const uint32_t *k, const uint32_t *n){
memcpy_P(dest+ 0, theta+ 0, 4);
memcpy( dest+ 4, k+ 0, 16);
memcpy_P(dest+20, theta+ 4, 4);
salsa20_hash(dest);
}
-void salsa20_genBlock256(void* dest, const void* k, const void* iv, uint64_t i){
+void salsa20_genBlock256(void *dest, const void *k, const void *iv, uint64_t i){
uint32_t n[4];
memcpy(n, iv, 8);
memcpy(n+8, &i, 8);
salsa_k32((uint32_t*)dest, (uint32_t*)k, n);
}
-void salsa20_genBlock128(void* dest, const void* k, const void* iv, uint64_t i){
+void salsa20_genBlock128(void *dest, const void *k, const void *iv, uint64_t i){
uint32_t n[4];
memcpy(n, iv, 8);
memcpy(n+8, &i, 8);
}
-void salsa20_init(void* key, uint16_t keylength_b, void* iv, salsa20_ctx_t* ctx){
+void salsa20_init(void *key, uint16_t keylength_b, void *iv, salsa20_ctx_t *ctx){
if(keylength_b==256){
memcpy_P((ctx->a.v8+ 0), sigma+ 0, 4);
memcpy_P((ctx->a.v8+20), sigma+ 4, 4);
ctx->buffer_idx=64;
}
-uint8_t salsa20_gen(salsa20_ctx_t* ctx){
+uint8_t salsa20_gen(salsa20_ctx_t *ctx){
if(ctx->buffer_idx==64){
memcpy(ctx->buffer, ctx->a.v8, 64);
salsa20_hash((uint32_t*)(ctx->buffer));
uint8_t buffer_idx;
} salsa20_ctx_t;
-void salsa20_hash(uint32_t* a);
-void salsa_k32(uint32_t* dest, const uint32_t* k, const uint32_t* n);
-void salsa_k16(uint32_t* dest, const uint32_t* k, const uint32_t* n);
-void salsa20_genBlock256(void* dest, const void* k, const void* iv, uint64_t i);
-void salsa20_genBlock128(void* dest, const void* k, const void* iv, uint64_t i);
-
-void salsa20_init(void* key, uint16_t keylength_b, void* iv, salsa20_ctx_t* ctx);
-uint8_t salsa20_gen(salsa20_ctx_t* ctx);
+void salsa20_hash(uint32_t *a);
+void salsa_k32(uint32_t *dest, const uint32_t *k, const uint32_t *n);
+void salsa_k16(uint32_t *dest, const uint32_t *k, const uint32_t *n);
+void salsa20_genBlock256(void *dest, const void *k, const void *iv, uint64_t i);
+void salsa20_genBlock128(void *dest, const void *k, const void *iv, uint64_t i);
+
+void salsa20_init(void *key, uint16_t keylength_b, void *iv, salsa20_ctx_t *ctx);
+uint8_t salsa20_gen(salsa20_ctx_t *ctx);
#endif /* SALSA20_H_ */
#include "streamcipher_descriptor.h"
#include "keysize_descriptor.h"
-uint8_t scal_cipher_init(const scdesc_t* cipher_descriptor,
- const void* key, uint16_t keysize_b,
- const void* iv, uint16_t ivsize_b, scgen_ctx_t* ctx){
+uint8_t scal_cipher_init(const scdesc_t *cipher_descriptor,
+ const void *key, uint16_t keysize_b,
+ const void *iv, uint16_t ivsize_b, scgen_ctx_t *ctx){
ctx->buffer = NULL;
ctx->ctx = NULL;
}
-void scal_cipher_free(scgen_ctx_t* ctx){
+void scal_cipher_free(scgen_ctx_t *ctx){
if(ctx->buffer){
free(ctx->buffer);
}
}
}
-uint8_t scal_cipher_gen_byte(scgen_ctx_t* ctx){
+uint8_t scal_cipher_gen_byte(scgen_ctx_t *ctx){
uint8_t flags;
uint16_t blocksize_b;
void_fpt gen_fpt;
}
}
-void scal_cipher_gen_block(void* block, scgen_ctx_t* ctx){
+void scal_cipher_gen_block(void *block, scgen_ctx_t *ctx){
uint8_t flags;
void_fpt gen_fpt;
flags = pgm_read_byte(&(ctx->desc_ptr->flags));
}
}
-void scal_cipher_gen_fillblock(void* block, uint16_t blocksize_B, scgen_ctx_t* ctx){
+void scal_cipher_gen_fillblock(void *block, uint16_t blocksize_B, scgen_ctx_t *ctx){
while(blocksize_B){
*((uint8_t*)block) = scal_cipher_gen_byte(ctx);
block = (uint8_t*)block + 1;
}
}
-uint16_t scal_cipher_getBlocksize_b(const scdesc_t* desc){
+uint16_t scal_cipher_getBlocksize_b(const scdesc_t *desc){
uint16_t blocksize_b;
blocksize_b = pgm_read_word(&(desc->gensize_b));
return blocksize_b;
}
-PGM_VOID_P scal_cipher_getKeysizeDesc(const scdesc_t* desc){
+PGM_VOID_P scal_cipher_getKeysizeDesc(const scdesc_t *desc){
return (PGM_VOID_P)pgm_read_word(&(desc->valid_keysize_desc));
}
-PGM_VOID_P scal_cipher_getIVsizeDesc(const scdesc_t* desc){
+PGM_VOID_P scal_cipher_getIVsizeDesc(const scdesc_t *desc){
return (PGM_VOID_P)pgm_read_word(&(desc->valid_ivsize_desc));
}
#include "keysize_descriptor.h"
#include <avr/pgmspace.h>
-uint8_t scal_cipher_init(const scdesc_t* cipher_descriptor,
- const void* key, uint16_t keysize_b,
- const void* iv, uint16_t ivsize_b, scgen_ctx_t* ctx);
-void scal_cipher_free(scgen_ctx_t* ctx);
-uint8_t scal_cipher_gen_byte(scgen_ctx_t* ctx);
-void scal_cipher_gen_block(void* block, scgen_ctx_t* ctx);
-void scal_cipher_gen_fillblock(void* block, uint16_t blocksize_B, scgen_ctx_t* ctx);
-uint16_t scal_cipher_getBlocksize_b(const scdesc_t* desc);
-PGM_VOID_P scal_cipher_getKeysizeDesc(const scdesc_t* desc);
-PGM_VOID_P scal_cipher_getIVsizeDesc(const scdesc_t* desc);
+uint8_t scal_cipher_init(const scdesc_t *cipher_descriptor,
+ const void *key, uint16_t keysize_b,
+ const void *iv, uint16_t ivsize_b, scgen_ctx_t *ctx);
+void scal_cipher_free(scgen_ctx_t *ctx);
+uint8_t scal_cipher_gen_byte(scgen_ctx_t *ctx);
+void scal_cipher_gen_block(void *block, scgen_ctx_t *ctx);
+void scal_cipher_gen_fillblock(void *block, uint16_t blocksize_B, scgen_ctx_t *ctx);
+uint16_t scal_cipher_getBlocksize_b(const scdesc_t *desc);
+PGM_VOID_P scal_cipher_getKeysizeDesc(const scdesc_t *desc);
+PGM_VOID_P scal_cipher_getIVsizeDesc(const scdesc_t *desc);
#endif /* SCAL_BASIC_H_ */
static const char streamX_n_estream[] PROGMEM = "xor-digest";
static const char streamX_n_nessie[] PROGMEM = "stream[0..511]xored";
-static const char* stream_n_str[] = {
+static const char *stream_n_str[] = {
stream0_n,
stream1_n,
stream2_n,
static const char streamX_l_estream[] PROGMEM = "xor-digest";
static const char streamX_l_nessie[] PROGMEM = "stream[0..131071]xored";
-static const char* stream_l_str[] = {
+static const char *stream_l_str[] = {
stream0_n,
stream1_l,
stream2_l,
nessie_print_footer();
}
-void scal_nessie_run(const scdesc_t* desc){
+void scal_nessie_run(const scdesc_t *desc){
uint16_t keysizes_count, ivsizes_count,i,j;
uint16_t *keysizes=NULL, *ivsizes=NULL;
keysizes_count = get_keysizes((PGM_VOID_P)pgm_read_word(&(desc->valid_keysize_desc)), &keysizes);
uint8_t scal_nessie_get_estream(void);
void scal_nessie_stream_run(const scdesc_t *desc, uint16_t keysize_b, uint16_t ivsize_b);
-void scal_nessie_run(const scdesc_t* desc);
+void scal_nessie_run(const scdesc_t *desc);
#endif /* SCALNESSIE_H_ */
/*
static
-uint64_t f_function(const uint64_t* a, uint32_t k0, uint32_t k1){
+uint64_t f_function(const uint64_t *a, uint32_t k0, uint32_t k1){
uint32_t c,d;
c = *a & 0x00000000FFFFFFFFLL;
/******************************************************************************/
static
-uint64_t f_function(const uint64_t* a, uint32_t k0, uint32_t k1){
+uint64_t f_function(const uint64_t *a, uint32_t k0, uint32_t k1){
uint32_t c,d;
c = *a & 0x00000000FFFFFFFFLL;
ret
/*
- * void serpent_init(const void* key, uint16_t keysize_b, serpent_ctx_t* ctx)
+ * void serpent_init(const void *key, uint16_t keysize_b, serpent_ctx_t *ctx)
*/
/*
* param key is passed in r24:r25
ret
/*
- * void serpent_enc(void* buffer, const serpent_ctx_t* ctx){
+ * void serpent_enc(void *buffer, const serpent_ctx_t *ctx){
*/
/*
* param buffer is passed in r24:r25
rjmp memxor
/*
- * void serpent_dec(void* buffer, const serpent_ctx_t* ctx){
+ * void serpent_dec(void *buffer, const serpent_ctx_t *ctx){
*/
/*
* param buffer is passed in r24:r25
/* depth = 5,7,4,2, Total gates=18 */
static
-void sb0(uint8_t* out, const uint8_t* in){
+void sb0(uint8_t *out, const uint8_t *in){
// (a,b,c,d,w,x,y,z)
uint8_t t01, t02, t03, t05, t06, t07, t08, t09, t11, t12, t13, t14, t15, t17;
t01 = in[4*1] ^ in[4*2];
/* depth = 8,4,3,6, Total gates=19 */
static
-void sb0_inv(uint8_t* out, const uint8_t* in){
+void sb0_inv(uint8_t *out, const uint8_t *in){
uint8_t t02, t03, t04, t05, t06, t08, t09, t10, t12, t13, t14, t15, t17, t18, t01;
t01 = in[4*2] ^ in[4*3];
t02 = in[4*0] | in[4*1];
/* depth = 10,7,3,5, Total gates=18 */
static
-void sb1(uint8_t* out, const uint8_t* in){
+void sb1(uint8_t *out, const uint8_t *in){
uint8_t t02, t03, t04, t05, t06, t07, t08, t10, t11, t12, t13, t16, t17, t01;
t01 = in[4*0] | in[4*3];
t02 = in[4*2] ^ in[4*3];
/* InvS1: 5 8 2 14 15 6 12 3 11 4 7 9 1 13 10 0 */
/* depth = 7,4,5,3, Total gates=18 */
-static void sb1_inv(uint8_t* out, const uint8_t* in){
+static void sb1_inv(uint8_t *out, const uint8_t *in){
uint8_t t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t14, t15, t17, t01;
t01 = in[4*0] ^ in[4*1];
t02 = in[4*1] | in[4*3];
/* S2: 8 6 7 9 3 12 10 15 13 1 14 4 0 11 5 2 */
/* depth = 3,8,11,7, Total gates=16 */
-static void sb2(uint8_t* out, const uint8_t* in){
+static void sb2(uint8_t *out, const uint8_t *in){
uint8_t t02, t03, t05, t06, t07, t08, t09, t10, t12, t13, t14, t01;
t01 = in[4*0] | in[4*2];
t02 = in[4*0] ^ in[4*1];
/* InvS2: 12 9 15 4 11 14 1 2 0 3 6 13 5 8 10 7 */
/* depth = 3,6,8,3, Total gates=18 */
-static void sb2_inv(uint8_t* out, const uint8_t* in){
+static void sb2_inv(uint8_t *out, const uint8_t *in){
uint8_t t02, t03, t04, t06, t07, t08, t09, t10, t11, t12, t15, t16, t17, t01;
t01 = in[4*0] ^ in[4*3];
t02 = in[4*2] ^ in[4*3];
/* S3: 0 15 11 8 12 9 6 3 13 1 2 4 10 7 5 14 */
/* depth = 8,3,5,5, Total gates=18 */
-static void sb3(uint8_t* out, const uint8_t* in){
+static void sb3(uint8_t *out, const uint8_t *in){
uint8_t t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t13, t14, t15, t01;
t01 = in[4*0] ^ in[4*2];
t02 = in[4*0] | in[4*3];
/* InvS3: 0 9 10 7 11 14 6 13 3 5 12 2 4 8 15 1 */
/* depth = 3,6,4,4, Total gates=17 */
-static void sb3_inv(uint8_t* out, const uint8_t* in){
+static void sb3_inv(uint8_t *out, const uint8_t *in){
uint8_t t02, t03, t04, t05, t06, t07, t09, t11, t12, t13, t14, t16, t01;
t01 = in[4*2] | in[4*3];
t02 = in[4*0] | in[4*3];
/* S4: 1 15 8 3 12 0 11 6 2 5 4 10 9 14 7 13 */
/* depth = 6,7,5,3, Total gates=19 */
-static void sb4(uint8_t* out, const uint8_t* in){
+static void sb4(uint8_t *out, const uint8_t *in){
uint8_t t02, t03, t04, t05, t06, t08, t09, t10, t11, t12, t13, t14, t15, t16, t01;
t01 = in[4*0] | in[4*1];
t02 = in[4*1] | in[4*2];
/* InvS4: 5 0 8 3 10 9 7 14 2 12 11 6 4 15 13 1 */
/* depth = 6,4,7,3, Total gates=17 */
-static void sb4_inv(uint8_t* out, const uint8_t* in){
+static void sb4_inv(uint8_t *out, const uint8_t *in){
uint8_t t02, t03, t04, t05, t06, t07, t09, t10, t11, t12, t13, t15, t01;
t01 = in[4*1] | in[4*3];
t02 = in[4*2] | in[4*3];
/* S5: 15 5 2 11 4 10 9 12 0 3 14 8 13 6 7 1 */
/* depth = 4,6,8,6, Total gates=17 */
-static void sb5(uint8_t* out, const uint8_t* in){
+static void sb5(uint8_t *out, const uint8_t *in){
uint8_t t02, t03, t04, t05, t07, t08, t09, t10, t11, t12, t13, t14, t01;
t01 = in[4*1] ^ in[4*3];
t02 = in[4*1] | in[4*3];
/* InvS5: 8 15 2 9 4 1 13 14 11 6 5 3 7 12 10 0 */
/* depth = 4,6,9,7, Total gates=17 */
-static void sb5_inv(uint8_t* out, const uint8_t* in){
+static void sb5_inv(uint8_t *out, const uint8_t *in){
uint8_t t02, t03, t04, t05, t07, t08, t09, t10, t12, t13, t15, t16, t01;
t01 = in[4*0] & in[4*3];
t02 = in[4*2] ^ t01;
/* S6: 7 2 12 5 8 4 6 11 14 9 1 15 13 3 10 0 */
/* depth = 8,3,6,3, Total gates=19 */
-static void sb6(uint8_t* out, const uint8_t* in){
+static void sb6(uint8_t *out, const uint8_t *in){
uint8_t t02, t03, t04, t05, t07, t08, t09, t10, t11, t12, t13, t15, t17, t18, t01;
t01 = in[4*0] & in[4*3];
t02 = in[4*1] ^ in[4*2];
/* InvS6: 15 10 1 13 5 3 6 0 4 9 14 7 2 12 8 11 */
/* depth = 5,3,8,6, Total gates=19 */
-static void sb6_inv(uint8_t* out, const uint8_t* in){
+static void sb6_inv(uint8_t *out, const uint8_t *in){
uint8_t t02, t03, t04, t05, t06, t07, t08, t09, t12, t13, t14, t15, t16, t17, t01;
t01 = in[4*0] ^ in[4*2];
t02 = ~ in[4*2];
/* S7: 1 13 15 0 14 8 2 11 7 4 12 10 9 3 5 6 */
/* depth = 10,7,10,4, Total gates=19 */
-static void sb7(uint8_t* out, const uint8_t* in){
+static void sb7(uint8_t *out, const uint8_t *in){
uint8_t t02, t03, t04, t05, t06, t08, t09, t10, t11, t13, t14, t15, t16, t17, t01;
t01 = in[4*0] & in[4*2];
t02 = ~ in[4*3];
/* InvS7: 3 0 6 13 9 14 15 8 5 12 11 7 10 1 4 2 */
/* depth = 9,7,3,3, Total gates=18 */
-static void sb7_inv(uint8_t* out, const uint8_t* in){
+static void sb7_inv(uint8_t *out, const uint8_t *in){
uint8_t t02, t03, t04, t06, t07, t08, t09, t10, t11, t13, t14, t15, t16, t01;
t01 = in[4*0] & in[4*1];
t02 = in[4*0] | in[4*1];
}
/******************************************************************************/
-static void sbox128x(uint8_t box, void* w){
+static void sbox128x(uint8_t box, void *w){
uint8_t sb[16];
uint8_t i,t,x;
box &= 0x0f;
return ret;
}
-void serpent_init(const void* key, uint16_t keysize_b, serpent_ctx_t* ctx){
+void serpent_init(const void *key, uint16_t keysize_b, serpent_ctx_t *ctx){
uint32_t buffer[8];
uint8_t i,j;
if(keysize_b<256){
}
}
-void serpent_enc(void* buffer, const serpent_ctx_t* ctx){
+void serpent_enc(void *buffer, const serpent_ctx_t *ctx){
uint8_t i;
for(i=0; i<31; ++i){
memxor(buffer, ctx->k[i], 16);
memxor(buffer, ctx->k[i], 16);
}
-void serpent_dec(void* buffer, const serpent_ctx_t* ctx){
+void serpent_dec(void *buffer, const serpent_ctx_t *ctx){
int8_t i=32;
memxor(buffer, ctx->k[i], 16);
/* key must be 256bit (32 byte) large! */
-void serpent_init(const void* key, uint16_t keysize_b, serpent_ctx_t* ctx);
-void serpent_enc(void* buffer, const serpent_ctx_t* ctx);
-void serpent_dec(void* buffer, const serpent_ctx_t* ctx);
+void serpent_init(const void *key, uint16_t keysize_b, serpent_ctx_t *ctx);
+void serpent_enc(void *buffer, const serpent_ctx_t *ctx);
+void serpent_dec(void *buffer, const serpent_ctx_t *ctx);
#endif /*SERPENT_H_*/
typedef uint32_t (*pf_t)(uint32_t x, uint32_t y, uint32_t z);
-void sha1_nextBlock (sha1_ctx_t *state, const void* block){
+void sha1_nextBlock (sha1_ctx_t *state, const void *block){
uint32_t a[5];
uint32_t w[16];
uint32_t temp;
/********************************************************************************************************/
-void sha1_lastBlock(sha1_ctx_t *state, const void* block, uint16_t length){
+void sha1_lastBlock(sha1_ctx_t *state, const void *block, uint16_t length){
uint8_t lb[SHA1_BLOCK_BYTES]; /* local block */
while(length>=SHA1_BLOCK_BITS){
sha1_nextBlock(state, block);
*
*
*/
-void sha1 (void *dest, const void* msg, uint32_t length){
+void sha1 (void *dest, const void *msg, uint32_t length){
sha1_ctx_t s;
DEBUG_S("\r\nBLA BLUB");
sha1_init(&s);
*/
void sha1_init(sha1_ctx_t *state);
-/** \fn sha1_nextBlock(sha1_ctx_t *state, const void* block)
+/** \fn sha1_nextBlock(sha1_ctx_t *state, const void *block)
* \brief process one input block
* This function processes one input block and updates the hash context
* accordingly
* \param state pointer to the state variable to update
* \param block pointer to the message block to process
*/
-void sha1_nextBlock (sha1_ctx_t *state, const void* block);
+void sha1_nextBlock (sha1_ctx_t *state, const void *block);
-/** \fn sha1_lastBlock(sha1_ctx_t *state, const void* block, uint16_t length_b)
+/** \fn sha1_lastBlock(sha1_ctx_t *state, const void *block, uint16_t length_b)
* \brief processes the given block and finalizes the context
* This function processes the last block in a SHA-1 hashing process.
* The block should have a maximum length of a single input block.
* \param block pointer to themessage block to process
* \param length_b length of the message block in bits
*/
-void sha1_lastBlock (sha1_ctx_t *state, const void* block, uint16_t length_b);
+void sha1_lastBlock (sha1_ctx_t *state, const void *block, uint16_t length_b);
/** \fn sha1_ctx2hash(sha1_hash_t *dest, sha1_ctx_t *state)
* \brief convert a state variable into an actual hash value
*/
void sha1_ctx2hash (void *dest, sha1_ctx_t *state);
-/** \fn sha1(sha1_hash_t *dest, const void* msg, uint32_t length_b)
+/** \fn sha1(sha1_hash_t *dest, const void *msg, uint32_t length_b)
* \brief hashing a message which in located entirely in RAM
* This function automatically hashes a message which is entirely in RAM with
* the SHA-1 hashing algorithm.
* \param msg pointer to the message which should be hashed
* \param length_b length of the message in bits
*/
-void sha1(void *dest, const void* msg, uint32_t length_b);
+void sha1(void *dest, const void *msg, uint32_t length_b);
}
/*************************************************************************/
-void sha224_nextBlock (sha224_ctx_t *state, const void* block){
+void sha224_nextBlock (sha224_ctx_t *state, const void *block){
sha2_small_common_nextBlock(state, block);
}
/*************************************************************************/
-void sha224_lastBlock (sha224_ctx_t *state, const void* block, uint16_t length_b){
+void sha224_lastBlock (sha224_ctx_t *state, const void *block, uint16_t length_b){
sha2_small_common_lastBlock(state, block, length_b);
}
/*************************************************************************/
/*
* length in bits!
*/
-void sha224(void* dest, const void* msg, uint32_t length_b){ /* length could be choosen longer but this is for µC */
+void sha224(void *dest, const void *msg, uint32_t length_b){ /* length could be choosen longer but this is for µC */
sha224_ctx_t s;
sha224_init(&s);
while(length_b >= SHA224_BLOCK_BITS){
/*************************************************************************/
-void sha224_ctx2hash(void* dest, const sha224_ctx_t *state){
+void sha224_ctx2hash(void *dest, const sha224_ctx_t *state){
#if defined LITTLE_ENDIAN
uint8_t i, j, *s=(uint8_t*)(state->h);
i=7;
*/
void sha224_init(sha224_ctx_t *state);
-/** \fn void sha224_nextBlock (sha224_ctx_t* state, const void* block)
+/** \fn void sha224_nextBlock (sha224_ctx_t *state, const void *block)
* \brief update the context with a given block
*
* This function updates the SHA-224 hash context by processing the given block
* \param state pointer to the SHA-224 hash context
* \param block pointer to the block of fixed length (512 bit = 64 byte)
*/
-void sha224_nextBlock (sha224_ctx_t* state, const void* block);
+void sha224_nextBlock (sha224_ctx_t *state, const void *block);
-/** \fn void sha224_lastBlock(sha224_ctx_t* state, const void* block, uint16_t length_b)
+/** \fn void sha224_lastBlock(sha224_ctx_t *state, const void *block, uint16_t length_b)
* \brief finalize the context with the given block
*
* This function finalizes the SHA-224 hash context by processing the given block
* \param block pointer to the block of fixed length (512 bit = 64 byte)
* \param length_b the length of the block in bits
*/
-void sha224_lastBlock(sha224_ctx_t* state, const void* block, uint16_t length_b);
+void sha224_lastBlock(sha224_ctx_t *state, const void *block, uint16_t length_b);
-/** \fn void sha224_ctx2hash(sha224_hash_t* dest, const sha224_ctx_t* state)
+/** \fn void sha224_ctx2hash(sha224_hash_t *dest, const sha224_ctx_t *state)
* \brief convert the hash state into the hash value
* This function reads the context and writes the hash value to the destination
* \param dest pointer to the location where the hash value should be written
* \param state pointer to the SHA-224 hash context
*/
-void sha224_ctx2hash(void* dest, const sha224_ctx_t* state);
+void sha224_ctx2hash(void *dest, const sha224_ctx_t *state);
-/** \fn void sha224(sha224_hash_t* dest, const void* msg, uint32_t length_b)
+/** \fn void sha224(sha224_hash_t *dest, const void *msg, uint32_t length_b)
* \brief simple SHA-224 hashing function for direct hashing
*
* This function automatically hashes a given message of arbitary length with
* \param msg pointer to the message thats going to be hashed
* \param length_b length of the message in bits
*/
-void sha224(void* dest, const void* msg, uint32_t length_b);
+void sha224(void *dest, const void *msg, uint32_t length_b);
#endif /*SHA224_H_*/
}
/*************************************************************************/
-void sha256_nextBlock (sha256_ctx_t *state, const void* block){
+void sha256_nextBlock (sha256_ctx_t *state, const void *block){
sha2_small_common_nextBlock(state, block);
}
/*************************************************************************/
-void sha256_lastBlock (sha256_ctx_t *state, const void* block, uint16_t length_b){
+void sha256_lastBlock (sha256_ctx_t *state, const void *block, uint16_t length_b){
sha2_small_common_lastBlock(state, block, length_b);
}
/*************************************************************************/
/*
* length in bits!
*/
-void sha256(void* dest, const void* msg, uint32_t length_b){ /* length could be choosen longer but this is for µC */
+void sha256(void *dest, const void *msg, uint32_t length_b){ /* length could be choosen longer but this is for µC */
sha256_ctx_t s;
sha256_init(&s);
while(length_b >= SHA256_BLOCK_BITS){
/*************************************************************************/
-void sha256_ctx2hash(void* dest, const sha256_ctx_t *state){
+void sha256_ctx2hash(void *dest, const sha256_ctx_t *state){
#if defined LITTLE_ENDIAN
uint8_t i, j, *s=(uint8_t*)(state->h);
i=8;
*/
void sha256_init(sha256_ctx_t *state);
-/** \fn void sha256_nextBlock (sha256_ctx_t* state, const void* block)
+/** \fn void sha256_nextBlock (sha256_ctx_t *state, const void *block)
* \brief update the context with a given block
*
* This function updates the SHA-256 hash context by processing the given block
* \param state pointer to the SHA-256 hash context
* \param block pointer to the block of fixed length (512 bit = 64 byte)
*/
-void sha256_nextBlock (sha256_ctx_t* state, const void* block);
+void sha256_nextBlock (sha256_ctx_t *state, const void *block);
-/** \fn void sha256_lastBlock(sha256_ctx_t* state, const void* block, uint16_t length_b)
+/** \fn void sha256_lastBlock(sha256_ctx_t *state, const void *block, uint16_t length_b)
* \brief finalize the context with the given block
*
* This function finalizes the SHA-256 hash context by processing the given block
* \param block pointer to the block of fixed length (512 bit = 64 byte)
* \param length_b the length of the block in bits
*/
-void sha256_lastBlock(sha256_ctx_t* state, const void* block, uint16_t length_b);
+void sha256_lastBlock(sha256_ctx_t *state, const void *block, uint16_t length_b);
-/** \fn void sha256_ctx2hash(sha256_hash_t* dest, const sha256_ctx_t* state)
+/** \fn void sha256_ctx2hash(sha256_hash_t *dest, const sha256_ctx_t *state)
* \brief convert the hash state into the hash value
* This function reads the context and writes the hash value to the destination
* \param dest pointer to the location where the hash value should be written
* \param state pointer to the SHA-256 hash context
*/
-void sha256_ctx2hash(void* dest, const sha256_ctx_t* state);
+void sha256_ctx2hash(void *dest, const sha256_ctx_t *state);
-/** \fn void sha256(sha256_hash_t* dest, const void* msg, uint32_t length_b)
+/** \fn void sha256(sha256_hash_t *dest, const void *msg, uint32_t length_b)
* \brief simple SHA-256 hashing function for direct hashing
*
* This function automatically hashes a given message of arbitary length with
* \param msg pointer to the message thats going to be hashed
* \param length_b length of the message in bits
*/
-void sha256(void* dest, const void* msg, uint32_t length_b);
+void sha256(void *dest, const void *msg, uint32_t length_b);
#endif /*SHA256_H_*/
#define SIGMA_a(x) (rotr64((x), 1) ^ rotr64((x), 8) ^ ((x)>>7))
#define SIGMA_b(x) (rotr64((x), 19) ^ rotl64((x), 3) ^ ((x)>>6))
-void sha2_large_common_nextBlock(sha2_large_common_ctx_t* ctx, const void* block){
+void sha2_large_common_nextBlock(sha2_large_common_ctx_t *ctx, const void *block){
uint64_t w[16], wx;
uint64_t a[8];
uint64_t t1, t2;
ctx->length += 1;
}
-void sha2_large_common_lastBlock(sha2_large_common_ctx_t* ctx, const void* block, uint16_t length_b){
+void sha2_large_common_lastBlock(sha2_large_common_ctx_t *ctx, const void *block, uint16_t length_b){
while(length_b >= 1024){
sha2_large_common_nextBlock(ctx, block);
block = (uint8_t*)block + 1024/8;
} sha2_large_common_ctx_t;
-void sha2_large_common_nextBlock(sha2_large_common_ctx_t* ctx, const void* block);
-void sha2_large_common_lastBlock(sha2_large_common_ctx_t* ctx, const void* block, uint16_t length_b);
+void sha2_large_common_nextBlock(sha2_large_common_ctx_t *ctx, const void *block);
+void sha2_large_common_lastBlock(sha2_large_common_ctx_t *ctx, const void *block, uint16_t length_b);
#endif /* SHA2_LARGE_COMMON_H_ */
/**
* block must be, 512, Bit = 64, Byte, long !!!
*/
-void sha2_small_common_nextBlock (sha2_small_common_ctx_t *state, const void* block){
+void sha2_small_common_nextBlock (sha2_small_common_ctx_t *state, const void *block){
uint32_t w[16], wx;
uint8_t i;
uint32_t a[8],t1,t2;
}
-void sha2_small_common_lastBlock(sha2_small_common_ctx_t *state, const void* block, uint16_t length_b){
+void sha2_small_common_lastBlock(sha2_small_common_ctx_t *state, const void *block, uint16_t length_b){
uint8_t lb[512/8]; /* local block */
uint64_t len;
while(length_b>=512){
uint32_t length;
} sha2_small_common_ctx_t;
-void sha2_small_common_nextBlock(sha2_small_common_ctx_t* state, const void* block);
-void sha2_small_common_lastBlock(sha2_small_common_ctx_t* state, const void* block, uint16_t length_b);
+void sha2_small_common_nextBlock(sha2_small_common_ctx_t *state, const void *block);
+void sha2_small_common_lastBlock(sha2_small_common_ctx_t *state, const void *block, uint16_t length_b);
#endif /* SHA2_SMALL_COMMON_H_ */
#include "sha384.h"
-void sha384_nextBlock (sha384_ctx_t* ctx, const void* block){
+void sha384_nextBlock (sha384_ctx_t *ctx, const void *block){
sha2_large_common_nextBlock(ctx, block);
}
-void sha384_lastBlock(sha384_ctx_t* ctx, const void* block, uint16_t length_b){
+void sha384_lastBlock(sha384_ctx_t *ctx, const void *block, uint16_t length_b){
sha2_large_common_lastBlock(ctx, block, length_b);
}
};
-void sha384_init(sha384_ctx_t* ctx){
+void sha384_init(sha384_ctx_t *ctx){
ctx->length = 0;
memcpy_P(ctx->h, sha384_init_values, 8*8);
}
-void sha384_ctx2hash(void* dest, const sha384_ctx_t* ctx){
+void sha384_ctx2hash(void *dest, const sha384_ctx_t *ctx){
uint8_t i=6, j, *s = (uint8_t*)(ctx->h);
do{
j=7;
}
-void sha384(void* dest, const void* msg, uint32_t length_b){
+void sha384(void *dest, const void *msg, uint32_t length_b){
sha384_ctx_t ctx;
sha384_init(&ctx);
while(length_b >= 1024){
void sha384_init(sha384_ctx_t *ctx);
-void sha384_nextBlock (sha384_ctx_t* ctx, const void* block);
-void sha384_lastBlock(sha384_ctx_t* ctx, const void* block, uint16_t length_b);
-void sha384_ctx2hash(void* dest, const sha384_ctx_t* ctx);
-void sha384(void* dest, const void* msg, uint32_t length_b);
+void sha384_nextBlock (sha384_ctx_t *ctx, const void *block);
+void sha384_lastBlock(sha384_ctx_t *ctx, const void *block, uint16_t length_b);
+void sha384_ctx2hash(void *dest, const sha384_ctx_t *ctx);
+void sha384(void *dest, const void *msg, uint32_t length_b);
#endif /* SHA384_H_ */
#include "sha512.h"
-void sha512_nextBlock (sha512_ctx_t* ctx, const void* block){
+void sha512_nextBlock (sha512_ctx_t *ctx, const void *block){
sha2_large_common_nextBlock(ctx, block);
}
-void sha512_lastBlock(sha512_ctx_t* ctx, const void* block, uint16_t length_b){
+void sha512_lastBlock(sha512_ctx_t *ctx, const void *block, uint16_t length_b){
sha2_large_common_lastBlock(ctx, block, length_b);
}
};
-void sha512_init(sha512_ctx_t* ctx){
+void sha512_init(sha512_ctx_t *ctx){
ctx->length = 0;
memcpy_P(ctx->h, sha512_init_values, 8*8);
}
-void sha512_ctx2hash(void* dest, const sha512_ctx_t* ctx){
+void sha512_ctx2hash(void *dest, const sha512_ctx_t *ctx){
uint8_t i=8, j, *s = (uint8_t*)(ctx->h);
do{
j=7;
}
-void sha512(void* dest, const void* msg, uint32_t length_b){
+void sha512(void *dest, const void *msg, uint32_t length_b){
sha512_ctx_t ctx;
sha512_init(&ctx);
while(length_b >= 1024){
void sha512_init(sha512_ctx_t *ctx);
-void sha512_nextBlock (sha512_ctx_t* ctx, const void* block);
-void sha512_lastBlock(sha512_ctx_t* ctx, const void* block, uint16_t length_b);
-void sha512_ctx2hash(void* dest, const sha512_ctx_t* ctx);
-void sha512(void* dest, const void* msg, uint32_t length_b);
+void sha512_nextBlock (sha512_ctx_t *ctx, const void *block);
+void sha512_lastBlock(sha512_ctx_t *ctx, const void *block, uint16_t length_b);
+void sha512_ctx2hash(void *dest, const sha512_ctx_t *ctx);
+void sha512(void *dest, const void *msg, uint32_t length_b);
#endif /* SHA512_H_ */
/**
* block must be, 512, Bit = 64, Byte, long !!!
*/
-void sha256_nextBlock (sha256_ctx_t *state, const void* block){
+void sha256_nextBlock (sha256_ctx_t *state, const void *block){
uint32_t w[64]; /* this is 256, byte, large, */
uint8_t i;
uint32_t a[8],t1,t2;
* bits are big endian, meaning high bits come first.
* if you have a message with bits at the end, the byte must be padded with zeros
*/
-void sha256_lastBlock(sha256_ctx_t *state, const void* block, uint16_t length){
+void sha256_lastBlock(sha256_ctx_t *state, const void *block, uint16_t length){
uint8_t lb[SHA256_BLOCK_BITS/8]; /* local block */
while(length>=SHA256_BLOCK_BITS){
sha256_nextBlock(state, block);
/*
* length in bits!
*/
-void sha256(sha256_hash_t *dest, const void* msg, uint32_t length){ /* length could be choosen longer but this is for µC */
+void sha256(sha256_hash_t *dest, const void *msg, uint32_t length){ /* length could be choosen longer but this is for µC */
sha256_ctx_t s;
sha256_init(&s);
while(length >= SHA256_BLOCK_BITS){
* \brief SHA-256 hash value type
*
* A variable of this type may hold the hash value produced by the
- * sha256_ctx2hash(sha256_hash_t* dest, const sha256_ctx_t* state) function.
+ * sha256_ctx2hash(sha256_hash_t *dest, const sha256_ctx_t *state) function.
*/
typedef uint8_t sha256_hash_t[SHA256_HASH_BYTES];
*/
void sha256_init(sha256_ctx_t *state);
-/** \fn void sha256_nextBlock (sha256_ctx_t* state, const void* block)
+/** \fn void sha256_nextBlock (sha256_ctx_t *state, const void *block)
* \brief update the context with a given block
*
* This function updates the SHA-256 hash context by processing the given block
* \param state pointer to the SHA-256 hash context
* \param block pointer to the block of fixed length (512 bit = 64 byte)
*/
-void sha256_nextBlock (sha256_ctx_t* state, const void* block);
+void sha256_nextBlock (sha256_ctx_t *state, const void *block);
-/** \fn void sha256_lastBlock(sha256_ctx_t* state, const void* block, uint16_t length_b)
+/** \fn void sha256_lastBlock(sha256_ctx_t *state, const void *block, uint16_t length_b)
* \brief finalize the context with the given block
*
* This function finalizes the SHA-256 hash context by processing the given block
* \param block pointer to the block of fixed length (512 bit = 64 byte)
* \param length_b the length of the block in bits
*/
-void sha256_lastBlock(sha256_ctx_t* state, const void* block, uint16_t length_b);
+void sha256_lastBlock(sha256_ctx_t *state, const void *block, uint16_t length_b);
-/** \fn void sha256_ctx2hash(sha256_hash_t* dest, const sha256_ctx_t* state)
+/** \fn void sha256_ctx2hash(sha256_hash_t *dest, const sha256_ctx_t *state)
* \brief convert the hash state into the hash value
* This function reads the context and writes the hash value to the destination
* \param dest pointer to the location where the hash value should be written
* \param state pointer to the SHA-256 hash context
*/
-void sha256_ctx2hash(sha256_hash_t* dest, const sha256_ctx_t* state);
+void sha256_ctx2hash(sha256_hash_t *dest, const sha256_ctx_t *state);
-/** \fn void sha256(sha256_hash_t* dest, const void* msg, uint32_t length_b)
+/** \fn void sha256(sha256_hash_t *dest, const void *msg, uint32_t length_b)
* \brief simple SHA-256 hashing function for direct hashing
*
* This function automaticaly hashes a given message of arbitary length with
* \param msg pointer to the message thats going to be hashed
* \param length_b length of the message in bits
*/
-void sha256(sha256_hash_t* dest, const void* msg, uint32_t length_b);
+void sha256(sha256_hash_t *dest, const void *msg, uint32_t length_b);
#endif /*SHA256_H_*/
/******************************************************************************/
/*
-void shabal_p(shabal_ctx_t* ctx, const void* m){
+void shabal_p(shabal_ctx_t *ctx, const void *m){
uint8_t i,j;
for(i=0;i<16;++i){
ctx->b[i] = ROTL32(ctx->b[i],17);
/******************************************************************************/
/*
-void shabal_nextBlock(shabal_ctx_t* ctx, const void* block){
+void shabal_nextBlock(shabal_ctx_t *ctx, const void *block){
uint8_t i;
- uint32_t* t;
+ uint32_t *t;
for(i=0;i<16;++i){
ctx->b[i] += ((uint32_t*)block)[i];
}
/******************************************************************************/
/*
-void shabal_lastBlock(shabal_ctx_t* ctx, const void* block, uint16_t length_b){
+void shabal_lastBlock(shabal_ctx_t *ctx, const void *block, uint16_t length_b){
uint8_t i,j;
- uint32_t* t;
+ uint32_t *t;
uint8_t buffer[64];
while(length_b>=SHABAL_BLOCKSIZE){
shabal_nextBlock(ctx, block);
#define ROTL32(a,n) (((a)<<(n))|((a)>>(32-(n))))
static
-void shabal_p(shabal_ctx_t* ctx, const void* m){
+void shabal_p(shabal_ctx_t *ctx, const void *m){
uint8_t i,j;
for(i=0;i<16;++i){
ctx->b[i] = ROTL32(ctx->b[i],17);
}
}
-void shabal_nextBlock(shabal_ctx_t* ctx, const void* block){
+void shabal_nextBlock(shabal_ctx_t *ctx, const void *block){
uint8_t i;
- uint32_t* t;
+ uint32_t *t;
for(i=0;i<16;++i){
ctx->b[i] += ((uint32_t*)block)[i];
}
ctx->b = t;
}
-void shabal_lastBlock(shabal_ctx_t* ctx, const void* block, uint16_t length_b){
+void shabal_lastBlock(shabal_ctx_t *ctx, const void *block, uint16_t length_b){
uint8_t i,j;
- uint32_t* t;
+ uint32_t *t;
uint8_t buffer[64];
while(length_b>=SHABAL_BLOCKSIZE){
shabal_nextBlock(ctx, block);
}
-void shabal_ctx2hash(void* dest, const shabal_ctx_t* ctx, uint16_t outlength_b){
+void shabal_ctx2hash(void *dest, const shabal_ctx_t *ctx, uint16_t outlength_b){
memcpy(dest, &(ctx->c[16-outlength_b/32]), outlength_b/8);
}
}shabal_ctx_t;
-void shabal192_init(shabal_ctx_t* ctx);
-void shabal224_init(shabal_ctx_t* ctx);
-void shabal256_init(shabal_ctx_t* ctx);
-void shabal384_init(shabal_ctx_t* ctx);
-void shabal512_init(shabal_ctx_t* ctx);
+void shabal192_init(shabal_ctx_t *ctx);
+void shabal224_init(shabal_ctx_t *ctx);
+void shabal256_init(shabal_ctx_t *ctx);
+void shabal384_init(shabal_ctx_t *ctx);
+void shabal512_init(shabal_ctx_t *ctx);
-void shabal_nextBlock(shabal_ctx_t* ctx, const void* block);
-void shabal_lastBlock(shabal_ctx_t* ctx, const void* block, uint16_t length_b);
+void shabal_nextBlock(shabal_ctx_t *ctx, const void *block);
+void shabal_lastBlock(shabal_ctx_t *ctx, const void *block, uint16_t length_b);
-void shabal192_ctx2hash(void* dest, const shabal_ctx_t* ctx);
-void shabal224_ctx2hash(void* dest, const shabal_ctx_t* ctx);
-void shabal256_ctx2hash(void* dest, const shabal_ctx_t* ctx);
-void shabal384_ctx2hash(void* dest, const shabal_ctx_t* ctx);
-void shabal512_ctx2hash(void* dest, const shabal_ctx_t* ctx);
+void shabal192_ctx2hash(void *dest, const shabal_ctx_t *ctx);
+void shabal224_ctx2hash(void *dest, const shabal_ctx_t *ctx);
+void shabal256_ctx2hash(void *dest, const shabal_ctx_t *ctx);
+void shabal384_ctx2hash(void *dest, const shabal_ctx_t *ctx);
+void shabal512_ctx2hash(void *dest, const shabal_ctx_t *ctx);
-void shabal192(void* dest, void* msg, uint32_t length_b);
-void shabal224(void* dest, void* msg, uint32_t length_b);
-void shabal256(void* dest, void* msg, uint32_t length_b);
-void shabal384(void* dest, void* msg, uint32_t length_b);
-void shabal512(void* dest, void* msg, uint32_t length_b);
+void shabal192(void *dest, void *msg, uint32_t length_b);
+void shabal224(void *dest, void *msg, uint32_t length_b);
+void shabal256(void *dest, void *msg, uint32_t length_b);
+void shabal384(void *dest, void *msg, uint32_t length_b);
+void shabal512(void *dest, void *msg, uint32_t length_b);
-void shabal_ctx2hash(void* dest, const shabal_ctx_t* ctx, uint16_t outlength_b);
+void shabal_ctx2hash(void *dest, const shabal_ctx_t *ctx, uint16_t outlength_b);
#endif /* SHABAL_H_ */
/******************************************************************************/
/*
-void shabal192_init(shabal_ctx_t* ctx){
+void shabal192_init(shabal_ctx_t *ctx){
uint8_t i;
ctx->b = ctx->b_buffer;
ctx->c = ctx->c_buffer;
/******************************************************************************/
/*
-void shabal192(void* dest, void* msg, uint32_t length_b){
+void shabal192(void *dest, void *msg, uint32_t length_b){
shabal_ctx_t ctx;
shabal192_init(&ctx);
while(length_b>=SHABAL_BLOCKSIZE){
0x1C096BF4, 0xAC76224B, 0x5215781C, 0xCD5D2669
};
-void shabal192_init(shabal_ctx_t* ctx){
+void shabal192_init(shabal_ctx_t *ctx){
uint8_t i;
ctx->b = ctx->b_buffer;
ctx->c = ctx->c_buffer;
}
}
-void shabal192_ctx2hash(void* dest, const shabal_ctx_t* ctx){
+void shabal192_ctx2hash(void *dest, const shabal_ctx_t *ctx){
shabal_ctx2hash(dest, ctx, 192);
}
-void shabal192(void* dest, void* msg, uint32_t length_b){
+void shabal192(void *dest, void *msg, uint32_t length_b){
shabal_ctx_t ctx;
shabal192_init(&ctx);
while(length_b>=SHABAL_BLOCKSIZE){
0x16F1AC05, 0x38BBEB56, 0x9B01DC60, 0xB1096D83
};
-void shabal224_init(shabal_ctx_t* ctx){
+void shabal224_init(shabal_ctx_t *ctx){
uint8_t i;
ctx->b = ctx->b_buffer;
ctx->c = ctx->c_buffer;
}
}
-void shabal224_ctx2hash(void* dest, const shabal_ctx_t* ctx){
+void shabal224_ctx2hash(void *dest, const shabal_ctx_t *ctx){
shabal_ctx2hash(dest, ctx, 224);
}
-void shabal224(void* dest, void* msg, uint32_t length_b){
+void shabal224(void *dest, void *msg, uint32_t length_b){
shabal_ctx_t ctx;
shabal224_init(&ctx);
while(length_b>=SHABAL_BLOCKSIZE){
0xBC968828, 0xE6E00BF7, 0xBA839E55, 0x9B491C60
};
-void shabal256_init(shabal_ctx_t* ctx){
+void shabal256_init(shabal_ctx_t *ctx){
uint8_t i;
ctx->b = ctx->b_buffer;
ctx->c = ctx->c_buffer;
}
}
-void shabal256_ctx2hash(void* dest, const shabal_ctx_t* ctx){
+void shabal256_ctx2hash(void *dest, const shabal_ctx_t *ctx){
shabal_ctx2hash(dest, ctx, 256);
}
-void shabal256(void* dest, void* msg, uint32_t length_b){
+void shabal256(void *dest, void *msg, uint32_t length_b){
shabal_ctx_t ctx;
shabal256_init(&ctx);
while(length_b>=SHABAL_BLOCKSIZE){
0x7C35073B, 0x28D95E6D, 0xAA340E0D, 0xCB3DEE70
};
-void shabal384_init(shabal_ctx_t* ctx){
+void shabal384_init(shabal_ctx_t *ctx){
uint8_t i;
ctx->b = ctx->b_buffer;
ctx->c = ctx->c_buffer;
}
}
-void shabal384_ctx2hash(void* dest, const shabal_ctx_t* ctx){
+void shabal384_ctx2hash(void *dest, const shabal_ctx_t *ctx){
shabal_ctx2hash(dest, ctx, 384);
}
-void shabal384(void* dest, void* msg, uint32_t length_b){
+void shabal384(void *dest, void *msg, uint32_t length_b){
shabal_ctx_t ctx;
shabal384_init(&ctx);
while(length_b>=SHABAL_BLOCKSIZE){
0x950C3434, 0xAED9A06D, 0x2537DC8D, 0x7CDB5969,
};
-void shabal512_init(shabal_ctx_t* ctx){
+void shabal512_init(shabal_ctx_t *ctx){
uint8_t i;
ctx->b = ctx->b_buffer;
ctx->c = ctx->c_buffer;
}
}
-void shabal512_ctx2hash(void* dest, const shabal_ctx_t* ctx){
+void shabal512_ctx2hash(void *dest, const shabal_ctx_t *ctx){
shabal_ctx2hash(dest, ctx, 512);
}
-void shabal512(void* dest, void* msg, uint32_t length_b){
+void shabal512(void *dest, void *msg, uint32_t length_b){
shabal_ctx_t ctx;
shabal512_init(&ctx);
while(length_b>=SHABAL_BLOCKSIZE){
#include "sha1.h"
#include "shacal1_enc.h"
-void shacal1_enc(void* buffer, void* key, uint16_t keysize_b){
+void shacal1_enc(void *buffer, void *key, uint16_t keysize_b){
sha1_ctx_t ctx, t_ctx;
uint8_t i;
memcpy(t_ctx.h, buffer, SHA1_HASH_BITS/8);
#define SHACAL1_KEYSIZE 512
#define SHACAL1_KEYSIZE_B ((SHACAL1_KEYSIZE+7)/8)
-void shacal1_enc(void* buffer, void* key, uint16_t keysize_b);
+void shacal1_enc(void *buffer, void *key, uint16_t keysize_b);
#endif /*SHACAL1_ENC_H_*/
#include "shacal2_enc.h"
-void shacal2_enc(void* buffer, void* key, uint16_t keysize_b){
+void shacal2_enc(void *buffer, void *key, uint16_t keysize_b){
uint8_t i;
sha256_ctx_t ctx, t_ctx;
memcpy(ctx.h, buffer, SHACAL2_BLOCKSIZE_B);
#define SHACAL2_KEYSIZE SHA256_BLOCK_BITS
#define SHACAL2_KEYSIZE_B ((SHACAL2_KEYSIZE+7)/8)
-void shacal2_enc(void* buffer, void* key, uint16_t keysize_b);
+void shacal2_enc(void *buffer, void *key, uint16_t keysize_b);
#endif /*SHACAL2_ENC_H_*/
ubi256_ctx_t ubictx;
}skein256_ctx_t;
-void skein256_init(skein256_ctx_t* ctx, uint16_t outsize_b);
-void skein256_nextBlock(skein256_ctx_t* ctx, const void* block);
-void skein256_lastBlock(skein256_ctx_t* ctx, const void* block, uint16_t length_b);
-void skein256_ctx2hash(void* dest, skein256_ctx_t* ctx);
-void skein256(void* dest, uint16_t outlength_b, const void* msg, uint32_t length_b);
+void skein256_init(skein256_ctx_t *ctx, uint16_t outsize_b);
+void skein256_nextBlock(skein256_ctx_t *ctx, const void *block);
+void skein256_lastBlock(skein256_ctx_t *ctx, const void *block, uint16_t length_b);
+void skein256_ctx2hash(void *dest, skein256_ctx_t *ctx);
+void skein256(void *dest, uint16_t outlength_b, const void *msg, uint32_t length_b);
typedef struct{
uint16_t outsize_b;
ubi512_ctx_t ubictx;
}skein512_ctx_t;
-void skein512_init(skein512_ctx_t* ctx, uint16_t outsize_b);
-void skein512_nextBlock(skein512_ctx_t* ctx, const void* block);
-void skein512_lastBlock(skein512_ctx_t* ctx, const void* block, uint16_t length_b);
-void skein512_ctx2hash(void* dest, skein512_ctx_t* ctx);
-void skein512(void* dest, uint16_t outlength_b, const void* msg, uint32_t length_b);
+void skein512_init(skein512_ctx_t *ctx, uint16_t outsize_b);
+void skein512_nextBlock(skein512_ctx_t *ctx, const void *block);
+void skein512_lastBlock(skein512_ctx_t *ctx, const void *block, uint16_t length_b);
+void skein512_ctx2hash(void *dest, skein512_ctx_t *ctx);
+void skein512(void *dest, uint16_t outlength_b, const void *msg, uint32_t length_b);
typedef struct{
uint16_t outsize_b;
ubi1024_ctx_t ubictx;
}skein1024_ctx_t;
-void skein1024_init(skein1024_ctx_t* ctx, uint16_t outsize_b);
-void skein1024_nextBlock(skein1024_ctx_t* ctx, const void* block);
-void skein1024_lastBlock(skein1024_ctx_t* ctx, const void* block, uint16_t length_b);
-void skein1024_ctx2hash(void* dest, skein1024_ctx_t* ctx);
-void skein1024(void* dest, uint16_t outlength_b, const void* msg, uint32_t length_b);
+void skein1024_init(skein1024_ctx_t *ctx, uint16_t outsize_b);
+void skein1024_nextBlock(skein1024_ctx_t *ctx, const void *block);
+void skein1024_lastBlock(skein1024_ctx_t *ctx, const void *block, uint16_t length_b);
+void skein1024_ctx2hash(void *dest, skein1024_ctx_t *ctx);
+void skein1024(void *dest, uint16_t outlength_b, const void *msg, uint32_t length_b);
#endif /* SKEIN_H_ */
#include "skein.h"
-void skein1024_init(skein1024_ctx_t* ctx, uint16_t outsize_b){
+void skein1024_init(skein1024_ctx_t *ctx, uint16_t outsize_b){
skein_config_t conf;
uint8_t null[UBI1024_BLOCKSIZE_B];
memset(null, 0, UBI1024_BLOCKSIZE_B);
ubi1024_init(&(ctx->ubictx), ctx->ubictx.g, UBI_TYPE_MSG);
}
-void skein1024_nextBlock(skein1024_ctx_t* ctx, const void* block){
+void skein1024_nextBlock(skein1024_ctx_t *ctx, const void *block){
ubi1024_nextBlock(&(ctx->ubictx), block);
}
-void skein1024_lastBlock(skein1024_ctx_t* ctx, const void* block, uint16_t length_b){
+void skein1024_lastBlock(skein1024_ctx_t *ctx, const void *block, uint16_t length_b){
ubi1024_lastBlock(&(ctx->ubictx), block, length_b);
}
-void skein1024_ctx2hash(void* dest, skein1024_ctx_t* ctx){
+void skein1024_ctx2hash(void *dest, skein1024_ctx_t *ctx){
ubi1024_ctx_t uctx;
uint16_t outsize_b;
}
}
-void skein1024(void* dest, uint16_t outlength_b, const void* msg, uint32_t length_b){
+void skein1024(void *dest, uint16_t outlength_b, const void *msg, uint32_t length_b){
skein1024_ctx_t ctx;
skein1024_init(&ctx, outlength_b);
while(length_b>SKEIN1024_BLOCKSIZE){
/******************************************************************************/
/*
-void skein1024_init(skein1024_ctx_t* ctx, uint16_t outsize_b){
+void skein1024_init(skein1024_ctx_t *ctx, uint16_t outsize_b){
skein_config_t conf;
uint8_t null[UBI1024_BLOCKSIZE_B];
memset(null, 0, UBI1024_BLOCKSIZE_B);
/******************************************************************************/
/*
-void skein1024_ctx2hash(void* dest, skein1024_ctx_t* ctx){
+void skein1024_ctx2hash(void *dest, skein1024_ctx_t *ctx){
ubi1024_ctx_t uctx;
uint16_t outsize_b;
/******************************************************************************/
/*
-void skein1024(void* dest, uint16_t outlength_b, const void* msg, uint32_t length_b){
+void skein1024(void *dest, uint16_t outlength_b, const void *msg, uint32_t length_b){
skein1024_ctx_t ctx;
skein1024_init(&ctx, outlength_b);
while(length_b>SKEIN1024_BLOCKSIZE){
#include "cli.h"
-void skein256_init(skein256_ctx_t* ctx, uint16_t outsize_b){
+void skein256_init(skein256_ctx_t *ctx, uint16_t outsize_b){
skein_config_t conf;
uint8_t null[UBI256_BLOCKSIZE_B];
memset(null, 0, UBI256_BLOCKSIZE_B);
ubi256_init(&(ctx->ubictx), ctx->ubictx.g, UBI_TYPE_MSG);
}
-void skein256_nextBlock(skein256_ctx_t* ctx, const void* block){
+void skein256_nextBlock(skein256_ctx_t *ctx, const void *block){
ubi256_nextBlock(&(ctx->ubictx), block);
}
-void skein256_lastBlock(skein256_ctx_t* ctx, const void* block, uint16_t length_b){
+void skein256_lastBlock(skein256_ctx_t *ctx, const void *block, uint16_t length_b){
ubi256_lastBlock(&(ctx->ubictx), block, length_b);
}
-void skein256_ctx2hash(void* dest, skein256_ctx_t* ctx){
+void skein256_ctx2hash(void *dest, skein256_ctx_t *ctx){
ubi256_ctx_t uctx;
uint16_t outsize_b;
}
}
-void skein256(void* dest, uint16_t outlength_b,const void* msg, uint32_t length_b){
+void skein256(void *dest, uint16_t outlength_b,const void *msg, uint32_t length_b){
skein256_ctx_t ctx;
skein256_init(&ctx, outlength_b);
while(length_b>SKEIN256_BLOCKSIZE){
/******************************************************************************/
/*
-void skein256_init(skein256_ctx_t* ctx, uint16_t outsize_b){
+void skein256_init(skein256_ctx_t *ctx, uint16_t outsize_b){
skein_config_t conf;
uint8_t null[UBI256_BLOCKSIZE_B];
memset(null, 0, UBI256_BLOCKSIZE_B);
/******************************************************************************/
/*
-void skein256_ctx2hash(void* dest, skein256_ctx_t* ctx){
+void skein256_ctx2hash(void *dest, skein256_ctx_t *ctx){
ubi256_ctx_t uctx;
uint16_t outsize_b;
/******************************************************************************/
/*
-void skein256(void* dest, uint16_t outlength_b, const void* msg, uint32_t length_b){
+void skein256(void *dest, uint16_t outlength_b, const void *msg, uint32_t length_b){
skein256_ctx_t ctx;
skein256_init(&ctx, outlength_b);
while(length_b>SKEIN256_BLOCKSIZE){
#include "skein.h"
-void skein512_init(skein512_ctx_t* ctx, uint16_t outsize_b){
+void skein512_init(skein512_ctx_t *ctx, uint16_t outsize_b){
skein_config_t conf;
uint8_t null[UBI512_BLOCKSIZE_B];
memset(null, 0, UBI512_BLOCKSIZE_B);
ubi512_init(&(ctx->ubictx), ctx->ubictx.g, UBI_TYPE_MSG);
}
-void skein512_nextBlock(skein512_ctx_t* ctx, const void* block){
+void skein512_nextBlock(skein512_ctx_t *ctx, const void *block){
ubi512_nextBlock(&(ctx->ubictx), block);
}
-void skein512_lastBlock(skein512_ctx_t* ctx, const void* block, uint16_t length_b){
+void skein512_lastBlock(skein512_ctx_t *ctx, const void *block, uint16_t length_b){
ubi512_lastBlock(&(ctx->ubictx), block, length_b);
}
-void skein512_ctx2hash(void* dest, skein512_ctx_t* ctx){
+void skein512_ctx2hash(void *dest, skein512_ctx_t *ctx){
ubi512_ctx_t uctx;
uint16_t outsize_b;
}
}
-void skein512(void* dest, uint16_t outlength_b,const void* msg, uint32_t length_b){
+void skein512(void *dest, uint16_t outlength_b,const void *msg, uint32_t length_b){
skein512_ctx_t ctx;
skein512_init(&ctx, outlength_b);
while(length_b>SKEIN512_BLOCKSIZE){
/******************************************************************************/
/*
-void skein512_init(skein512_ctx_t* ctx, uint16_t outsize_b){
+void skein512_init(skein512_ctx_t *ctx, uint16_t outsize_b){
skein_config_t conf;
uint8_t null[UBI512_BLOCKSIZE_B];
memset(null, 0, UBI512_BLOCKSIZE_B);
/******************************************************************************/
/*
-void skein512_ctx2hash(void* dest, skein512_ctx_t* ctx){
+void skein512_ctx2hash(void *dest, skein512_ctx_t *ctx){
ubi512_ctx_t uctx;
uint16_t outsize_b;
/******************************************************************************/
/*
-void skein512(void* dest, uint16_t outlength_b,const void* msg, uint32_t length_b){
+void skein512(void *dest, uint16_t outlength_b,const void *msg, uint32_t length_b){
skein512_ctx_t ctx;
skein512_init(&ctx, outlength_b);
while(length_b>SKEIN512_BLOCKSIZE){
} threefish1024_ctx_t;
-void threefish_mix(void* data, uint8_t rot);
-void threefish_invmix(void* data, uint8_t rot);
+void threefish_mix(void *data, uint8_t rot);
+void threefish_invmix(void *data, uint8_t rot);
-void threefish256_init(const void* key, const void* tweak, threefish256_ctx_t* ctx);
-void threefish512_init(const void* key, const void* tweak, threefish512_ctx_t* ctx);
-void threefish1024_init(const void* key, const void* tweak, threefish1024_ctx_t* ctx);
+void threefish256_init(const void *key, const void *tweak, threefish256_ctx_t *ctx);
+void threefish512_init(const void *key, const void *tweak, threefish512_ctx_t *ctx);
+void threefish1024_init(const void *key, const void *tweak, threefish1024_ctx_t *ctx);
-void threefish256_enc(void* data, const threefish256_ctx_t* ctx);
-void threefish512_enc(void* data, const threefish512_ctx_t* ctx);
-void threefish1024_enc(void* data, const threefish1024_ctx_t* ctx);
+void threefish256_enc(void *data, const threefish256_ctx_t *ctx);
+void threefish512_enc(void *data, const threefish512_ctx_t *ctx);
+void threefish1024_enc(void *data, const threefish1024_ctx_t *ctx);
-void threefish256_dec(void* data, const threefish256_ctx_t* ctx);
-void threefish512_dec(void* data, const threefish512_ctx_t* ctx);
-void threefish1024_dec(void* data, const threefish1024_ctx_t* ctx);
+void threefish256_dec(void *data, const threefish256_ctx_t *ctx);
+void threefish512_dec(void *data, const threefish512_ctx_t *ctx);
+void threefish1024_dec(void *data, const threefish1024_ctx_t *ctx);
#endif /* THREEFISH_H_ */
#define X(a) (((uint64_t*)data)[(a)])
static
-void permute_inv16(void* data){
+void permute_inv16(void *data){
uint64_t t;
t = X(15);
X(15) = X(7);
}
static
-void add_key_16(void* data, const threefish1024_ctx_t* ctx, uint8_t s){
+void add_key_16(void *data, const threefish1024_ctx_t *ctx, uint8_t s){
uint8_t i;
for(i=0; i<13; ++i){
X(i) -= ctx->k[(s+i)%17];
X(15) -= ctx->k[(s+15)%17] + s;
}
-void threefish1024_dec(void* data, const threefish1024_ctx_t* ctx){
+void threefish1024_dec(void *data, const threefish1024_ctx_t *ctx){
uint8_t i=0,s=20;
/* old round constants
uint8_t r0[8] = {47, 58, 17, 28, 34, 33, 25, 55};
/******************************************************************************/
/*
-void permute_inv16(void* data){
+void permute_inv16(void *data){
uint64_t t;
t = X(15);
X(15) = X(7);
X(10) = X(8);
X(8) = t;
}
-void add_key_16(void* data, const threefish1024_ctx_t* ctx, uint8_t s){
+void add_key_16(void *data, const threefish1024_ctx_t *ctx, uint8_t s){
uint8_t i;
for(i=0; i<13; ++i){
X(i) -= ctx->k[(s+i)%17];
X(14) -= ctx->k[(s+14)%17] + ctx->t[(s+1)%3];
X(15) -= ctx->k[(s+15)%17] + s;
}
-void threefish1024_dec(void* data, const threefish1024_ctx_t* ctx){
+void threefish1024_dec(void *data, const threefish1024_ctx_t *ctx){
uint8_t i=0,s=20;
uint8_t r0[8] = {0x69, 0x72, 0x21, 0x34, 0x42, 0x41, 0x31, 0x79};
uint8_t r1[8] = {0x61, 0x19, 0x1a, 0x19, 0x53, 0x10, 0x31, 0x53};
#define X(a) (((uint64_t*)data)[(a)])
static
-void permute_inv16(void* data){
+void permute_inv16(void *data){
uint64_t t;
t = X(15);
X(15) = X(7);
}
static
-void add_key_16(void* data, const threefish1024_ctx_t* ctx, uint8_t s){
+void add_key_16(void *data, const threefish1024_ctx_t *ctx, uint8_t s){
uint8_t i;
for(i=0; i<13; ++i){
X(i) -= ctx->k[(s+i)%17];
X(15) -= ctx->k[(s+15)%17] + s;
}
-void threefish1024_dec(void* data, const threefish1024_ctx_t* ctx){
+void threefish1024_dec(void *data, const threefish1024_ctx_t *ctx){
uint8_t i=0,s=20;
uint8_t r0[8] = {0x69, 0x72, 0x21, 0x34, 0x42, 0x41, 0x31, 0x79};
uint8_t r1[8] = {0x61, 0x19, 0x1a, 0x19, 0x53, 0x10, 0x31, 0x53};
#define X(a) (((uint64_t*)data)[(a)])
static
-void permute_16(void* data){
+void permute_16(void *data){
uint64_t t;
t = X(1);
X(1) = X(9);
#define K(s) (((uint64_t*)key)[(s)])
#define T(s) (((uint64_t*)tweak)[(s)])
-void threefish1024_init(const void* key, const void* tweak, threefish1024_ctx_t* ctx){
+void threefish1024_init(const void *key, const void *tweak, threefish1024_ctx_t *ctx){
memcpy(ctx->k, key, 16*8);
if(tweak){
memcpy(ctx->t, tweak, 2*8);
}
static
-void add_key_16(void* data, const threefish1024_ctx_t* ctx, uint8_t s){
+void add_key_16(void *data, const threefish1024_ctx_t *ctx, uint8_t s){
uint8_t i;
for(i=0; i<13; ++i){
X(i) += ctx->k[(s+i)%17];
X(15) += ctx->k[(s+15)%17] + s;
}
-void threefish1024_enc(void* data, const threefish1024_ctx_t* ctx){
+void threefish1024_enc(void *data, const threefish1024_ctx_t *ctx){
uint8_t i=0,s=0;
/* old constans, changed at round 2 of the SHA-3 contest
uint8_t r0[8] = {55, 25, 33, 34, 28, 17, 58, 47};
#define K(s) (((uint64_t*)key)[(s)])
#define T(s) (((uint64_t*)tweak)[(s)])
-void threefish1024_init(const void* key, const void* tweak, threefish512_ctx_t* ctx){
+void threefish1024_init(const void *key, const void *tweak, threefish512_ctx_t *ctx){
memcpy(ctx->k, key, 16*8);
memcpy(ctx->t, tweak, 2*8);
uint8_t i;
/******************************************************************************/
/*
#define X(a) (((uint64_t*)data)[(a)])
-void permute_16(void* data){
+void permute_16(void *data){
uint64_t t;
t = X(1);
X(1) = X(9);
X(12) = X(14);
X(14) = t;
}
-void add_key_16(void* data, const threefish1024_ctx_t* ctx, uint8_t s){
+void add_key_16(void *data, const threefish1024_ctx_t *ctx, uint8_t s){
uint8_t i;
for(i=0; i<13; ++i){
X(i) += ctx->k[(s+i)%17];
X(14) += ctx->k[(s+14)%17] + ctx->t[(s+1)%3];
X(15) += ctx->k[(s+15)%17] + s;
}
-void threefish1024_enc(void* data, const threefish1024_ctx_t* ctx){
+void threefish1024_enc(void *data, const threefish1024_ctx_t *ctx){
uint8_t i=0,s=0;
uint8_t r0[8] = {55, 25, 33, 34, 28, 17, 58, 47};
uint8_t r1[8] = {43, 25, 8, 43, 7, 6, 7, 49};
#define X(a) (((uint64_t*)data)[(a)])
static
-void permute_4(void* data){
+void permute_4(void *data){
uint64_t t;
t = X(1);
X(1) = X(3);
#define T(s) (((uint64_t*)tweak)[(s)])
static
-void add_key_4(void* data, const threefish256_ctx_t* ctx, uint8_t s){
+void add_key_4(void *data, const threefish256_ctx_t *ctx, uint8_t s){
X(0) -= ctx->k[(s+0)%5];
X(1) -= ctx->k[(s+1)%5] + ctx->t[s%3];
X(2) -= ctx->k[(s+2)%5] + ctx->t[(s+1)%3];
X(3) -= ctx->k[(s+3)%5] + s;
}
-void threefish256_dec(void* data, const threefish256_ctx_t* ctx){
+void threefish256_dec(void *data, const threefish256_ctx_t *ctx){
uint8_t i=0,s=18;
/* old constans, changed at round 2 of the SHA-3 contest
uint8_t r0[8] = {59, 11, 53, 26, 58, 13, 36, 5};
/******************************************************************************/
/*
-void permute_4(void* data){
+void permute_4(void *data){
uint64_t t;
t = X(1);
X(1) = X(3);
X(3) = t;
}
-void add_key_4(void* data, const threefish256_ctx_t* ctx, uint8_t s){
+void add_key_4(void *data, const threefish256_ctx_t *ctx, uint8_t s){
X(0) -= ctx->k[(s+0)%5];
X(1) -= ctx->k[(s+1)%5] + ctx->t[s%3];
X(2) -= ctx->k[(s+2)%5] + ctx->t[(s+1)%3];
X(3) -= ctx->k[(s+3)%5] + s;
}
-void threefish256_dec(void* data, const threefish256_ctx_t* ctx){
+void threefish256_dec(void *data, const threefish256_ctx_t *ctx){
uint8_t i=0,s=18;
uint8_t r0[8] = {0x73, 0x13, 0x7b, 0x32, 0x72, 0x2b, 0x44, 0x1b};
uint8_t r1[8] = {0x62, 0x52, 0x43, 0x24, 0x54, 0x6a, 0x34, 0x70};
#define X(a) (((uint64_t*)data)[(a)])
static
-void permute_4(void* data){
+void permute_4(void *data){
uint64_t t;
t = X(1);
X(1) = X(3);
}
static
-void add_key_4(void* data, const threefish256_ctx_t* ctx, uint8_t s){
+void add_key_4(void *data, const threefish256_ctx_t *ctx, uint8_t s){
X(0) -= ctx->k[(s+0)%5];
X(1) -= ctx->k[(s+1)%5] + ctx->t[s%3];
X(2) -= ctx->k[(s+2)%5] + ctx->t[(s+1)%3];
X(3) -= ctx->k[(s+3)%5] + s;
}
-void threefish256_dec(void* data, const threefish256_ctx_t* ctx){
+void threefish256_dec(void *data, const threefish256_ctx_t *ctx){
uint8_t i=0,s=18;
uint8_t r0[8] = {0x73, 0x13, 0x7b, 0x32, 0x72, 0x2b, 0x44, 0x1b};
uint8_t r1[8] = {0x62, 0x52, 0x43, 0x24, 0x54, 0x6a, 0x34, 0x70};
#define X(a) (((uint64_t*)data)[(a)])
static
-void permute_4(void* data){
+void permute_4(void *data){
uint64_t t;
t = X(1);
X(1) = X(3);
#define K(s) (((uint64_t*)key)[(s)])
#define T(s) (((uint64_t*)tweak)[(s)])
-void threefish256_init(const void* key, const void* tweak, threefish256_ctx_t* ctx){
+void threefish256_init(const void *key, const void *tweak, threefish256_ctx_t *ctx){
memcpy(ctx->k, key, 4*8);
if(tweak){
memcpy(ctx->t, tweak, 2*8);
}
static
-void add_key_4(void* data, const threefish256_ctx_t* ctx, uint8_t s){
+void add_key_4(void *data, const threefish256_ctx_t *ctx, uint8_t s){
X(0) += ctx->k[(s+0)%5];
X(1) += ctx->k[(s+1)%5] + ctx->t[s%3];
X(2) += ctx->k[(s+2)%5] + ctx->t[(s+1)%3];
X(3) += ctx->k[(s+3)%5] + s;
}
-void threefish256_enc(void* data, const threefish256_ctx_t* ctx){
+void threefish256_enc(void *data, const threefish256_ctx_t *ctx){
uint8_t i=0,s=0;
/* old constans, changed at round 2 of the SHA-3 contest
uint8_t r0[8] = { 5, 36, 13, 58, 26, 53, 11, 59};
#define K(s) (((uint64_t*)key)[(s)])
#define T(s) (((uint64_t*)tweak)[(s)])
-void threefish256_init(void* key, void* tweak, threefish256_ctx_t* ctx){
+void threefish256_init(void *key, void *tweak, threefish256_ctx_t *ctx){
memcpy(ctx->k, key, 4*8);
memcpy(ctx->t, tweak, 2*8);
uint8_t i;
/******************************************************************************/
/*
#define X(a) (((uint64_t*)data)[(a)])
-void permute_4(void* data){
+void permute_4(void *data){
uint64_t t;
t = X(1);
X(1) = X(3);
X(3) = t;
}
-void add_key_4(void* data, threefish256_ctx_t* ctx, uint8_t s){ / * s: 0..19 * /
+void add_key_4(void *data, threefish256_ctx_t *ctx, uint8_t s){ / * s: 0..19 * /
X(0) += ctx->k[(s+0)%5];
X(1) += ctx->k[(s+1)%5] + ctx->t[s%3];
X(2) += ctx->k[(s+2)%5] + ctx->t[(s+1)%3];
X(3) += ctx->k[(s+3)%5] + s;
}
-void threefish256_enc(void* data, threefish256_ctx_t* ctx){
+void threefish256_enc(void *data, threefish256_ctx_t *ctx){
uint8_t i=0,s=0;
uint8_t r0[8] = { 5, 36, 13, 58, 26, 53, 11, 59};
uint8_t r1[8] = {56, 28, 46, 44, 20, 35, 42, 50};
#define K(s) (((uint64_t*)key)[(s)])
#define T(s) (((uint64_t*)tweak)[(s)])
-void threefish256_init(void* key, void* tweak, threefish256_ctx_t* ctx){
+void threefish256_init(void *key, void *tweak, threefish256_ctx_t *ctx){
memcpy(ctx->k, key, 4*8);
memcpy(ctx->t, tweak, 2*8);
uint8_t i;
/******************************************************************************/
/*
#define X(a) (((uint64_t*)data)[(a)])
-void permute_4(void* data){
+void permute_4(void *data){
uint64_t t;
t = X(1);
X(1) = X(3);
X(3) = t;
}
-void add_key_4(void* data, threefish256_ctx_t* ctx, uint8_t s){ / * s: 0..19 * /
+void add_key_4(void *data, threefish256_ctx_t *ctx, uint8_t s){ / * s: 0..19 * /
X(0) += ctx->k[(s+0)%5];
X(1) += ctx->k[(s+1)%5] + ctx->t[s%3];
X(2) += ctx->k[(s+2)%5] + ctx->t[(s+1)%3];
X(3) += ctx->k[(s+3)%5] + s;
}
-void threefish256_enc(void* data, threefish256_ctx_t* ctx){
+void threefish256_enc(void *data, threefish256_ctx_t *ctx){
uint8_t i=0,s=0;
uint8_t r0[8] = { 5, 36, 13, 58, 26, 53, 11, 59};
uint8_t r1[8] = {56, 28, 46, 44, 20, 35, 42, 50};
static
-void permute_inv8(void* data){
+void permute_inv8(void *data){
uint64_t t;
t = X(6);
X(6) = X(4);
}
static
-void add_key_8(void* data, const threefish512_ctx_t* ctx, uint8_t s){
+void add_key_8(void *data, const threefish512_ctx_t *ctx, uint8_t s){
uint8_t i;
for(i=0; i<5; ++i){
X(i) -= ctx->k[(s+i)%9];
X(7) -= ctx->k[(s+7)%9] + s;
}
-void threefish512_dec(void* data, const threefish512_ctx_t* ctx){
+void threefish512_dec(void *data, const threefish512_ctx_t *ctx){
uint8_t i=0,s=18;
/* old round constants
uint8_t r0[8] = {33, 29, 39, 33, 26, 34, 48, 38};
static
-void permute_inv8(void* data){
+void permute_inv8(void *data){
uint64_t t;
t = X(6);
X(6) = X(4);
}
static
-void add_key_8(void* data, const threefish512_ctx_t* ctx, uint8_t s){
+void add_key_8(void *data, const threefish512_ctx_t *ctx, uint8_t s){
uint8_t i;
for(i=0; i<5; ++i){
X(i) -= ctx->k[(s+i)%9];
X(7) -= ctx->k[(s+7)%9] + s;
}
-void threefish512_dec(void* data, const threefish512_ctx_t* ctx){
+void threefish512_dec(void *data, const threefish512_ctx_t *ctx){
uint8_t i=0,s=18;
uint8_t r0[8] = {0x41, 0x4b, 0x59, 0x41, 0x32, 0x42, 0x60, 0x5a};
uint8_t r1[8] = {0x63, 0x32, 0x33, 0x61, 0x14, 0x2a, 0x24, 0x4a};
static
-void permute_inv8(void* data){
+void permute_inv8(void *data){
uint64_t t;
t = X(6);
X(6) = X(4);
}
static
-void add_key_8(void* data, const threefish512_ctx_t* ctx, uint8_t s){
+void add_key_8(void *data, const threefish512_ctx_t *ctx, uint8_t s){
uint8_t i;
for(i=0; i<5; ++i){
X(i) -= ctx->k[(s+i)%9];
X(7) -= ctx->k[(s+7)%9] + s;
}
-void threefish512_dec(void* data, const threefish512_ctx_t* ctx){
+void threefish512_dec(void *data, const threefish512_ctx_t *ctx){
uint8_t i=0,s=18;
uint8_t r0[8] = {0x41, 0x4b, 0x59, 0x41, 0x32, 0x42, 0x60, 0x5a};
uint8_t r1[8] = {0x63, 0x32, 0x33, 0x61, 0x14, 0x2a, 0x24, 0x4a};
static
-void permute_8(void* data){
+void permute_8(void *data){
uint64_t t;
t = X(0);
X(0) = X(2);
}
/*
static
-void permute_inv8(void* data){
+void permute_inv8(void *data){
uint64_t t;
t = X(6);
X(6) = X(4);
#define K(s) (((uint64_t*)key)[(s)])
#define T(s) (((uint64_t*)tweak)[(s)])
-void threefish512_init(const void* key, const void* tweak, threefish512_ctx_t* ctx){
+void threefish512_init(const void *key, const void *tweak, threefish512_ctx_t *ctx){
memcpy(ctx->k, key, 8*8);
if(tweak){
memcpy(ctx->t, tweak, 2*8);
}
static
-void add_key_8(void* data, const threefish512_ctx_t* ctx, uint8_t s){
+void add_key_8(void *data, const threefish512_ctx_t *ctx, uint8_t s){
uint8_t i;
for(i=0; i<5; ++i){
X(i) += ctx->k[(s+i)%9];
X(7) += ctx->k[(s+7)%9] + s;
}
-void threefish512_enc(void* data, const threefish512_ctx_t* ctx){
+void threefish512_enc(void *data, const threefish512_ctx_t *ctx){
uint8_t i=0,s=0;
/* old constans, changed at round 2 of the SHA-3 contest
uint8_t r0[8] = {38, 48, 34, 26, 33, 39, 29, 33};
#define K(s) (((uint64_t*)key)[(s)])
#define T(s) (((uint64_t*)tweak)[(s)])
-void threefish512_init(const void* key, const void* tweak, threefish512_ctx_t* ctx){
+void threefish512_init(const void *key, const void *tweak, threefish512_ctx_t *ctx){
memcpy(ctx->k, key, 8*8);
memcpy(ctx->t, tweak, 2*8);
uint8_t i;
/******************************************************************************/
/*
#define X(a) (((uint64_t*)data)[(a)])
-void permute_8(void* data){
+void permute_8(void *data){
uint64_t t;
t = X(0);
X(0) = X(2);
X(3) = X(7);
X(7) = t;
}
-void add_key_8(void* data, const threefish512_ctx_t* ctx, uint8_t s){
+void add_key_8(void *data, const threefish512_ctx_t *ctx, uint8_t s){
uint8_t i;
for(i=0; i<5; ++i){
X(i) += ctx->k[(s+i)%9];
X(6) += ctx->k[(s+6)%9] + ctx->t[(s+1)%3];
X(7) += ctx->k[(s+7)%9] + s;
}
-void threefish512_enc(void* data, const threefish512_ctx_t* ctx){
+void threefish512_enc(void *data, const threefish512_ctx_t *ctx){
uint8_t i=0,s=0;
uint8_t r0[8] = {38, 48, 34, 26, 33, 39, 29, 33};
uint8_t r1[8] = {30, 20, 14, 12, 49, 27, 26, 51};
/*
#define X0 (((uint64_t*)data)[0])
#define X1 (((uint64_t*)data)[1])
-void threefish_invmix(void* data, uint8_t rot){
+void threefish_invmix(void *data, uint8_t rot){
uint64_t x;
x = X1;
x ^= X0;
/*
#define X0 (((uint64_t*)data)[0])
#define X1 (((uint64_t*)data)[1])
-void threefish_invmix(void* data, uint8_t rot){
+void threefish_invmix(void *data, uint8_t rot){
uint64_t x;
x = X1;
x ^= X0;
#define X0 (((uint64_t*)data)[0])
#define X1 (((uint64_t*)data)[1])
-void threefish_invmix(void* data, uint8_t rot){
+void threefish_invmix(void *data, uint8_t rot){
uint64_t x;
x = X1;
x ^= X0;
#define B0 (((uint64_t*)data)[0])
#define B1 (((uint64_t*)data)[1])
static
-void mix(void* data, uint8_t rot){
+void mix(void *data, uint8_t rot){
uint64_t x;
x = B1;
B0 += x;
#define B0 (((uint64_t*)data)[0])
#define B1 (((uint64_t*)data)[1])
static
-void mix(void* data, uint8_t rot){
+void mix(void *data, uint8_t rot){
uint64_t x;
x = B1;
B0 += x;
#define X0 (((uint64_t*)data)[0])
#define X1 (((uint64_t*)data)[1])
-void threefish_mix(void* data, uint8_t rot){
+void threefish_mix(void *data, uint8_t rot){
uint64_t x;
x = X1;
X0 += x;
uint8_t g[128];
}ubi1024_ctx_t;
-void ubi256_init(ubi256_ctx_t* ctx, const void* g, uint8_t type);
-void ubi256_nextBlock(ubi256_ctx_t* ctx, const void* block);
-void ubi256_lastBlock(ubi256_ctx_t* ctx, const void* block, uint16_t length_b);
-void ubi256_ctx2hash(void* dest, const ubi256_ctx_t* ctx);
-
-void ubi512_init(ubi512_ctx_t* ctx, const void* g, uint8_t type);
-void ubi512_nextBlock(ubi512_ctx_t* ctx, const void* block);
-void ubi512_lastBlock(ubi512_ctx_t* ctx, const void* block, uint16_t length_b);
-void ubi512_ctx2hash(void* dest, const ubi512_ctx_t* ctx);
-
-void ubi1024_init(ubi1024_ctx_t* ctx, const void* g, uint8_t type);
-void ubi1024_nextBlock(ubi1024_ctx_t* ctx, const void* block);
-void ubi1024_lastBlock(ubi1024_ctx_t* ctx, const void* block, uint16_t length_b);
-void ubi1024_ctx2hash(void* dest, const ubi1024_ctx_t* ctx);
+void ubi256_init(ubi256_ctx_t *ctx, const void *g, uint8_t type);
+void ubi256_nextBlock(ubi256_ctx_t *ctx, const void *block);
+void ubi256_lastBlock(ubi256_ctx_t *ctx, const void *block, uint16_t length_b);
+void ubi256_ctx2hash(void *dest, const ubi256_ctx_t *ctx);
+
+void ubi512_init(ubi512_ctx_t *ctx, const void *g, uint8_t type);
+void ubi512_nextBlock(ubi512_ctx_t *ctx, const void *block);
+void ubi512_lastBlock(ubi512_ctx_t *ctx, const void *block, uint16_t length_b);
+void ubi512_ctx2hash(void *dest, const ubi512_ctx_t *ctx);
+
+void ubi1024_init(ubi1024_ctx_t *ctx, const void *g, uint8_t type);
+void ubi1024_nextBlock(ubi1024_ctx_t *ctx, const void *block);
+void ubi1024_lastBlock(ubi1024_ctx_t *ctx, const void *block, uint16_t length_b);
+void ubi1024_ctx2hash(void *dest, const ubi1024_ctx_t *ctx);
typedef struct{
char schema[4];
#include "memxor.h"
#include "ubi.h"
-void ubi1024_init(ubi1024_ctx_t* ctx, const void* g, uint8_t type){
+void ubi1024_init(ubi1024_ctx_t *ctx, const void *g, uint8_t type){
memset(ctx->tweak.v8, 0, 15);
ctx->tweak.v8[15] = 0x40+type;
memcpy(ctx->g, g, UBI1024_BLOCKSIZE_B);
}
-void ubi1024_nextBlock(ubi1024_ctx_t* ctx, const void* block){
+void ubi1024_nextBlock(ubi1024_ctx_t *ctx, const void *block){
threefish1024_ctx_t tfctx;
ctx->tweak.v64[0] += UBI1024_BLOCKSIZE_B;
threefish1024_init(ctx->g, ctx->tweak.v8, &tfctx);
}
-void ubi1024_lastBlock(ubi1024_ctx_t* ctx, const void* block, uint16_t length_b){
+void ubi1024_lastBlock(ubi1024_ctx_t *ctx, const void *block, uint16_t length_b){
threefish1024_ctx_t tfctx;
while(length_b>UBI1024_BLOCKSIZE){
ubi1024_nextBlock(ctx, block);
}
}
-void ubi1024_ctx2hash(void* dest, const ubi1024_ctx_t* ctx){
+void ubi1024_ctx2hash(void *dest, const ubi1024_ctx_t *ctx){
memcpy(dest, ctx->g, UBI1024_BLOCKSIZE_B);
}
/******************************************************************************/
/*
-void ubi1024_init(ubi1024_ctx_t* ctx, const void* g, uint8_t type){
+void ubi1024_init(ubi1024_ctx_t *ctx, const void *g, uint8_t type){
memset(ctx->tweak, 0, 15);
ctx->tweak[15] = 0x40+type;
memcpy(ctx->g, g, UBI1024_BLOCKSIZE_B);
/******************************************************************************/
/*
-void ubi1024_ctx2hash(void* dest, const ubi1024_ctx_t* ctx){
+void ubi1024_ctx2hash(void *dest, const ubi1024_ctx_t *ctx){
memcpy(dest, ctx->g, UBI1024_BLOCKSIZE_B);
}
*/
/******************************************************************************/
/*
-void ubi1024_nextBlock(ubi1024_ctx_t* ctx, const void* block){
+void ubi1024_nextBlock(ubi1024_ctx_t *ctx, const void *block){
threefish1024_ctx_t tfctx;
((uint64_t*)(ctx->tweak))[0] += UBI1024_BLOCKSIZE_B;
threefish1024_init(ctx->g, ctx->tweak, &tfctx);
/******************************************************************************/
/*
-void ubi1024_lastBlock(ubi1024_ctx_t* ctx, const void* block, uint16_t length_b){
+void ubi1024_lastBlock(ubi1024_ctx_t *ctx, const void *block, uint16_t length_b){
threefish1024_ctx_t tfctx;
while(length_b>UBI1024_BLOCKSIZE){
ubi1024_nextBlock(ctx, block);
#include "memxor.h"
#include "ubi.h"
-void ubi256_init(ubi256_ctx_t* ctx, const void* g, uint8_t type){
+void ubi256_init(ubi256_ctx_t *ctx, const void *g, uint8_t type){
memset(ctx->tweak.v8, 0, 15);
ctx->tweak.v8[15] = 0x40+type;
memcpy(ctx->g, g, 32);
}
-void ubi256_nextBlock(ubi256_ctx_t* ctx, const void* block){
+void ubi256_nextBlock(ubi256_ctx_t *ctx, const void *block){
threefish256_ctx_t tfctx;
ctx->tweak.v64[0] += UBI256_BLOCKSIZE_B;
threefish256_init(ctx->g, ctx->tweak.v8, &tfctx);
}
-void ubi256_lastBlock(ubi256_ctx_t* ctx, const void* block, uint16_t length_b){
+void ubi256_lastBlock(ubi256_ctx_t *ctx, const void *block, uint16_t length_b){
threefish256_ctx_t tfctx;
while(length_b>UBI256_BLOCKSIZE){
ubi256_nextBlock(ctx, block);
}
-void ubi256_ctx2hash(void* dest, const ubi256_ctx_t* ctx){
+void ubi256_ctx2hash(void *dest, const ubi256_ctx_t *ctx){
memcpy(dest, ctx->g, UBI256_BLOCKSIZE_B);
}
/******************************************************************************/
/*
-void ubi256_init(ubi256_ctx_t* ctx, const void* g, uint8_t type){
+void ubi256_init(ubi256_ctx_t *ctx, const void *g, uint8_t type){
memset(ctx->tweak, 0, 15);
ctx->tweak[15] = 0x40+type;
memcpy(ctx->g, g, 32);
/******************************************************************************/
/*
-void ubi256_ctx2hash(void* dest, const ubi256_ctx_t* ctx){
+void ubi256_ctx2hash(void *dest, const ubi256_ctx_t *ctx){
memcpy(dest, ctx->g, UBI256_BLOCKSIZE_B);
}
*/
/******************************************************************************/
/*
-void ubi256_nextBlock(ubi256_ctx_t* ctx, const void* block){
+void ubi256_nextBlock(ubi256_ctx_t *ctx, const void *block){
threefish256_ctx_t tfctx;
((uint64_t*)(ctx->tweak))[0] += UBI256_BLOCKSIZE_B;
threefish256_init(ctx->g, ctx->tweak, &tfctx);
/******************************************************************************/
/*
-void ubi256_lastBlock(ubi256_ctx_t* ctx, const void* block, uint16_t length_b){
+void ubi256_lastBlock(ubi256_ctx_t *ctx, const void *block, uint16_t length_b){
threefish256_ctx_t tfctx;
while(length_b>UBI256_BLOCKSIZE){
ubi256_nextBlock(ctx, block);
#include "memxor.h"
#include "ubi.h"
-void ubi512_init(ubi512_ctx_t* ctx, const void* g, uint8_t type){
+void ubi512_init(ubi512_ctx_t *ctx, const void *g, uint8_t type){
memset(ctx->tweak.v8, 0, 15);
ctx->tweak.v8[15] = 0x40+type;
memcpy(ctx->g, g, UBI512_BLOCKSIZE_B);
}
-void ubi512_nextBlock(ubi512_ctx_t* ctx, const void* block){
+void ubi512_nextBlock(ubi512_ctx_t *ctx, const void *block){
threefish512_ctx_t tfctx;
ctx->tweak.v64[0] += UBI512_BLOCKSIZE_B;
threefish512_init(ctx->g, ctx->tweak.v8, &tfctx);
}
-void ubi512_lastBlock(ubi512_ctx_t* ctx, const void* block, uint16_t length_b){
+void ubi512_lastBlock(ubi512_ctx_t *ctx, const void *block, uint16_t length_b){
threefish512_ctx_t tfctx;
while(length_b>UBI512_BLOCKSIZE){
ubi512_nextBlock(ctx, block);
}
}
-void ubi512_ctx2hash(void* dest, const ubi512_ctx_t* ctx){
+void ubi512_ctx2hash(void *dest, const ubi512_ctx_t *ctx){
memcpy(dest, ctx->g, UBI512_BLOCKSIZE_B);
}
/******************************************************************************/
/*
-void ubi512_init(ubi512_ctx_t* ctx, const void* g, uint8_t type){
+void ubi512_init(ubi512_ctx_t *ctx, const void *g, uint8_t type){
memset(ctx->tweak, 0, 15);
ctx->tweak[15] = 0x40+type;
memcpy(ctx->g, g, UBI512_BLOCKSIZE_B);
/******************************************************************************/
/*
-void ubi512_ctx2hash(void* dest, const ubi512_ctx_t* ctx){
+void ubi512_ctx2hash(void *dest, const ubi512_ctx_t *ctx){
memcpy(dest, ctx->g, UBI512_BLOCKSIZE_B);
}
*/
/******************************************************************************/
/*
-void ubi512_nextBlock(ubi512_ctx_t* ctx, const void* block){
+void ubi512_nextBlock(ubi512_ctx_t *ctx, const void *block){
threefish512_ctx_t tfctx;
((uint64_t*)(ctx->tweak))[0] += UBI512_BLOCKSIZE_B;
threefish512_init(ctx->g, ctx->tweak, &tfctx);
/******************************************************************************/
/*
-void ubi512_lastBlock(ubi512_ctx_t* ctx, const void* block, uint16_t length_b){
+void ubi512_lastBlock(ubi512_ctx_t *ctx, const void *block, uint16_t length_b){
threefish512_ctx_t tfctx;
while(length_b>UBI512_BLOCKSIZE){
ubi512_nextBlock(ctx, block);
/*****************************************************************************/
static
-void skipjack_a(uint16_t* w, uint8_t k, uint8_t* key){
+void skipjack_a(uint16_t *w, uint8_t k, uint8_t *key){
uint16_t t;
t = w[0];
w[0] = w[1];
/*****************************************************************************/
static
-void skipjack_a_inv(uint16_t* w, uint8_t k, uint8_t* key){
+void skipjack_a_inv(uint16_t *w, uint8_t k, uint8_t *key){
uint16_t t;
t = w[3] ^ w[2];
w[3] = skipjack_g_inv(w[2],k,key);
/*****************************************************************************/
static
-void skipjack_b(uint16_t* w, uint8_t k, uint8_t* key){
+void skipjack_b(uint16_t *w, uint8_t k, uint8_t *key){
uint16_t t;
t = w[3];
w[3] = w[0];
/*****************************************************************************/
static
-void skipjack_b_inv(uint16_t* w, uint8_t k, uint8_t* key){
+void skipjack_b_inv(uint16_t *w, uint8_t k, uint8_t *key){
uint16_t t;
t = w[1];
w[1] = w[0];
* block is 64 bits (=8 bytes) in size, key is 80 bits (=10 bytes) in size.
*
*/
-void skipjack_enc(void* block, void* key){
+void skipjack_enc(void *block, void *key){
uint8_t k;
for(k=0; k<32; ++k){
if(k & 0x08){
* block is 64 bits (=8 bytes) in size, key is 80 bits (=10 bytes) in size.
*
*/
-void skipjack_dec(void* block, void* key){
+void skipjack_dec(void *block, void *key){
int8_t k;
for(k=31; k>=0; --k){
if(k & 0x08){
#include <stdint.h>
-/** \fn void skipjack_enc(void* block, void* key)
+/** \fn void skipjack_enc(void *block, void *key)
* \brief skipjack encryption function
*
* This function encrypts a block of plaintext with the Skipjac encryption
* \param block pointer to the 64 bit (8 byte) block to encrypt
* \param key pointer to the 80 bit (10 byte) key
*/
-void skipjack_enc(void* block, void* key);
+void skipjack_enc(void *block, void *key);
-/** \fn void skipjack_dec(void* block, void* key)
+/** \fn void skipjack_dec(void *block, void *key)
* \brief skipjack decryption function
*
* This function decrypts a block of ciphertext encrypted with the Skipjac
* \param block pointer to the 64 bit (8 byte) block to decrypt
* \param key pointer to the 80 bit (10 byte) key
*/
-void skipjack_dec(void* block, void* key);
+void skipjack_dec(void *block, void *key);
#endif /*SKIPJACK_H_*/
/*****************************************************************************/
-void skipjack_a(uint16_t* w, uint8_t k, uint8_t* key){
+void skipjack_a(uint16_t *w, uint8_t k, uint8_t *key){
uint16_t t;
t = w[3];
/*****************************************************************************/
-void skipjack_a_inv(uint16_t* w, uint8_t k, uint8_t* key){
+void skipjack_a_inv(uint16_t *w, uint8_t k, uint8_t *key){
uint16_t t;
t = w[0] ^ w[1];
w[0] = skipjack_g_inv(w[1],k,key);
/*****************************************************************************/
-void skipjack_b(uint16_t* w, uint8_t k, uint8_t* key){
+void skipjack_b(uint16_t *w, uint8_t k, uint8_t *key){
uint16_t t;
t = w[0];
w[0] = w[3];
/*****************************************************************************/
-void skipjack_b_inv(uint16_t* w, uint8_t k, uint8_t* key){
+void skipjack_b_inv(uint16_t *w, uint8_t k, uint8_t *key){
uint16_t t;
t = w[2];
w[2] = w[3];
*
*/
#if NO_FIX
-void skipjack_enc(void* block, void* key){
+void skipjack_enc(void *block, void *key){
uint8_t k;
for(k=0; k<32; ++k){
if(k & 0x08){
}
}
#else
-void skipjack_enc(void* block, void* key){
+void skipjack_enc(void *block, void *key){
uint8_t k;
uint8_t buffer[8], local_key[10];
for(k=0; k<8; ++k){
*
*/
#if NO_FIX
-void skipjack_dec(void* block, void* key){
+void skipjack_dec(void *block, void *key){
int8_t k;
for(k=31; k>=0; --k){
if(k & 0x08){
}
}
#else
-void skipjack_dec(void* block, void* key){
+void skipjack_dec(void *block, void *key){
int8_t k;
uint8_t buffer[8], local_key[10];
for(k=0; k<8; ++k){
uint8_t pattern;
} stack_measuring_ctx_t;
-void stack_measure_init(stack_measuring_ctx_t* ctx, uint8_t pattern);
-uint16_t stack_measure_final(const stack_measuring_ctx_t* ctx);
+void stack_measure_init(stack_measuring_ctx_t *ctx, uint8_t pattern);
+uint16_t stack_measure_final(const stack_measuring_ctx_t *ctx);
/* for testing only
void stack_measure_usestack(uint16_t size, uint8_t value); */
} scdesc_t; /* streamcipher descriptor type */
typedef struct{
- const scdesc_t* desc_ptr;
+ const scdesc_t *desc_ptr;
uint16_t keysize;
uint16_t ivsize;
uint16_t index;
*
*/
-/** \fn stridentcnt_P(char* a, PGM_P b)
+/** \fn stridentcnt_P(char *a, PGM_P b)
* \brief counts the number of identic chars
*
* This function compares the supplyed strings and returns the index of the
* \param b pointer to string in Flash
* \return index of the first char where \c a and \c b differ
*/
-uint16_t stridentcnt_P(char* a, PGM_P b);
+uint16_t stridentcnt_P(char *a, PGM_P b);
-/** \fn firstword_length(char* s)
+/** \fn firstword_length(char *s)
* \brief compute the length of the first word in supllyed string
*
* This function searches for the first whitespace in the string and returns the
* \param s string
* \return number of chars in first word
*/
-uint16_t firstword_length(char* s);
+uint16_t firstword_length(char *s);
-/** \fn strstrip(char* str)
+/** \fn strstrip(char *str)
* \brief removes whitespace at the beginning and the end of a string
*
* This function removes whitespaces at the end of a string.
* \param str sting
* \return pointer to the first non-whitespace char in string
*/
-char* strstrip(char* str);
+char *strstrip(char *str);
typedef struct {
uint8_t buffer_size;
uint8_t fillcount;
- uint8_t* buffer;
- uint8_t* head;
- uint8_t* tail;
- uint8_t* top;
+ uint8_t *buffer;
+ uint8_t *head;
+ uint8_t *tail;
+ uint8_t *top;
} circularbytebuffer_t;
*/
/******************************************************************************/
/*
- * uint8_t circularbytebuffer_init(uint8_t buffersize, circularbytebuffer_t* cb){
+ * uint8_t circularbytebuffer_init(uint8_t buffersize, circularbytebuffer_t *cb){
* cb->buffer_size = buffersize;
* cb->buffer = malloc(buffersize);
* cb->head = cb->tail = cb->buffer;
/******************************************************************************/
/*
- * void circularbytebuffer_free(circularbytebuffer_t* cb){
+ * void circularbytebuffer_free(circularbytebuffer_t *cb){
* free(cb->buffer);
* }
*
/******************************************************************************/
/*
- * void circularbytebuffer_init2(uint8_t buffersize, circularbytebuffer_t* cb, void* buffer){
+ * void circularbytebuffer_init2(uint8_t buffersize, circularbytebuffer_t *cb, void *buffer){
* cb->buffer_size = buffersize;
* cb->buffer = buffer
* cb->head = cb->tail = cb->buffer;
/******************************************************************************/
/*
- * uint8_t circularbytebuffer_cnt(circularbytebuffer_t* cb){
+ * uint8_t circularbytebuffer_cnt(circularbytebuffer_t *cb){
* return (cb->fillcount);
* }
*
/******************************************************************************/
/*
- * uint16_t circularbytebuffer_get_lifo(circularbytebuffer_t* cb){
+ * uint16_t circularbytebuffer_get_lifo(circularbytebuffer_t *cb){
* uint8_t ret;
* if(cb->fillcount==0)
* return 0xffff;
/******************************************************************************/
/*
- * uint16_t circularbytebuffer_get_fifo(circularbytebuffer_t* cb){
+ * uint16_t circularbytebuffer_get_fifo(circularbytebuffer_t *cb){
* uint8_t ret;
* if(cb->fillcount==0)
* return 0xffff;
/******************************************************************************/
/*
- * uint8_t circularbytebuffer_append(uint8_t elem, circularbytebuffer_t* cb){
+ * uint8_t circularbytebuffer_append(uint8_t elem, circularbytebuffer_t *cb){
* if(cb->fillcount==cb->buffer_size)
* return 1;
* cb->fillcount++;
/******************************************************************************/
/*
- * uint8_t circularbytebuffer_push(uint8_t elem, circularbytebuffer_t* cb){
+ * uint8_t circularbytebuffer_push(uint8_t elem, circularbytebuffer_t *cb){
* if(cb->fillcount==cb->buffer_size)
* return 1;
* cb->fillcount++;
typedef struct {
uint8_t buffer_size; /**< holds the amount of bytes which may be stored in the buffer */
uint8_t fillcount; /**< holds the amount of bytes actually stored in the buffer */
- uint8_t* buffer; /**< pointer to the actual buffer */
- uint8_t* head; /**< pointer to the head of the buffer */
- uint8_t* tail; /**< pointer to the tail of the buffer */
- uint8_t* top; /**< pointer to the last free address in the buffer */
+ uint8_t *buffer; /**< pointer to the actual buffer */
+ uint8_t *head; /**< pointer to the head of the buffer */
+ uint8_t *tail; /**< pointer to the tail of the buffer */
+ uint8_t *top; /**< pointer to the last free address in the buffer */
} circularbytebuffer_t;
* \param buffersize size of the buffer to allocate
* \param cb buffer context to be initialized
*/
-uint8_t circularbytebuffer_init(uint8_t buffersize, circularbytebuffer_t* cb);
+uint8_t circularbytebuffer_init(uint8_t buffersize, circularbytebuffer_t *cb);
#endif
#if CIRCULARBYTEBUFFER_NO_INIT2==0
/** \brief buffer initialisation without automatic allocation
* \param cb buffer context to be initialized
* \param buffer buffer for the storage of data (you are responisble for allocation and freeing)
*/
-void circularbytebuffer_init2(uint8_t buffersize, circularbytebuffer_t* cb, void* buffer);
+void circularbytebuffer_init2(uint8_t buffersize, circularbytebuffer_t *cb, void *buffer);
#endif
/** \brief
*
*
*/
-uint16_t circularbytebuffer_get_lifo(circularbytebuffer_t* cb);
-uint16_t circularbytebuffer_get_fifo(circularbytebuffer_t* cb);
-uint8_t circularbytebuffer_append(uint8_t, circularbytebuffer_t* cb);
-uint8_t circularbytebuffer_push(uint8_t, circularbytebuffer_t* cb);
-uint8_t circularbytebuffer_cnt(circularbytebuffer_t* cb);
-void circularbytebuffer_free(circularbytebuffer_t* cb);
+uint16_t circularbytebuffer_get_lifo(circularbytebuffer_t *cb);
+uint16_t circularbytebuffer_get_fifo(circularbytebuffer_t *cb);
+uint8_t circularbytebuffer_append(uint8_t, circularbytebuffer_t *cb);
+uint8_t circularbytebuffer_push(uint8_t, circularbytebuffer_t *cb);
+uint8_t circularbytebuffer_cnt(circularbytebuffer_t *cb);
+void circularbytebuffer_free(circularbytebuffer_t *cb);
/*@}*/
#endif /* CIRCULARBYTEBUFFER_H_ */
/******************************************************************************/
/* uint16_t max_cmd_length(PGM_VOID_P cmdlist){
uint16_t t,ret=0;
- char* str;
+ char *str;
for(;;){
str = (char*)pgm_read_word(cmdlist);
cmdlist = (uint8_t*)cmdlist + CMDLIST_ENTRY_SIZE;
.asciz "\r\necho is o"
/******************************************************************************/
-/* int8_t search_and_call(char* cmd, uint16_t maxcmdlength, PGM_VOID_P cmdlist)
+/* int8_t search_and_call(char *cmd, uint16_t maxcmdlength, PGM_VOID_P cmdlist)
* param cmd: r24:r25
* param maxcmdlength: r22:r23
* param cmdlist: r20:r21
.asciz "\r\ncommand not found, try 'help'"
/******************************************************************************/
-/* void cli_option_listing(char* buffer, PGM_VOID_P cmdlist)
+/* void cli_option_listing(char *buffer, PGM_VOID_P cmdlist)
* param buffer: r24:r25
* param cmdlist: r22:r23
*/
rjmp 1b
/******************************************************************************/
-/* void cli_hexdump_block(const void* data, uint16_t length, uint8_t indent, uint8_t width)
+/* void cli_hexdump_block(const void *data, uint16_t length, uint8_t indent, uint8_t width)
* param data: r24:r25
* param length: r22:r23
* param indent: r20
cli_tx_fpt cli_tx = NULL;
uint8_t cli_echo = 1;
-void echo_ctrl(char* s);
+void echo_ctrl(char *s);
uint16_t max_cmd_length(PGM_VOID_P cmdlist);
-int8_t search_and_call(char* cmd, uint16_t maxcmdlength, PGM_VOID_P cmdlist);
-void cli_option_listing(char* buffer, PGM_VOID_P cmdlist);
+int8_t search_and_call(char *cmd, uint16_t maxcmdlength, PGM_VOID_P cmdlist);
+void cli_option_listing(char *buffer, PGM_VOID_P cmdlist);
void cli_auto_help(uint16_t maxcmdlength, PGM_VOID_P cmdlist);
typedef void(*str_fpt)(char*);
#define CLI_BACKSPACE 8
#define CLI_TABULATOR 9
-uint8_t cli_completion(char* buffer, uint16_t maxcmdlength, PGM_VOID_P cmdlist){
+uint8_t cli_completion(char *buffer, uint16_t maxcmdlength, PGM_VOID_P cmdlist){
uint8_t i=0;
char ref[maxcmdlength+1];
- char* itemstr;
+ char *itemstr;
ref[0]='\0';
/* check if we are behind the first word */
while(buffer[i]){
uint16_t cli_buffer_index;
int8_t exit_code;
uint8_t completion_failed=0;
- char* cli_buffer;
+ char *cli_buffer;
char c;
uint16_t maxcmdlength = max_cmd_length(cmd_desc);
cli_buffer = calloc(1,cli_buffer_size=maxcmdlength+2);
PGM_P cmd_name; /* string containing the function name */
PGM_P cmd_param_str; /* param descriptor string */
void_fpt cmd_function; /* function pointer */
- cmdoption_t* options;
+ cmdoption_t *options;
} cmdlist_entry_t;
extern cli_rx_fpt cli_rx;
void cli_putc(char c);
uint16_t cli_getc(void);
uint16_t cli_getc_cecho(void);
-uint8_t cli_getsn(char* s, size_t n);
-uint8_t cli_getsn_cecho(char* s, uint16_t n);
-void cli_putstr(const char* s);
+uint8_t cli_getsn(char *s, size_t n);
+uint8_t cli_getsn_cecho(char *s, uint16_t n);
+void cli_putstr(const char *s);
void cli_putstr_P(PGM_P s);
void cli_hexdump_byte(uint8_t byte);
-void cli_hexdump(const void* data, size_t length);
-void cli_hexdump_rev(const void* data, size_t length);
-void cli_hexdump2(const void* data, size_t length);
-void cli_hexdump_block(const void* data, size_t length, uint8_t indent, uint8_t width);
+void cli_hexdump(const void *data, size_t length);
+void cli_hexdump_rev(const void *data, size_t length);
+void cli_hexdump2(const void *data, size_t length);
+void cli_hexdump_block(const void *data, size_t length, uint8_t indent, uint8_t width);
-void echo_ctrl(char* s);
+void echo_ctrl(char *s);
int8_t cmd_interface(PGM_VOID_P cmd_desc);
void cmacvs_listalgos(void){
char option = 'a';
- bcdesc_t* t;
+ bcdesc_t *t;
uint8_t i=0;
cli_putstr_P(PSTR("\r\nthe following algorithms are available:\r\n"));
while(option<='z' && (t=(bcdesc_t*)pgm_read_word(&(cmacvs_algolist[i])))){
}
}
-void cmacvs_setalgo(char* param){
+void cmacvs_setalgo(char *param){
param = strstrip(param);
if(param[1]=='\0'){ /* single letter specified */
uint8_t i,option = param[0]-'a';
}
cmacvs_algo=(bcdesc_t*)pgm_read_word(&(cmacvs_algolist[option]));
} else { /* name specifyed */
- bcdesc_t* t=NULL;
+ bcdesc_t *t=NULL;
uint8_t i=0;
while((t=(bcdesc_t*)pgm_read_word(&(cmacvs_algolist[i]))) &&
strcasecmp_P(param, (void*)pgm_read_word(&(t->name))))
uint16_t buffersize_B;
uint32_t blocks;
bcal_cmac_ctx_t ctx;
- uint8_t* buffer;
+ uint8_t *buffer;
uint8_t in_byte;
} cmacvs_ctx_t;
int32_t getValue_P(PGM_P key){
uint32_t val=0;
char instr[21];
- char* str2;
+ char *str2;
for(;;){
memset(instr, 0, 21);
cli_getsn_cecho(instr, 20);
return -2;
}
-uint8_t getKey(void* key_buffer, uint8_t klen_B){
+uint8_t getKey(void *key_buffer, uint8_t klen_B){
char c;
uint8_t v,i=0;
memset(key_buffer, 0x00, klen_B);
return 0;
}
-uint8_t getMac(void* mac_buffer, uint8_t mlen_B){
+uint8_t getMac(void *mac_buffer, uint8_t mlen_B){
char c;
uint8_t v,i=0;
memset(mac_buffer, 0x00, mlen_B);
extern bcdesc_t** cmacvs_algolist;
void cmacvs_listalgos(void);
-void cmacvs_setalgo(char* param);
+void cmacvs_setalgo(char *param);
void cmacvs_test1(void);
void cmacvs_test2(void);
/******************************************************************************/
-uint8_t dbz_strcount(const char* str){
+uint8_t dbz_strcount(const char *str){
uint8_t ret=1;
if(*str=='\0' && *(str+1)=='\0')
return 0;
/******************************************************************************/
-void dbz_splitup(char* dbzstr, char** strings){
+void dbz_splitup(char *dbzstr, char** strings){
if(*dbzstr=='\0' && *(dbzstr+1)=='\0')
return;
*strings++ = dbzstr;
/******************************************************************************/
-void dbz_splitup_P(PGM_P dbzstr, PGM_P* strings){
+void dbz_splitup_P(PGM_P dbzstr, PGM_P *strings){
if(pgm_read_byte(dbzstr)=='\0' && pgm_read_byte(dbzstr+1)=='\0')
return;
*strings++ = dbzstr;
#include <stdint.h>
#include <avr/pgmspace.h>
-/** \fn uint8_t dbz_strcount(const char* str)
+/** \fn uint8_t dbz_strcount(const char *str)
* \brief count stings in dbz-terminated string
*
* Count the single zero terminated strings in a
* double terminated string
* \param str pointer to the double-zero-terminated string
*/
-uint8_t dbz_strcount(const char* str);
+uint8_t dbz_strcount(const char *str);
-/** \fn void dbz_splitup(char* dbzstr, char** strings)
+/** \fn void dbz_splitup(char *dbzstr, char** strings)
* \brief split up a dbz-terminated string
*
* Fills an array with pointers to the single terminated string
* \param dbzstr pointer to the double-zero-terminated string
* \param strings pointer to the array of strings (char pointers)
*/
-void dbz_splitup(char* dbzstr, char** strings);
+void dbz_splitup(char *dbzstr, char** strings);
/** \fn uint8_t dbz_strcount_P(PGM_P str)
* \brief count stings in dbz-terminated string in flash
*/
uint8_t dbz_strcount_P(PGM_P str);
-/** \fn void dbz_splitup_P(PGM_P dbzstr, PGM_P* strings)
+/** \fn void dbz_splitup_P(PGM_P dbzstr, PGM_P *strings)
* \brief split up a dbz-terminated string in flash
*
* Fills an array with pointers (PGM_P) to the single terminated string
* \param dbzstr pointer to the double-zero-terminated string in flash
* \param strings pointer to the array of strings (PGM_P)
*/
-void dbz_splitup_P(PGM_P dbzstr, PGM_P* strings);
+void dbz_splitup_P(PGM_P dbzstr, PGM_P *strings);
#endif /*DBZ_STRINGS_H_*/
uart0_putc(c);
}
- void debug_str(char* s){
+ void debug_str(char *s){
while (*s)
debug_char(*s++);
}
ret
/******************************************************************************/
-/* void dump_chars(uint8_t* buffer, uint8_t len)
+/* void dump_chars(uint8_t *buffer, uint8_t len)
* param buffer: r24:r25
* param len: r22
*/
ret
/*****************************************************************************/
- /* void dump(char* s)
+ /* void dump(char *s)
* param s: r24:r25
*/
.byte 0
/******************************************************************************/
-/* void pgm_read_block(void* buffer, uint32_t addr, uint8_t length)
+/* void pgm_read_block(void *buffer, uint32_t addr, uint8_t length)
* param buffer: r24:r25
* param addr: r20:r23
* param length: r18
#endif
/******************************************************************************/
-/* void ram_read_block(void* buffer, uint32_t addr, uint8_t length)
+/* void ram_read_block(void *buffer, uint32_t addr, uint8_t length)
* param buffer: r24:r25
* param addr: r20:r23
* param length: r18
ret
/******************************************************************************/
-/* void ee_read_block(void* buffer, uint32_t addr, uint8_t length)
+/* void ee_read_block(void *buffer, uint32_t addr, uint8_t length)
* param buffer: r24:r25
* param addr: r20:r23
* param length: r18
#define DUMP_WIDTH 16
-void pgm_read_block(void* buffer, uint32_t addr, uint8_t length);
-void ee_read_block(void* buffer, uint32_t addr, uint8_t length);
-void ram_read_block(void* buffer, uint32_t addr, uint8_t length);
+void pgm_read_block(void *buffer, uint32_t addr, uint8_t length);
+void ee_read_block(void *buffer, uint32_t addr, uint8_t length);
+void ram_read_block(void *buffer, uint32_t addr, uint8_t length);
const char flash_trigger[] PROGMEM = "fF";
const char ram_trigger[] PROGMEM = "sSrRmM";
{ NULL, NULL, NULL }
};
-void dump(char* s);
+void dump(char *s);
#define DUMP_WIDTH 16
-void dump(char* s);
+void dump(char *s);
#endif /* DUMP_H_ */
#include "A5_1.h"
#include "nessie_stream_test.h"
-char* algo_name = "A5_1";
+char *algo_name = "A5_1";
/*****************************************************************************
* additional validation-functions *
*****************************************************************************/
-void a51_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
+void a51_genctx_dummy(uint8_t *key, uint16_t keysize, void *ctx){
a5_1_init(ctx,key, keysize, NULL, 0);
}
#include "bcal-performance.h"
#include "bcal-nessie.h"
-const char* algo_name = "AES";
+const char *algo_name = "AES";
-const bcdesc_t* const const algolist[] PROGMEM = {
+const bcdesc_t *const const algolist[] PROGMEM = {
(bcdesc_t*)&aes128_desc,
(bcdesc_t*)&aes192_desc,
(bcdesc_t*)&aes256_desc,
#include "scal-basic.h"
#include "scal-nessie.h"
-char* algo_name = "Arcfour";
+char *algo_name = "Arcfour";
/*****************************************************************************
* additional validation-functions *
*****************************************************************************/
-void arcfour_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
+void arcfour_genctx_dummy(uint8_t *key, uint16_t keysize, void *ctx){
arcfour_init(key, (uint8_t)((keysize+7)/8), ctx);
}
#include "performance_test.h"
-char* algo_name = "Base64";
+char *algo_name = "Base64";
/*****************************************************************************
* additional validation-functions *
#include "performance_test.h"
-char* algo_name = "BigInt";
+char *algo_name = "BigInt";
/*****************************************************************************
* additional validation-functions *
#include "nessie_hash_test.h"
#include "performance_test.h"
-char* algo_name = "Blake";
+char *algo_name = "Blake";
-const hfdesc_t* const algolist[] PROGMEM = {
+const hfdesc_t *const algolist[] PROGMEM = {
(hfdesc_t*)&blake224_desc,
(hfdesc_t*)&blake256_desc,
(hfdesc_t*)&blake384_desc,
void testrun_nessie_blake(void){
hfal_nessie_multiple(algolist);
}
-void blake224_test(void* msg, uint32_t length_b){
+void blake224_test(void *msg, uint32_t length_b){
hfal_test(&blake224_desc, msg, length_b);
}
-void blake256_test(void* msg, uint32_t length_b){
+void blake256_test(void *msg, uint32_t length_b){
hfal_test(&blake256_desc, msg, length_b);
}
-void blake384_test(void* msg, uint32_t length_b){
+void blake384_test(void *msg, uint32_t length_b){
hfal_test(&blake384_desc, msg, length_b);
}
-void blake512_test(void* msg, uint32_t length_b){
+void blake512_test(void *msg, uint32_t length_b){
hfal_test(&blake512_desc, msg, length_b);
}
void testrun_stdtest_blake(void){
#include "hfal-test.h"
#include "performance_test.h"
-char* algo_name = "BlueMidnightWish";
+char *algo_name = "BlueMidnightWish";
-const hfdesc_t* const algolist[] PROGMEM = {
+const hfdesc_t *const algolist[] PROGMEM = {
(hfdesc_t*)&bmw224_desc,
(hfdesc_t*)&bmw256_desc,
(hfdesc_t*)&bmw384_desc,
hfal_nessie_multiple(algolist);
}
-void bmw224_test(void* msg, uint32_t length_b){
+void bmw224_test(void *msg, uint32_t length_b){
hfal_test(&bmw224_desc, msg, length_b);
}
-void bmw256_test(void* msg, uint32_t length_b){
+void bmw256_test(void *msg, uint32_t length_b){
hfal_test(&bmw256_desc, msg, length_b);
}
-void bmw384_test(void* msg, uint32_t length_b){
+void bmw384_test(void *msg, uint32_t length_b){
hfal_test(&bmw384_desc, msg, length_b);
}
-void bmw512_test(void* msg, uint32_t length_b){
+void bmw512_test(void *msg, uint32_t length_b){
hfal_test(&bmw512_desc, msg, length_b);
}
}
void testrun_stdtest_bmw(void){
- char* msg0 = "abc";
- char* msg1 = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
+ char *msg0 = "abc";
+ char *msg1 = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
bmw224_test(msg0, strlen(msg0)*8);
bmw224_test(msg1, strlen(msg1)*8);
bmw256_test(msg0, strlen(msg0)*8);
bmw512_test(msg1, strlen(msg1)*8);
}
-void bmw256_short_test(void* msg, uint32_t length_b){
+void bmw256_short_test(void *msg, uint32_t length_b){
bmw256_test("abc", 3*8);
}
void testshort(void){
- char* msg0 = "abc";
+ char *msg0 = "abc";
bmw224_test(msg0, strlen(msg0)*8);
}
void testlshort(void){
- char* msg0 = "abc";
+ char *msg0 = "abc";
bmw384_test(msg0, strlen(msg0)*8);
}
#include "bcal-performance.h"
#include "bcal-nessie.h"
-char* algo_name = "Camellia";
+char *algo_name = "Camellia";
-const bcdesc_t* const algolist[] PROGMEM = {
+const bcdesc_t *const algolist[] PROGMEM = {
(bcdesc_t*)&camellia128_desc,
NULL
};
0xEF, 0xCD, 0xAB, 0x89, 0x67, 0x45, 0x23, 0x01, 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE
};
-void hexdump128(void* data){
+void hexdump128(void *data){
uint8_t i;
for(i=0; i<16; ++i){
cli_hexdump(data, 1);
#include "bcal-nessie.h"
#include "bcal_cast5.h"
-char* algo_name = "cast-128 (cast5)";
+char *algo_name = "cast-128 (cast5)";
-const bcdesc_t* const algolist[] PROGMEM = {
+const bcdesc_t *const algolist[] PROGMEM = {
(bcdesc_t*)&cast5_desc,
NULL
};
#include "bcal-nessie.h"
#include "bcal_cast6.h"
-char* algo_name = "CAST-256";
+char *algo_name = "CAST-256";
-const bcdesc_t* const algolist[] PROGMEM = {
+const bcdesc_t *const algolist[] PROGMEM = {
(bcdesc_t*)&cast6_desc,
NULL
};
#include "bcal-performance.h"
#include "bcal_cscipher.h"
-char* algo_name = "CS-Cipher";
+char *algo_name = "CS-Cipher";
-const bcdesc_t* const algolist[] PROGMEM = {
+const bcdesc_t *const algolist[] PROGMEM = {
(bcdesc_t*)&cscipher_desc,
NULL
};
* additional validation-functions *
*****************************************************************************/
-void cscipher_init_dummy(const uint8_t* key, uint16_t keysize_b, void* ctx){
+void cscipher_init_dummy(const uint8_t *key, uint16_t keysize_b, void *ctx){
cscipher_init(key, ctx);
}
#include "hfal-performance.h"
#include "hfal-test.h"
-char* algo_name = "CubeHash";
+char *algo_name = "CubeHash";
-const hfdesc_t* const algolist[] PROGMEM = {
+const hfdesc_t *const algolist[] PROGMEM = {
(hfdesc_t*)&cubehash224_desc,
(hfdesc_t*)&cubehash256_desc,
(hfdesc_t*)&cubehash384_desc,
#include "bcal_tdes.h"
#include "bcal_tdes2.h"
-char* algo_name = "DES";
+char *algo_name = "DES";
-const bcdesc_t* const algolist[] PROGMEM = {
+const bcdesc_t *const algolist[] PROGMEM = {
(bcdesc_t*)&des_desc,
(bcdesc_t*)&tdes2_desc,
(bcdesc_t*)&tdes_desc,
* additional validation-functions *
*****************************************************************************/
-void testrun_nessie_des(const char* param){
+void testrun_nessie_des(const char *param){
if(!param){
bcal_nessie_multiple(algolist);
}else{
uint8_t i=0;
- bcdesc_t* ptr;
+ bcdesc_t *ptr;
for(;;){
ptr = (bcdesc_t*)pgm_read_word(&algolist[i++]);
if(ptr == NULL){
#include "base64_enc.h"
#include "base64_dec.h"
-char* algo_name = "DSA";
+char *algo_name = "DSA";
/*****************************************************************************
* additional validation-functions *
load_dsa_key_blob(&dsa_ctx);
}
-void dsa_print_item(bigint_t* a, PGM_P pstr){
+void dsa_print_item(bigint_t *a, PGM_P pstr){
uint8_t *p;
cli_putstr_P(PSTR("\r\n"));
cli_putstr_P(pstr);
cli_hexdump(p, 1);
}
-void dsa_print_signature_b64(dsa_signature_t* s){
+void dsa_print_signature_b64(dsa_signature_t *s){
uint16_t size_r, size_s, size_o, i,j;
size_r = s->r.length_W +2;
size_s = s->s.length_W +2;
cli_putstr(b64_b);
}
-void dsa_print_ctx(dsa_ctx_t* ctx){
+void dsa_print_ctx(dsa_ctx_t *ctx){
dsa_print_item(&(ctx->priv), PSTR("private"));
dsa_print_item(&(ctx->pub), PSTR("public"));
dsa_print_item(&(ctx->domain.p), PSTR("P"));
dsa_print_item(&(ctx->domain.g), PSTR("G"));
}
-void dsa_print_signature(const dsa_signature_t* sig){
+void dsa_print_signature(const dsa_signature_t *sig){
cli_putstr_P(PSTR("\r\nDSA-Signature:\r\n r:"));
bigint_print_hex(&(sig->r));
cli_putstr_P(PSTR("\r\n s:"));
#include "base64_enc.h"
#include "base64_dec.h"
-char* algo_name = "ECDSA";
+char *algo_name = "ECDSA";
/*****************************************************************************
* additional validation-functions *
return (convert_hexchar_to_value(a) << 4) | convert_hexchar_to_value(b);
}
-void *hash_message(hfdesc_t* hash_function){
+void *hash_message(hfdesc_t *hash_function){
uint8_t *block, *hash_value;
uint16_t index = 0;
hfgen_ctx_t ctx;
0x83, 0x07, 0xa1, 0x43, 0x70, 0xbc, 0x0a, 0xcb
};
-void hash_mem_P(const hfdesc_t* hfdesc, void* dest, const void* msg, uint16_t msg_len_b){
+void hash_mem_P(const hfdesc_t *hfdesc, void *dest, const void *msg, uint16_t msg_len_b){
uint16_t blocksize = hfal_hash_getBlocksize(hfdesc);
uint8_t block[blocksize / 8];
hfgen_ctx_t ctx;
#include "hfal-performance.h"
#include "hfal-test.h"
-char* algo_name = "Echo";
+char *algo_name = "Echo";
-const hfdesc_t* const algolist[] PROGMEM = {
+const hfdesc_t *const algolist[] PROGMEM = {
(hfdesc_t*)&echo224_desc,
(hfdesc_t*)&echo256_desc,
(hfdesc_t*)&echo384_desc,
#include "nessie_bc_test.h"
#include "performance_test.h"
-char* algo_name = "Entropium";
+char *algo_name = "Entropium";
/*****************************************************************************
* additional validation-functions *
#include "scal-nessie.h"
#include "performance_test.h"
-char* algo_name = "Grain";
+char *algo_name = "Grain";
/*****************************************************************************
* additional validation-functions *
*****************************************************************************/
-void grain_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
+void grain_genctx_dummy(uint8_t *key, uint16_t keysize_b, void *ctx){
uint8_t iv[8]={0};
grain_init(key, &iv, ctx);
}
-uint8_t grain_getbyte_dummy(grain_ctx_t* ctx){
+uint8_t grain_getbyte_dummy(grain_ctx_t *ctx){
uint8_t i,ret=0;
for(i=0; i<8; ++i){
ret<<=1;
return ret;
}
-uint8_t grain_getbyte_dummy_rev(grain_ctx_t* ctx){
+uint8_t grain_getbyte_dummy_rev(grain_ctx_t *ctx){
uint8_t i,ret=0;
for(i=0; i<8; ++i){
ret >>= 1;
#include "nessie_hash_test.h"
#include "performance_test.h"
-char* algo_name = "Groestl";
+char *algo_name = "Groestl";
-const hfdesc_t* const algolist[] PROGMEM = {
+const hfdesc_t *const algolist[] PROGMEM = {
(hfdesc_t*)&groestl224_desc,
(hfdesc_t*)&groestl256_desc,
(hfdesc_t*)&groestl384_desc,
void testrun_nessie_groestl(void){
hfal_nessie_multiple(algolist);
}
-void groestl224_test(void* msg, uint32_t length_b){
+void groestl224_test(void *msg, uint32_t length_b){
hfal_test(&groestl224_desc, msg, length_b);
}
-void groestl256_test(void* msg, uint32_t length_b){
+void groestl256_test(void *msg, uint32_t length_b){
hfal_test(&groestl256_desc, msg, length_b);
}
-void groestl384_test(void* msg, uint32_t length_b){
+void groestl384_test(void *msg, uint32_t length_b){
hfal_test(&groestl384_desc, msg, length_b);
}
-void groestl512_test(void* msg, uint32_t length_b){
+void groestl512_test(void *msg, uint32_t length_b){
hfal_test(&groestl512_desc, msg, length_b);
}
#include "hmac-md5.h"
#include "nessie_mac_test.h"
-char* algo_name = "HMAC-MD5";
+char *algo_name = "HMAC-MD5";
/*****************************************************************************
* additional validation-functions *
cli_hexdump(hmac, HMAC_MD5_BYTES);
}
-void strhexdump(char* dest, void* src, uint16_t length){
+void strhexdump(char *dest, void *src, uint16_t length){
char table[] = { '0', '1', '2', '3',
'4', '5', '6', '7',
'8', '9', 'a', 'b',
#include "nessie_mac_test.h"
-char* algo_name = "HMAC-SHA1";
+char *algo_name = "HMAC-SHA1";
/*****************************************************************************
* additional validation-functions *
#include "nessie_mac_test.h"
-char* algo_name = "HMAC-SHA256";
+char *algo_name = "HMAC-SHA256";
/*****************************************************************************
* additional validation-functions *
#include "nessie_hash_test.h"
#include "performance_test.h"
-char* algo_name = "JH";
+char *algo_name = "JH";
-const hfdesc_t* const algolist[] PROGMEM = {
+const hfdesc_t *const algolist[] PROGMEM = {
(hfdesc_t*)&jh224_desc,
(hfdesc_t*)&jh256_desc,
(hfdesc_t*)&jh384_desc,
#include "hfal-performance.h"
#include "hfal-test.h"
-char* algo_name = "Keccak";
+char *algo_name = "Keccak";
-const hfdesc_t* const algolist[] PROGMEM = {
+const hfdesc_t *const algolist[] PROGMEM = {
(hfdesc_t*)&keccak224_desc,
(hfdesc_t*)&keccak256_desc,
(hfdesc_t*)&keccak384_desc,
#include "bcal-nessie.h"
#include "bcal_khazad.h"
-char* algo_name = "Khazad";
+char *algo_name = "Khazad";
-const bcdesc_t* const algolist[] PROGMEM = {
+const bcdesc_t *const algolist[] PROGMEM = {
(bcdesc_t*)&khazad_desc,
NULL
};
#include "hfal_md5.h"
#include "hfal-performance.h"
-char* algo_name = "MD5";
+char *algo_name = "MD5";
-const hfdesc_t* const algolist[] PROGMEM = {
+const hfdesc_t *const algolist[] PROGMEM = {
(hfdesc_t*)&md5_desc,
NULL
};
* additional validation-functions *
*****************************************************************************/
-void md5_ctx2hash_dummy(void* buffer, void* ctx){
+void md5_ctx2hash_dummy(void *buffer, void *ctx){
memcpy(buffer, ctx, 16);
}
void testrun_md5(void){
md5_hash_t hash;
- char* testv[]={
+ char *testv[]={
"",
"a",
"abc",
#include "scal-basic.h"
#include "scal-nessie.h"
-char* algo_name = "Mickey128";
+char *algo_name = "Mickey128";
/*****************************************************************************
* additional validation-functions *
#include "performance_test.h"
#include "stack_measuring.h"
-char* algo_name = "MQQ160-sign";
+char *algo_name = "MQQ160-sign";
/*****************************************************************************
#include "nessie_stream_test.h"
#include "performance_test.h"
-char* algo_name = "MUGI";
+char *algo_name = "MUGI";
/*****************************************************************************
* additional validation-functions *
#include "bcal-performance.h"
#include "bcal_noekeon.h"
-char* algo_name = "Noekeon";
+char *algo_name = "Noekeon";
-const bcdesc_t* const algolist[] PROGMEM = {
+const bcdesc_t *const algolist[] PROGMEM = {
(bcdesc_t*)&noekeon_direct_desc,
(bcdesc_t*)&noekeon_indirect_desc,
NULL
}
-void testrun_stdtest_rundirect(void* data, void* key){
+void testrun_stdtest_rundirect(void *data, void *key){
cli_putstr_P(PSTR("\r\n "));
cli_putstr_P(PSTR("k = "));
cli_hexdump(key,16);
cli_putstr_P(PSTR("\r\n"));
}
-void testrun_stdtest_runindirect(void* data, void* key){
+void testrun_stdtest_runindirect(void *data, void *key){
noekeon_ctx_t ctx;
cli_putstr_P(PSTR("\r\n "));
cli_putstr_P(PSTR("k = "));
#include "nessie_mac_test.h"
#include "performance_test.h"
-char* algo_name = "OMAC-Noekeon";
+char *algo_name = "OMAC-Noekeon";
/*****************************************************************************
* additional validation-functions *
*****************************************************************************/
-void test_mac(void* key, void* data, uint16_t datalength_b){
+void test_mac(void *key, void *data, uint16_t datalength_b){
uint8_t mac[16];
cli_putstr_P(PSTR("\r\n-----------\r\n msg length (bit): 0x"));
cli_hexdump(((uint8_t*)&datalength_b)+1, 1);
uint8_t stat_key[16];
-void omac_noekeon_next_dummy(void* ctx, const void* buffer){
+void omac_noekeon_next_dummy(void *ctx, const void *buffer){
omac_noekeon_next(buffer, stat_key, ctx);
}
-void omac_noekeon_init_dummy(void* ctx, const void* key, uint16_t keysize_b){
+void omac_noekeon_init_dummy(void *ctx, const void *key, uint16_t keysize_b){
omac_noekeon_init(ctx);
memcpy(stat_key, key, 16);
}
-void omac_noekeon_last_dummy(void* ctx, const void* buffer, uint16_t size_b){
+void omac_noekeon_last_dummy(void *ctx, const void *buffer, uint16_t size_b){
while(size_b>128){
omac_noekeon_next(buffer, stat_key, ctx);
size_b -= 128;
omac_noekeon_last(buffer, size_b, stat_key, ctx);
}
-void omac_noekeon_conv_dummy(void* buffer, void* ctx){
+void omac_noekeon_conv_dummy(void *buffer, void *ctx){
memcpy(buffer, ctx, 16);
}
#include "bcal_present80.h"
#include "bcal_present128.h"
-char* algo_name = "Present";
+char *algo_name = "Present";
-const bcdesc_t* const algolist[] PROGMEM = {
+const bcdesc_t *const algolist[] PROGMEM = {
(bcdesc_t*)&present80_desc,
(bcdesc_t*)&present128_desc,
NULL
bcal_nessie_multiple(algolist);
}
-void testrun_selfenc(uint8_t* key, uint8_t* buffer){
+void testrun_selfenc(uint8_t *key, uint8_t *buffer){
present80_ctx_t ctx;
cli_putstr_P(PSTR("\r\nkey : "));
cli_putstr_P(PSTR("\r\n"));
}
-void testrun_selfenc_128(uint8_t* key, uint8_t* buffer){
+void testrun_selfenc_128(uint8_t *key, uint8_t *buffer){
present128_ctx_t ctx;
cli_putstr_P(PSTR("\r\nkey : "));
cli_hexdump(buffer, 8);
cli_putstr_P(PSTR("\r\n"));
}
-// void present_key_test(const uint8_t* key);
+// void present_key_test(const uint8_t *key);
void testrun_self_present(void){
#include "scal-basic.h"
#include "scal-nessie.h"
-const char* algo_name = "Rabbit";
+const char *algo_name = "Rabbit";
/*****************************************************************************
* additional validation-functions *
*****************************************************************************/
-void test_vector(void* key, void* iv, const void* ref){
+void test_vector(void *key, void *iv, const void *ref){
rabbit_ctx_t ctx;
uint8_t fail=0;
cli_putstr_P(PSTR("\r\n testing with\r\n key: "));
#include "bcal_rc5.h"
#define RC5_ROUNDS 12
-char* algo_name = "RC5-32/12/16";
+char *algo_name = "RC5-32/12/16";
-const bcdesc_t* const algolist[] PROGMEM = {
+const bcdesc_t *const algolist[] PROGMEM = {
(bcdesc_t*)&rc5_desc,
NULL
};
/*****************************************************************************
* additional validation-functions *
*****************************************************************************/
-void rc5_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
+void rc5_genctx_dummy(uint8_t *key, uint16_t keysize_b, void *ctx){
rc5_init(key, keysize_b, RC5_ROUNDS, ctx);
}
#include "bcal_rc6.h"
#define RC6_ROUNDS 20
-char* algo_name = "RC6-32/20/16";
+char *algo_name = "RC6-32/20/16";
-const bcdesc_t* const algolist[] PROGMEM = {
+const bcdesc_t *const algolist[] PROGMEM = {
(bcdesc_t*)&rc6_desc,
NULL
};
/*****************************************************************************
* additional validation-functions *
*****************************************************************************/
-void rc6_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
+void rc6_genctx_dummy(uint8_t *key, uint16_t keysize_b, void *ctx){
rc6_initl(key, keysize_b, RC6_ROUNDS, ctx);
}
#include "performance_test.h"
-const char* algo_name = "RSAES-OAEP";
+const char *algo_name = "RSAES-OAEP";
#define BIGINT_CEIL(x) ((((x) + sizeof(bigint_word_t) - 1) / sizeof(bigint_word_t)) * sizeof(bigint_word_t))
#define BIGINT_OFF(x) ((sizeof(bigint_word_t) - (x) % sizeof(bigint_word_t)) % sizeof(bigint_word_t))
const char *block_ignore_string=" \t\r\n,;";
#define BUFFER_LIMIT 120
-uint16_t read_os(void* dst, uint16_t length, const char* ignore_string){
+uint16_t read_os(void *dst, uint16_t length, const char *ignore_string){
uint16_t counter = 0;
uint16_t c;
uint8_t v, tmp = 0, idx = 0;
return counter;
}
-uint16_t own_atou(const char* str){
+uint16_t own_atou(const char *str){
uint16_t r=0;
while(*str && *str >= '0' && *str <= '9'){
r *= 10;
return r;
}
-uint8_t read_bigint(bigint_t* a, char* prompt){
+uint8_t read_bigint(bigint_t *a, char *prompt){
uint16_t read_length, actual_length;
uint8_t off;
uint8_t *buffer;
return r;
}
-uint8_t load_bigint_from_os(bigint_t* a, PGM_VOID_P os, uint16_t length_B){
+uint8_t load_bigint_from_os(bigint_t *a, PGM_VOID_P os, uint16_t length_B){
a->length_W = BIGINT_CEIL(length_B) / sizeof(bigint_word_t);
a->wordv = malloc(BIGINT_CEIL(length_B));
if(!a->wordv){
#define DEBUG 1
-const char* algo_name = "RSAES-PKCS1V15";
+const char *algo_name = "RSAES-PKCS1V15";
#define BIGINT_CEIL(x) ((((x) + sizeof(bigint_word_t) - 1) / sizeof(bigint_word_t)) * sizeof(bigint_word_t))
#define BIGINT_OFF(x) ((sizeof(bigint_word_t) - (x) % sizeof(bigint_word_t)) % sizeof(bigint_word_t))
const char *block_ignore_string=" \t\r\n,;";
#define BUFFER_LIMIT 120
-uint16_t read_os(void* dst, uint16_t length, const char* ignore_string){
+uint16_t read_os(void *dst, uint16_t length, const char *ignore_string){
uint16_t counter = 0;
uint16_t c;
uint8_t v, tmp = 0, idx = 0;
return counter;
}
-uint16_t own_atou(const char* str){
+uint16_t own_atou(const char *str){
uint16_t r=0;
while(*str && *str >= '0' && *str <= '9'){
r *= 10;
return r;
}
-uint8_t read_bigint(bigint_t* a, char* prompt){
+uint8_t read_bigint(bigint_t *a, char *prompt){
uint16_t read_length, actual_length;
uint8_t off;
uint8_t *buffer;
return r;
}
-uint8_t load_bigint_from_os(bigint_t* a, PGM_VOID_P os, uint16_t length_B){
+uint8_t load_bigint_from_os(bigint_t *a, PGM_VOID_P os, uint16_t length_B){
a->length_W = BIGINT_CEIL(length_B) / sizeof(bigint_word_t);
a->wordv = malloc(BIGINT_CEIL(length_B));
if(!a->wordv){
}
}
-uint8_t load_bigint_from_os(bigint_t* a, PGM_VOID_P os, uint16_t length_B){
+uint8_t load_bigint_from_os(bigint_t *a, PGM_VOID_P os, uint16_t length_B){
a->length_W = BIGINT_CEIL(length_B) / sizeof(bigint_word_t);
a->wordv = malloc(BIGINT_CEIL(length_B));
if(!a->wordv){
#include "scal-basic.h"
#include "scal-nessie.h"
-char* algo_name = "Salsa20";
+char *algo_name = "Salsa20";
/*****************************************************************************
* additional validation-functions *
#include "bcal-nessie.h"
#include "bcal_seed.h"
-char* algo_name = "Seed";
+char *algo_name = "Seed";
-const bcdesc_t* const algolist[] PROGMEM = {
+const bcdesc_t *const algolist[] PROGMEM = {
(bcdesc_t*)&seed_desc,
NULL
};
/*****************************************************************************
* additional validation-functions *
*****************************************************************************/
-void seed_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
+void seed_genctx_dummy(uint8_t *key, uint16_t keysize, void *ctx){
seed_init(key, ctx);
}
* self tests *
*****************************************************************************/
-void testencrypt(uint8_t* block, uint8_t* key){
+void testencrypt(uint8_t *block, uint8_t *key){
seed_ctx_t ctx;
cli_putstr("\r\n==testy-encrypt==\r\n key: ");
cli_hexdump(key,16);
cli_hexdump(block,16);
}
-void testdecrypt(uint8_t* block, uint8_t* key){
+void testdecrypt(uint8_t *block, uint8_t *key){
seed_ctx_t ctx;
cli_putstr("\r\n==testy-decrypt==\r\n key: ");
cli_hexdump(key,16);
#include "bcal-nessie.h"
#include "bcal_serpent.h"
-char* algo_name = "Serpent";
+char *algo_name = "Serpent";
-const bcdesc_t* const algolist[] PROGMEM = {
+const bcdesc_t *const algolist[] PROGMEM = {
(bcdesc_t*)&serpent_desc,
NULL
};
/*****************************************************************************
* additional validation-functions *
*****************************************************************************/
-void serpent_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
+void serpent_genctx_dummy(uint8_t *key, uint16_t keysize, void *ctx){
serpent_init(key, keysize&0xff, ctx);
}
#include "hfal_sha1.h"
#include "dump.h"
-char* algo_name = "SHA-1";
+char *algo_name = "SHA-1";
-const hfdesc_t* const algolist[] PROGMEM = {
+const hfdesc_t *const algolist[] PROGMEM = {
(hfdesc_t*)&sha1_desc,
NULL
};
#include "sha512.h"
#include "hfal_sha512.h"
-const char* algo_name = "SHA-2";
+const char *algo_name = "SHA-2";
-const hfdesc_t* const algolist[] PROGMEM = {
+const hfdesc_t *const algolist[] PROGMEM = {
(hfdesc_t*)&sha224_desc,
(hfdesc_t*)&sha256_desc,
(hfdesc_t*)&sha384_desc,
#include "dump.h"
-char* algo_name = "SHA-256";
+char *algo_name = "SHA-256";
-const hfdesc_t* const algolist[] PROGMEM = {
+const hfdesc_t *const algolist[] PROGMEM = {
(hfdesc_t*)&sha256_desc,
NULL
};
#include "nessie_hash_test.h"
#include "performance_test.h"
-char* algo_name = "Shabal";
+char *algo_name = "Shabal";
-const hfdesc_t* const algolist[] PROGMEM = {
+const hfdesc_t *const algolist[] PROGMEM = {
(hfdesc_t*)&shabal192_desc,
(hfdesc_t*)&shabal224_desc,
(hfdesc_t*)&shabal256_desc,
/*****************************************************************************
* additional validation-functions *
*****************************************************************************/
-void testrun_stdtest_shabal192(void* msg, uint16_t size_b){
+void testrun_stdtest_shabal192(void *msg, uint16_t size_b){
hfal_test(&shabal192_desc, msg, size_b);
}
-void testrun_stdtest_shabal224(void* msg, uint16_t size_b){
+void testrun_stdtest_shabal224(void *msg, uint16_t size_b){
hfal_test(&shabal224_desc, msg, size_b);
}
-void testrun_stdtest_shabal256(void* msg, uint16_t size_b){
+void testrun_stdtest_shabal256(void *msg, uint16_t size_b){
hfal_test(&shabal256_desc, msg, size_b);
}
-void testrun_stdtest_shabal384(void* msg, uint16_t size_b){
+void testrun_stdtest_shabal384(void *msg, uint16_t size_b){
hfal_test(&shabal384_desc, msg, size_b);
}
-void testrun_stdtest_shabal512(void* msg, uint16_t size_b){
+void testrun_stdtest_shabal512(void *msg, uint16_t size_b){
hfal_test(&shabal512_desc, msg, size_b);
}
testrun_stdtest_shabal192(ma, 64*8);
}
-void shabal_ctx_dump(shabal_ctx_t* ctx){
+void shabal_ctx_dump(shabal_ctx_t *ctx){
uint8_t i;
- void* p;
+ void *p;
cli_putstr_P(PSTR("\r\n=== shabal ctx dump ===\r\n size = "));
i=sizeof(shabal_ctx_t);
if(i>=100)
#include "nessie_bc_test.h"
#include "performance_test.h"
-char* algo_name = "Shabea";
+char *algo_name = "Shabea";
/*****************************************************************************
* additional validation-functions *
*****************************************************************************/
-void shabea_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
+void shabea_genctx_dummy(uint8_t *key, uint16_t keysize_b, void *ctx){
memcpy(ctx, key, (keysize_b+7)/8);
}
-void shabea_enc_dummy(void* buffer, void* ctx){
+void shabea_enc_dummy(void *buffer, void *ctx){
shabea256(buffer, ctx, 256, 1, 16);
}
-void shabea_dec_dummy(void* buffer, void* ctx){
+void shabea_dec_dummy(void *buffer, void *ctx){
shabea256(buffer, ctx, 256, 0, 16);
}
* self tests *
*****************************************************************************/
-void testencrypt(uint8_t* block, uint8_t* key){
+void testencrypt(uint8_t *block, uint8_t *key){
cli_putstr("\r\n==testy-encrypt==\r\n key: ");
cli_hexdump(key,16);
cli_putstr("\r\n plain: ");
cli_hexdump(block,32);
}
-void testdecrypt(uint8_t* block, uint8_t* key){
+void testdecrypt(uint8_t *block, uint8_t *key){
cli_putstr("\r\n==testy-decrypt==\r\n key: ");
cli_hexdump(key,16);
#include "nessie_bc_test.h"
#include "performance_test.h"
-char* algo_name = "Shacal1 encryption only";
+char *algo_name = "Shacal1 encryption only";
/*****************************************************************************
* additional validation-functions *
*****************************************************************************/
-void shacal1_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
+void shacal1_genctx_dummy(uint8_t *key, uint16_t keysize_b, void *ctx){
memcpy(ctx, key, (keysize_b+7)/8);
}
-void shacal1_enc_dummy(void* buffer, void* ctx){
+void shacal1_enc_dummy(void *buffer, void *ctx){
shacal1_enc(buffer, ctx, 512);
}
#include "nessie_bc_test.h"
#include "performance_test.h"
-char* algo_name = "Shacal2 encryption only";
+char *algo_name = "Shacal2 encryption only";
/*****************************************************************************
* additional validation-functions *
*****************************************************************************/
-void shacal2_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
+void shacal2_genctx_dummy(uint8_t *key, uint16_t keysize_b, void *ctx){
memcpy(ctx, key, (keysize_b+7)/8);
}
-void shacal2_enc_dummy(void* buffer, void* ctx){
+void shacal2_enc_dummy(void *buffer, void *ctx){
shacal2_enc(buffer, ctx, SHACAL2_KEYSIZE);
}
#include "hfal-nessie.h"
#include "hfal-basic.h"
-char* algo_name = "Skein";
+char *algo_name = "Skein";
-const hfdesc_t* const algolist[] PROGMEM = {
+const hfdesc_t *const algolist[] PROGMEM = {
(hfdesc_t*)&skein256_128_desc,
(hfdesc_t*)&skein256_160_desc,
(hfdesc_t*)&skein256_224_desc,
cli_hexdump_block(hash, (outsize_b+7)/8, 4, 16);
}
-void zeromsg_test_common(char* p){
+void zeromsg_test_common(char *p){
uint8_t i;
uint16_t s=0;
uint16_t sizes[]={128, 160, 224, 256, 384, 512, 1024};
#include "bcal-nessie.h"
#include "bcal_skipjack.h"
-char* algo_name = "Skipjack";
+char *algo_name = "Skipjack";
-const bcdesc_t* const algolist[] PROGMEM = {
+const bcdesc_t *const algolist[] PROGMEM = {
(bcdesc_t*)&skipjack_desc,
NULL
};
/*****************************************************************************
* additional validation-functions *
*****************************************************************************/
-void skipjack_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
+void skipjack_genctx_dummy(uint8_t *key, uint16_t keysize, void *ctx){
memcpy(ctx, key, 10);
}
bcal_performance_multiple(algolist);
}
-int test_enc(const void* buffer, void* key){
+int test_enc(const void *buffer, void *key){
uint8_t data[8];
int r;
memcpy(data, buffer, 8);
* self tests *
*****************************************************************************/
-void testencrypt(uint8_t* block, uint8_t* key){
+void testencrypt(uint8_t *block, uint8_t *key){
cli_putstr("\r\n==testy-encrypt==\r\n key: ");
cli_hexdump(key,10);
cli_putstr("\r\n plain: ");
cli_hexdump(block,8);
}
-void testdecrypt(uint8_t* block, uint8_t* key){
+void testdecrypt(uint8_t *block, uint8_t *key){
cli_putstr("\r\n==testy-decrypt==\r\n key: ");
cli_hexdump(key,10);
cli_putstr("\r\n crypt: ");
#include "bcal_tdes.h"
#include "bcal_tdes2.h"
-char* algo_name = "TDES";
+char *algo_name = "TDES";
-const bcdesc_t* const algolist[] PROGMEM = {
+const bcdesc_t *const algolist[] PROGMEM = {
(bcdesc_t*)&tdes_desc,
(bcdesc_t*)&tdes2_desc,
NULL
#include "main-test-common.h"
static
-int std_stream_put(char c, FILE* f){
+int std_stream_put(char c, FILE *f){
static uint8_t did_r = 0;
if(!did_r && c == '\n'){
uart0_putc('\r');
}
static
-int std_stream_get(FILE* f){
+int std_stream_get(FILE *f){
return (int)uart0_getc();
}
fdevopen(std_stream_put, std_stream_get);
}
-void welcome_msg(const char* algoname){
+void welcome_msg(const char *algoname){
/*
cli_putstr_P(PSTR("\r\n\r\nAVR-Crypto-Lib VS ("));
cli_putstr(algoname);
#include <avr/pgmspace.h>
void main_setup(void);
-void welcome_msg(const char* algoname);
+void welcome_msg(const char *algoname);
#endif /* MAINTESTCOMMON_H_ */
#include "bcal_threefish512.h"
#include "bcal_threefish1024.h"
-char* algo_name = "Threefish";
+char *algo_name = "Threefish";
-const bcdesc_t* const algolist[] PROGMEM = {
+const bcdesc_t *const algolist[] PROGMEM = {
(bcdesc_t*)&threefish256_desc,
(bcdesc_t*)&threefish512_desc,
(bcdesc_t*)&threefish1024_desc,
* additional validation-functions *
*****************************************************************************/
-void threefish256_dump(threefish256_ctx_t* ctx){
+void threefish256_dump(threefish256_ctx_t *ctx){
uint8_t i;
cli_putstr_P(PSTR("\r\n=== ctx dump (256) === \r\n k: "));
for(i=0; i<5; ++i){
#include "scal-nessie.h"
#include "performance_test.h"
-char* algo_name = "Trivium";
+char *algo_name = "Trivium";
/*****************************************************************************
* additional validation-functions *
#include "hfal-test.h"
#include "shavs.h"
-char* algo_name = "TWISTER";
+char *algo_name = "TWISTER";
-const hfdesc_t* const algolist[] PROGMEM = {
+const hfdesc_t *const algolist[] PROGMEM = {
(hfdesc_t*)&twister224_desc,
(hfdesc_t*)&twister256_desc,
(hfdesc_t*)&twister384_desc,
*
*****************************************************************************/
-void test_twister224( void* msg, uint32_t length_b){
+void test_twister224( void *msg, uint32_t length_b){
hfal_test(&twister224_desc, msg, length_b);
}
-void test_twister256( void* msg, uint32_t length_b){
+void test_twister256( void *msg, uint32_t length_b){
hfal_test(&twister256_desc, msg, length_b);
}
-void test_twister384( void* msg, uint32_t length_b){
+void test_twister384( void *msg, uint32_t length_b){
hfal_test(&twister384_desc, msg, length_b);
}
-void test_twister512( void* msg, uint32_t length_b){
+void test_twister512( void *msg, uint32_t length_b){
hfal_test(&twister512_desc, msg, length_b);
}
void testrun_twister(void){
- const hfdesc_t* desc[4] = { &twister224_desc, &twister256_desc,
+ const hfdesc_t *desc[4] = { &twister224_desc, &twister256_desc,
&twister384_desc, &twister512_desc };
uint8_t i,j;
- char* testv[]={
+ char *testv[]={
"",
"a",
"abc",
#include "ubi.h"
#include "performance_test.h"
-char* algo_name = "UBI-Threefish";
+char *algo_name = "UBI-Threefish";
/*****************************************************************************
* additional validation-functions *
#include "hfal_whirlpool_0.h"
#include "dump.h"
-char* algo_name = "Whirlpool-0";
+char *algo_name = "Whirlpool-0";
-const hfdesc_t* const algolist[] PROGMEM = {
+const hfdesc_t *const algolist[] PROGMEM = {
(hfdesc_t*)&whirlpool_0_desc,
NULL
};
#include "hfal_whirlpool_t.h"
#include "dump.h"
-char* algo_name = "Whirlpool-T";
+char *algo_name = "Whirlpool-T";
-const hfdesc_t* const algolist[] PROGMEM = {
+const hfdesc_t *const algolist[] PROGMEM = {
(hfdesc_t*)&whirlpool_t_desc,
NULL
};
#include "hfal_whirlpool.h"
#include "dump.h"
-char* algo_name = "Whirlpool";
+char *algo_name = "Whirlpool";
-const hfdesc_t* const algolist[] PROGMEM = {
+const hfdesc_t *const algolist[] PROGMEM = {
(hfdesc_t*)&whirlpool_desc,
NULL
};
#include "bcal-nessie.h"
#include "bcal_xtea.h"
-char* algo_name = "XTEA";
+char *algo_name = "XTEA";
-const bcdesc_t* const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const algolist[] PROGMEM = {
+const bcdesc_t *const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const const algolist[] PROGMEM = {
(bcdesc_t*)&xtea_desc,
NULL
};
memset(&nessie_bc_ctx, 0, sizeof(nessie_bc_ctx_t));
}
static
-void nessie_bc_free(void* ctx){
+void nessie_bc_free(void *ctx){
if(nessie_bc_ctx.cipher_free)
nessie_bc_ctx.cipher_free(ctx);
}
-void nessie_bc_enc(uint8_t* key, uint8_t* pt){
+void nessie_bc_enc(uint8_t *key, uint8_t *pt){
uint8_t ctx[nessie_bc_ctx.ctx_size_B];
uint8_t buffer[nessie_bc_ctx.blocksize_B];
uint16_t i;
nessie_bc_free(ctx);
}
-void nessie_bc_dec(uint8_t* key, uint8_t* ct){
+void nessie_bc_dec(uint8_t *key, uint8_t *ct){
uint8_t ctx[nessie_bc_ctx.ctx_size_B];
uint8_t buffer[nessie_bc_ctx.blocksize_B];
#include <stdint.h>
-typedef void (*nessie_bc_gen_fpt)(const uint8_t* key, uint16_t keysize_b, void* ctx);
-typedef void (*nessie_bc_free_fpt)(void* ctx);
-typedef void (*nessie_bc_enc_fpt)(void* buffer, const void* ctx);
-typedef void (*nessie_bc_dec_fpt)(void* buffer, const void* ctx);
+typedef void (*nessie_bc_gen_fpt)(const uint8_t *key, uint16_t keysize_b, void *ctx);
+typedef void (*nessie_bc_free_fpt)(void *ctx);
+typedef void (*nessie_bc_enc_fpt)(void *buffer, const void *ctx);
+typedef void (*nessie_bc_dec_fpt)(void *buffer, const void *ctx);
typedef struct nessie_bc_ctx_st{
uint16_t keysize_b;
uint16_t blocksize_B;
uint16_t ctx_size_B;
- char* name;
+ char *name;
nessie_bc_gen_fpt cipher_genctx;
nessie_bc_free_fpt cipher_free;
nessie_bc_enc_fpt cipher_enc;
#define nessie_out_file stdout
-void nessie_set_output_stream(FILE* out_stream){
+void nessie_set_output_stream(FILE *out_stream){
nessie_out_file = out_stream;
}
}
#endif
-void nessie_print_block(uint8_t* block, uint16_t blocksize_bit){
+void nessie_print_block(uint8_t *block, uint16_t blocksize_bit){
uint16_t i;
for(i=0; i<(blocksize_bit+7)/8; ++i){
putc(pgm_read_byte(hexdigit_tab_uc_P + ((block[i]) >> 4)), nessie_out_file);
#define SPACES 31
#define BYTESPERLINE 16
-void nessie_print_item(const char* name, uint8_t* buffer, uint16_t size_B){
+void nessie_print_item(const char *name, uint8_t *buffer, uint16_t size_B){
uint8_t name_len;
uint8_t i;
name_len = strlen(name);
Block size: 128 bits
*/
-void nessie_print_header(const char* name,
+void nessie_print_header(const char *name,
uint16_t keysize_b,
uint16_t blocksize_b,
uint16_t hashsize_b,
#endif
*/
-void nessie_set_output_stream(FILE* out_stream);
+void nessie_set_output_stream(FILE *out_stream);
-void nessie_print_block(uint8_t* block, uint16_t blocksize_bit);
-void nessie_print_item(const char* name, uint8_t* buffer, uint16_t size_B);
+void nessie_print_block(uint8_t *block, uint16_t blocksize_bit);
+void nessie_print_item(const char *name, uint8_t *buffer, uint16_t size_B);
void nessie_print_set_vector(uint8_t set, uint16_t vector);
void nessie_print_setheader(uint8_t set);
-void nessie_print_header(const char* name,
+void nessie_print_header(const char *name,
uint16_t keysize_b,
uint16_t blocksize_b,
uint16_t hashsize_b,
uint8_t hash[(nessie_hash_ctx.hashsize_b+7)/8];
uint8_t block[nessie_hash_ctx.blocksize_B];
uint16_t n=512;
- char* tab[8] = { "80", "40", "20", "10",
+ char *tab[8] = { "80", "40", "20", "10",
"08", "04", "02", "01" };
pos&=511;
nessie_print_header(nessie_hash_ctx.name, 0, 0, nessie_hash_ctx.hashsize_b, 0, 0);
/* test set 1 */
- const char* challange_dbz= PSTR(
+ const char *challange_dbz= PSTR(
"\0"
"\"\" (empty string)\0"
"a\0"
#include <stdint.h>
-typedef void (*nessie_hash_init_fpt)(void* ctx);
-typedef void (*nessie_hash_next_fpt)(void* ctx, const void* buffer);
-typedef void (*nessie_hash_last_fpt)(void* ctx, const void* buffer, uint16_t size_b);
-typedef void (*nessie_hash_conv_fpt)(void* buffer, void* ctx);
+typedef void (*nessie_hash_init_fpt)(void *ctx);
+typedef void (*nessie_hash_next_fpt)(void *ctx, const void *buffer);
+typedef void (*nessie_hash_last_fpt)(void *ctx, const void *buffer, uint16_t size_b);
+typedef void (*nessie_hash_conv_fpt)(void *buffer, void *ctx);
typedef struct nessie_hash_ctx_st{
uint16_t hashsize_b;
uint16_t blocksize_B;
uint16_t ctx_size_B;
- char* name;
+ char *name;
nessie_hash_init_fpt hash_init;
nessie_hash_next_fpt hash_next;
nessie_hash_last_fpt hash_last;
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };
static
-void ascii_mac_P(PGM_P data, PGM_P desc, uint8_t* key){
+void ascii_mac_P(PGM_P data, PGM_P desc, uint8_t *key){
uint8_t ctx[nessie_mac_ctx.ctx_size_B];
uint8_t mac[MACSIZE_B];
uint16_t sl;
// message=1 million times "a"
static
-void amillion_mac(uint8_t* key){
+void amillion_mac(uint8_t *key){
uint8_t ctx[nessie_mac_ctx.ctx_size_B];
uint8_t mac[MACSIZE_B];
uint8_t block[nessie_mac_ctx.blocksize_B];
static
-void zero_mac(uint16_t n, uint8_t* key){
+void zero_mac(uint16_t n, uint8_t *key){
uint8_t ctx[nessie_mac_ctx.ctx_size_B];
uint8_t mac[MACSIZE_B];
uint8_t block[nessie_mac_ctx.blocksize_B];
}
static
-void one_in512_mac(uint16_t pos, uint8_t* key){
+void one_in512_mac(uint16_t pos, uint8_t *key){
uint8_t ctx[nessie_mac_ctx.ctx_size_B];
uint8_t mac[MACSIZE_B];
uint8_t block[nessie_mac_ctx.blocksize_B];
uint16_t n=512;
- char* tab[8] = { "80", "40", "20", "10",
+ char *tab[8] = { "80", "40", "20", "10",
"08", "04", "02", "01" };
pos&=511;
/* now the real stuff */
memset(block, 0, 512/8);
block[pos>>3] = 0x80>>(pos&0x7);
- uint8_t* bp;
+ uint8_t *bp;
bp = block;
nessie_mac_ctx.mac_init(ctx, key, nessie_mac_ctx.keysize_b);
while(n>nessie_mac_ctx.blocksize_B*8){
nessie_print_header(nessie_mac_ctx.name, nessie_mac_ctx.keysize_b, 0, 0,
nessie_mac_ctx.macsize_b, 0);
/* test set 1 */
- const char* challange_dbz= PSTR(
+ const char *challange_dbz= PSTR(
"\0"
"\"\" (empty string)\0"
"a\0"
#include <stdint.h>
-typedef void (*nessie_mac_init_fpt)(void* ctx, const void* key, uint16_t keysize_b);
-typedef void (*nessie_mac_next_fpt)(void* ctx, const void* buffer);
-typedef void (*nessie_mac_last_fpt)(void* ctx, const void* buffer, uint16_t size_b);
-typedef void (*nessie_mac_conv_fpt)(void* buffer, void* ctx);
+typedef void (*nessie_mac_init_fpt)(void *ctx, const void *key, uint16_t keysize_b);
+typedef void (*nessie_mac_next_fpt)(void *ctx, const void *buffer);
+typedef void (*nessie_mac_last_fpt)(void *ctx, const void *buffer, uint16_t size_b);
+typedef void (*nessie_mac_conv_fpt)(void *buffer, void *ctx);
typedef struct nessie_mac_ctx_st{
uint16_t keysize_b;
uint16_t blocksize_B;
uint16_t ctx_size_B;
- char* name;
+ char *name;
nessie_mac_init_fpt mac_init;
nessie_mac_next_fpt mac_next;
nessie_mac_last_fpt mac_last;
static
-void nessie_gen_block(void* ctx, uint8_t* block){
+void nessie_gen_block(void *ctx, uint8_t *block){
uint16_t i;
for(i=0; i<BLOCKSIZE_B; ++i){
block[i] = nessie_stream_ctx.cipher_enc(ctx);
}
static
-void nessie_stream_enc(uint8_t* key){
+void nessie_stream_enc(uint8_t *key){
uint8_t ctx[nessie_stream_ctx.ctx_size_B];
uint8_t buffer[BLOCKSIZE_B];
uint8_t xorbuffer[BLOCKSIZE_B];
static
-void nessie_stream_enc_large(uint8_t* key){
+void nessie_stream_enc_large(uint8_t *key){
uint8_t ctx[nessie_stream_ctx.ctx_size_B];
uint8_t buffer[BLOCKSIZE_B];
uint8_t xorbuffer[BLOCKSIZE_B];
#include <stdint.h>
-typedef void (*nessie_stream_genctx_fpt)(uint8_t* key, uint16_t keylength_b, void* ctx);
-typedef uint8_t (*nessie_stream_genenc_fpt)(void* ctx);
+typedef void (*nessie_stream_genctx_fpt)(uint8_t *key, uint16_t keylength_b, void *ctx);
+typedef uint8_t (*nessie_stream_genenc_fpt)(void *ctx);
typedef struct nessie_stream_ctx_st{
uint16_t keysize_b;
uint16_t ivsize_b;
uint16_t outsize_b;
uint16_t ctx_size_B;
- char* name;
+ char *name;
nessie_stream_genctx_fpt cipher_genctx;
nessie_stream_genenc_fpt cipher_enc;
} nessie_stream_ctx_t;
return ret;
}
-void getOverhead(uint16_t* constoh, uint16_t* intoh){
+void getOverhead(uint16_t *constoh, uint16_t *intoh){
*constoh = const_overhead;
*intoh = int_overhead;
}
void calibrateTimer(void);
void startTimer(uint8_t granularity);
uint64_t stopTimer(void);
-void getOverhead(uint16_t* constoh, uint16_t* intoh);
+void getOverhead(uint16_t *constoh, uint16_t *intoh);
void print_time_P(PGM_P s, uint64_t t);
void print_overhead(void);
void shavs_listalgos(void){
char option = 'a';
- hfdesc_t* t;
+ hfdesc_t *t;
uint8_t i=0;
fputs_P(PSTR("\nthe following algorithms are available:\n"), shavs_out_file);
while(option <= 'z' && (t = (hfdesc_t*)pgm_read_word(&(shavs_algolist[i])))){
}
}
-void shavs_setalgo(char* param){
+void shavs_setalgo(char *param){
param = strstrip(param);
if(param[1]=='\0'){ /* single letter specified */
uint8_t i, option = param[0] - 'a';
}
shavs_algo=(hfdesc_t*)pgm_read_word(&(shavs_algolist[option]));
} else { /* name specifyed */
- hfdesc_t* t=NULL;
+ hfdesc_t *t=NULL;
uint8_t i=0;
while((t=(hfdesc_t*)pgm_read_word(&(shavs_algolist[i]))) &&
strcasecmp_P(param, (void*)pgm_read_word(&(t->name))))
uint16_t buffersize_B;
uint32_t blocks;
hfgen_ctx_t ctx;
- uint8_t* buffer;
+ uint8_t *buffer;
uint8_t in_byte;
} shavs_ctx_t;
}
static
-uint32_t my_strtoul(const char* str){
+uint32_t my_strtoul(const char *str){
uint32_t r=0;
while(*str && (*str<'0' || *str>'9')){
str++;
int32_t getLength(void){
uint32_t len=0;
char lenstr[21];
- char* len2;
+ char *len2;
for(;;){
memset(lenstr, 0, 21);
cli_getsn_cecho(lenstr, 20);
extern hfdesc_t** shavs_algolist;
void shavs_listalgos(void);
-void shavs_setalgo(char* param);
+void shavs_setalgo(char *param);
void shavs_test1(void);
void shavs_test2(void);
void shavs_test3(void);
/******************************************************************************/
/*
- uint16_t stridentcnt_P(char* a, PGM_P b){
+ uint16_t stridentcnt_P(char *a, PGM_P b){
uint16_t i=0;
char c;
for(;;){
/******************************************************************************/
/*
- uint16_t firstword_length(char* s){
+ uint16_t firstword_length(char *s){
uint16_t ret=0;
while(isgraph(*s++))
ret++;
/******************************************************************************/
/*
- char* strstrip(char* str){
+ char *strstrip(char *str){
if(!str)
return str;
- char* endptr;
+ char *endptr;
while(*str && (*str==' ' || *str=='\t'))
++str;
endptr=str;
*
*/
-/** \fn stridentcnt_P(char* a, PGM_P b)
+/** \fn stridentcnt_P(char *a, PGM_P b)
* \brief counts the number of identic chars
*
* This function compares the supplyed strings and returns the index of the
* \param b pointer to string in Flash
* \return index of the first char where \c a and \c b differ
*/
-uint16_t stridentcnt_P(char* a, PGM_P b);
+uint16_t stridentcnt_P(char *a, PGM_P b);
-/** \fn firstword_length(char* s)
+/** \fn firstword_length(char *s)
* \brief compute the length of the first word in supllyed string
*
* This function searches for the first whitespace in the string and returns the
* \param s string
* \return number of chars in first word
*/
-uint16_t firstword_length(char* s);
+uint16_t firstword_length(char *s);
-/** \fn strstrip(char* str)
+/** \fn strstrip(char *str)
* \brief removes whitespace at the beginning and the end of a string
*
* This function removes whitespaces at the end of a string.
* \param str sting
* \return pointer to the first non-whitespace char in string
*/
-char* strstrip(char* str);
+char *strstrip(char *str);
#define G(i) ((((*ctx)[(i)/8])>>(((i)%8)))&1)
#define S(i,v) ((*ctx)[(i)/8] = (((*ctx)[(i)/8]) & (uint8_t)~(1<<((i)%8))) | ((v)<<((i)%8)))
-uint8_t trivium_enc(trivium_ctx_t* ctx){
+uint8_t trivium_enc(trivium_ctx_t *ctx){
uint8_t t1,t2,t3,z;
t1 = G(65) ^ G(92);
0x03, 0x0B, 0x07, 0x0F /* 0011 1011 0111 1111 */
};
-void trivium_init(const void* key, uint16_t keysize_b,
- const void* iv, uint16_t ivsize_b,
- trivium_ctx_t* ctx){
+void trivium_init(const void *key, uint16_t keysize_b,
+ const void *iv, uint16_t ivsize_b,
+ trivium_ctx_t *ctx){
uint16_t i;
uint8_t c1,c2;
uint8_t t1,t2;
typedef uint8_t trivium_ctx_t[36]; /* 288bit */
-uint8_t trivium_enc(trivium_ctx_t* ctx);
-uint8_t trivium_getbyte(trivium_ctx_t* ctx);
-void trivium_init(const void* key, uint16_t keysize_b,
- const void* iv, uint16_t ivsize_b,
- trivium_ctx_t* ctx);
+uint8_t trivium_enc(trivium_ctx_t *ctx);
+uint8_t trivium_getbyte(trivium_ctx_t *ctx);
+void trivium_init(const void *key, uint16_t keysize_b,
+ const void *iv, uint16_t ivsize_b,
+ trivium_ctx_t *ctx);
#endif /*TRIVIUM_H_*/
/*********************************************************************/
-/* void twister_small_nextBlock(twister_state_t* ctx, void* msg) */
+/* void twister_small_nextBlock(twister_state_t *ctx, void *msg) */
/*
* param ctx: r24:r25
* param msg: r22:r23
#include "avr-asm-macros.S"
-/* void checksum_update(twister_large_ctx_t* ctx, uint8_t col) */
+/* void checksum_update(twister_large_ctx_t *ctx, uint8_t col) */
/*
* param ctx: r24:r25
* param col: r22
ret
/*********************************************************************/
-/* void twister_large_init(twister_large_ctx_t* ctx, uint16_t hashsize_b)*/
+/* void twister_large_init(twister_large_ctx_t *ctx, uint16_t hashsize_b)*/
/*
* param ctx: r24:r25
* param hashsize_b: r22:r23
ret
/*********************************************************************/
-/* void twister_large_nextBlock(twister_state_t* ctx, void* msg) */
+/* void twister_large_nextBlock(twister_state_t *ctx, void *msg) */
/*
* param ctx: r24:r25
* param msg: r22:r23
ret
/*********************************************************************/
-/* void twister_large_lastBlock(twister_state_t* ctx, void* msg, uint16_t length_b) */
+/* void twister_large_lastBlock(twister_state_t *ctx, void *msg, uint16_t length_b) */
/*
* param ctx: r24:r25
* param msg: r22:r23
/*********************************************************************/
static
-void checksum_update(twister_large_ctx_t* ctx, uint8_t col){
+void checksum_update(twister_large_ctx_t *ctx, uint8_t col){
uint8_t i, col2;
uint8_t carry = 0;
int sum = 0;
/*********************************************************************/
-void twister_large_init(twister_large_ctx_t* ctx, uint16_t hashsize_b){
+void twister_large_init(twister_large_ctx_t *ctx, uint16_t hashsize_b){
memset(ctx->state.s, 0, 64);
memset(ctx->checksum, 0, 64);
ctx->state.counter=0xffffffffffffffffLL;
/*********************************************************************/
-void twister_large_nextBlock(twister_large_ctx_t* ctx, const void* msg){
+void twister_large_nextBlock(twister_large_ctx_t *ctx, const void *msg){
uint8_t tmp[8][8];
/* 1st maxi round */
/*********************************************************************/
-void twister_inject_chksum(twister_large_ctx_t* ctx, uint8_t col){
+void twister_inject_chksum(twister_large_ctx_t *ctx, uint8_t col){
uint8_t i=7;
do{
ctx->state.s[7][i] ^= ctx->checksum[col][i];
/*********************************************************************/
-void twister_large_lastBlock(twister_large_ctx_t* ctx, const void* msg, uint16_t length_b){
+void twister_large_lastBlock(twister_large_ctx_t *ctx, const void *msg, uint16_t length_b){
uint8_t tmp[64];
while(length_b>=512){
twister_large_nextBlock(ctx, msg);
/*********************************************************************/
-void twister_large_ctx2hash(void* dest, twister_large_ctx_t* ctx, uint16_t hashsize_b){
+void twister_large_ctx2hash(void *dest, twister_large_ctx_t *ctx, uint16_t hashsize_b){
twister_ctx2hash(dest, &(ctx->state), hashsize_b);
}
/*********************************************************************/
/*********************************************************************/
-void twister384_init(twister384_ctx_t* ctx){
+void twister384_init(twister384_ctx_t *ctx){
twister_large_init(ctx, 384);
}
/*********************************************************************/
-void twister384_nextBlock(twister384_ctx_t* ctx, const void* msg){
+void twister384_nextBlock(twister384_ctx_t *ctx, const void *msg){
twister_large_nextBlock(ctx, msg);
}
/*********************************************************************/
-void twister384_lastBlock(twister384_ctx_t* ctx, const void* msg, uint16_t length_b){
+void twister384_lastBlock(twister384_ctx_t *ctx, const void *msg, uint16_t length_b){
twister_large_lastBlock(ctx, msg, length_b);
}
/*********************************************************************/
-void twister384_ctx2hash(void* dest, twister384_ctx_t* ctx){
+void twister384_ctx2hash(void *dest, twister384_ctx_t *ctx){
twister_large_ctx2hash(dest, ctx, 384);
}
/*********************************************************************/
-void twister384(void* dest, const void* msg, uint32_t msg_length_b){
+void twister384(void *dest, const void *msg, uint32_t msg_length_b){
twister_large_ctx_t ctx;
twister_large_init(&ctx, 384);
while(msg_length_b >=512){
/*********************************************************************/
-void twister512_init(twister512_ctx_t* ctx){
+void twister512_init(twister512_ctx_t *ctx){
twister_large_init(ctx, 512);
}
/*********************************************************************/
-void twister512_nextBlock(twister512_ctx_t* ctx, const void* msg){
+void twister512_nextBlock(twister512_ctx_t *ctx, const void *msg){
twister_large_nextBlock(ctx, msg);
}
/*********************************************************************/
-void twister512_lastBlock(twister512_ctx_t* ctx, const void* msg, uint16_t length_b){
+void twister512_lastBlock(twister512_ctx_t *ctx, const void *msg, uint16_t length_b){
twister_large_lastBlock(ctx, msg, length_b);
}
/*********************************************************************/
-void twister512_ctx2hash(void* dest, twister512_ctx_t* ctx){
+void twister512_ctx2hash(void *dest, twister512_ctx_t *ctx){
twister_large_ctx2hash(dest, ctx, 512);
}
/*********************************************************************/
-void twister512(void* dest, const void* msg, uint32_t msg_length_b){
+void twister512(void *dest, const void *msg, uint32_t msg_length_b){
twister_large_ctx_t ctx;
twister_large_init(&ctx, 512);
while(msg_length_b >=512){
/*********************************************************************/
-void twister_large_nextBlock(twister_large_ctx_t* ctx, const void* msg);
-void twister_large_init(twister_large_ctx_t* ctx, uint16_t hashsize_b);
-void twister_large_lastBlock(twister_large_ctx_t* ctx, const void* msg, uint16_t length_b);
-void twister_large_ctx2hash(void* dest, twister_large_ctx_t* ctx, uint16_t hashsize_b);
+void twister_large_nextBlock(twister_large_ctx_t *ctx, const void *msg);
+void twister_large_init(twister_large_ctx_t *ctx, uint16_t hashsize_b);
+void twister_large_lastBlock(twister_large_ctx_t *ctx, const void *msg, uint16_t length_b);
+void twister_large_ctx2hash(void *dest, twister_large_ctx_t *ctx, uint16_t hashsize_b);
/*********************************************************************/
-void twister384_init(twister384_ctx_t* ctx);
-void twister384_nextBlock(twister384_ctx_t* ctx, const void* msg);
-void twister384_lastBlock(twister384_ctx_t* ctx, const void* msg, uint16_t length_b);
-void twister384_ctx2hash(void* dest, twister384_ctx_t* ctx);
-void twister384(void* dest, const void* msg, uint32_t msg_length_b);
+void twister384_init(twister384_ctx_t *ctx);
+void twister384_nextBlock(twister384_ctx_t *ctx, const void *msg);
+void twister384_lastBlock(twister384_ctx_t *ctx, const void *msg, uint16_t length_b);
+void twister384_ctx2hash(void *dest, twister384_ctx_t *ctx);
+void twister384(void *dest, const void *msg, uint32_t msg_length_b);
/*********************************************************************/
-void twister512_init(twister512_ctx_t* ctx);
-void twister512_nextBlock(twister512_ctx_t* ctx, const void* msg);
-void twister512_lastBlock(twister512_ctx_t* ctx, const void* msg, uint16_t length_b);
-void twister512_ctx2hash(void* dest, twister512_ctx_t* ctx);
-void twister512(void* dest, const void* msg, uint32_t msg_length_b);
+void twister512_init(twister512_ctx_t *ctx);
+void twister512_nextBlock(twister512_ctx_t *ctx, const void *msg);
+void twister512_lastBlock(twister512_ctx_t *ctx, const void *msg, uint16_t length_b);
+void twister512_ctx2hash(void *dest, twister512_ctx_t *ctx);
+void twister512(void *dest, const void *msg, uint32_t msg_length_b);
#endif /* TWISTER_large_H_ */
#include "avr-asm-macros.S"
-/* void twister_small_init(twister_state_t* ctx, uint16_t hashsize_b)*/
+/* void twister_small_init(twister_state_t *ctx, uint16_t hashsize_b)*/
/*
* param ctx: r24:r25
* param hashsize_b: r22:r23
ret
#if 1
/*********************************************************************/
-/* void twister_small_lastBlock(twister_state_t* ctx, void* msg, uint16_t length_b) */
+/* void twister_small_lastBlock(twister_state_t *ctx, void *msg, uint16_t length_b) */
/*
* param ctx: r24:r25
* param msg: r22:r23
/*********************************************************************/
#if 0
-void twister_small_init(twister_state_t* ctx, uint16_t hashsize_b){
+void twister_small_init(twister_state_t *ctx, uint16_t hashsize_b){
memset(ctx->s, 0, 64);
ctx->counter=0xffffffffffffffffLL;
ctx->s[0][7] = hashsize_b>>8;
/*********************************************************************/
-void twister_small_nextBlock(twister_state_t* ctx, void* msg){
+void twister_small_nextBlock(twister_state_t *ctx, void *msg){
uint8_t tmp[8][8];
/* round 1 */
memcpy(tmp, ctx->s, 64);
#endif
/*********************************************************************/
#if 0
-void twister_small_lastBlock(twister_state_t* ctx, void* msg, uint16_t length_b){
+void twister_small_lastBlock(twister_state_t *ctx, void *msg, uint16_t length_b){
uint8_t tmp[64];
while(length_b>512){
twister_small_nextBlock(ctx, msg);
}
-void twister256_lastBlock(twister256_ctx_t* ctx, void* msg, uint16_t length_b){
+void twister256_lastBlock(twister256_ctx_t *ctx, void *msg, uint16_t length_b){
twister_small_lastBlock(ctx, msg, length_b);
}
-void twister224_lastBlock(twister224_ctx_t* ctx, void* msg, uint16_t length_b){
+void twister224_lastBlock(twister224_ctx_t *ctx, void *msg, uint16_t length_b){
twister_small_lastBlock(ctx, msg, length_b);
}
#if 0
/*********************************************************************/
-void twister_small_ctx2hash(void* dest, twister_state_t* ctx, uint16_t hashsize_b){
+void twister_small_ctx2hash(void *dest, twister_state_t *ctx, uint16_t hashsize_b){
twister_ctx2hash(dest, ctx, hashsize_b);
}
#ifndef NO_TWISTER_256
-void twister256_init(twister256_ctx_t* ctx){
+void twister256_init(twister256_ctx_t *ctx){
twister_small_init(ctx, 256);
}
/*********************************************************************/
-void twister256_nextBlock(twister256_ctx_t* ctx, void* msg){
+void twister256_nextBlock(twister256_ctx_t *ctx, void *msg){
twister_small_nextBlock(ctx, msg);
}
/*********************************************************************/
-void twister256_ctx2hash(void* dest, twister256_ctx_t* ctx){
+void twister256_ctx2hash(void *dest, twister256_ctx_t *ctx){
twister_ctx2hash(dest, ctx, 256);
}
/*********************************************************************/
-void twister256(void* dest, void* msg, uint32_t msg_length_b){
+void twister256(void *dest, void *msg, uint32_t msg_length_b){
twister_state_t ctx;
twister_small_init(&ctx, 256);
while(msg_length_b >=512){
#ifndef NO_TWISTER_224
-void twister224_init(twister224_ctx_t* ctx){
+void twister224_init(twister224_ctx_t *ctx){
twister_small_init(ctx, 224);
}
/*********************************************************************/
-void twister224_nextBlock(twister224_ctx_t* ctx, void* msg){
+void twister224_nextBlock(twister224_ctx_t *ctx, void *msg){
twister_small_nextBlock(ctx, msg);
}
/*********************************************************************/
-void twister224_ctx2hash(void* dest, twister224_ctx_t* ctx){
+void twister224_ctx2hash(void *dest, twister224_ctx_t *ctx){
twister_ctx2hash(dest, ctx, 224);
}
/*********************************************************************/
-void twister224(void* dest, void* msg, uint32_t msg_length_b){
+void twister224(void *dest, void *msg, uint32_t msg_length_b){
twister_state_t ctx;
twister_small_init(&ctx, 224);
while(msg_length_b >=512){
/*********************************************************************/
-void twister_small_init(twister_state_t* ctx, uint16_t hashsize_b){
+void twister_small_init(twister_state_t *ctx, uint16_t hashsize_b){
memset(ctx->s, 0, 64);
ctx->counter=0xffffffffffffffffLL;
ctx->s[0][7] = hashsize_b>>8;
/*********************************************************************/
-void twister_small_nextBlock(twister_state_t* ctx, const void* msg){
+void twister_small_nextBlock(twister_state_t *ctx, const void *msg){
uint8_t tmp[8][8];
/* round 1 */
memcpy(tmp, ctx->s, 64);
/*********************************************************************/
-void twister_small_lastBlock(twister_state_t* ctx, const void* msg, uint16_t length_b){
+void twister_small_lastBlock(twister_state_t *ctx, const void *msg, uint16_t length_b){
uint8_t tmp[64];
while(length_b>=512){
twister_small_nextBlock(ctx, msg);
/*********************************************************************/
-void twister_small_ctx2hash(void* dest, twister_state_t* ctx, uint16_t hashsize_b){
+void twister_small_ctx2hash(void *dest, twister_state_t *ctx, uint16_t hashsize_b){
twister_ctx2hash(dest, ctx, hashsize_b);
}
#ifndef NO_TWISTER_256
-void twister256_init(twister256_ctx_t* ctx){
+void twister256_init(twister256_ctx_t *ctx){
twister_small_init(ctx, 256);
}
/*********************************************************************/
-void twister256_nextBlock(twister256_ctx_t* ctx, const void* msg){
+void twister256_nextBlock(twister256_ctx_t *ctx, const void *msg){
twister_small_nextBlock(ctx, msg);
}
/*********************************************************************/
-void twister256_lastBlock(twister256_ctx_t* ctx, const void* msg, uint16_t length_b){
+void twister256_lastBlock(twister256_ctx_t *ctx, const void *msg, uint16_t length_b){
twister_small_lastBlock(ctx, msg, length_b);
}
/*********************************************************************/
-void twister256_ctx2hash(void* dest, twister256_ctx_t* ctx){
+void twister256_ctx2hash(void *dest, twister256_ctx_t *ctx){
twister_ctx2hash(dest, ctx, 256);
}
/*********************************************************************/
-void twister256(void* dest, const void* msg, uint32_t msg_length_b){
+void twister256(void *dest, const void *msg, uint32_t msg_length_b){
twister_state_t ctx;
twister_small_init(&ctx, 256);
while(msg_length_b >=512){
#ifndef NO_TWISTER_224
-void twister224_init(twister224_ctx_t* ctx){
+void twister224_init(twister224_ctx_t *ctx){
twister_small_init(ctx, 224);
}
/*********************************************************************/
-void twister224_nextBlock(twister224_ctx_t* ctx, const void* msg){
+void twister224_nextBlock(twister224_ctx_t *ctx, const void *msg){
twister_small_nextBlock(ctx, msg);
}
/*********************************************************************/
-void twister224_lastBlock(twister224_ctx_t* ctx, const void* msg, uint16_t length_b){
+void twister224_lastBlock(twister224_ctx_t *ctx, const void *msg, uint16_t length_b){
twister_small_lastBlock(ctx, msg, length_b);
}
/*********************************************************************/
-void twister224_ctx2hash(void* dest, twister224_ctx_t* ctx){
+void twister224_ctx2hash(void *dest, twister224_ctx_t *ctx){
twister_ctx2hash(dest, ctx, 224);
}
/*********************************************************************/
-void twister224(void* dest, const void* msg, uint32_t msg_length_b){
+void twister224(void *dest, const void *msg, uint32_t msg_length_b){
twister_state_t ctx;
twister_small_init(&ctx, 224);
while(msg_length_b >=512){
typedef twister_state_t twister256_ctx_t;
typedef twister_state_t twister224_ctx_t;
-void twister_small_init(twister_state_t* ctx, uint16_t hashsize_b);
-void twister_small_lastBlock(twister_state_t* ctx, const void* msg, uint16_t length_b);
-void twister_small_ctx2hash(void* dest, twister_state_t* ctx, uint16_t hashsize_b);
-void twister_small_nextBlock(twister_state_t* ctx, const void* msg);
-
-
-void twister256_init(twister256_ctx_t* ctx);
-void twister256_nextBlock(twister256_ctx_t* ctx, const void* msg);
-void twister256_lastBlock(twister256_ctx_t* ctx, const void* msg, uint16_t length_b);
-void twister256_ctx2hash(void* dest, twister_state_t* ctx);
-void twister256(void* dest, const void* msg, uint32_t msg_length_b);
-
-void twister224_init(twister224_ctx_t* ctx);
-void twister224_nextBlock(twister224_ctx_t* ctx, const void* msg);
-void twister224_lastBlock(twister224_ctx_t* ctx, const void* msg, uint16_t length_b);
-void twister224_ctx2hash(void* dest, twister224_ctx_t* ctx);
-void twister224(void* dest, const void* msg, uint32_t msg_length_b);
+void twister_small_init(twister_state_t *ctx, uint16_t hashsize_b);
+void twister_small_lastBlock(twister_state_t *ctx, const void *msg, uint16_t length_b);
+void twister_small_ctx2hash(void *dest, twister_state_t *ctx, uint16_t hashsize_b);
+void twister_small_nextBlock(twister_state_t *ctx, const void *msg);
+
+
+void twister256_init(twister256_ctx_t *ctx);
+void twister256_nextBlock(twister256_ctx_t *ctx, const void *msg);
+void twister256_lastBlock(twister256_ctx_t *ctx, const void *msg, uint16_t length_b);
+void twister256_ctx2hash(void *dest, twister_state_t *ctx);
+void twister256(void *dest, const void *msg, uint32_t msg_length_b);
+
+void twister224_init(twister224_ctx_t *ctx);
+void twister224_nextBlock(twister224_ctx_t *ctx, const void *msg);
+void twister224_lastBlock(twister224_ctx_t *ctx, const void *msg, uint16_t length_b);
+void twister224_ctx2hash(void *dest, twister224_ctx_t *ctx);
+void twister224(void *dest, const void *msg, uint32_t msg_length_b);
#endif /* TWISTER_SMALL_H_ */
# define MULT(a,b) gf256mul((a),(b), 0x4D)
//#endif
-void twister_blank_round(twister_state_t* ctx){
+void twister_blank_round(twister_state_t *ctx){
uint8_t i,j,k;
uint8_t tmp[8][8];
/* add twist counter */
}
}
}
-void twister_mini_round(twister_state_t* ctx, const void* msg){
+void twister_mini_round(twister_state_t *ctx, const void *msg){
/* inject message */
uint8_t i;
for(i=0; i<8; ++i){
twister_blank_round(ctx);
}
-void twister_ctx2hash(void* dest, twister_state_t* ctx, uint16_t hashsize_b){
+void twister_ctx2hash(void *dest, twister_state_t *ctx, uint16_t hashsize_b){
uint8_t tmp[8][8];
uint8_t j;
uint16_t i=hashsize_b;
typedef uint8_t twister_checksum_t[8][8];
-void twister_blank_round(twister_state_t* ctx);
-void twister_mini_round(twister_state_t* ctx, const void* msg);
-void twister_ctx2hash(void* dest, twister_state_t* ctx, uint16_t hashsize_b);
+void twister_blank_round(twister_state_t *ctx);
+void twister_mini_round(twister_state_t *ctx, const void *msg);
+void twister_ctx2hash(void *dest, twister_state_t *ctx, uint16_t hashsize_b);
#endif /* TWISTER_H_ */
#include "avr-asm-macros.S"
/*********************************************************************/
-/* void twister224(void* dest, void* msg, uint32_t msg_length_b) */
+/* void twister224(void *dest, void *msg, uint32_t msg_length_b) */
/*
* param dest: r24:r25
* param msg: r22:r23
#include "avr-asm-macros.S"
/*********************************************************************/
-/* void twister256(void* dest, void* msg, uint32_t msg_length_b) */
+/* void twister256(void *dest, void *msg, uint32_t msg_length_b) */
/*
* param dest: r24:r25
* param msg: r22:r23
#include "avr-asm-macros.S"
/*********************************************************************/
-/* void twister384(void* dest, void* msg, uint32_t msg_length_b) */
+/* void twister384(void *dest, void *msg, uint32_t msg_length_b) */
/*
* param dest: r24:r25
* param msg: r22:r23
#include "avr-asm-macros.S"
/*********************************************************************/
-/* void twister384(void* dest, void* msg, uint32_t msg_length_b) */
+/* void twister384(void *dest, void *msg, uint32_t msg_length_b) */
/*
* param dest: r24:r25
* param msg: r22:r23
#endif
-static void gamma_1(uint8_t* a){
+static void gamma_1(uint8_t *a){
uint8_t i;
for(i=0; i<64; ++i){
*a = whirlpool_sbox(*a);
}
}
-static void pi(uint8_t* a){
+static void pi(uint8_t *a){
uint8_t b[8];
uint8_t i,j;
for(i=1; i<8; ++i){
#define POLYNOM 0x1D
-static void theta(uint8_t* a){
+static void theta(uint8_t *a){
uint8_t b[8], c, accu;
uint8_t i,j,k;
for(i=0; i<8; ++i){
}
}
-static void w_round(uint8_t* a, const uint8_t* k){
+static void w_round(uint8_t *a, const uint8_t *k){
gamma_1(a);
#if DEBUG
cli_putstr_P(PSTR("\r\n pre-pi:"));
memxor(a, k, 64);
}
-static void w_enc(uint8_t *a, const uint8_t* k){
+static void w_enc(uint8_t *a, const uint8_t *k){
#if DEBUG
cli_putstr_P(PSTR("\r\n== w_enc ==\r\n w'_00:"));
cli_hexdump_block(a, 64, 4, 8);
}
}
-void whirlpool_init(whirlpool_ctx_t* ctx){
+void whirlpool_init(whirlpool_ctx_t *ctx){
memset(ctx->s, 0, 64);
ctx->blocks = 0;
}
-void whirlpool_nextBlock(whirlpool_ctx_t* ctx, const void* block){
+void whirlpool_nextBlock(whirlpool_ctx_t *ctx, const void *block){
uint8_t state[64];
ctx->blocks += 1;
memcpy(state, block, 64);
memxor((ctx->s), block, 64);
}
-void whirlpool_lastBlock(whirlpool_ctx_t* ctx, const void* block, uint16_t length_b){
+void whirlpool_lastBlock(whirlpool_ctx_t *ctx, const void *block, uint16_t length_b){
while(length_b>=512){
whirlpool_nextBlock(ctx, block);
block = (uint8_t*)block + 64;
whirlpool_nextBlock(ctx, buffer);
}
-void whirlpool_ctx2hash(void* dest, const whirlpool_ctx_t* ctx){
+void whirlpool_ctx2hash(void *dest, const whirlpool_ctx_t *ctx){
memcpy(dest, (ctx->s), 64);
}
} whirlpool_ctx_t;
-void whirlpool_init(whirlpool_ctx_t* ctx);
-void whirlpool_nextBlock(whirlpool_ctx_t* ctx,const void* block);
-void whirlpool_lastBlock(whirlpool_ctx_t* ctx, const void* block, uint16_t length_b);
-void whirlpool_ctx2hash(void* dest, const whirlpool_ctx_t* ctx);
+void whirlpool_init(whirlpool_ctx_t *ctx);
+void whirlpool_nextBlock(whirlpool_ctx_t *ctx,const void *block);
+void whirlpool_lastBlock(whirlpool_ctx_t *ctx, const void *block, uint16_t length_b);
+void whirlpool_ctx2hash(void *dest, const whirlpool_ctx_t *ctx);
#endif /* WIRLPOOL_H_ */
#include <stdint.h>
-void xtea_enc(void* dest, const void* v, const void* k) {
+void xtea_enc(void *dest, const void *v, const void *k) {
uint8_t i;
uint32_t v0=((uint32_t*)v)[0], v1=((uint32_t*)v)[1];
uint32_t sum=0, delta=0x9E3779B9;
((uint32_t*)dest)[0]=v0; ((uint32_t*)dest)[1]=v1;
}
-void xtea_dec(void* dest, const void* v, const void* k) {
+void xtea_dec(void *dest, const void *v, const void *k) {
uint8_t i;
uint32_t v0=((uint32_t*)v)[0], v1=((uint32_t*)v)[1];
uint32_t sum=0xC6EF3720, delta=0x9E3779B9;
* v: the block to operate on (64 bit)
* k: the key for en/decryption (128 bit)
*/
-void xtea_enc(void* dest, const void* v, const void* k);
-void xtea_dec(void* dest, const void* v, const void* k);
+void xtea_enc(void *dest, const void *v, const void *k);
+void xtea_dec(void *dest, const void *v, const void *k);
#endif /*XTEA_H_*/