1 (edited by lk 2015-06-30 18:33:30)

Topic: generating a publickey.der

1. I generate RSA key pair on embedded platform. 
    Embedded Platform runs a firmware - no file system as of now.   
    My peer device runs a mobile operating system (android/iOS).
2. Send the Public Key over to my peer.
    What format does my public key have to be, inorder to send it over to my peer?
    Like "RsaKeyToDer()" can be used to convert my Private Key to der format, is there any function that could be used for converting my Public Key to der format?
3. My peer uses my Public Key to encrypt his message and sends the encrypted message to me.

4. I use my private key to decrypt the received encrypted message.
   I am assuming, I would use "RsaPrivateDecrypt(out, ret, plain, sizeof(plain), &key);" where the last parameter is the key I generated.

Share

Re: generating a publickey.der

1. Ok so you have a public/private key pair. Notice in my response to your other question I mentioned chapter 7 of the manual. If you reference chapter 7.7.1 you'll see we currently have no way of storing the public key separate from the private key (as there is no agreed upon specification for doing this).

2. Moving on to section 7.8 we do support certificate Generation. The format you are looking for to send to your peer is in the form of an X.509 certificate. Chapter 7 Section 8 will guide you through generating a Certificate using the RSA key structure you just created.

3. Extracting the public key from the X.509 certificate can be accomplished with RsaPublicKeyDecode() as mentioned in 7.7.1 in reference to loading a public key.
an example:

wc_RsaPublicKeyDecode(cert.publicKey, &idx, &pubKey, cert.pubKeySize);

where cert.publicKey is the public RSA Key you want to get from your embedded platform to your peer.

4. Your assumptions are correct.

For further Documentation see:
http://wolfssl.com/wolfSSL/Docs-wolfssl-manual-toc.html