add support for two byte tags in sc_asn1_find_tag() + normalize return value
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2840 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
8494d9cfde
commit
8c926455d0
|
@ -476,7 +476,7 @@ static void process_arr(sc_card_t *card, sc_file_t *file,
|
|||
skip = 1; /* Skip over initial unknown SC DOs. */
|
||||
for (;;) {
|
||||
buf = p;
|
||||
if (sc_asn1_read_tag(&p, left, &cla, &tag, &taglen) != 1)
|
||||
if (sc_asn1_read_tag(&p, left, &cla, &tag, &taglen) != SC_SUCCESS)
|
||||
break;
|
||||
left -= (p - buf);
|
||||
tag |= cla;
|
||||
|
|
|
@ -662,22 +662,15 @@ static int parse_ext_pubkey_file(sc_card_t *card, const u8 *data, size_t len,
|
|||
sc_pkcs15_pubkey_t *pubkey)
|
||||
{
|
||||
const u8 *p;
|
||||
size_t ilen = 0, tlen = 0, i;
|
||||
size_t ilen = 0, tlen = 0;
|
||||
|
||||
if (data == NULL || len < 32)
|
||||
return SC_ERROR_INVALID_ARGUMENTS;
|
||||
if (*data++ != 0x7f || *data++ != 0x49) {
|
||||
data = sc_asn1_find_tag(card->ctx, data, len, 0x7f49, &ilen);
|
||||
if (data == NULL) {
|
||||
sc_error(card->ctx, "invalid public key data: missing tag");
|
||||
return SC_ERROR_INVALID_ARGUMENTS;
|
||||
return SC_ERROR_INTERNAL;
|
||||
}
|
||||
len -= 2;
|
||||
tlen = *data++ & 0x7f;
|
||||
if (tlen > 3) {
|
||||
sc_error(card->ctx, "invalid public key data: invalid tag length");
|
||||
return SC_ERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
for (i = 0; i < tlen; i++)
|
||||
ilen += (*data++) << (8 * (tlen - i - 1));
|
||||
|
||||
p = sc_asn1_find_tag(card->ctx, data, ilen, 0x81, &tlen);
|
||||
if (p == NULL) {
|
||||
|
|
Loading…
Reference in New Issue