When I am decoding a certificate, I get the following data:
{:OTPSubjectPublicKeyInfo, {:PublicKeyAlgorithm, {1, 2, 840, 10045, 2, 1}, {:namedCurve, {1, 2, 840, 10045, 3, 1, 7}}}
I know by doing some quick googling that the namedCurve corresponds to :secp256r1
. However I'm looking for an existing function that can do that translation for me. For example we can find information about the PublicKeyAlgorithm by using the pkix_sign_types
function. Is there a corresponding function for named curves?
There's an undocumented module (marked as private and therefore subject to breaking changes or removal at any time) that has a function which provides bidirectional mapping of namedCurves's values and their names: pubkey_cert_records:namedCurves/1
:
iex(1)> :pubkey_cert_records.namedCurves({1, 2, 840, 10045, 3, 1, 7})
:secp256r1
iex(2)> :pubkey_cert_records.namedCurves(:secp256r1)
{1, 2, 840, 10045, 3, 1, 7}
I could not find a documented function which allows calling this function with a tuple as argument and getting back an atom.