-
Notifications
You must be signed in to change notification settings - Fork 185
When using PSK for TLS authentication, look up and use the PSK ID requested by the client #379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
9b6608d
b283e1d
2cc5eea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -178,6 +178,18 @@ UINT private_key_length; | |
| /* Check for PSK ciphersuites and generate the pre-master-secret. */ | ||
| if (ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_PSK) | ||
| { | ||
| /* Store the requested PSK ID in the TLS credentials. */ | ||
| if (message_length < 2) | ||
| { | ||
| return NX_INVALID_PACKET; | ||
| } | ||
| tls_credentials -> nx_secure_tls_remote_psk_id_size = ((packet_buffer[0] << 8) | packet_buffer[1]); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like you read past the handshake buffer for truncated PSK identities. The code checks
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed, now returns |
||
| if (tls_credentials -> nx_secure_tls_remote_psk_id_size > NX_SECURE_TLS_MAX_PSK_ID_SIZE) | ||
| { | ||
| return NX_SIZE_ERROR; | ||
| } | ||
| NX_SECURE_MEMCPY(tls_credentials -> nx_secure_tls_remote_psk_id, &packet_buffer[2], tls_credentials -> nx_secure_tls_remote_psk_id_size); | ||
|
|
||
| status = _nx_secure_generate_premaster_secret(ciphersuite, protocol_version, tls_key_material, tls_credentials, | ||
| NX_SECURE_TLS_SESSION_TYPE_SERVER, received_remote_credentials, | ||
| public_cipher_metadata, public_cipher_metadata_size, tls_ecc_curves); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You return
NX_OPTION_ERRORwhen the requested PSK identity is not found. Existing PSK lookup helpers returnNX_SECURE_TLS_NO_MATCHING_PSK, which maps tounknown_psk_identity.NX_OPTION_ERRORfalls through to an internal-error alert. Use the TLS-specific error, and preferably scan onlynx_secure_tls_psk_countor sharethe existing lookup behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, return code changed to
NX_SECURE_TLS_NO_MATCHING_PSK.