scd: ambiguous certificate IDs for pkcs#15 certificates

Mario Haustein via Gnupg-devel <[email protected]>
Newsgroups gmane.comp.encryption.gpg.devel
Organization TU Chemnitz
Message-ID <8375366.NyiUUSuA9g@localdomain>
Dear developers,

I am currently in the process of implementing the D-Trust ECC smartcards and 
encountered an issue in the certificate management for PKCS#15 cards. It is 
not limited to ECC cards and presumably concerns all PKCS#15 cards.

When importing the keys and certificates from the smartcard, I get the 
following error:

```
$ gpgsm --learn-card
gpgsm: dirmngr cache-only key lookup failed: No data
gpgsm: issuer certificate {B01842AD4A24815A2A202C7DC4C0270C7CD07AE1} not found 
using authorityKeyIdentifier
gpgsm: dirmngr cache-only key lookup failed: No data
gpgsm: issuer certificate (#/CN=D-TRUST Limited Basic CA 1-4 2019,O=D-Trust 
GmbH,C=DE) not found
[... much more similar lines for each certificate ...]
```

The card contains 2 keys and scdaemon reports 3 certificates for each key 
(root certificate, intermediate certificate, end user certificate).

```
$ ./scd/scdaemon --server   
scdaemon[12113]: NOTE: this is a development version!
OK GNU Privacy Guard's Smartcard server ready
learn
scdaemon[12113]: detected reader 'Alcor Micro AU9540 00 00'
S READER Alcor Micro AU9540 00 00
S SERIALNO 9276003211600214693F
INQUIRE KNOWNCARDP 9276003211600214693F
end
S APPTYPE p15
S MANUFACTURER 0 D-TRUST GmbH (C) [D-Trust 4.1/4.4]
S CERTINFO 100 P15-0104.02 Signaturzertifikat
S CERTINFO 100 P15-0104.03 Authentisierungszertifikat
S CERTINFO 101 P15-0104.02 Root-CA-Zertifikat_fuer_Signatur
S CERTINFO 101 P15-0104.02 CA-Zertifikat_fuer_Signatur
S CERTINFO 101 P15-0104.03 Root-CA-Zertifikat_fuer_Authentisierung
S CERTINFO 101 P15-0104.03 CA-Zertifikat_fuer_Authentisierung
S KEYPAIRINFO A45148C590655BA844A13F52D59105979BC93545 P15-0104.02 s 
1682058347 rsa3072
S KEYPAIRINFO AF621109BA799E313088DD77F9732159EA9EE55F P15-0104.03 scea 
1682058347 rsa3072
S CHV-STATUS 3 3 -2
S CHV-LABEL Card-PIN Card-PUK Signature-PIN
OK
```

For this card, all certificates have the same ID tag for each key (2 or 3 in 
the example), as they are part of the same certificate chain. Thus the 
scdaemon certificate ID (P15-0104.02 and P15-0104.03 in the example) is not 
unique amongst all the certificates.

When importing the certificate from the card, gpgsm issues a READCERT command 
which just returns the first matched certificate, but never the intermediate 
nor the root certificate.

Is there a way to avoid this unambiguity? Would it for example be possible to 
use the path ID of the certificate file instead of the ID tag in the 
certificate descriptor?

Is this mailinglist the right place to discuss this issue or should I open a 
task in the issue tracker?

For completeness this is the content of the certificate directory object (path 
3F00/0104/5101).

```
30 SEQUENCE (53 bytes)
   30 SEQUENCE (32 bytes)
      0C UTF8String (26 bytes): Authentisierungszertifikat
      03 BIT STRING (2 bytes): 10
   30 SEQUENCE (3 bytes)
      04 OCTET STRING (1 byte): 03 .
   A1 Context 1  (12 bytes)
      30 SEQUENCE (10 bytes)
         30 SEQUENCE (8 bytes)
            04 OCTET STRING (6 bytes): 3F 00 01 03 02 04 ?.....
30 SEQUENCE (45 bytes)
   30 SEQUENCE (24 bytes)
      0C UTF8String (18 bytes): Signaturzertifikat
      03 BIT STRING (2 bytes): 10
   30 SEQUENCE (3 bytes)
      04 OCTET STRING (1 byte): 02 .
   A1 Context 1  (12 bytes)
      30 SEQUENCE (10 bytes)
         30 SEQUENCE (8 bytes)
            04 OCTET STRING (6 bytes): 3F 00 01 03 02 01 ?.....
```

This is the content of the additional certificate directory object (path 
3F00/0104/5102).

```
30 SEQUENCE (64 bytes)
   30 SEQUENCE (40 bytes)
      0C UTF8String (34 bytes): CA-Zertifikat fuer Authentisierung
      03 BIT STRING (2 bytes): 10
   30 SEQUENCE (6 bytes)
      04 OCTET STRING (1 byte): 03 .
      01 BOOLEAN (1 byte): true
   A1 Context 1  (12 bytes)
      30 SEQUENCE (10 bytes)
         30 SEQUENCE (8 bytes)
            04 OCTET STRING (6 bytes): 3F 00 01 03 02 05 ?.....
30 SEQUENCE (69 bytes)
   30 SEQUENCE (45 bytes)
      0C UTF8String (39 bytes): Root-CA-Zertifikat fuer Authentisierung
      03 BIT STRING (2 bytes): 10
   30 SEQUENCE (6 bytes)
      04 OCTET STRING (1 byte): 03 .
      01 BOOLEAN (1 byte): true
   A1 Context 1  (12 bytes)
      30 SEQUENCE (10 bytes)
         30 SEQUENCE (8 bytes)
            04 OCTET STRING (6 bytes): 3F 00 01 03 02 06 ?.....
30 SEQUENCE (57 bytes)
   30 SEQUENCE (33 bytes)
      0C UTF8String (27 bytes): CA-Zertifikat fuer Signatur
      03 BIT STRING (2 bytes): 10
   30 SEQUENCE (6 bytes)
      04 OCTET STRING (1 byte): 02 .
      01 BOOLEAN (1 byte): true
   A1 Context 1  (12 bytes)
      30 SEQUENCE (10 bytes)
         30 SEQUENCE (8 bytes)
            04 OCTET STRING (6 bytes): 3F 00 01 03 02 02 ?.....
30 SEQUENCE (62 bytes)
   30 SEQUENCE (38 bytes)
      0C UTF8String (32 bytes): Root-CA-Zertifikat fuer Signatur
      03 BIT STRING (2 bytes): 10
   30 SEQUENCE (6 bytes)
      04 OCTET STRING (1 byte): 02 .
      01 BOOLEAN (1 byte): true
   A1 Context 1  (12 bytes)
      30 SEQUENCE (10 bytes)
         30 SEQUENCE (8 bytes)
            04 OCTET STRING (6 bytes): 3F 00 01 03 02 03 ?.....
```

Kind regards
-- 
Mario Haustein
Facharbeitsgruppe Anwendungen
Universitätsrechenzentrum

Technische Universität Chemnitz
Straße der Nationen 62 | R. 1/B303 (neu: A11.303)
09111 Chemnitz
Germany

Tel:    +49 371 531-36606
Fax:    +49 371 531-836606

[email protected]
www.tu-chemnitz.de

_______________________________________________
Gnupg-devel mailing list
[email protected]
https://lists.gnupg.org/mailman/listinfo/gnupg-devel
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEE0dWxQ/gtEp4RcqrdrrMm8sIKEfoFAmXPLlYACgkQrrMm8sIK
EfrMJA/+ITtnAy2GRJi3eb2c94gZuh1ZtPOjbtgoHd6Ae26bX2m9DmI/A3NR71GG
KWwlnGqj/D+FgMUtaTxH1WDJtUYNlpx2+YEbV7iY8h3pF1DpBomZcbDCuJt+MlOv
oQnUICLsY6RDfy1x90rhWOkQ8bepMH0bRMQXYyta/YS1HaApy7/t/r7y7jXkpnTC
JgAWcqnSYJUnrYCbmINMZ8VYNrktQlhnigN/Geq1V8Jv/sy5gpWOuhHnJlyPI6k9
d/tKzMxKeL5BGPmGKsJ9wIDqFa7LjDamc/U5xkdZKV4R/+j06S3/3qCuucf9YekW
qbetzq8imZuijOLw4Wg/fMkr/p4MyMRLylxwToo7cMox/ri+kVhig4u1xK7NFY2Q
a6+Rb+fK+EyVHkEpSMGGsFv1P+58NX74HkHbOc4RGVbjLhZ2Pm/MSJPXFoE7TqVm
ElqJCY9/gBi2yLZdX6OXp/Zm/sYbWxz1h+S7nyzMahZmgVoCz4wd9gGVGlcE+WNd
ylLgCZ5vpY6vvBVSSxfsxQisYPZDqPHEc5T6xu3xMLY5lzZfA+5n8LvN+9v/uxVz
Ti/8tZxTjgbgurYV9xqFaAPuM85UIjNbFWNzytlvKd1N2rs9+euPrfANZEjaKLVJ
uPm2ub5Rx3mV5qPxHXvyCQOAw2YyCAFBTi/57bpmkxxZeLF6IDE=
=TyZn
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.