| psk.c | psk.c | |||
|---|---|---|---|---|
| skipping to change at line 164 | skipping to change at line 164 | |||
| * | * | |||
| */ | */ | |||
| int | int | |||
| _gnutls_gen_psk_client_kx(gnutls_session_t session, | _gnutls_gen_psk_client_kx(gnutls_session_t session, | |||
| gnutls_buffer_st * data) | gnutls_buffer_st * data) | |||
| { | { | |||
| int ret, free; | int ret, free; | |||
| gnutls_datum_t username = {NULL, 0}; | gnutls_datum_t username = {NULL, 0}; | |||
| gnutls_datum_t key; | gnutls_datum_t key; | |||
| gnutls_psk_client_credentials_t cred; | gnutls_psk_client_credentials_t cred; | |||
| psk_auth_info_t info; | ||||
| cred = (gnutls_psk_client_credentials_t) | cred = (gnutls_psk_client_credentials_t) | |||
| _gnutls_get_cred(session, GNUTLS_CRD_PSK); | _gnutls_get_cred(session, GNUTLS_CRD_PSK); | |||
| if (cred == NULL) { | if (cred == NULL) { | |||
| gnutls_assert(); | gnutls_assert(); | |||
| return GNUTLS_E_INSUFFICIENT_CREDENTIALS; | return GNUTLS_E_INSUFFICIENT_CREDENTIALS; | |||
| } | } | |||
| info = _gnutls_get_auth_info(session, GNUTLS_CRD_PSK); | ||||
| if (info == NULL) { | ||||
| gnutls_assert(); | ||||
| return GNUTLS_E_INTERNAL_ERROR; | ||||
| } | ||||
| ret = _gnutls_find_psk_key(session, cred, &username, &key, &free); | ret = _gnutls_find_psk_key(session, cred, &username, &key, &free); | |||
| if (ret < 0) | if (ret < 0) | |||
| return gnutls_assert_val(ret); | return gnutls_assert_val(ret); | |||
| ret = _gnutls_set_psk_session_key(session, &key, NULL); | ret = _gnutls_set_psk_session_key(session, &key, NULL); | |||
| if (ret < 0) { | if (ret < 0) { | |||
| gnutls_assert(); | gnutls_assert(); | |||
| goto cleanup; | goto cleanup; | |||
| } | } | |||
| ret = | ret = | |||
| _gnutls_buffer_append_data_prefix(data, 16, username.data, | _gnutls_buffer_append_data_prefix(data, 16, username.data, | |||
| username.size); | username.size); | |||
| if (ret < 0) { | if (ret < 0) { | |||
| gnutls_assert(); | gnutls_assert(); | |||
| } | } | |||
| if (username.size > sizeof(info->username)-1) { | ||||
| gnutls_assert(); | ||||
| ret = GNUTLS_E_ILLEGAL_SRP_USERNAME; | ||||
| goto cleanup; | ||||
| } | ||||
| memcpy(info->username, username.data, username.size); | ||||
| info->username[username.size] = 0; | ||||
| cleanup: | cleanup: | |||
| if (free) { | if (free) { | |||
| gnutls_free(username.data); | gnutls_free(username.data); | |||
| _gnutls_free_temp_key_datum(&key); | _gnutls_free_temp_key_datum(&key); | |||
| } | } | |||
| return ret; | return ret; | |||
| } | } | |||
| /* just read the username from the client key exchange. | /* just read the username from the client key exchange. | |||
| skipping to change at line 349 | skipping to change at line 365 | |||
| hint.data = &data[2]; | hint.data = &data[2]; | |||
| /* copy the hint to the auth info structures | /* copy the hint to the auth info structures | |||
| */ | */ | |||
| info = _gnutls_get_auth_info(session, GNUTLS_CRD_PSK); | info = _gnutls_get_auth_info(session, GNUTLS_CRD_PSK); | |||
| if (info == NULL) { | if (info == NULL) { | |||
| gnutls_assert(); | gnutls_assert(); | |||
| return GNUTLS_E_INTERNAL_ERROR; | return GNUTLS_E_INTERNAL_ERROR; | |||
| } | } | |||
| if (hint.size > MAX_USERNAME_SIZE) { | if (hint.size > sizeof(info->hint)-1) { | |||
| gnutls_assert(); | gnutls_assert(); | |||
| return GNUTLS_E_ILLEGAL_SRP_USERNAME; | return GNUTLS_E_ILLEGAL_SRP_USERNAME; | |||
| } | } | |||
| memcpy(info->hint, hint.data, hint.size); | memcpy(info->hint, hint.data, hint.size); | |||
| info->hint[hint.size] = 0; | info->hint[hint.size] = 0; | |||
| ret = 0; | ret = 0; | |||
| return ret; | return ret; | |||
| End of changes. 4 change blocks. | ||||
| 1 lines changed or deleted | 17 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ | ||||