Add AES-GCM DEM, CryptoCb support, and devId threading to ECIES#10883
Add AES-GCM DEM, CryptoCb support, and devId threading to ECIES#10883night1rider wants to merge 7 commits into
Conversation
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #10883
Scan targets checked: wolfcrypt-bugs, wolfcrypt-port-bugs, wolfcrypt-rs-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src
Findings: 4
4 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
|
retest this please |
e077b08 to
55e2253
Compare
|
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #10883
Scan targets checked: wolfcrypt-bugs, wolfcrypt-port-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src
Failed targets: wolfcrypt-rs-bugs
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #10883
Scan targets checked: wolfcrypt-bugs, wolfcrypt-port-bugs, wolfcrypt-rs-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
7766011 to
a1354e4
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #10883
Scan targets checked: wolfcrypt-bugs, wolfcrypt-port-bugs, wolfcrypt-rs-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #10883
Scan targets checked: wolfcrypt-bugs, wolfcrypt-port-bugs, wolfcrypt-rs-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src
No new issues found in the changed files. ✅
9e00bad to
2d5b2c2
Compare
|
Rebased to fix merge conflict |
|
Jenkins retest this please |
| ecEncCtx* cliCtx = wc_ecc_ctx_new(REQ_RESP_CLIENT, &gRng); | ||
| ecEncCtx* srvCtx = wc_ecc_ctx_new(REQ_RESP_SERVER, &gRng); | ||
| char encDesc[32]; | ||
| char decDesc[32]; |
There was a problem hiding this comment.
Avoid magic numbers here (32), maybe WC_BENCH_MAX_LINE_LEN if it should fit on one line. Or another macro.
| if ((msgSz % blockSz) != 0) | ||
| return BAD_PADDING_E; | ||
|
|
||
| if (ecc_is_gcm(ctx->encAlgo)) { |
There was a problem hiding this comment.
This section of code is identical to the section at line 15700, please consider a helper function for the checks.
There was a problem hiding this comment.
Created a static function helper
| #else | ||
| ctx->encAlgo = ecAES_128_CTR; | ||
| #endif | ||
| #elif !defined(NO_AES) && defined(HAVE_AESGCM) |
There was a problem hiding this comment.
In a GCM-only build with default IV mode, ecc_ctx_init defaults to AES-GCM but encrypt/decrypt then reject GCM with NOT_COMPILED_IN, making ECIES unusable without a manual wc_ecc_ctx_set_algo override.
There was a problem hiding this comment.
Good observation, added a compile time check.
| IV_SIZE_64 = 8, | ||
| IV_SIZE_128 = 16, | ||
| ECC_MAX_IV_SIZE = 16, | ||
| AES_GCM_NONCE_SZ = 12, /* GCM IV/nonce length for ECIES DEM */ |
There was a problem hiding this comment.
I think these enums are duplicates of existing AES ones available. Use GCM_NONCE_MID_SZ for nonce size and in other places we use WC_AES_BLOCK_SIZE for a 16 bit tag.
There was a problem hiding this comment.
removed the duplicates
Add AES-GCM (128/256) as an ECIES DEM next to the AES-CBC/CTR+HMAC modes. Only the encryption key comes from the KDF; the mac salt is bound as GCM AAD and the 16-byte tag replaces the HMAC. The GCM DEM honors all three IV build modes, and default fixed-nonce GCM is gated behind the new WOLFSSL_ECIES_STATIC_GCM_NONCE opt-in. Adds ECIES CryptoCb encrypt/decrypt, the WOLF_CRYPTO_CB ctx getters, devId/heap threading into the DEM primitives, and test/benchmark/CI coverage.
…Id field by reading it into a guarded local (PLUTON_CRYPTO_ECC/WOLF_CRYPTO_CB) that defaults to INVALID_DEVID
…path so a device that services encrypt/decrypt without a software fallback cannot reuse the ctx. Add a testwolfcrypt case that services ECIES entirely in the callback and checks a second op on the same ctx is rejected with BAD_STATE_E.
… output size into ecc_ecies_total_size helper, gate the AES-GCM ctx default on a usable IV mode, and name the benchmark ECIES desc buffer size
…e new ECIES tests
d0a3611 to
3062dea
Compare
|
Addressed comments, and rebased off current master. |
Add AES-GCM (128/256) as an ECIES DEM next to the AES-CBC/CTR+HMAC modes.
Only the encryption key comes from the KDF; the mac salt is bound as GCM AAD and the 16-byte tag replaces the HMAC.
The GCM DEM honors all three IV build modes, and default fixed-nonce GCM is gated behind the new WOLFSSL_ECIES_STATIC_GCM_NONCE opt-in. Adds ECIES CryptoCb encrypt/decrypt, the WOLF_CRYPTO_CB ctx getters, devId/heap threading into the DEM primitives, and test/benchmark/CI coverage.