Skip to content

Commit

Permalink
Remember what form we got the HOTP secret in
Browse files Browse the repository at this point in the history
We'll care about this shortly...

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Aug 12, 2014
1 parent 9556496 commit 3dce327
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library.c
Expand Up @@ -639,18 +639,21 @@ 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,
&vpninfo->oath_secret_len);
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;
}
Expand Down
6 changes: 6 additions & 0 deletions openconnect-internal.h
Expand Up @@ -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;
Expand Down

0 comments on commit 3dce327

Please sign in to comment.