Changeset 3028
- Timestamp:
- 09/26/06 10:55:02 (2 years ago)
- Location:
- trunk/src/libopensc
- Files:
-
- 6 modified
-
pkcs15-cert.c (modified) (1 diff)
-
pkcs15-data.c (modified) (1 diff)
-
pkcs15-prkey.c (modified) (1 diff)
-
pkcs15-pubkey.c (modified) (1 diff)
-
pkcs15.c (modified) (7 diffs)
-
pkcs15.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libopensc/pkcs15-cert.c
r2815 r3028 219 219 return r; 220 220 SC_TEST_RET(ctx, r, "ASN.1 decoding failed"); 221 r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &info.path); 222 if (r < 0) 223 return r; 221 224 obj->type = SC_PKCS15_TYPE_CERT_X509; 222 225 obj->data = malloc(sizeof(info)); -
trunk/src/libopensc/pkcs15-data.c
r2815 r3028 110 110 if (r == SC_ERROR_ASN1_END_OF_CONTENTS) 111 111 return r; 112 113 112 SC_TEST_RET(ctx, r, "ASN.1 decoding failed"); 113 r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &info.path); 114 if (r < 0) 115 return r; 114 116 obj->type = SC_PKCS15_TYPE_DATA_OBJECT; 115 117 obj->data = malloc(sizeof(info)); -
trunk/src/libopensc/pkcs15-prkey.c
r2815 r3028 154 154 SC_FUNC_RETURN(ctx, 0, SC_ERROR_INVALID_ASN1_OBJECT); 155 155 } 156 r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &info.path); 157 if (r < 0) 158 return r; 156 159 obj->data = malloc(sizeof(info)); 157 160 if (obj->data == NULL) -
trunk/src/libopensc/pkcs15-pubkey.c
r2815 r3028 136 136 obj->type = SC_PKCS15_TYPE_PUBKEY_DSA; 137 137 } 138 r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &info.path); 139 if (r < 0) 140 return r; 138 141 obj->data = malloc(sizeof(info)); 139 142 if (obj->data == NULL) -
trunk/src/libopensc/pkcs15.c
r3027 r3028 314 314 const u8 *p = buf; 315 315 size_t left = buflen; 316 int r, i ;316 int r, i, type; 317 317 sc_path_t path; 318 318 struct sc_asn1_entry asn1_obj_or_path[] = { … … 331 331 if (r < 0) 332 332 return r; 333 r = sc_pkcs15_add_df(card, odf_indexes[r], &path, NULL); 333 type = r; 334 r = sc_pkcs15_make_absolute_path(&card->file_app->path, &path); 335 if (r < 0) 336 return r; 337 r = sc_pkcs15_add_df(card, odf_indexes[type], &path, NULL); 334 338 if (r) 335 339 return r; … … 1534 1538 return r; 1535 1539 /* If the path length is 0, it's a dummy path then don't add it. 1536 * If the path length isn't include (-1) then it's against the standard1540 * If the path length isn't included (-1) then it's against the standard 1537 1541 * but we'll just ignore it instead of returning an error. */ 1538 1542 if (path.count > 0) { 1543 r = sc_pkcs15_make_absolute_path(&card->file_app->path, &path); 1544 if (r < 0) 1545 return r; 1539 1546 r = sc_pkcs15_add_unusedspace(card, &path, &auth_id); 1540 1547 if (r) … … 1554 1561 { 1555 1562 sc_file_t *file = NULL; 1556 sc_path_t tmp_path, *path = &tmp_path;1557 1563 u8 *data = NULL; 1558 1564 size_t len = 0, offset = 0; … … 1572 1578 } 1573 1579 1574 if (in_path->type == SC_PATH_TYPE_FILE_ID) {1575 /* in case of a FID prepend the application DF */1576 memcpy(path, &p15card->file_app->path, sizeof(sc_path_t));1577 sc_append_path(path, in_path);1578 path->index = in_path->index;1579 path->count = in_path->count;1580 } else {1581 memcpy(path, in_path, sizeof(sc_path_t));1582 }1583 1580 r = -1; /* file state: not in cache */ 1584 1581 if (p15card->opts.use_cache) { 1585 r = sc_pkcs15_read_cached_file(p15card, path, &data, &len);1582 r = sc_pkcs15_read_cached_file(p15card, in_path, &data, &len); 1586 1583 } 1587 1584 if (r) { 1588 1585 r = sc_lock(p15card->card); 1589 1586 SC_TEST_RET(p15card->card->ctx, r, "sc_lock() failed"); 1590 r = sc_select_file(p15card->card, path, &file);1587 r = sc_select_file(p15card->card, in_path, &file); 1591 1588 if (r) 1592 1589 goto fail_unlock; … … 1594 1591 /* Handle the case where the ASN.1 Path object specified 1595 1592 * index and length values */ 1596 if ( path->count < 0) {1593 if (in_path->count < 0) { 1597 1594 len = file->size; 1598 1595 offset = 0; 1599 1596 } else { 1600 offset = path->index;1601 len = path->count;1597 offset = in_path->index; 1598 len = in_path->count; 1602 1599 /* Make sure we're within proper bounds */ 1603 1600 if (offset >= file->size … … 1714 1711 return sc_hex_to_bin(in, out->value, &out->len); 1715 1712 } 1713 1714 int sc_pkcs15_make_absolute_path(const sc_path_t *parent, sc_path_t *child) 1715 { 1716 if (sc_compare_path_prefix(sc_get_mf_path(), child)) 1717 return 0; 1718 return sc_concatenate_path(child, parent, child); 1719 } -
trunk/src/libopensc/pkcs15.h
r2872 r3028 633 633 void sc_der_copy(sc_pkcs15_der_t *, const sc_pkcs15_der_t *); 634 634 void sc_der_clear(sc_pkcs15_der_t *); 635 /* Prepend 'parent' to 'child' in case 'child' is a relative path */ 636 int sc_pkcs15_make_absolute_path(const sc_path_t *parent, sc_path_t *child); 635 637 636 638 /* New object search API.
