How to use rsa relative functions?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
liTa_2157431
Level 1
Level 1
First like received

Hi, Broadcom Support team

Can you give me an example of RSA relative functions? For instance:

rsa_init, rsa_free, rsa_public, rsa_private ......

Thanks,

Alinket Engineer

11 Replies
SeyhanA_31
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Hi,

Working on a sample app of RSA related functions.

Thanks,

-Seyhan

Anonymous
Not applicable

Hello

Is there a way to import an existing RSA public key and encrypt with it ?

Thanks,

Pascal

0 Likes
lock attach
Attachments are accessible only for community members.

Hi,

Please update the ...\Apps\snip\crypto\crypto.c and ...\include\wiced_security.h files with attached copies.

Build the App_Crypto application "snip.crypto-BCM943362WCD4 download run" and run it.

Outputs are printed on the serial terminal.

Seyhan

0 Likes
Anonymous
Not applicable

Hi,

Thanks but unfortunately there is no clue about importing an existing RSA public key in this snippet.

The rsa_usage() function calls :

          rsa_gen_key(rsa, 1024, 65537);

I would like to call instead something like:

          rsa_import_pubkey(peer_pub_key);

Thanks,

Pascal.

0 Likes

I'll second that request for sample code that imports an RSA public key.  I'm looking at ways to do a secure firmware update by signing the image, and the rsa_pkcs1_sign/verify functions in the WICED API look like just what I need.

seyhan, looking at your modified crypto.c code snippet I have a few questions/concerns:

- no runtime seed is being provided to srand(), so rand() will generate the same series of pseudorandom numbers every time the code snippet is run

- rand() is generally not considered safe to use for cryptography (fine for sample code, but probably worth a mention in a comment)

- I *think* the rsa_context 'rsa' itself still needs to be freed, even after calling rsa_free(rsa);  (That's just my guess based on the one-liner description of rsa_free(), I could be wrong.)

Cheers!

Hello,

Just bumping this ticket.  Any progress on a PKCS#1 signature verification example that uses an RSA key imported from another system?  Alternatively, is there any documentation to help explain the 'mpi' data elements used in the rsa_context structure?

Thanks!

Sorry for the delay, we will have to investigate the best way to address these types of inquiries.

0 Likes

Is there a way to extract the public key from rsa context after the key pair has been generated? I can see the rsa context structure in crypto_structures.h but there is no description of what those variables mean. Without the ability to extract and publish the pubic key, RSA functions are nearly useless. Thanks for your help.

0 Likes

Hi, Kthakur

Thank you reply my questions. We had sloved this issue last year.  You can close this issue now.

Thanks again.

0 Likes

Hi lintaot,

Would you be able to share what you're doing to solve the original problem you posted about?  I think what kthakur is finding is similar to what I encountered when trying to use the RSA library -- there's no clear way to import or export an RSA key to/from a standard format.  The rsa_context type isn't useful outside of the WICED framework.

For now I've had to workaround using RSA altogether, but it'd be still be nice to get some direction on this.

Thanks!

0 Likes

Hi,

The following functions checks the RSA keys.

/**

* @brief          Check a public RSA key

*

* @param ctx      RSA context to be checked

*

* @return        0 if successful

*/

int32_t rsa_check_pubkey( const rsa_context *ctx );

/**

* @brief          Check a private RSA key

*

* @param ctx      RSA context to be checked

*

* @return        0 if successful

*/

int32_t rsa_check_privkey( const rsa_context *ctx );

Seyhan

0 Likes