Skip to content

Commit

Permalink
Feat/hw accelerated sha updated (#46)
Browse files Browse the repository at this point in the history
* feat(SHA): Use hardware acceleration for SHA operations

* feat(SHA): Borrow the SHA peripheral instead of unsafely stealing

* fix(init_ssl): Cleanup allocated resources on error to prevent a memory leak.

* Use patched version of `edge-net` and `embassy-executor`

- Use the current HEAD of edge-net for the lifetimes fix in edge-http
- Use a patched version for embassy-executor before 0.6.0 was yanked.
  • Loading branch information
AnthonyGrondin authored Nov 5, 2024
1 parent f292457 commit d5e29f8
Show file tree
Hide file tree
Showing 45 changed files with 2,833 additions and 158 deletions.
13 changes: 9 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ esp-println = { version = "0.12.0", features = ["log"] }
esp-hal-embassy = { version = "0.4.0", optional = true }

embassy-time = { version = "0.3.0", optional = true }
embassy-executor = { version = "0.6.0", package = "embassy-executor", features = [
embassy-executor = { version = "=0.6.0", package = "embassy-executor", features = [
"nightly",
"integrated-timers",
], optional = true }
Expand Down Expand Up @@ -149,6 +149,11 @@ edge-server = [

# Patch until new release
[patch.crates-io]
edge-http = { git = "https://github.com/ivmarkov/edge-net", rev = "f90468953aec1d476ba52fe3b63f392a07bb9daa" }
edge-nal = { git = "https://github.com/ivmarkov/edge-net", rev = "f90468953aec1d476ba52fe3b63f392a07bb9daa" }
edge-nal-embassy = { git = "https://github.com/ivmarkov/edge-net", rev = "f90468953aec1d476ba52fe3b63f392a07bb9daa" }
edge-http = { git = "https://github.com/ivmarkov/edge-net", rev = "722f92ac0fffd0cb1e1ce76086cca58df6eb49ee" }
edge-nal = { git = "https://github.com/ivmarkov/edge-net", rev = "722f92ac0fffd0cb1e1ce76086cca58df6eb49ee" }
edge-nal-embassy = { git = "https://github.com/ivmarkov/edge-net", rev = "722f92ac0fffd0cb1e1ce76086cca58df6eb49ee" }

# Patch before 0.6.0 got yanked
embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "886580179ff250e15b0fad6448e8ebed6cdabf2b" }
embassy-time-driver = { git = "https://github.com/embassy-rs/embassy", rev = "886580179ff250e15b0fad6448e8ebed6cdabf2b" }
embassy-time-queue-driver = { git = "https://github.com/embassy-rs/embassy", rev = "886580179ff250e15b0fad6448e8ebed6cdabf2b" }
4 changes: 2 additions & 2 deletions esp-mbedtls-sys/headers/esp32/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@
//#define MBEDTLS_POLY1305_ALT
//#define MBEDTLS_RIPEMD160_ALT
//#define MBEDTLS_RSA_ALT
//#define MBEDTLS_SHA1_ALT
// #define MBEDTLS_SHA1_ALT
//#define MBEDTLS_SHA256_ALT
//#define MBEDTLS_SHA512_ALT
// #define MBEDTLS_SHA512_ALT

/*
* When replacing the elliptic curve module, please consider, that it is
Expand Down
2 changes: 1 addition & 1 deletion esp-mbedtls-sys/headers/esp32c3/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@
//#define MBEDTLS_POLY1305_ALT
//#define MBEDTLS_RIPEMD160_ALT
//#define MBEDTLS_RSA_ALT
//#define MBEDTLS_SHA1_ALT
#define MBEDTLS_SHA1_ALT
//#define MBEDTLS_SHA256_ALT
//#define MBEDTLS_SHA512_ALT

Expand Down
3 changes: 3 additions & 0 deletions esp-mbedtls-sys/headers/esp32c3/sha1_alt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
typedef struct mbedtls_sha1_context {
void* hasher;
} mbedtls_sha1_context;
6 changes: 3 additions & 3 deletions esp-mbedtls-sys/headers/esp32s2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@
//#define MBEDTLS_POLY1305_ALT
//#define MBEDTLS_RIPEMD160_ALT
//#define MBEDTLS_RSA_ALT
//#define MBEDTLS_SHA1_ALT
//#define MBEDTLS_SHA256_ALT
//#define MBEDTLS_SHA512_ALT
#define MBEDTLS_SHA1_ALT
#define MBEDTLS_SHA256_ALT
#define MBEDTLS_SHA512_ALT

/*
* When replacing the elliptic curve module, please consider, that it is
Expand Down
3 changes: 3 additions & 0 deletions esp-mbedtls-sys/headers/esp32s2/sha1_alt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
typedef struct mbedtls_sha1_context {
void* hasher;
} mbedtls_sha1_context;
5 changes: 5 additions & 0 deletions esp-mbedtls-sys/headers/esp32s2/sha256_alt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
typedef struct mbedtls_sha256_context {
void* sha224_hasher;
void* sha256_hasher;
int is224;
} mbedtls_sha256_context;
5 changes: 5 additions & 0 deletions esp-mbedtls-sys/headers/esp32s2/sha512_alt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
typedef struct mbedtls_sha512_context {
void* sha384_hasher;
void* sha512_hasher;
int is384;
} mbedtls_sha512_context;
6 changes: 3 additions & 3 deletions esp-mbedtls-sys/headers/esp32s3/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@
//#define MBEDTLS_POLY1305_ALT
//#define MBEDTLS_RIPEMD160_ALT
//#define MBEDTLS_RSA_ALT
//#define MBEDTLS_SHA1_ALT
//#define MBEDTLS_SHA256_ALT
//#define MBEDTLS_SHA512_ALT
#define MBEDTLS_SHA1_ALT
#define MBEDTLS_SHA256_ALT
#define MBEDTLS_SHA512_ALT

/*
* When replacing the elliptic curve module, please consider, that it is
Expand Down
3 changes: 3 additions & 0 deletions esp-mbedtls-sys/headers/esp32s3/sha1_alt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
typedef struct mbedtls_sha1_context {
void* hasher;
} mbedtls_sha1_context;
5 changes: 5 additions & 0 deletions esp-mbedtls-sys/headers/esp32s3/sha256_alt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
typedef struct mbedtls_sha256_context {
void* sha224_hasher;
void* sha256_hasher;
int is224;
} mbedtls_sha256_context;
5 changes: 5 additions & 0 deletions esp-mbedtls-sys/headers/esp32s3/sha512_alt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
typedef struct mbedtls_sha512_context {
void* sha384_hasher;
void* sha512_hasher;
int is384;
} mbedtls_sha512_context;
Loading

0 comments on commit d5e29f8

Please sign in to comment.