AtaSmrk
AtaSmrk

Reputation: 165

Parsing signature algorithm from certificate using openssl api

I am trying to parse this certificate using OpenSSL API and sig_alg is giving me trouble.

Entire certificate is supplied to OpenSSL library via PEM_read_bio_X509 call, however NID, SN and LN fields of cert->sig_alg->algor->algorithm are all NULL, while length is 8 and data points to 8 bytes which I presume hold the OID.

So my question is this. What function can I use to extract NID from OID?

I thought I could do it with d2i_ASN1_OBJECT, but I think this just copies the data aray to new or supplied asn1 object and does not interpret the data. And I do not believe that I have to construct my own list of well known OIDs like i think it was done here (not actually proficient in PHP).

On a side note, this site is instructing users to extract signature from cert->cert_info->key->algor->algorithm. I have tried to get the data from there but I have the same result. Some data in data, zeroes everywhere else. Also, is this information really on signature? Judging by the names there is information about the public key in there.

Upvotes: 1

Views: 1465

Answers (1)

jww
jww

Reputation: 102205

So my question is this. What function can I use to extract NID from OID?

I believe the functions you are looking for are OBJ_nid2obj, OBJ_obj2nid, OBJ_txt2nid and friends. They can be found in <openssl src dir>/crypto/objects/objects.h.

The OpenSSL docs on them are located at OBJ_nid2obj(3).

Upvotes: 1

Related Questions