From: Klas Lindfors Date: Wed, 8 Jan 2014 14:03:51 +0000 (+0100) Subject: let ykp_AES_key_from_hex() return error X-Git-Tag: v1.15.0~18 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=229d2f7194d46133192ab9f3aa3475fde4a753e3;p=yubikey-personalization let ykp_AES_key_from_hex() return error --- diff --git a/ykpers.c b/ykpers.c index 18f4984..4dafcea 100644 --- 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));