Topic: wc_KeyPemToDer to Converts a public key in PEM format to DER format.

Hi,
i have a TCP/IP server and clients implemented in C. The server has a database of the authorized clients' public keys, which are stored in pem format. I am using RSA keypairs so that the client signs the data with the private key and the server can verify it using the public key. I used wc_KeyPemToDer to convert the keys to DER format. The function works only for the private key but returns the -162 when applying it to the public key.
Do you have any recommendation to convert the public key to DER format.

Best regards.
Bassem Trifa.

Share

Re: wc_KeyPemToDer to Converts a public key in PEM format to DER format.

Hi Bassem,

wc_KeyPemToDer is meant for private keys, you're getting -162 (ASN_NO_PEM_HEADER) for your public key as it specifically checks for private key headers only.  For public keys, you can use wc_PubKeyPemToDer.  You can also use wc_PemToDer as a general PEM to DER conversion function.

Thanks,
Kareem

Share