Topic: Bug in ssl.c for RSA private key handling in ProcessBuffer()?

Hi All,

We have been using the SSL functionality of wolfSSL embedded SSL and everything until works fine. We are using wolfssl-2.6.0.

In ssl.c in the method ProcessBuffer() for private key handling, starting from  line number 1425: 

        if (type == PRIVATEKEY_TYPE && format != SSL_FILETYPE_RAW) {
#ifndef NO_RSA
            if (!eccKey) { 
                /* make sure RSA key can be used */
                RsaKey key;
                word32 idx = 0;
        
                InitRsaKey(&key, 0);
                if (RsaPrivateKeyDecode(der.buffer,&idx,&key,der.length) != 0) {
                 ...
              }

This block tries to construct a RsaKey from a encoded key in DER format to make sure that the encoded key can be used later. As I understand, RsaPrivateKeyDecode() is used to decode a key in DER format into RsaKey. Then line 1425 shall be

        if (type == PRIVATEKEY_TYPE && format == SSL_FILETYPE_RAW) 

instead of

        if (type == PRIVATEKEY_TYPE && format != SSL_FILETYPE_RAW) 

Is it correct what I understand?

Thanks, Yun

Share

Re: Bug in ssl.c for RSA private key handling in ProcessBuffer()?

Hi Yun,

Your understanding of RsaPrivateKeyDecode() is correct.  It is used to decode a key from a DER format into an RsaKey structure. 

SSL_FILETYPE_RAW is used with NTRU (a separate public key algorithm which CyaSSL supports).  DER format is indicated by SSL_FILETYPE_ASN1.

Best Regards,
Chris