Skip to content

support non-NULL-terminated PSKs

Ander Juaristi requested to merge ajuaristi-issue-586 into master

This MR introduces two new functions, and two new associated callbacks (for client and server) to accommodate non-NULL-terminated PSK usernames.

  • gnutls_psk_set_client_credentials2(): Lets the client set its PSK credentials. It's identical to gnutls_psk_set_client_credentials(), but it expects a gnutls_datum_t as the username instead of a const char *.
  • gnutls_psk_server_get_username2(): Lets the sever retrieve the peer's PSK username. It's also identical to gnutls_psk_server_get_username(), except that it outputs the username to a gnutls_datum_t.

I also introduce new callback functions as well as new setters for them.

typedef int gnutls_psk_server_credentials_function2(gnutls_session_t,
						    const gnutls_datum_t *username,
						    gnutls_datum_t *key);
void
gnutls_psk_set_server_credentials_function2(gnutls_psk_server_credentials_t cred,
					    gnutls_psk_server_credentials_function2 *func);

typedef int gnutls_psk_client_credentials_function2(gnutls_session_t,
						    gnutls_datum_t *username,
						    gnutls_datum_t *key);

void
gnutls_psk_set_client_credentials_function2(gnutls_psk_client_credentials_t cred,
					    gnutls_psk_client_credentials_function2 *func);

Checklist

  • Code modified for feature
  • Test suite updated with functionality tests
  • Test suite updated with negative tests
  • Documentation updated / NEWS entry present (for non-trivial changes)

Reviewer's checklist:

  • Any issues marked for closing are addressed
  • There is a test suite reasonably covering new functionality or modifications
  • Function naming, parameters, return values, types, etc., are consistent and according to CONTRIBUTION.md
  • This feature/change has adequate documentation added
  • No obvious mistakes in the code
Edited by Nikos Mavrogiannopoulos

Merge request reports