-#include "memxor/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 r;
- ctx->blocksize_B = (bcal_cipher_getBlocksize_b(desc)+7)/8;
- ctx->nonce = malloc(ctx->blocksize_B);
- if(ctx->nonce==NULL){
- return 0x81;
- }
- r = bcal_cmac_init(desc, key, keysize_b, &(ctx->ctag));
- if(r){
- return r;
- }
- r = bcal_cmac_init(desc, key, keysize_b, &(ctx->htag));
- if(r){
- return (r|0x10);
- }
- r = bcal_cmac_init(desc, key, keysize_b, &(ctx->ntag));
- if(r){
- return (r|0x20);
- }
- r = bcal_ctr_init(desc, key, keysize_b, NULL, &(ctx->cipher));
- if(r){
- return (r|0x30);
- }
- ctx->header_set=0;
- uint8_t tmp[ctx->blocksize_B];
- memset(tmp, 0, ctx->blocksize_B);
- bcal_cmac_nextBlock(&(ctx->ntag), tmp);
- tmp[ctx->blocksize_B-1]=1;
- bcal_cmac_nextBlock(&(ctx->htag), tmp);
- tmp[ctx->blocksize_B-1]=2;
- bcal_cmac_nextBlock(&(ctx->ctag), tmp);
- return 0;
+#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 r;
+ ctx->blocksize_B = (bcal_cipher_getBlocksize_b(desc) + 7) / 8;
+ ctx->nonce = malloc(ctx->blocksize_B);
+ if (ctx->nonce == NULL) {
+ return 0x81;
+ }
+ r = bcal_cmac_init(desc, key, keysize_b, &(ctx->ctag));
+ if (r) {
+ return r;
+ }
+ r = bcal_cmac_init(desc, key, keysize_b, &(ctx->htag));
+ if (r) {
+ return (r | 0x10);
+ }
+ r = bcal_cmac_init(desc, key, keysize_b, &(ctx->ntag));
+ if (r) {
+ return (r | 0x20);
+ }
+ r = bcal_ctr_init(desc, key, keysize_b, NULL, &(ctx->cipher));
+ if (r) {
+ return (r | 0x30);
+ }
+ ctx->header_set = 0;
+ uint8_t tmp[ctx->blocksize_B];
+ memset(tmp, 0, ctx->blocksize_B);
+ bcal_cmac_nextBlock(&(ctx->ntag), tmp);
+ tmp[ctx->blocksize_B - 1] = 1;
+ bcal_cmac_nextBlock(&(ctx->htag), tmp);
+ tmp[ctx->blocksize_B - 1] = 2;
+ bcal_cmac_nextBlock(&(ctx->ctag), tmp);
+ return 0;