X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=hfal%2Fhfal-hmac.c;h=01a6409356d4284a9cd42b92f7ba0b9525b63fe4;hb=fba438e4a194e3d3c61ba7ebbbf5a34c42e5cb66;hp=f36b58e7683b75a7fba50ee5e5bf3ebc87f4b70d;hpb=1ee55d2589fee6c40acb72a24c04528a8cc1772f;p=arm-crypto-lib.git diff --git a/hfal/hfal-hmac.c b/hfal/hfal-hmac.c index f36b58e..01a6409 100644 --- a/hfal/hfal-hmac.c +++ b/hfal/hfal-hmac.c @@ -38,13 +38,13 @@ uint8_t hfal_hmac_init(const hfdesc_t* hash_descriptor, ctx->desc = hash_descriptor; ctx->ctx = malloc(hash_descriptor->ctxsize_B); ctx->finctx = malloc(hash_descriptor->ctxsize_B); - if(ctx->ctx==NULL && ctx->finctx==NULL) + if(ctx->ctx == NULL && ctx->finctx == NULL) return 3; - if(ctx->finctx==NULL){ + if(ctx->finctx == NULL){ free(ctx->ctx); return 2; } - if(ctx->ctx==NULL){ + if(ctx->ctx == NULL){ free(ctx->finctx); return 1; } @@ -69,16 +69,17 @@ uint8_t hfal_hmac_init(const hfdesc_t* hash_descriptor, return 0; } -int hfal_hmac_ctxcopy(hfhmacgen_ctx_t* dest, hfhmacgen_ctx_t* src){ +uint8_t hfal_hmac_ctxcopy(hfhmacgen_ctx_t* dest, hfhmacgen_ctx_t* src){ dest->desc = src->desc; dest->ctx = malloc(dest->desc->ctxsize_B); if(dest->ctx == NULL){ - return -1; + return 1; } memcpy(dest->ctx, src->ctx, dest->desc->ctxsize_B); dest->finctx = malloc(dest->desc->ctxsize_B); if(dest->finctx == NULL){ - return -1; + free(dest->ctx); + return 1; } memcpy(dest->finctx, src->finctx, dest->desc->ctxsize_B); return 0;