Skip to content

Commit

Permalink
[core] Fixed invalid ASSERT checking outdated object in haicrypt (#2652
Browse files Browse the repository at this point in the history
…).
  • Loading branch information
ethouris authored Feb 8, 2023
1 parent a7bd1b0 commit 6d774dd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions haicrypt/hcrypt_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,25 @@ int HaiCrypt_Tx_GetBuf(HaiCrypt_Handle hhc, size_t data_len, unsigned char **in_
int HaiCrypt_Tx_ManageKeys(HaiCrypt_Handle hhc, void *out_p[], size_t out_len_p[], int maxout)
{
hcrypt_Session *crypto = (hcrypt_Session *)hhc;
hcrypt_Ctx *ctx = NULL;
int nbout = 0;

if ((NULL == crypto)
|| (NULL == (ctx = crypto->ctx))
|| (NULL == crypto->ctx)
|| (NULL == out_p)
|| (NULL == out_len_p)) {
HCRYPT_LOG(LOG_ERR, "ManageKeys: invalid params: crypto=%p crypto->ctx=%p\n", crypto, ctx);
HCRYPT_LOG(LOG_ERR, "ManageKeys: invalid params: crypto=%p out_p=%p out_len_p=%p\n",
crypto, out_p, out_len_p);
return(-1);
}

/* Manage Key Material (refresh, announce, decommission) */
hcryptCtx_Tx_ManageKM(crypto);

ASSERT(ctx->status == HCRYPT_CTX_S_ACTIVE);
if (NULL == crypto->ctx) {
HCRYPT_LOG(LOG_ERR, "%s", "crypto context NULL after ManageKM call\n");
return(-1);
}
ASSERT(crypto->ctx->status == HCRYPT_CTX_S_ACTIVE);

nbout = hcryptCtx_Tx_InjectKM(crypto, out_p, out_len_p, maxout);
return(nbout);
Expand Down

0 comments on commit 6d774dd

Please sign in to comment.