Global Platform PIN Encoding: 1. Fix for pin changes: use the real length instead of the max length -- 2. Check for valid pin chars
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1356 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
062fcebf0a
commit
c3c68e86f0
@ -226,8 +226,15 @@ int sc_build_pin(u8 *buf, size_t buflen, struct sc_pin_cmd_pin *pin, int pad)
|
||||
return SC_ERROR_INVALID_ARGUMENTS;
|
||||
|
||||
if (pin->encoding == SC_PIN_ENCODING_GLP) {
|
||||
int i;
|
||||
while (pin_len > 0 && pin->data[pin_len - 1] == 0xFF)
|
||||
pin_len--;
|
||||
if (pin_len > 12)
|
||||
return SC_ERROR_INVALID_ARGUMENTS;
|
||||
for (i = 0; i < pin_len; i++) {
|
||||
if (pin->data[i] < '0' || pin->data[i] > '9')
|
||||
return SC_ERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
buf[0] = 0x20 | pin_len;
|
||||
buf++;
|
||||
buflen--;
|
||||
|
Loading…
Reference in New Issue
Block a user