In the esp32 files, there are libraries about BIGNUMBER (GMP), such as MbedTLS which claims to support hardware acceleration up to 4096b.
I don't found any examples of using bignumb for esp32, does anyone know of an example with MbedTLS libraries or some other library?
BigNumber (GMP)?
Re: BigNumber (GMP)?
The mbedTLS big number library (mbedtls/bignum.h) is probably the best candidate.
I don't know of any generic examples using this code, but if you grep the mbedTLS library source you will find many examples of this API being used for RSA, EC ciphers, etc.
I don't know of any generic examples using this code, but if you grep the mbedTLS library source you will find many examples of this API being used for RSA, EC ciphers, etc.
Re: BigNumber (GMP)?
I have not found any examples on the specific usage of BigNumber (mbed), however, in the bignumber.h file itself there is a help on the functions that allowed me to start.
Obviously something would have to go wrong, when I try to add the result of the accounts using bignum in a string, it returns me an internal library error (line 589 bignumber.c) What can I do? If someone understands the use of this library, you can pass an example or even add an example to the ESP-IDF
Note: error in "write_string", I tried several values in the last parameter of this function, some give "store prohibited" error or nothing happens. I would also like to know what to put in the last parameter.
Note2: I found this example, but it can't help me to understand better. (https://github.com/ARMmbed/mbedtls/blob ... mpi_demo.c)
Image (error and code): https://i.imgur.com/dpIYMY2.png
Obviously something would have to go wrong, when I try to add the result of the accounts using bignum in a string, it returns me an internal library error (line 589 bignumber.c) What can I do? If someone understands the use of this library, you can pass an example or even add an example to the ESP-IDF
Note: error in "write_string", I tried several values in the last parameter of this function, some give "store prohibited" error or nothing happens. I would also like to know what to put in the last parameter.
Note2: I found this example, but it can't help me to understand better. (https://github.com/ARMmbed/mbedtls/blob ... mpi_demo.c)
Image (error and code): https://i.imgur.com/dpIYMY2.png
Re: BigNumber (GMP)?
The olen parameter (last parameter) can't be null. A hin that the StoreProhibted error is failing to write to a NULL pointer is that EXCVADDR (the address which lead to the exception) is 0x00000000. Try something like :urbanze wrote: Note: error in "write_string", I tried several values in the last parameter of this function, some give "store prohibited" error or nothing happens. I would also like to know what to put in the last parameter.
Code: Select all
int olen;
int r = mbedtls_write_string( ... , &olen);
printf("mbedtls_write_string result %d olen %d value %s\n", r, olen, gg);
PS Please paste actual text into "code" tags (or on a site like pastebin.com) where possible, reading screenshots is quite fiddly.
Re: BigNumber (GMP)?
The right instead of int olen is size_t olen, doing this worked properly.ESP_Angus wrote:The olen parameter (last parameter) can't be null. A hin that the StoreProhibted error is failing to write to a NULL pointer is that EXCVADDR (the address which lead to the exception) is 0x00000000. Try something like :urbanze wrote: Note: error in "write_string", I tried several values in the last parameter of this function, some give "store prohibited" error or nothing happens. I would also like to know what to put in the last parameter.
Code: Select all
int olen; int r = mbedtls_write_string( ... , &olen); printf("mbedtls_write_string result %d olen %d value %s\n", r, olen, gg);
and you should get a full picture of what's happening.
PS Please paste actual text into "code" tags (or on a site like pastebin.com) where possible, reading screenshots is quite fiddly.
Code:
Code: Select all
mbedtls_mpi x;
char bf[200];
extern "C" void app_main()
{
initArduino();
Serial.begin(115200);
uint32_t a;
size_t n = 0;
mbedtls_mpi_init(&x);
a = mbedtls_mpi_read_string(&x, 10, "18446744073709551616"); Serial.println(a);
a = mbedtls_mpi_mul_int(&x, &x, 652); Serial.println(a);
a = mbedtls_mpi_write_string(&x, 16, bf, sizeof(bf)-1, &n); Serial.println(a);
for (int i = 0; i < 30; i++)
{
Serial.printf("%c", bf[i]);
}
esp_deep_sleep(300000000);
}
Note: the write_string only worked with base 16, when using base 10 it simply happens nothing, giving impression that the MCU has locked, will it be a bug?
I did the multiplication of 18446744073709551616 by 652 is it worked, see the result in the image: https://i.imgur.com/7fj81Gh.png
Factorial 1-5010 test: https://i.imgur.com/8jdfHw0.png
This really work
Who is online
Users browsing this forum: No registered users and 82 guests