[libfko] ensure a NULL HMAC key is properly handled
authorMichael Rash <mbr@cipherdyne.org>
Thu, 2 Jan 2014 00:45:38 +0000 (19:45 -0500)
committerMichael Rash <mbr@cipherdyne.org>
Thu, 2 Jan 2014 00:45:38 +0000 (19:45 -0500)
lib/fko_hmac.c

index dac961b..337a638 100644 (file)
@@ -48,6 +48,9 @@ fko_verify_hmac(fko_ctx_t ctx,
     if(!CTX_INITIALIZED(ctx))
         return(FKO_ERROR_CTX_NOT_INITIALIZED);
 
+    if(hmac_key == NULL)
+        return(FKO_ERROR_INVALID_DATA);
+
     if (! is_valid_encoded_msg_len(ctx->encrypted_msg_len))
         return(FKO_ERROR_INVALID_DATA_HMAC_MSGLEN_VALIDFAIL);
 
@@ -230,6 +233,9 @@ int fko_set_spa_hmac(fko_ctx_t ctx,
     if(!CTX_INITIALIZED(ctx))
         return(FKO_ERROR_CTX_NOT_INITIALIZED);
 
+    if(hmac_key == NULL)
+        return(FKO_ERROR_INVALID_DATA);
+
     if(hmac_key_len < 0 || hmac_key_len > MAX_DIGEST_BLOCK_LEN)
         return(FKO_ERROR_INVALID_HMAC_KEY_LEN);