diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2001-05-14 09:45:20 +0000 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2001-05-14 09:45:20 +0000 |
commit | 9746d01d3576874253237e6341724657069d6c37 (patch) | |
tree | 79bb7f95a46542d74914d3047a71632727bca88e /lib/ext_srp.c | |
parent | b530091f8591014f3f111dc3d2139a95d7c1b13d (diff) | |
download | gnutls-9746d01d3576874253237e6341724657069d6c37.tar.gz |
added functions to access authentication data (like username), and
the key exchange algorithm used.
Diffstat (limited to 'lib/ext_srp.c')
-rw-r--r-- | lib/ext_srp.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/ext_srp.c b/lib/ext_srp.c index 9c545ef6a9..2e71c8ec02 100644 --- a/lib/ext_srp.c +++ b/lib/ext_srp.c @@ -22,13 +22,25 @@ #include "gnutls_int.h" #include "gnutls_auth_int.h" #include "auth_srp.h" +#include "gnutls_errors.h" int _gnutls_srp_recv_params( GNUTLS_STATE state, const opaque* data, int data_size) { if (state->security_parameters.entity == GNUTLS_SERVER) { if (data_size > 0) { - state->gnutls_key->username = gnutls_malloc(data_size+1); - memcpy(state->gnutls_key->username, data, data_size); - state->gnutls_key->username[data_size]=0; /* null terminated */ + state->gnutls_key->auth_info = gnutls_malloc(sizeof(SRP_AUTH_INFO)); + if (state->gnutls_key->auth_info==NULL) return GNUTLS_E_MEMORY_ERROR; + + if (sizeof( ((SRP_AUTH_INFO*)state->gnutls_key->auth_info)->username) > data_size) { + memcpy( ((SRP_AUTH_INFO*)state->gnutls_key->auth_info)->username, data, data_size); + ((SRP_AUTH_INFO*)state->gnutls_key->auth_info)->username[data_size]=0; /* null terminated */ + state->gnutls_key->auth_info_size = sizeof(SRP_AUTH_INFO); + } else { + state->gnutls_key->auth_info_size = 0; + gnutls_free(state->gnutls_key->auth_info); + state->gnutls_key->auth_info = NULL; + gnutls_assert(); + return GNUTLS_E_MEMORY_ERROR; + } } } return 0; |