From: Wenkai Lin linwenkai6@hisilicon.com
The ctx key may be null if the user use the normal mode, it should return an error before copy data to the key.
Signed-off-by: Wenkai Lin linwenkai6@hisilicon.com --- v1/wd_aead.c | 4 ++-- v1/wd_cipher.c | 2 +- v1/wd_digest.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/v1/wd_aead.c b/v1/wd_aead.c index f79c9d9c..87bd6acb 100644 --- a/v1/wd_aead.c +++ b/v1/wd_aead.c @@ -362,7 +362,7 @@ int wcrypto_set_aead_ckey(void *ctx, __u8 *key, __u16 key_len) struct wcrypto_aead_ctx *ctxt = ctx; int ret;
- if (!ctx || !key) { + if (!ctx || !ctxt->ckey || !key) { WD_ERR("input param is NULL!\n"); return -WD_EINVAL; } @@ -387,7 +387,7 @@ int wcrypto_set_aead_akey(void *ctx, __u8 *key, __u16 key_len) { struct wcrypto_aead_ctx *ctxt = ctx;
- if (!ctx || (key_len && !key)) { + if (!ctx || !ctxt->akey || (key_len && !key)) { WD_ERR("failed to check authenticate key param!\n"); return -WD_EINVAL; } diff --git a/v1/wd_cipher.c b/v1/wd_cipher.c index 57f10091..6dbdebc3 100644 --- a/v1/wd_cipher.c +++ b/v1/wd_cipher.c @@ -309,7 +309,7 @@ int wcrypto_set_cipher_key(void *ctx, __u8 *key, __u16 key_len) struct wcrypto_cipher_ctx *ctxt = ctx; int ret;
- if (!ctx || !key) { + if (!ctx || !ctxt->key || !key) { WD_ERR("%s: input param err!\n", __func__); return -WD_EINVAL; } diff --git a/v1/wd_digest.c b/v1/wd_digest.c index e26909d3..c02b3b30 100644 --- a/v1/wd_digest.c +++ b/v1/wd_digest.c @@ -308,7 +308,7 @@ int wcrypto_set_digest_key(void *ctx, __u8 *key, __u16 key_len) struct wcrypto_digest_ctx *ctxt = ctx; int ret;
- if (!ctx || (key_len && !key)) { + if (!ctx || !ctxt->key || (key_len && !key)) { WD_ERR("%s(): input param err!\n", __func__); return -WD_EINVAL; }