call get_algorithm() to get the algorithm

as it was already implemented..
This commit is contained in:
Klas Lindfors
2015-03-19 14:37:59 +01:00
parent 91ddd394e4
commit 635729f339
+11 -26
View File
@@ -1231,39 +1231,24 @@ static void print_cert_info(ykpiv_state *state, enum enum_slot slot, const EVP_M
goto cert_out; goto cert_out;
} }
{ {
int type;
EVP_PKEY *key = X509_get_pubkey(x509); EVP_PKEY *key = X509_get_pubkey(x509);
if(!key) { if(!key) {
fprintf(output, "Parse error.\n"); fprintf(output, "Parse error.\n");
goto cert_out; goto cert_out;
} }
fprintf(output, "\n\tAlgorithm:\t"); fprintf(output, "\n\tAlgorithm:\t");
type = EVP_PKEY_type(key->type); switch(get_algorithm(key)) {
switch(type) { case YKPIV_ALGO_RSA1024:
case EVP_PKEY_RSA: fprintf(output, "RSA1024\n");
{ break;
RSA *rsa = EVP_PKEY_get1_RSA(key); case YKPIV_ALGO_RSA2048:
fprintf(output, "RSA%d\n", RSA_size(rsa) * 8); fprintf(output, "RSA2048\n");
break; break;
} case YKPIV_ALGO_ECCP256:
case EVP_PKEY_EC: fprintf(output, "ECCP256\n");
{ break;
EC_KEY *ec = EVP_PKEY_get1_EC_KEY(key);
const EC_GROUP *group = EC_KEY_get0_group(ec);
switch(EC_GROUP_get_curve_name(group)) {
case NID_X9_62_prime256v1:
fprintf(output, "ECCP256\n");
break;
case NID_secp384r1:
fprintf(output, "ECCP384\n"); /* is this correct NID? */
break;
default:
fprintf(output, "Unknown ECC curve\n");
}
break;
}
default: default:
fprintf(output, "Unknown algorithm\n"); fprintf(output, "Unknown\n");
} }
} }
subj = X509_get_subject_name(x509); subj = X509_get_subject_name(x509);