Commit 3dce3278 authored by David Woodhouse's avatar David Woodhouse

Remember what form we got the HOTP secret in

We'll care about this shortly...
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 95564968
......@@ -639,6 +639,7 @@ static int set_hotp_mode(struct openconnect_info *vpninfo,
}
if (strncasecmp(token_str, "base32:", strlen("base32:")) == 0) {
vpninfo->hotp_secret_format = HOTP_SECRET_BASE32;
ret = oath_base32_decode(token_str + strlen("base32:"),
toklen - strlen("base32:"),
&vpninfo->oath_secret,
......@@ -646,11 +647,13 @@ static int set_hotp_mode(struct openconnect_info *vpninfo,
if (ret != OATH_OK)
return -EINVAL;
} else if (strncmp(token_str, "0x", 2) == 0) {
vpninfo->hotp_secret_format = HOTP_SECRET_HEX;
vpninfo->oath_secret_len = (toklen - 2) / 2;
vpninfo->oath_secret = parse_hex(token_str + 2, toklen - 2);
if (!vpninfo->oath_secret)
return -EINVAL;
} else {
vpninfo->hotp_secret_format = HOTP_SECRET_RAW;
vpninfo->oath_secret = strdup(token_str);
vpninfo->oath_secret_len = toklen;
}
......
......@@ -268,6 +268,12 @@ struct openconnect_info {
#ifdef HAVE_LIBOATH
char *oath_secret;
size_t oath_secret_len;
enum {
HOTP_SECRET_BASE32 = 1,
HOTP_SECRET_RAW,
HOTP_SECRET_HEX,
HOTP_SECRET_PSKC,
} hotp_secret_format; /* We need to give it back in the same form */
#endif
OPENCONNECT_X509 *peer_cert;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment