ECDHE_ECDSA ClientKeyExchange rejected as too short when DTLS_PSK_MAX_CLIENT_IDENTITY_LEN > 64
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 76/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- c
- Ambito
- networking, security
Direzione di ricerca
Leggi la definizione di DTLS_CKXEC_LENGTH e il ramo ECDHE_ECDSA di dtls_check_client_keyexchange() in dtls.c. Confronta il controllo della lunghezza minima con la dimensione del messaggio ECDHE descritta nell’issue, quindi compila con DTLS_PSK_MAX_CLIENT_IDENTITY_LEN=128 e con PSK ed ECC abilitati. Il lavoro è completato quando un ClientKeyExchange ECDHE_ECDSA legittimo viene accettato con questa impostazione e il buffer di invio PSK può ancora contenere entrambi i tipi di messaggio.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
When DTLS_PSK_MAX_CLIENT_IDENTITY_LEN is configured above 2 * DTLS_EC_KEY_SIZE (64), a TinyDTLS server rejects every legitimate ECDHE_ECDSA ClientKeyExchange with handshake_failure (40), because the minimum-length check uses a constant that is sized for the PSK identity.
Where
dtls.c:
#define DTLS_CKXEC_LENGTH (1 + 1 + max(DTLS_EC_KEY_SIZE + DTLS_EC_KEY_SIZE, DTLS_PSK_MAX_CLIENT_IDENTITY_LEN))
and in dtls_check_client_keyexchange() (ECDHE_ECDSA branch):
if (length < DTLS_HS_LENGTH + DTLS_CKXEC_LENGTH) {
dtls_debug("The client key exchange is too short\n");
return dtls_alert_fatal_create(DTLS_ALERT_HANDSHAKE_FAILURE);
}
Checked against 501d93c (current main). develop has the same form.
Why it fails
An ECDHE_ECDSA ClientKeyExchange carries a 1-octet length, a 1-octet point format (0x04) and an uncompressed P-256 point of 2 * DTLS_EC_KEY_SIZE = 64 octets: 66 octets in total. With the default DTLS_PSK_MAX_CLIENT_IDENTITY_LEN of 32 the macro evaluates to 1 + 1 + max(64, 32) = 66, which happens to be exact. With -DDTLS_PSK_MAX_CLIENT_IDENTITY_LEN=128 (RFC 4279 section 5.1 allows identities up to 128 octets) it evaluates to 130, so the 66-octet message is "too short" and the handshake fails. The PSK identity length has no bearing on the size of an ECDHE message.
Reproduction
Build with -DDTLS_PSK_MAX_CLIENT_IDENTITY_LEN=128 and both DTLS_PSK and DTLS_ECC enabled. Run a TinyDTLS server offering TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 (raw public keys or certificates) and connect with any client that completes the ECDHE_ECDSA flight. The server logs error in check_client_keyexchange err: -552 and sends a fatal handshake_failure alert. With the default of 32 the same pair handshakes normally.
Suggested fix
Check the ECDHE message against its true size, independent of the PSK identity length:
if (length < DTLS_HS_LENGTH + 1 + 1 + 2 * DTLS_EC_KEY_SIZE) {
DTLS_CKXEC_LENGTH is still correct as the size of the send buffer in dtls_send_client_key_exchange(), since that buffer holds either the PSK message (2 + identity length) or the ECDHE message.
I have verified the fix locally: with only that comparison changed, the ECDHE_ECDSA handshake succeeds at an identity limit of 128. Happy to send a PR with a test if that is useful.
- Lingua principale
- C
- Stelle
- 122
- Fork
- 67
- Merge medio
- 6g 8h
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di eclipse-tinydtls/tinydtls
-
`dtls_get_cookie`: dereference before the length check (currently masked by `dtls_create_cookie`)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
eclipse-tinydtls/tinydtls#279 · 2 commenti · 1 reazione ·
I maintainer di solito rispondono entro 2 giorni
-
MSVC build is broken (undeclared `DTLS_DEBUG_BUF_SIZE`)Forse già presa @mrdeep1 l’ha presa 9 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 25/100
eclipse-tinydtls/tinydtls#283 · 5 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 57/100
eclipse-tinydtls/tinydtls#278 · 3 commenti · 1 reazione ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
eclipse-tinydtls/tinydtls#274 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
eclipse-tinydtls/tinydtls#273 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di eclipse-tinydtls/tinydtls
Issue simili
-
type: feature
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 77/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
FujiNetWIFI/fujinet-firmware#1932 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
I maintainer di solito rispondono entro 1 giorno
-
stdlib
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
[LOGO] kairo linuxApertalogo request
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
fastfetch-cli/fastfetch#2650 ·
I maintainer di solito rispondono entro 1 giorno