p11test: Improve error reporting on unknown EC groups
This commit is contained in:
parent
87770df65b
commit
b65275d6f8
|
@ -321,9 +321,24 @@ int callback_public_keys(test_certs_t *objects,
|
|||
/* Parse the nid out of the EC_PARAMS */
|
||||
p = template[6].pValue;
|
||||
oid = d2i_ASN1_OBJECT(NULL, &p, template[6].ulValueLen);
|
||||
if (oid == NULL) {
|
||||
debug_print(" [WARN %s ] Failed to convert EC_PARAMS"
|
||||
" to OpenSSL format", o->id_str);
|
||||
return -1;
|
||||
}
|
||||
nid = OBJ_obj2nid(oid);
|
||||
ASN1_OBJECT_free(oid);
|
||||
if (nid == NID_undef) {
|
||||
debug_print(" [WARN %s ] Failed to convert EC_PARAMS"
|
||||
" to NID", o->id_str);
|
||||
return -1;
|
||||
}
|
||||
ecgroup = EC_GROUP_new_by_curve_name(nid);
|
||||
if (ecgroup == NULL) {
|
||||
debug_print(" [WARN %s ] Failed to create new EC_GROUP"
|
||||
" from NID", o->id_str);
|
||||
return -1;
|
||||
}
|
||||
EC_GROUP_set_asn1_flag(ecgroup, OPENSSL_EC_NAMED_CURVE);
|
||||
|
||||
p = template[7].pValue;
|
||||
|
@ -334,7 +349,7 @@ int callback_public_keys(test_certs_t *objects,
|
|||
ASN1_STRING_free(s);
|
||||
if (bn == NULL) {
|
||||
debug_print(" [WARN %s ] Can not convert EC_POINT from"
|
||||
"PKCS#11 to BIGNUM", o->id_str);
|
||||
" PKCS#11 to BIGNUM", o->id_str);
|
||||
EC_GROUP_free(ecgroup);
|
||||
return -1;
|
||||
}
|
||||
|
@ -343,7 +358,7 @@ int callback_public_keys(test_certs_t *objects,
|
|||
BN_free(bn);
|
||||
if (ecpoint == NULL) {
|
||||
debug_print(" [WARN %s ] Can not convert EC_POINT from"
|
||||
"BIGNUM to OpenSSL format", o->id_str);
|
||||
" BIGNUM to OpenSSL format", o->id_str);
|
||||
EC_GROUP_free(ecgroup);
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue