I will try and include this.

Larner, Russell wrote:
> After looking more, I found that the code I had looked at in the CHUID 
> on the PIV card should work for properly-issued cards.  (I.E. demo cards 
> may or may not work, depending on the manufacturer - but real cards 
> should work fine.)
> 
> Unfortunately, I can not get to Subversion from work (I get a PROPFIND 
> error, even through https), so I can't easily get the latest code to 
> generate a patch.  I've included the main method below, and I'll try to 
> get the patch made next week if no-one else does. 
> 
> int piv_get_serial_nr_from_CHUI(sc_card_t* card, sc_serial_number_t* serial)
> {
>         int r;
>         u8 *rbuf = NULL;
>         u8 *body, *fascn;
>         size_t rbuflen = 0, bodylen, fascnlen;
>         u8 temp[2000];
>         size_t templen = sizeof(temp);
> 
>         SC_FUNC_CALLED(card->ctx, 1);
> 
>         /* ensure we've got the PIV selected, and nothing else is in 
> process */
>         /* This fixes several problems due to previous incomplete APDUs 
> during card detection */
>         /* Note: We need the temp because (some?) Oberthur cards don't 
> like selecting an applet without response data */
>         piv_select_aid(card, piv_aids[0].value, piv_aids[0].len_short, 
> temp, &templen);
> 
>         r = piv_get_data(card, piv_find_obj_by_enum(card, PIV_OBJ_CHUI), 
> &rbuf, &rbuflen);
>         SC_TEST_RET(card->ctx, r, "Failure retrieving CHUI");
> 
>         r = SC_ERROR_INTERNAL;
>         if (rbuflen != 0) {
>                 body = (u8 *)sc_asn1_find_tag(card->ctx, rbuf, rbuflen, 
> 0x53, &bodylen); /* Pass the outer wrapper asn1 */
>                 if (body != NULL && bodylen != 0) {
>                         fascn = (u8 *)sc_asn1_find_tag(card->ctx, body, 
> bodylen, 0x30, &fascnlen); /* Find the FASC-N data */
>                         if (fascn != NULL && fascnlen != 0) {
>                                 serial->len = fascnlen < SC_MAX_SERIALNR 
> ? fascnlen : SC_MAX_SERIALNR;
>                                 memcpy (serial->value, fascn, serial->len);
>                                 r = SC_SUCCESS;
>                         }
>                 }
>         }
>        
>         if (rbuf != NULL)
>                 free (rbuf);
>         SC_FUNC_RETURN(card->ctx, 1, r);
> }
> 
>  
> 
> Russell Larner| Senior Software Engineer| +1781-515-7112| e-Mail 
> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> 
> **
> 
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> opensc-devel mailing list
> opensc-devel@lists.opensc-project.org
> http://www.opensc-project.org/mailman/listinfo/opensc-devel

-- 

  Douglas E. Engert  <[EMAIL PROTECTED]>
  Argonne National Laboratory
  9700 South Cass Avenue
  Argonne, Illinois  60439
  (630) 252-5444
_______________________________________________
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Reply via email to