@@ -2903,7 +2903,7 @@ static int piv_find_aid(sc_card_t * card)
2903
2903
priv -> init_flags |= PIV_INIT_AID_PARSED ;
2904
2904
/* look for 800-73-4 0xAC for Cipher Suite Algorithm Identifier Table 14 */
2905
2905
/* There may be more than one 0xAC tag, loop to find all */
2906
-
2906
+ /* TODO do we need to look for "Nitrokey PIVP" in tag 0x50 length 12 */
2907
2907
nextac = tag ;
2908
2908
while ((actag = sc_asn1_find_tag (card -> ctx , nextac , taglen - (nextac - tag ),
2909
2909
0xAC , & actaglen )) != NULL ) {
@@ -5396,6 +5396,7 @@ static int piv_match_card_continued(sc_card_t *card)
5396
5396
case SC_CARD_TYPE_PIV_II_PIVKEY :
5397
5397
case SC_CARD_TYPE_PIV_II_SWISSBIT :
5398
5398
case SC_CARD_TYPE_PIV_II_800_73_4 :
5399
+ case SC_CARD_TYPE_PIV_II_NITROKEY :
5399
5400
type = card -> type ;
5400
5401
break ;
5401
5402
default :
@@ -5431,7 +5432,9 @@ static int piv_match_card_continued(sc_card_t *card)
5431
5432
5432
5433
if ((data = sc_compacttlv_find_tag (card -> reader -> atr_info .hist_bytes + 1 ,
5433
5434
card -> reader -> atr_info .hist_bytes_len - 1 , 0x50 , & datalen ))) {
5434
- if (datalen == 7 && !(memcmp (data , "YubiKey" , 7 ))) {
5435
+ if (datalen >= 8 && !(memcmp (data , "Nitrokey" , 8 ))) { /* first 8 are Nitrokey */
5436
+ type = SC_CARD_TYPE_PIV_II_NITROKEY ;
5437
+ } else if (datalen == 7 && !(memcmp (data , "YubiKey" , 7 ))) {
5435
5438
type = SC_CARD_TYPE_PIV_II_YUBIKEY4 ; /* reader says 4 really 5 */
5436
5439
}
5437
5440
/* Yubikey 5 NFC ATR using ACR122 contactless reader does not match
@@ -5560,6 +5563,10 @@ static int piv_match_card_continued(sc_card_t *card)
5560
5563
priv -> yubico_version = (yubico_version_buf [0 ]<<16 ) | (yubico_version_buf [1 ] <<8 ) | yubico_version_buf [2 ];
5561
5564
sc_log (card -> ctx , "Yubico card->type=%d, r=0x%08x version=0x%08x" , card -> type , r , priv -> yubico_version );
5562
5565
}
5566
+ break ;
5567
+ case SC_CARD_TYPE_PIV_II_NITROKEY :
5568
+ /* TODO get Nitrokey version number */
5569
+ break ;
5563
5570
}
5564
5571
sc_debug (card -> ctx ,SC_LOG_DEBUG_MATCH , "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d\n" , card -> type , r2 , priv -> card_issues , r );
5565
5572
@@ -5612,6 +5619,7 @@ static int piv_match_card_continued(sc_card_t *card)
5612
5619
priv -> card_issues |= CI_DISCOVERY_USELESS ;
5613
5620
priv -> obj_cache [PIV_OBJ_DISCOVERY ].flags |= PIV_OBJ_CACHE_NOT_PRESENT ;
5614
5621
break ;
5622
+ /* TODO SC_CARD_TYPE_PIV_II_NITROKEY: nothing to do for now */
5615
5623
}
5616
5624
sc_debug (card -> ctx ,SC_LOG_DEBUG_MATCH , "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d\n" , card -> type , r2 , priv -> card_issues , r );
5617
5625
@@ -5620,6 +5628,7 @@ static int piv_match_card_continued(sc_card_t *card)
5620
5628
switch (card -> type ) {
5621
5629
case SC_CARD_TYPE_PIV_II_BASE :
5622
5630
case SC_CARD_TYPE_PIV_II_800_73_4 :
5631
+ case SC_CARD_TYPE_PIV_II_NITROKEY :
5623
5632
r2 = piv_find_aid (card );
5624
5633
}
5625
5634
}
@@ -5713,6 +5722,11 @@ static int piv_match_card_continued(sc_card_t *card)
5713
5722
/* TODO may need more research */
5714
5723
break ;
5715
5724
5725
+ case SC_CARD_TYPE_PIV_II_NITROKEY :
5726
+ priv -> card_issues |= CI_PIV_AID_LOSE_STATE ;
5727
+ /* TODO may need to add others */
5728
+ break ;
5729
+
5716
5730
default :
5717
5731
priv -> card_issues |= CI_VERIFY_LC0_FAIL
5718
5732
| CI_OTHER_AID_LOSE_STATE ;
0 commit comments