Topic: wolfSSL_KeyPemToDer

Hello, I'm very new to the world of C programming and I'm working on a project involving an embedded solution.

I'm attempting to use wolfSSL embedded SSL for it's RSA key cryptography abilities. My problem is hopefully a simple one...

Basically, I have a PEM private key file which I am storing as a buffer in the application, as I do not have file system capabilities (as of yet, anyway)
My goal is to decrypt a message using this key. From my understanding, the steps are as follows:

1. Convert the PEM file into a DER using wolfSSL_KeyPemToDer or some similar method
2. Use RsaPrivateKeyDecode to decrypt the message from its encoded state.

I am being hung up on a very common compiler error :
undefined reference to `wolfSSL_KeyPemToDer`

I am including wolfssl/ssl.h, and wolfssl/wolfcrypt/rsa.h.. Is there anything I might be missing, or perhaps a constant I need to define? The method signature appears in wolfssl/ssl.h as:
WOLFSSL_API wolfSSL_KeyPemToDer(const unsigned char* pem, int pemSz, unsigned char* buff,
                       int buffSz, const char* pass)

As I said, I am new to C so I am probably some kind of Noob mistake, but I would appreciate suggestions.. Thanks in advance big_smile

Share

Re: wolfSSL_KeyPemToDer

Hi dtiemann,

wolfSSL_KeyPemToDer() is currently only compiled into wolfSSL if our OpenSSL compatibility layer has been defined when building wolfSSL.

You can enable the compatibility layer by using the --enable-opensslextra ./configure option, or by adding OPENSSL_EXTRA to your list of preprocessor flags.

Can you give this a try and let me know if it works for you?

Thanks,
Chris

Re: wolfSSL_KeyPemToDer

Yes! That worked ... Thanks!

Now I'm just struggling to get my PEM String to be read by the wolfSSL_KeyPemToDer function. I keep getting a -4 as a return value.

Share

Re: wolfSSL_KeyPemToDer

Hi dtiemann,

A return value of -4 is an SSL_BAD_FILE error.  Can you double check the formatting of your PEM string?  You should have the header and footer and you should have lines separated with a LF or CRLF.

Regards,
Chris

Re: wolfSSL_KeyPemToDer

Thank you for such a helping update online that is really wise and updated. The people who need such help about games development and system up-gradation for them sharing information is useful. I must recommend https://www.analyzedu.com/writing-servi … eview.html blog to others for the helping material.

Share