Skip to content

Commit e4b7f66

Browse files
authored
Merge pull request #9286 from holtrop/rust-wc-ecc
Rust wrapper: add wolfssl::wolfcrypt::ecc module
2 parents 8a6297d + dbc1ecc commit e4b7f66

File tree

6 files changed

+1887
-8
lines changed

6 files changed

+1887
-8
lines changed

doc/dox_comments/header_files/ecc.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ int wc_ecc_make_key_ex(WC_RNG* rng, int keysize, ecc_key* key, int curve_id);
122122
slot.
123123
124124
\return 0 Returned on success.
125-
\return ECC_BAD_ARG_E Returned if rng or key evaluate to NULL
125+
\return ECC_BAD_ARG_E Returned if key is NULL
126126
\return BAD_FUNC_ARG Returned if the supplied key is not a valid ecc_key.
127127
\return MEMORY_E Returned if there is an error allocating memory while
128128
computing the public key
@@ -172,11 +172,10 @@ int wc_ecc_make_pub(ecc_key* key, ecc_point* pubOut);
172172
an existing private component. If pubOut is supplied, the computed public
173173
key is stored there, else it is stored in the supplied ecc_key public
174174
component slot. The supplied rng, if non-NULL, is used to blind the private
175-
key value used in the computation. If rng is NULL, an ephemeral rng is
176-
instantiated internally.
175+
key value used in the computation.
177176
178177
\return 0 Returned on success.
179-
\return ECC_BAD_ARG_E Returned if rng or key evaluate to NULL
178+
\return ECC_BAD_ARG_E Returned if key is NULL
180179
\return BAD_FUNC_ARG Returned if the supplied key is not a valid ecc_key.
181180
\return MEMORY_E Returned if there is an error allocating memory while
182181
computing the public key

wolfcrypt/src/ecc.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4083,7 +4083,9 @@ int wc_ecc_mulmod(const mp_int* k, ecc_point *G, ecc_point *R, mp_int* a,
40834083
/**
40844084
* Allocate a new ECC point (if one not provided)
40854085
* use a heap hint when creating new ecc_point
4086-
* return an allocated point on success or NULL on failure
4086+
* @return 0 on success
4087+
* @return BAD_FUNC_ARG for invalid arguments
4088+
* @return MEMORY_E on failure to allocate memory
40874089
*/
40884090
static int wc_ecc_new_point_ex(ecc_point** point, void* heap)
40894091
{
@@ -11812,15 +11814,14 @@ static int wc_ecc_import_raw_private(ecc_key* key, const char* qx,
1181211814
qy y component of the public key, as ASCII hex string
1181311815
d private key, as ASCII hex string, optional if importing public
1181411816
key only
11815-
dp Custom ecc_set_type
11816-
return MP_OKAY on success
11817+
curve_id The id of the curve.
11818+
@return MP_OKAY on success
1181711819
*/
1181811820
int wc_ecc_import_raw_ex(ecc_key* key, const char* qx, const char* qy,
1181911821
const char* d, int curve_id)
1182011822
{
1182111823
return wc_ecc_import_raw_private(key, qx, qy, d, curve_id,
1182211824
WC_TYPE_HEX_STR);
11823-
1182411825
}
1182511826

1182611827
/* Import x, y and optional private (d) as unsigned binary */

wrapper/rust/include.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ EXTRA_DIST += wrapper/rust/wolfssl/build.rs
1717
EXTRA_DIST += wrapper/rust/wolfssl/src/lib.rs
1818
EXTRA_DIST += wrapper/rust/wolfssl/src/wolfcrypt.rs
1919
EXTRA_DIST += wrapper/rust/wolfssl/src/wolfcrypt/aes.rs
20+
EXTRA_DIST += wrapper/rust/wolfssl/src/wolfcrypt/ecc.rs
2021
EXTRA_DIST += wrapper/rust/wolfssl/src/wolfcrypt/random.rs
2122
EXTRA_DIST += wrapper/rust/wolfssl/src/wolfcrypt/rsa.rs
2223
EXTRA_DIST += wrapper/rust/wolfssl/tests/test_aes.rs
24+
EXTRA_DIST += wrapper/rust/wolfssl/tests/test_ecc.rs
2325
EXTRA_DIST += wrapper/rust/wolfssl/tests/test_random.rs
2426
EXTRA_DIST += wrapper/rust/wolfssl/tests/test_rsa.rs

wrapper/rust/wolfssl/src/wolfcrypt.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
*/
2020

2121
pub mod aes;
22+
pub mod ecc;
2223
pub mod random;
2324
pub mod rsa;

0 commit comments

Comments
 (0)