Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAINT] Fixed invalid ASSERT checking outdated object in haicrypt #2652

Merged
merged 3 commits into from
Feb 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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