Skip to content

Commit

Permalink
feat(bignum): Add initial bignum hardware acceleration
Browse files Browse the repository at this point in the history
Libs need to be rebuilt:
- cargo +stable xtask compile
- cargo +stable xtask bindings

Signed-off-by: Anthony Grondin <=>
  • Loading branch information
AnthonyGrondin committed Dec 4, 2023
1 parent fcc50ea commit 8a5d33a
Show file tree
Hide file tree
Showing 14 changed files with 1,116 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "mbedtls"]
path = mbedtls
url = https://github.com/Mbed-TLS/mbedtls
url = https://github.com/espressif/mbedtls
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ static_cell = { version = "=1.2", features = ["nightly"] }

esp-mbedtls = { path = "./esp-mbedtls" }

[target.xtensa-esp32s3-none-elf.dependencies]
[[example]]
name = "crypto_self_test"
required-features = ["esp-wifi/wifi-logs"]

[[example]]
name = "async_client"
Expand Down
2 changes: 2 additions & 0 deletions esp-mbedtls-sys/headers/esp32c3/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3609,6 +3609,8 @@
/* MPI / BIGNUM options */
//#define MBEDTLS_MPI_WINDOW_SIZE 2 /**< Maximum window size used. */
//#define MBEDTLS_MPI_MAX_SIZE 1024 /**< Maximum number of bytes for usable MPIs. */
#define MBEDTLS_MPI_EXP_MOD_ALT
// #define MBEDTLS_MPI_MUL_MPI_ALT

/* CTR_DRBG options */
//#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 48 /**< Amount of entropy used per seed by default (48 with SHA-512, 32 with SHA-256) */
Expand Down
3 changes: 3 additions & 0 deletions esp-mbedtls-sys/headers/esp32s3/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3609,6 +3609,9 @@
/* MPI / BIGNUM options */
//#define MBEDTLS_MPI_WINDOW_SIZE 2 /**< Maximum window size used. */
//#define MBEDTLS_MPI_MAX_SIZE 1024 /**< Maximum number of bytes for usable MPIs. */
// #define MBEDTLS_BIGNUM_ALT
#define MBEDTLS_MPI_EXP_MOD_ALT
#define MBEDTLS_MPI_MUL_MPI_ALT

/* CTR_DRBG options */
//#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 48 /**< Amount of entropy used per seed by default (48 with SHA-512, 32 with SHA-256) */
Expand Down
1 change: 1 addition & 0 deletions esp-mbedtls-sys/src/include/esp32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4808,6 +4808,7 @@ extern "C" {
/// buffer of length \p blen Bytes. It may be \c NULL if
/// \p blen is zero.
/// \param blen The length of \p buf in Bytes.
/// \param md_alg The hash algorithm used to hash the original data.
/// \param f_rng_blind The RNG function used for blinding. This must not be
/// \c NULL.
/// \param p_rng_blind The RNG context to be passed to \p f_rng. This may be
Expand Down
1 change: 1 addition & 0 deletions esp-mbedtls-sys/src/include/esp32c3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4810,6 +4810,7 @@ extern "C" {
/// buffer of length \p blen Bytes. It may be \c NULL if
/// \p blen is zero.
/// \param blen The length of \p buf in Bytes.
/// \param md_alg The hash algorithm used to hash the original data.
/// \param f_rng_blind The RNG function used for blinding. This must not be
/// \c NULL.
/// \param p_rng_blind The RNG context to be passed to \p f_rng. This may be
Expand Down
1 change: 1 addition & 0 deletions esp-mbedtls-sys/src/include/esp32s2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4808,6 +4808,7 @@ extern "C" {
/// buffer of length \p blen Bytes. It may be \c NULL if
/// \p blen is zero.
/// \param blen The length of \p buf in Bytes.
/// \param md_alg The hash algorithm used to hash the original data.
/// \param f_rng_blind The RNG function used for blinding. This must not be
/// \c NULL.
/// \param p_rng_blind The RNG context to be passed to \p f_rng. This may be
Expand Down
1 change: 1 addition & 0 deletions esp-mbedtls-sys/src/include/esp32s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4808,6 +4808,7 @@ extern "C" {
/// buffer of length \p blen Bytes. It may be \c NULL if
/// \p blen is zero.
/// \param blen The length of \p buf in Bytes.
/// \param md_alg The hash algorithm used to hash the original data.
/// \param f_rng_blind The RNG function used for blinding. This must not be
/// \c NULL.
/// \param p_rng_blind The RNG context to be passed to \p f_rng. This may be
Expand Down
2 changes: 2 additions & 0 deletions esp-mbedtls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ esp-mbedtls-sys = { path = "../esp-mbedtls-sys" }
log = "0.4.17"
embedded-io = { version = "0.6.1" }
embedded-io-async = { version = "0.6.0", optional = true }
crypto-bigint = { version = "0.5.3", default-features = false, features = ["extra-sizes"] }
esp32-hal = { version = "0.16.0", optional = true }
esp32c3-hal = { version = "0.13.0", optional = true }
esp32s2-hal = { version = "0.13.0", optional = true }
esp32s3-hal = { version = "0.13.0", optional = true }
cfg-if = "1.0.0"

[features]
async = ["dep:embedded-io-async"]
Expand Down
Loading

0 comments on commit 8a5d33a

Please sign in to comment.