does there have an example for rsa_pkcs1_encrypt(.....) function?

wziy520
Posts: 42
Joined: Thu Nov 10, 2016 7:58 am

does there have an example for rsa_pkcs1_encrypt(.....) function?

Postby wziy520 » Mon Mar 13, 2017 9:46 am

does there have an example for rsa_pkcs1_encrypt(.....) function?

SombraRPK
Posts: 18
Joined: Wed Jul 04, 2018 2:37 am

Re: does there have an example for rsa_pkcs1_encrypt(.....) function?

Postby SombraRPK » Tue Oct 09, 2018 11:31 pm

Hi, i'm just looking for the same! Did you know something about that you can share? Thanks!

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: does there have an example for rsa_pkcs1_encrypt(.....) function?

Postby ESP_Angus » Wed Oct 10, 2018 2:42 am

Hi,

We don't have a standalone example of this function in ESP-IDF, but mbedTLS has a range of example programs (designed for Linux) which use the mbedTLS APIs.

An RSA encryption sample is here:
https://github.com/espressif/mbedtls/bl ... ypt.c#L152

This code (main function) will not work as-is in ESP-IDF, but you could adapt the relevant parts without too much trouble.

SombraRPK
Posts: 18
Joined: Wed Jul 04, 2018 2:37 am

Re: does there have an example for rsa_pkcs1_encrypt(.....) function?

Postby SombraRPK » Mon Oct 15, 2018 9:03 pm

Thank you, ESP_Angus! I find a couple of things trying to make this code work. I'd be so glad that you could help me.
The first one. I was reading the code and I see it use files, do you know if I can use files with the ESP32? Or do you have a recommendation to make it work? I think the best would be having the key in a char array, but i'm really lost on it.
The second. I'm trying to compile the code on Mac OS X High Sierra using gcc, but i have some problems with the linker, appearantly (i attach a screenshot). Do you think I need to try on Linux?

Thanks in advance!
Attachments
Captura de pantalla 2018-10-15 a la(s) 16.02.29.png
Captura de pantalla 2018-10-15 a la(s) 16.02.29.png (138.22 KiB) Viewed 7478 times

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: does there have an example for rsa_pkcs1_encrypt(.....) function?

Postby ESP_Angus » Mon Oct 15, 2018 10:36 pm

SombraRPK wrote:Thank you, ESP_Angus! I find a couple of things trying to make this code work. I'd be so glad that you could help me.
The first one. I was reading the code and I see it use files, do you know if I can use files with the ESP32? Or do you have a recommendation to make it work? I think the best would be having the key in a char array, but i'm really lost on it.
This is up to you. You could adapt the code in these files to use keys in arrays instead (refer to the mbedTLS docs for the functions to use), or you can continue to load from the filesystem (using one of the supported ESP32 embedded filesystems). It's really up to you.
SombraRPK wrote: The second. I'm trying to compile the code on Mac OS X High Sierra using gcc, but i have some problems with the linker, appearantly (i attach a screenshot). Do you think I need to try on Linux?
You need to build the mbedTLS library on macOS and then pass the required gcc options to link in this library. mbedTLS includes some Makefiles and CMakeLists files for the library and the example programs, which should help do this for you.

Unfortunately, supporting C programming on macOS is outside the scope of this forum - but there are lots of other resources online which can help you learn.

SombraRPK
Posts: 18
Joined: Wed Jul 04, 2018 2:37 am

Re: does there have an example for rsa_pkcs1_encrypt(.....) function?

Postby SombraRPK » Mon Oct 15, 2018 10:55 pm

Thanks a lot. What would you recommend me, talking about the string-in key or file-in key? And about the mbedTLS docs, are these? https://tls.mbed.org/api/, or are there some others specifically for ESP?

Who is online

Users browsing this forum: No registered users and 125 guests