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