Hi, Here is the debug of the function sc_pkcs15init_change_attrib().
First, in my profile I have this files: 3f0051156001 Private key EF 3f0051156002 Public key EF 3f0051156006 Certificate EF And you can look in the pkcs15.profile the other files. I attach you the debug because it a little long to paste it here. Thanks for all! -- Marc Rios Vallès m...@c3po.es C3PO, S.A. http://www.c3po.es C/ Alejandro Goicoechea, 6 Local 9 - 08960 St. Just Desvern, Barcelona Tel. 93 417 99 55 - Fax 93 253 12 80 On Wed, 2009-03-11 at 18:32 +0100, Andreas Jellinghaus wrote: > Am Mittwoch 11 März 2009 08:06:45 schrieb Marc Rios Valles: > > On Tue, 2009-03-10 at 18:19 +0100, Andreas Jellinghaus wrote: > > > Hi Marc, > > > > Hi andreas > > > > > could you be more specific, what your problem is? > > > > > > maybe you can debug your code and tell us if > > > df->file and file differ after the sc_profile_get_file_by_path > > > call. > > > > In df->file I have the correct structure with the path 3f0050156001 but > > when the program arribes to the sc_profile_get_file_by_path it searches > > this path in the pkcs15.profile and obviously retuns SC_FILE_NOT_FOUND. > > I don't see how that functions looks at any *.profile file. > those are loaded during library initialization, sc_pkcs15init_bind > should be the right function I guess. check if that code looks at > your profile file and assembles the correct information. > > > > If we can't ommit this line, how can I make possible to load my profile > > in that line and not pkcs15.profile??? > > why do you think that line looks at any file? > could you debug it to show it does so? > > from what I read in the code, the _bind functions loads the profiles, > first the generic, then the driver, and assembles the "profile" variable > structure. so I would debug if that structure contains the information you > want in it. > > Regards, Andreas
Breakpoint 1, sc_pkcs15init_change_attrib (p15card=0xb5c4e6b0, profile=0x90b0e58, object=0x99b0948, new_attrib_type=0, new_value=0x93f45e0, new_len=3) at pkcs15-lib.c:2751 2751 struct sc_card *card = p15card->card; Current language: auto; currently c (gdb) n 2752 u8 *buf = NULL; (gdb) n 2754 int df_type, r = 0; (gdb) n 2757 if (object == NULL || object->df == NULL) (gdb) n 2759 df_type = object->df->type; (gdb) n 2761 df = find_df_by_type(p15card, df_type); (gdb) n 2762 if (df == NULL) (gdb) n 2765 switch(new_attrib_type) (gdb) print *df $1 = {file = 0x95029f0, path = {value = "?\000P\025`\001\000\000\000\000\000\000\000\000\000", len = 6, index = 0, count = -1, type = 2}, record_length = 0, type = 0, enumerated = 1, next = 0xb5c4f0c8, prev = 0x0} (gdb) x/6b df->path->value 0xb5c4d734: 0x3f 0x00 0x50 0x15 0x60 0x01 /*THIS IS THE FILE THAT WILL SEARCH IN THE PROFILE*/ (gdb) n 2768 if (new_len >= SC_PKCS15_MAX_LABEL_SIZE) (gdb) 2770 memcpy(object->label, new_value, new_len); (gdb) [Thread 0xb1cccb90 (LWP 3570) exited] 2771 object->label[new_len] = '\0'; (gdb) 2772 break; (gdb) 2798 r = sc_pkcs15_encode_df(card->ctx, p15card, df, &buf, &bufsize); (gdb) [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'privateRSAKey' [opensc-pkcs11] asn1.c:1275:asn1_encode_entry: type=258, tag=0x1000010, parm=0xbffe39e4, len=0 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'commonObjectAttributes' [opensc-pkcs11] asn1.c:1275:asn1_encode_entry: type=129, tag=0x1000010, parm=0xbffe35d4, len=0 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'label' [opensc-pkcs11] asn1.c:1275:asn1_encode_entry: type=12, tag=0x0c, parm=0xbffe3668, len=3 [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=5 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'flags' [opensc-pkcs11] asn1.c:1275:asn1_encode_entry: type=131, tag=0x03, parm=0xbffe3768, len=4 [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=4 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'authId' [opensc-pkcs11] asn1.c:1275:asn1_encode_entry: type=257, tag=0x04, parm=0xbffe376c, len=0 [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=3 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'userConsent' (not present) [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=0 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'accessControlRules' (not present) [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=0 [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=14 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'classAttributes' [opensc-pkcs11] asn1.c:1275:asn1_encode_entry: type=129, tag=0x1000010, parm=0xbffe3bbc, len=0 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'iD' [opensc-pkcs11] asn1.c:1275:asn1_encode_entry: type=257, tag=0x04, parm=0x8dd2d00, len=0 [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=22 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'usage' [opensc-pkcs11] asn1.c:1275:asn1_encode_entry: type=131, tag=0x03, parm=0x8dd2e04, len=4 [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=4 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'native' (not present) [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=0 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'accessFlags' [opensc-pkcs11] asn1.c:1275:asn1_encode_entry: type=131, tag=0x03, parm=0x8dd2e08, len=4 [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=4 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'keyReference' [opensc-pkcs11] asn1.c:1275:asn1_encode_entry: type=2, tag=0x02, parm=0x8dd2e10, len=0 [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=3 [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=35 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'subClassAttributes' [opensc-pkcs11] asn1.c:1275:asn1_encode_entry: type=129, tag=0x21000000, parm=0xbffe3ba4, len=0 [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=2 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'typeAttributes' [opensc-pkcs11] asn1.c:1275:asn1_encode_entry: type=129, tag=0x21000001, parm=0xbffe3b14, len=0 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'privateRSAKeyAttributes' [opensc-pkcs11] asn1.c:1275:asn1_encode_entry: type=129, tag=0x1000010, parm=0xbffe3b44, len=0 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'value' [opensc-pkcs11] asn1.c:1275:asn1_encode_entry: type=256, tag=0x1000010, parm=0x8dd2e20, len=0 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'path' [opensc-pkcs11] asn1.c:1275:asn1_encode_entry: type=4, tag=0x04, parm=0xbffe31f4, len=6 [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=8 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'index' (not present) [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=0 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'length' (not present) [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=0 [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=10 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'modulusLength' [opensc-pkcs11] asn1.c:1275:asn1_encode_entry: type=2, tag=0x02, parm=0x8dd2e14, len=0 [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=4 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'keyInfo' (not present) [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=0 [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=16 [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=18 [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=71 [opensc-pkcs11] asn1.c:1269:asn1_encode_entry: encoding 'privateDSAKey' (not present) [opensc-pkcs11] asn1.c:1445:asn1_encode_entry: length of encoded item=0 2799 if (r >= 0) { (gdb) 2801 r = sc_profile_get_file_by_path(profile, &df->path, &file); (gdb) print *profile $2 = {name = 0x9430518 "pkcs15", options = {0x0 <repeats 16 times>}, card = 0xb5c5e9c0, driver = 0x0, ops = 0xc2a9e0, cbs = 0x6f7b360, dll = 0x9077dc0, mf_info = 0x998dc00, df_info = 0x9643f08, ef_list = 0x998dc00, df = {0x93b2b98, 0x8b4a0e8, 0x0, 0x0, 0x9a7ad48, 0x0, 0x0, 0x998d4c0, 0x9a5cbf8}, pin_list = 0x97c2700, auth_list = 0x0, template_list = 0x93b2fb8, macro_list = 0x939c930, pin_domains = 0, pin_maxlen = 16, pin_minlen = 4, pin_pad_char = 0, pin_encoding = 1, pin_attempts = 0, puk_attempts = 0, rsa_access_flags = 29, dsa_access_flags = 18, protect_certificates = 1, keep_public_key = 1, pkcs15 = {direct_certificates = 0, encode_df_length = 0, do_last_update = 0}, p15_spec = 0x98add00, p15_data = 0x0, dirty = 0} /*IN PROFILE I ONLY SEE pkcs15 AND ALL THE OTHER FUNCTIONS THAT NEED THE PROFILE WORKS CORRECT EXCEPT THIS*/ (gdb) print df->path $3 = {value = "?\000P\025`\001\000\000\000\000\000\000\000\000\000", len = 6, index = 0, count = -1, type = 2} (gdb) x/6b df->path->value 0xb5c4d734: 0x3f 0x00 0x50 0x15 0x60 0x01 /*THE CORRECT PATH OF THE FILE*/ (gdb) s sc_profile_get_file_by_path (profile=0x90b0e58, path=0xb5c4d734, ret=0xbffe3d14) at profile.c:512 512 if ((fi = sc_profile_find_file_by_path(profile, path)) == NULL) (gdb) s sc_profile_find_file_by_path (pro=0x90b0e58, path=0xb5c4d734) at profile.c:1731 1731 for (fi = pro->ef_list; fi; fi = fi->next) { (gdb) n 1732 fp = fi->file; /*HERE BEGINS SEARCHING IN THE pkcs15.profile AND WILL NOT FIND IT*/ (gdb) print *fp $4 = {path = {value = "���\b?\000\000\000\000\000\000\000\000\000\000", len = 0, index = 2, count = 0, type = -1}, name = "\000\000\000\000\001\000\000\000\001\000\000\000\002\000\000", namelen = 8, type = 1348031043, shareable = 1229672276, ef_structure = 0, size = 0, id = 0, status = 0, acl = {0x0, 0x0, 0x51, 0x99ccc88, 0x8ee87a0, 0x1000007, 0x0, 0x91a8200, 0x1}, record_length = 2, record_count = 0, sec_attr = 0x4 <Address 0x4 out of bounds>, sec_attr_len = 0, prop_attr = 0x5b53940 "U1�\211�]�\211�\215�'", prop_attr_len = 156124928, type_attr = 0x94db630 "\002", type_attr_len = 0, magic = 0} (gdb) n 1733 if (fp->path.len == path->len (gdb) 1731 for (fi = pro->ef_list; fi; fi = fi->next) { (gdb) n 1732 fp = fi->file; (gdb) print fi->file $5 = (struct sc_file *) 0x9a76588 (gdb) print *fi->file $6 = {path = {value = "?\000/", '\0' <repeats 12 times>, len = 4, index = 0, count = -1, type = 2}, name = '\0' <repeats 15 times>, namelen = 0, type = 1, shareable = 0, ef_structure = 1, size = 128, id = 12032, status = 0, acl = {0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2}, record_length = 0, record_count = 0, sec_attr = 0x0, sec_attr_len = 0, prop_attr = 0x0, prop_attr_len = 0, type_attr = 0x0, type_attr_len = 0, magic = 339896656} (gdb) x/4b fi->file->path->value 0x9a76588: 0x3f 0x00 0x2f 0x00 (gdb) n 1733 if (fp->path.len == path->len (gdb) 1731 for (fi = pro->ef_list; fi; fi = fi->next) { (gdb) 1732 fp = fi->file; (gdb) 1733 if (fp->path.len == path->len (gdb) print *fp $7 = {path = {value = "?\000P\025", '\0' <repeats 11 times>, len = 4, index = 0, count = -1, type = 2}, name = "�\000\000\000cPKCS-15\000\000\000", namelen = 12, type = 4, shareable = 0, ef_structure = 0, size = 5000, id = 20501, status = 0, acl = {0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2}, record_length = 0, record_count = 0, sec_attr = 0x0, sec_attr_len = 0, prop_attr = 0x0, prop_attr_len = 0, type_attr = 0x0, type_attr_len = 0, magic = 339896656} (gdb) x/4b fp->path->value 0x98035d8: 0x3f 0x00 0x50 0x15 (gdb) n 1731 for (fi = pro->ef_list; fi; fi = fi->next) { (gdb) 1732 fp = fi->file; (gdb) 1733 if (fp->path.len == path->len (gdb) print *fp $8 = {path = {value = "?\000P\025P1\000\000\000\000\000\000\000\000\000", len = 6, index = 0, count = -1, type = 2}, name = '\0' <repeats 15 times>, namelen = 0, type = 1, shareable = 0, ef_structure = 1, size = 256, id = 20529, status = 0, acl = {0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2}, record_length = 0, record_count = 0, sec_attr = 0x0, sec_attr_len = 0, prop_attr = 0x0, prop_attr_len = 0, type_attr = 0x0, type_attr_len = 0, magic = 339896656} (gdb) x/6b fp->path->value 0x8d003b0: 0x3f 0x00 0x50 0x15 0x50 0x31 (gdb) n 1731 for (fi = pro->ef_list; fi; fi = fi->next) { (gdb) 1732 fp = fi->file; (gdb) 1733 if (fp->path.len == path->len (gdb) print *fp $9 = {path = {value = "?\000P\025P2\000\000\000\000\000\000\000\000\000", len = 6, index = 0, count = -1, type = 2}, name = '\0' <repeats 15 times>, namelen = 0, type = 1, shareable = 0, ef_structure = 1, size = 0, id = 20530, status = 0, acl = {0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2}, record_length = 0, record_count = 0, sec_attr = 0x0, sec_attr_len = 0, prop_attr = 0x0, prop_attr_len = 0, type_attr = 0x0, type_attr_len = 0, magic = 339896656} (gdb) x/6b fp->path->value 0x95393f0: 0x3f 0x00 0x50 0x15 0x50 0x32 (gdb) n 1731 for (fi = pro->ef_list; fi; fi = fi->next) { (gdb) 1732 fp = fi->file; (gdb) 1733 if (fp->path.len == path->len (gdb) print *fp $10 = {path = {value = "?\000P\025P3\000\000\000\000\000\000\000\000\000", len = 6, index = 0, count = -1, type = 2}, name = '\0' <repeats 15 times>, namelen = 0, type = 1, shareable = 0, ef_structure = 1, size = 128, id = 20531, status = 0, acl = {0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2}, record_length = 0, record_count = 0, sec_attr = 0x0, sec_attr_len = 0, prop_attr = 0x0, prop_attr_len = 0, type_attr = 0x0, type_attr_len = 0, magic = 339896656} (gdb) x/6b fp->path->value 0x92c97d0: 0x3f 0x00 0x50 0x15 0x50 0x33 (gdb) n 1731 for (fi = pro->ef_list; fi; fi = fi->next) { (gdb) 1732 fp = fi->file; (gdb) print *fp $11 = {path = {value = "?\000P\025P3\000\000\000\000\000\000\000\000\000", len = 6, index = 0, count = -1, type = 2}, name = '\0' <repeats 15 times>, namelen = 0, type = 1, shareable = 0, ef_structure = 1, size = 128, id = 20531, status = 0, acl = {0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2}, record_length = 0, record_count = 0, sec_attr = 0x0, sec_attr_len = 0, prop_attr = 0x0, prop_attr_len = 0, type_attr = 0x0, type_attr_len = 0, magic = 339896656} (gdb) x/6b fp->path->value 0x92c97d0: 0x3f 0x00 0x50 0x15 0x50 0x33 (gdb) n 1733 if (fp->path.len == path->len (gdb) 1731 for (fi = pro->ef_list; fi; fi = fi->next) { (gdb) 1732 fp = fi->file; (gdb) n 1733 if (fp->path.len == path->len (gdb) print *fp $12 = {path = {value = "?\000P\025D\002\000\000\000\000\000\000\000\000\000", len = 6, index = 0, count = -1, type = 2}, name = '\0' <repeats 15 times>, namelen = 0, type = 1, shareable = 0, ef_structure = 1, size = 256, id = 17410, status = 0, acl = {0x2, 0x965ab68, 0x965ab78, 0x8eb11c0, 0x8eb11d0, 0x8eb11e0, 0x9415a90, 0x9415aa0, 0x9415ab0}, record_length = 0, record_count = 0, sec_attr = 0x0, sec_attr_len = 0, prop_attr = 0x0, prop_attr_len = 0, type_attr = 0x0, type_attr_len = 0, magic = 339896656} (gdb) x/6b fp->path->value 0x93b2b98: 0x3f 0x00 0x50 0x15 0x44 0x02 (gdb) n 1731 for (fi = pro->ef_list; fi; fi = fi->next) { (gdb) 1732 fp = fi->file; (gdb) 1733 if (fp->path.len == path->len (gdb) print *fp $13 = {path = {value = "?\000P\025D\003\000\000\000\000\000\000\000\000\000", len = 6, index = 0, count = -1, type = 2}, name = '\0' <repeats 15 times>, namelen = 0, type = 1, shareable = 0, ef_structure = 1, size = 256, id = 17411, status = 0, acl = {0x2, 0x944eeb8, 0x944eec8, 0x9a6d610, 0x9a6d620, 0x9a6d630, 0x9425338, 0x9425348, 0x9425358}, record_length = 0, record_count = 0, sec_attr = 0x0, sec_attr_len = 0, prop_attr = 0x0, prop_attr_len = 0, type_attr = 0x0, type_attr_len = 0, magic = 339896656} (gdb) x/6b fp->path->value 0x8b4a0e8: 0x3f 0x00 0x50 0x15 0x44 0x03 (gdb) n 1731 for (fi = pro->ef_list; fi; fi = fi->next) { (gdb) 1732 fp = fi->file; (gdb) 1733 if (fp->path.len == path->len (gdb) print *fp $14 = {path = {value = "?\000P\025D\004\000\000\000\000\000\000\000\000\000", len = 6, index = 0, count = -1, type = 2}, name = '\0' <repeats 15 times>, namelen = 0, type = 1, shareable = 0, ef_structure = 1, size = 512, id = 17412, status = 0, acl = {0x2, 0x99a6b08, 0x99a6b18, 0x99c6b58, 0x99c6b68, 0x99c6b78, 0x942bfc8, 0x942bfd8, 0x942bfe8}, record_length = 0, record_count = 0, sec_attr = 0x0, sec_attr_len = 0, prop_attr = 0x0, prop_attr_len = 0, type_attr = 0x0, type_attr_len = 0, magic = 339896656} (gdb) x/6b fp->path->value 0x9a7ad48: 0x3f 0x00 0x50 0x15 0x44 0x04 (gdb) n 1731 for (fi = pro->ef_list; fi; fi = fi->next) { (gdb) 1732 fp = fi->file; (gdb) n 1733 if (fp->path.len == path->len (gdb) print *fp $15 = {path = {value = "?\000P\025D\005\000\000\000\000\000\000\000\000\000", len = 6, index = 0, count = -1, type = 2}, name = '\0' <repeats 15 times>, namelen = 0, type = 1, shareable = 0, ef_structure = 1, size = 256, id = 17413, status = 0, acl = {0x2, 0x9a5e430, 0x9a5e440, 0x9334de8, 0x9334df8, 0x9334e08, 0x9aaa258, 0x9aaa268, 0x9aaa278}, record_length = 0, record_count = 0, sec_attr = 0x0, sec_attr_len = 0, prop_attr = 0x0, prop_attr_len = 0, type_attr = 0x0, type_attr_len = 0, magic = 339896656} (gdb) x/6b *fp->path->value 0x3f: Cannot access memory at address 0x3f (gdb) x/6b fp->path->value 0x998d4c0: 0x3f 0x00 0x50 0x15 0x44 0x05 (gdb) n 1731 for (fi = pro->ef_list; fi; fi = fi->next) { (gdb) 1737 return NULL; (gdb) 1738 } (gdb) sc_profile_get_file_by_path (profile=0x90b0e58, path=0xb5c4d734, ret=0xbffe3d14) at profile.c:513 513 return SC_ERROR_FILE_NOT_FOUND;
_______________________________________________ opensc-devel mailing list opensc-devel@lists.opensc-project.org http://www.opensc-project.org/mailman/listinfo/opensc-devel