]> err.no Git - yubikey-personalization/commitdiff
let ykp_AES_key_from_hex() return error
authorKlas Lindfors <klas@yubico.com>
Wed, 8 Jan 2014 14:03:51 +0000 (15:03 +0100)
committerKlas Lindfors <klas@yubico.com>
Thu, 9 Jan 2014 08:48:38 +0000 (09:48 +0100)
ykpers.c

index 18f4984b319ddabb88780e8439da615215430a5c..4dafcea1cb926e3c671c27e06fc4dcc4b45f7fab 100644 (file)
--- a/ykpers.c
+++ b/ykpers.c
@@ -253,12 +253,15 @@ int ykp_AES_key_from_hex(YKP_CONFIG *cfg, const char *hexkey) {
 
        /* Make sure that the hexkey is exactly 32 characters */
        if (strlen(hexkey) != 32) {
+               ykp_errno = YKP_EINVAL;
                return 1;  /* Bad AES 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));
        memcpy(cfg->ykcore_config.key, aesbin, sizeof(cfg->ykcore_config.key));