]> err.no Git - yubikey-personalization/commitdiff
set errno for errors in ykp_HMAC_key_from_hex()
authorKlas Lindfors <klas@yubico.com>
Wed, 8 Jan 2014 14:21:50 +0000 (15:21 +0100)
committerKlas Lindfors <klas@yubico.com>
Thu, 9 Jan 2014 08:48:38 +0000 (09:48 +0100)
ykpers.c

index 4dafcea1cb926e3c671c27e06fc4dcc4b45f7fab..e860419905e6165bf1978e215e89427c9dca62ed 100644 (file)
--- a/ykpers.c
+++ b/ykpers.c
@@ -280,12 +280,15 @@ int ykp_HMAC_key_from_hex(YKP_CONFIG *cfg, const char *hexkey) {
 
        /* Make sure that the hexkey is exactly 40 characters */
        if (strlen(hexkey) != 40) {
+               ykp_errno = YKP_EINVAL;
                return 1;  /* Bad HMAC key */
        }
 
        /* Make sure that the hexkey is made up of only [0-9a-f] */
-       if (! yubikey_hex_p(hexkey))
+       if (! yubikey_hex_p(hexkey)) {
+               ykp_errno = YKP_EINVAL;
                return 1;
+       }
 
        yubikey_hex_decode(aesbin, hexkey, sizeof(aesbin));
        i = sizeof(cfg->ykcore_config.key);