Repository navigation
Implement EC-JPAKE - #11961
Open
AlexLanzano wants to merge 4 commits into
Open
Implement EC-JPAKE#11961AlexLanzano wants to merge 4 commits into
AlexLanzano wants to merge 4 commits into
Conversation
Implement EC-JPAKE (RFC 8236 Section 3) with Schnorr NIZK proofs (RFC 8235 Section 3), profiled as in draft-cragie-tls-ecjpake-01, the profile used by Thread commissioning: P-256, SHA-256, "client"/"server" identities, PMS = SHA-256(K.x), and the TLS ECJPAKEKeyKP and ECSchnorrZKP wire structures. - New API in wolfssl/wolfcrypt/ecjpake.h: wc_EcJpakeInit/Free, wc_EcJpakeWrite/ReadRound1, wc_EcJpakeWrite/ReadRound2 and wc_EcJpakeDeriveSecret. Round messages use the TLS encoding so the (D)TLS layer can carry them directly. - Peer points are fully validated, every proof is verified against the peer identity, and a shared secret that reduces to zero is rejected. Secret scalars go through wc_ecc_mulmod_ex2 with RNG blinding. - Calls must follow the protocol order; repeated or out of order calls return BAD_STATE_E. - Enable with --enable-ecjpake or -DWOLFSSL_ECJPAKE=yes (defines WOLFCRYPT_HAVE_ECJPAKE). Requires ECC and SHA-256; not supported with --enable-sp-math. - wolfcrypt/test/test.c: known answer tests for both roles using vectors from an independent implementation of the specifications, full handshakes with matching and mismatched passwords, and negative tests covering malformed encodings, out of range values, corrupted and reflected proofs, round binding, buffer sizes and API misuse.
Implement TLS_ECJPAKE_WITH_AES_128_CCM_8 from draft-cragie-tls-ecjpake-01, DTLS 1.2 only. - Round one in the ecjpake_key_kp_pair hello extension; kept across HVR. - Round two in ServerKeyExchange and ClientKeyExchange; no certificates. - EC-JPAKE failures send handshake_failure. - Add wolfSSL_CTX_set_ecjpake_password() and wolfSSL_set_ecjpake_password(). - Codepoints 0xC0,0xFF and 256 come from the Thread specification. - Add tests/api/test_ecjpake.c.
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Secret-dependent variable-time inversion and a client-only build failure remain unresolved, alongside EC-JPAKE negotiation, password-state, and buffer-sizing defects.
5 open issues
Client-only builds reference an uncompiled server function · New Secret ECC multiplication uses variable-time modular inversion · New Shared buffer is too small for EC-JPAKE round two · New Password changes leave the active EC-JPAKE state stale · New EC-JPAKE fallback ignores the client's supported groups · New
What changed in this PR
Adds EC-JPAKE password-authenticated key exchange to wolfCrypt and integrates it with DTLS 1.2 for Thread commissioning.
Changes:
- Introduces P-256/SHA-256 EC-JPAKE APIs, proof validation, and secret derivation.
- Adds the DTLS cipher suite, handshake extensions, and password setters.
- Adds build options, known-answer tests, and handshake and malformed-message tests.
| File | Description |
|---|---|
| wolfssl/wolfcrypt/include.am | Installs the EC-JPAKE public header. |
| wolfssl/wolfcrypt/ecjpake.h | Declares EC-JPAKE APIs and state. |
| wolfssl/ssl.h | Declares DTLS password setters. |
| wolfssl/internal.h | Adds suite definitions and handshake state. |
| wolfcrypt/test/test.h | Declares the cryptographic self-test. |
| wolfcrypt/test/test.c | Adds known-answer and negative tests. |
| wolfcrypt/src/ecjpake.c | Implements EC-JPAKE exchanges and proofs. |
| tests/api/test_tls.c | Excludes EC-JPAKE from certificate-based record tests. |
| tests/api/test_ossl_sk.c | Adds cipher-description expectations. |
| tests/api/test_ecjpake.h | Declares and groups API tests. |
| tests/api/test_ecjpake.c | Tests DTLS negotiation, proofs, and passwords. |
| tests/api/include.am | Includes API tests in Autotools builds. |
| tests/api.c | Registers EC-JPAKE API tests. |
| src/tls.c | Implements round-one handshake extensions. |
| src/ssl.c | Adds key-exchange and authentication labels. |
| src/ssl_api_hs.c | Supports password-based server authentication. |
| src/ssl_api_dtls.c | Implements password setters. |
| src/keys.c | Defines cipher-suite parameters. |
| src/internal.c | Integrates key exchange, negotiation, and cleanup. |
| src/include.am | Includes the cryptographic implementation. |
| configure.ac | Adds the Autotools feature option and checks. |
| CMakeLists.txt | Adds the CMake option and API test source. |
| cmake/options.h.in | Exports the feature macro. |
| cmake/functions.cmake | Selects EC-JPAKE library sources. |
Review effort: Balanced
- Use constant time mapping for EC-JPAKE point multiplication. - Fix client only build (TLSX_SetResponse not compiled). - Size MAX_ENCRYPT_SZ for the client round two message. - Reject password changes once the exchange has started. - Require secp256r1 in the client's groups for the suite. - Add explicit API test guards and new negotiation/password tests.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Secret-dependent scalar arithmetic exposes nonce-dependent timing even in hardened builds, and clearing an unfinished handshake leaves EC-JPAKE state allocated, blocking password replacement on retry.
2 open issues
5 resolved since last review
Review effort: Balanced
- Use constant time subtraction for the Schnorr proof response. - Free EC-JPAKE state in wolfSSL_clear() so the password can change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description
Adds EC-JPAKE (RFC 8236 with RFC 8235 Schnorr proofs, profiled per
draft-cragie-tls-ecjpake-01) to wolfCrypt, plus the DTLS 1.2 cipher suite
TLS_ECJPAKE_WITH_AES_128_CCM_8used for Thread commissioning.EC-JPAKE is necessary for Thread network commissioning. MBedTLS provides
this but is going EOL. It would be a good thing for wolfssl to add support for
so users of this have an alternative
wolfssl/wolfcrypt/ecjpake.h:wc_EcJpakeInit,Free,Write/ReadRound1,Write/ReadRound2,DeriveSecret. Messages use theTLS encodings. Peer points and proofs are fully validated, and calls must
follow protocol order.
ecjpake_key_kp_pairextension, round two inServerKeyExchange/ClientKeyExchange, no certificates. New
wolfSSL_CTX_set_ecjpake_password()/wolfSSL_set_ecjpake_password().Code points come from the Thread specification.
--enable-ecjpake(-DWOLFSSL_ECJPAKE=yes). Requires ECC andSHA-256; not supported with
--enable-sp-math.Testing
wolfcrypt/test/test.c: known answer tests against an independentimplementation, handshakes with matching and mismatched passwords, and
negative tests for malformed, mutated and reflected messages and API misuse.
tests/api/test_ecjpake.c: DTLS 1.2 handshake, wrong password, suitenegotiation, bad proof, password setters.
--enable-ecjpake --enable-dtls --enable-aesccm: all pass.