From 80e6fe525ab494e6773795f1bd50b9a3f0dc09d9 Mon Sep 17 00:00:00 2001 From: Klas Lindfors Date: Tue, 30 Jun 2015 07:33:39 +0200 Subject: [PATCH] change IS_XXKEY macros to be YKPIV_IS_XX --- lib/ykpiv.c | 6 +++--- lib/ykpiv.h | 4 ++-- tool/yubico-piv-tool.c | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/ykpiv.c b/lib/ykpiv.c index 7dec9e5..5897c2c 100644 --- a/lib/ykpiv.c +++ b/lib/ykpiv.c @@ -562,7 +562,7 @@ static ykpiv_rc _general_authenticate(ykpiv_state *state, dataptr += set_length(dataptr, in_len + bytes + 3); *dataptr++ = 0x82; *dataptr++ = 0x00; - *dataptr++ = IS_ECKEY(algorithm) && decipher ? 0x85 : 0x81; + *dataptr++ = YKPIV_IS_EC(algorithm) && decipher ? 0x85 : 0x81; dataptr += set_length(dataptr, in_len); memcpy(dataptr, sign_in, (size_t)in_len); dataptr += in_len; @@ -615,13 +615,13 @@ ykpiv_rc ykpiv_sign_data(ykpiv_state *state, unsigned char sign_in[256]; size_t key_len = 0; - if(IS_RSAKEY(algorithm)) { + if(YKPIV_IS_RSA(algorithm)) { key_len = 128; if(algorithm == YKPIV_ALGO_RSA2048) { key_len = 256; } } - if(IS_RSAKEY(algorithm) && key_len != in_len) { + if(YKPIV_IS_RSA(algorithm) && key_len != in_len) { if(in_len + RSA_PKCS1_PADDING_SIZE > key_len) { return YKPIV_SIZE_ERROR; } diff --git a/lib/ykpiv.h b/lib/ykpiv.h index 4585d4c..0570b9b 100644 --- a/lib/ykpiv.h +++ b/lib/ykpiv.h @@ -158,8 +158,8 @@ extern "C" #define YKPIV_TOUCHPOLICY_NEVER 1 #define YKPIV_TOUCHPOLICY_ALWAYS 2 -#define IS_ECKEY(a) ((a == YKPIV_ALGO_ECCP256 || a == YKPIV_ALGO_ECCP384)) -#define IS_RSAKEY(a) ((a == YKPIV_ALGO_RSA1024 || a == YKPIV_ALGO_RSA2048)) +#define YKPIV_IS_EC(a) ((a == YKPIV_ALGO_ECCP256 || a == YKPIV_ALGO_ECCP384)) +#define YKPIV_IS_RSA(a) ((a == YKPIV_ALGO_RSA1024 || a == YKPIV_ALGO_RSA2048)) #ifdef __cplusplus } diff --git a/tool/yubico-piv-tool.c b/tool/yubico-piv-tool.c index 601dcf6..233dd51 100644 --- a/tool/yubico-piv-tool.c +++ b/tool/yubico-piv-tool.c @@ -353,7 +353,7 @@ static bool import_key(ykpiv_state *state, enum enum_key_format key_format, unsigned char *in_ptr = in_data; unsigned char templ[] = {0, YKPIV_INS_IMPORT_KEY, algorithm, key}; int sw; - if(IS_RSAKEY(algorithm)) { + if(YKPIV_IS_RSA(algorithm)) { RSA *rsa_private_key = EVP_PKEY_get1_RSA(private_key); unsigned char e[4]; unsigned char *e_ptr = e; @@ -397,7 +397,7 @@ static bool import_key(ykpiv_state *state, enum enum_key_format key_format, fprintf(stderr, "Failed setting iqmp component.\n"); goto import_out; } - } else if(IS_ECKEY(algorithm)) { + } else if(YKPIV_IS_EC(algorithm)) { EC_KEY *ec = EVP_PKEY_get1_EC_KEY(private_key); const BIGNUM *s = EC_KEY_get0_private_key(ec); int element_len = 32; @@ -682,7 +682,7 @@ static bool request_certificate(ykpiv_state *state, enum enum_key_format key_for fprintf(stderr, "Unsupported algorithm %x or hash %x\n", algorithm, hash); goto request_out; } - if(IS_RSAKEY(algorithm)) { + if(YKPIV_IS_RSA(algorithm)) { signinput = digest; len = oid_len + digest_len; } else { @@ -827,7 +827,7 @@ static bool selfsign_certificate(ykpiv_state *state, enum enum_key_format key_fo if(nid == 0) { goto selfsign_out; } - if(IS_RSAKEY(algorithm)) { + if(YKPIV_IS_RSA(algorithm)) { signinput = digest; len = oid_len + md_len; } else { @@ -1090,7 +1090,7 @@ static bool sign_file(ykpiv_state *state, const char *input, const char *output, EVP_MD_CTX_destroy(mdctx); } - if(IS_RSAKEY(algo)) { + if(YKPIV_IS_RSA(algo)) { prepare_rsa_signature(hashed, hash_len, hashed, &hash_len, EVP_MD_type(md)); } @@ -1342,7 +1342,7 @@ static bool test_signature(ykpiv_state *state, enum enum_slot slot, goto test_out; } sscanf(cmdline_parser_slot_values[slot], "%2x", &key); - if(IS_RSAKEY(algorithm)) { + if(YKPIV_IS_RSA(algorithm)) { prepare_rsa_signature(data, data_len, encoded, &enc_len, EVP_MD_type(md)); ptr = encoded; } else { @@ -1448,7 +1448,7 @@ static bool test_decipher(ykpiv_state *state, enum enum_slot slot, goto decipher_out; } sscanf(cmdline_parser_slot_values[slot], "%2x", &key); - if(IS_RSAKEY(algorithm)) { + if(YKPIV_IS_RSA(algorithm)) { unsigned char secret[32]; unsigned char secret2[32]; unsigned char data[256]; @@ -1489,7 +1489,7 @@ static bool test_decipher(ykpiv_state *state, enum enum_slot slot, } else { fprintf(stderr, "Failed unwrapping PKCS1 envelope.\n"); } - } else if(IS_ECKEY(algorithm)) { + } else if(YKPIV_IS_EC(algorithm)) { unsigned char secret[48]; unsigned char secret2[48]; unsigned char public_key[97];