summaryrefslogtreecommitdiff
path: root/lib/auth
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2015-07-21 08:36:14 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2015-07-21 11:47:35 +0200
commit84b1f2b39f02c5ba241f50807329b53fdac1a903 (patch)
treeef6918c8953fdf61a07c3395f0a981cce405069b /lib/auth
parent608fc7e5136eeaa3d0d7f04047a95b0dc095550f (diff)
downloadgnutls-84b1f2b39f02c5ba241f50807329b53fdac1a903.tar.gz
psk: use gnutls_hex_decode2 for key decoding
Diffstat (limited to 'lib/auth')
-rw-r--r--lib/auth/psk_passwd.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/lib/auth/psk_passwd.c b/lib/auth/psk_passwd.c
index f378770bd7..d593c3c453 100644
--- a/lib/auth/psk_passwd.c
+++ b/lib/auth/psk_passwd.c
@@ -46,7 +46,7 @@ static int pwd_put_values(gnutls_datum_t * psk, char *str)
{
char *p;
int len, ret;
- size_t size;
+ gnutls_datum_t tmp;
p = strchr(str, ':');
if (p == NULL) {
@@ -66,21 +66,14 @@ static int pwd_put_values(gnutls_datum_t * psk, char *str)
if (p[len - 1] == '\n' || p[len - 1] == ' ')
len--;
- size = psk->size = len / 2;
- psk->data = gnutls_malloc(size);
- if (psk->data == NULL) {
- gnutls_assert();
- return GNUTLS_E_MEMORY_ERROR;
- }
-
- ret = _gnutls_hex2bin(p, len, psk->data, &size);
- psk->size = (unsigned int) size;
+ tmp.data = (void*)p;
+ tmp.size = len;
+ ret = gnutls_hex_decode2(&tmp, psk);
if (ret < 0) {
gnutls_assert();
return ret;
}
-
return 0;
}