Description
Summary
In this PR we made Parsec less strict about the PKCS#11 spec when returning the public portion of elliptic curve keys. This was to resolve an interoperability issue with a PKCS#11 library that was not precisely following the spec. In the code review, we discussed adding some additional validity checks to make sure that the data being returned is in fact a valid EC public key and not garbage.
Detail
Probably the most sensible approach is to refactor the existing handle_ecc_public_import_attrib()
function, which already contains some of the checks that we need. The checks themselves could be factored out into a validate_ecc_public_key_data()
method (or some other suitable name). As inputs, this function would take the key data and the key size (in bits). This function can then be used in common both when importing and exporting.