Skip to content

Commit acff4d6

Browse files
Merge pull request #10883 from night1rider/Extend-ECIES
Add AES-GCM DEM, CryptoCb support, and devId threading to ECIES
2 parents f5ace71 + 3062dea commit acff4d6

12 files changed

Lines changed: 1760 additions & 115 deletions

File tree

.github/workflows/os-check.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,21 @@ jobs:
269269
{"name": "cryptocb-aesgcm-setkey-free", "minutes": 2.1,
270270
"configure": ["--enable-cryptocb", "--enable-aesgcm",
271271
"CPPFLAGS=-DWOLF_CRYPTO_CB_AES_SETKEY -DWOLF_CRYPTO_CB_FREE"]},
272+
{"name": "ecies-sec1-gcm-static-nonce", "minutes": 2.0,
273+
"comment": "ECIES with the AES-GCM DEM in the default SEC1 IV mode; WOLFSSL_ECIES_STATIC_GCM_NONCE opts into the fixed-nonce GCM path so the GCM KAT/round-trip and cryptocb tests run.",
274+
"configure": ["--enable-eccencrypt", "--enable-aesgcm", "--enable-aesctr",
275+
"--enable-x963kdf", "--enable-cryptocb", "--enable-keygen",
276+
"CPPFLAGS=-DWOLFSSL_ECIES_STATIC_GCM_NONCE"]},
277+
{"name": "ecies-geniv-gcm-static-nonce", "minutes": 2.0,
278+
"comment": "Same ECIES-GCM coverage in the WOLFSSL_ECIES_GEN_IV mode (random embedded nonce).",
279+
"configure": ["--enable-eccencrypt=geniv", "--enable-aesgcm", "--enable-aesctr",
280+
"--enable-x963kdf", "--enable-cryptocb", "--enable-keygen",
281+
"CPPFLAGS=-DWOLFSSL_ECIES_STATIC_GCM_NONCE"]},
282+
{"name": "ecies-old-gcm-static-nonce", "minutes": 2.0,
283+
"comment": "Same ECIES-GCM coverage in the legacy WOLFSSL_ECIES_OLD mode (KDF-derived nonce, no ephemeral pubkey prepended).",
284+
"configure": ["--enable-eccencrypt=old", "--enable-aesgcm", "--enable-aesctr",
285+
"--enable-x963kdf", "--enable-cryptocb", "--enable-keygen",
286+
"CPPFLAGS=-DWOLFSSL_ECIES_STATIC_GCM_NONCE"]},
272287
{"name": "opensslextra-x509small", "minutes": 2.0,
273288
"configure": ["--enable-opensslextra=x509small"]},
274289
{"name": "cryptocb-keygen-find", "minutes": 2.0,

.wolfssl_known_macro_extras

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,7 @@ WOLFSSL_ECC_NO_SMALL_STACK
832832
WOLFSSL_ECC_SIGALG_PARAMS_NULL_ALLOWED
833833
WOLFSSL_ECDSA_MATCH_HASH
834834
WOLFSSL_ECDSA_SET_K_ONE_LOOP
835+
WOLFSSL_ECIES_STATIC_GCM_NONCE
835836
WOLFSSL_EC_POINT_CMP_JACOBIAN
836837
WOLFSSL_ED448_NO_LARGE_CODE
837838
WOLFSSL_EDDSA_CHECK_PRIV_ON_SIGN

doc/dox_comments/header_files/ecc.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,6 +2025,11 @@ int wc_ecc_ctx_set_info(ecEncCtx* ctx, const byte* info, int sz);
20252025
\param ctx Optional: pointer to an ecEncCtx object specifying different
20262026
encryption algorithms to use
20272027
2028+
\note Selecting an AES-GCM DEM algorithm (ecAES_128_GCM, ecAES_256_GCM) in
2029+
the default IV mode requires the WOLFSSL_ECIES_STATIC_GCM_NONCE build macro;
2030+
otherwise this function returns NOT_COMPILED_IN. See wc_ecc_encrypt_ex for
2031+
the full rationale.
2032+
20282033
_Example_
20292034
\code
20302035
byte msg[] = { initialize with msg to encrypt. Ensure padded to block size };
@@ -2072,6 +2077,9 @@ int wc_ecc_encrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
20722077
small to store the encrypted ciphertext
20732078
\return MEMORY_E Returned if there is an error allocating memory
20742079
for the shared secret key
2080+
\return NOT_COMPILED_IN Returned if an AES-GCM DEM algorithm
2081+
(ecAES_128_GCM or ecAES_256_GCM) is requested in the default IV mode
2082+
without the WOLFSSL_ECIES_STATIC_GCM_NONCE build macro defined
20752083
20762084
\param privKey pointer to the ecc_key object containing the
20772085
private key to use for encryption
@@ -2088,6 +2096,16 @@ int wc_ecc_encrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
20882096
encryption algorithms to use
20892097
\param compressed Public key field is to be output in compressed format.
20902098
2099+
\note The AES-GCM DEM algorithms (ecAES_128_GCM, ecAES_256_GCM) in the
2100+
default IV mode use a fixed all-zero GCM nonce. That is safe only because
2101+
ECIES derives a fresh symmetric key from a fresh ephemeral key on every
2102+
encryption, so the (key, nonce) pair never repeats; reusing the ephemeral
2103+
key is catastrophic for AES-GCM. For that reason the fixed-nonce GCM DEM is
2104+
off by default and must be enabled with the WOLFSSL_ECIES_STATIC_GCM_NONCE
2105+
build macro, otherwise this function returns NOT_COMPILED_IN for a GCM
2106+
algorithm. The macro is not needed with WOLFSSL_ECIES_GEN_IV (random
2107+
per-message nonce) or WOLFSSL_ECIES_OLD (nonce derived from the KDF output).
2108+
20912109
_Example_
20922110
\code
20932111
byte msg[] = { initialize with msg to encrypt. Ensure padded to block size };
@@ -2136,6 +2154,9 @@ int wc_ecc_encrypt_ex(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
21362154
small to store the decrypted plaintext
21372155
\return MEMORY_E Returned if there is an error allocating memory
21382156
for the shared secret key
2157+
\return NOT_COMPILED_IN Returned if an AES-GCM DEM algorithm
2158+
(ecAES_128_GCM or ecAES_256_GCM) is requested in the default IV mode
2159+
without the WOLFSSL_ECIES_STATIC_GCM_NONCE build macro defined
21392160
21402161
\param privKey pointer to the ecc_key object containing the private
21412162
key to use for decryption
@@ -2150,6 +2171,11 @@ int wc_ecc_encrypt_ex(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
21502171
\param ctx Optional: pointer to an ecEncCtx object specifying
21512172
different decryption algorithms to use
21522173
2174+
\note Selecting an AES-GCM DEM algorithm (ecAES_128_GCM, ecAES_256_GCM) in
2175+
the default IV mode requires the WOLFSSL_ECIES_STATIC_GCM_NONCE build macro;
2176+
otherwise this function returns NOT_COMPILED_IN. See wc_ecc_encrypt_ex for
2177+
the full rationale.
2178+
21532179
_Example_
21542180
\code
21552181
byte cipher[] = { initialize with

0 commit comments

Comments
 (0)