Skip to content

Commit

Permalink
Use endian-specific access functions in yubikey.c
Browse files Browse the repository at this point in the history
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Jan 26, 2015
1 parent 04f2bb5 commit 426600f
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions yubikey.c
Expand Up @@ -96,12 +96,10 @@ static int yubikey_cmd(struct openconnect_info *vpninfo, SCARDHANDLE card, int e
outlen = sizeof(send_remaining);
} while (buf->data[buf->pos] == 0x61);

if ((unsigned char)buf->data[buf->pos] == 0x90 && buf->data[buf->pos+1] == 0x00)
status = load_be16(buf->data + buf->pos);
if (status == 0x9000)
return 0;

status = (unsigned short)buf->data[buf->pos] << 8;
status |= (unsigned char)buf->data[buf->pos+1];

vpn_progress(vpninfo, errlvl,
_("Failure response to \"%s\": %04x\n"),
desc, (unsigned)status);
Expand Down Expand Up @@ -483,8 +481,7 @@ static int append_tlvlen(unsigned char *p, int tlvlen)
} else {
if (p) {
p[0] = 0x82;
p[1] = tlvlen >> 8;
p[2] = tlvlen & 0xff;
store_be16(p + 1, tlvlen);
}
return 3;
}
Expand Down Expand Up @@ -550,10 +547,8 @@ int do_gen_yubikey_code(struct openconnect_info *vpninfo,
reqbuf[i++] = 0;
reqbuf[i++] = 0;
reqbuf[i++] = 0;
reqbuf[i++] = token_steps >> 24;
reqbuf[i++] = token_steps >> 16;
reqbuf[i++] = token_steps >> 8;
reqbuf[i++] = token_steps;
store_be32(reqbuf + i, token_steps);
i += 4;
} else {
reqbuf[i++] = 0; /* HOTP mode, zero-length challenge */
}
Expand All @@ -571,10 +566,7 @@ int do_gen_yubikey_code(struct openconnect_info *vpninfo,
goto out;
}

tokval = ((unsigned char)respbuf->data[3] << 24) +
((unsigned char)respbuf->data[4] << 16) +
((unsigned char)respbuf->data[5] << 8) +
(unsigned char)respbuf->data[6];
tokval = load_be32(respbuf->data + 3);
opt->_value = malloc(respbuf->data[2] + 1);
if (!opt->_value) {
ret = -ENOMEM;
Expand Down

0 comments on commit 426600f

Please sign in to comment.