mirror of
https://github.com/polhenarejos/pico-fido.git
synced 2024-09-20 03:10:10 +00:00
Fix when IMF is not 8 bytes.
It must be prepended with 0 up to 8 bytes. Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
parent
0dc547dbe5
commit
061b5e919e
@ -109,13 +109,24 @@ int oath_unload() {
|
|||||||
int cmd_put() {
|
int cmd_put() {
|
||||||
if (validated == false)
|
if (validated == false)
|
||||||
return SW_SECURITY_STATUS_NOT_SATISFIED();
|
return SW_SECURITY_STATUS_NOT_SATISFIED();
|
||||||
size_t key_len = 0;
|
size_t key_len = 0, imf_len = 0;
|
||||||
uint8_t *key = NULL;
|
uint8_t *key = NULL, *imf;
|
||||||
if (asn1_find_tag(apdu.data, apdu.nc, TAG_KEY, &key_len, &key) == false)
|
if (asn1_find_tag(apdu.data, apdu.nc, TAG_KEY, &key_len, &key) == false)
|
||||||
return SW_INCORRECT_PARAMS();
|
return SW_INCORRECT_PARAMS();
|
||||||
if (((key[0] & OATH_TYPE_MASK) == OATH_TYPE_HOTP) && asn1_find_tag(apdu.data, apdu.nc, TAG_IMF, NULL, NULL) == false) {
|
if ((key[0] & OATH_TYPE_MASK) == OATH_TYPE_HOTP) {
|
||||||
memcpy(apdu.data + apdu.nc, "\x7a\x08\x00\x00\x00\x00\x00\x00\x00\x00", 10);
|
if (asn1_find_tag(apdu.data, apdu.nc, TAG_IMF, &imf_len, &imf) == false) {
|
||||||
apdu.nc += 10;
|
memcpy(apdu.data + apdu.nc, "\x7a\x08\x00\x00\x00\x00\x00\x00\x00\x00", 10);
|
||||||
|
apdu.nc += 10;
|
||||||
|
}
|
||||||
|
else { //prepend zero-valued bytes
|
||||||
|
if (imf_len < 8) {
|
||||||
|
memmove(imf+(8-imf_len), imf, imf_len);
|
||||||
|
memset(imf, 0, 8-imf_len);
|
||||||
|
*(imf-1) = 8;
|
||||||
|
apdu.nc += (8-imf_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < MAX_OATH_CRED; i++) {
|
for (int i = 0; i < MAX_OATH_CRED; i++) {
|
||||||
file_t *ef = search_dynamic_file(EF_OATH_CRED + i);
|
file_t *ef = search_dynamic_file(EF_OATH_CRED + i);
|
||||||
|
Loading…
Reference in New Issue
Block a user