Skip to content

Commit 9e724be

Browse files
author
z4yx
committed
test PIV cipher extension with Yubico piv tool
1 parent 609b490 commit 9e724be

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

applets/piv/piv.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
#define ALG_RSA_2048 0x07
4242
#define ALG_ECC_256 0x11
4343
#define ALG_ECC_384 0x14
44-
#define ALG_ED25519_DEFAULT 0x22 // defined in https://github.com/go-piv/piv-go/pull/69
44+
#define ALG_ED25519_DEFAULT 0xE0
4545
#define ALG_RSA_3072_DEFAULT 0x05 // defined in NIST SP 800-78-5 (Initial Public Draft)
46-
#define ALG_RSA_4096_DEFAULT 0x51
47-
#define ALG_X25519_DEFAULT 0x52
46+
#define ALG_RSA_4096_DEFAULT 0x16
47+
#define ALG_X25519_DEFAULT 0xE1
4848
#define ALG_SECP256K1_DEFAULT 0x53
4949
#define ALG_SM2_DEFAULT 0x54
5050

@@ -1099,7 +1099,7 @@ static int piv_get_version(const CAPDU *capdu, RAPDU *rapdu) {
10991099
if (P1 != 0x00 || P2 != 0x00) EXCEPT(SW_WRONG_P1P2);
11001100
if (LC != 0) EXCEPT(SW_WRONG_LENGTH);
11011101
RDATA[0] = 0x05;
1102-
RDATA[1] = 0x04;
1102+
RDATA[1] = 0x07;
11031103
RDATA[2] = 0x00;
11041104
LL = 3;
11051105
return 0;

test-real/test-piv.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ test_ChangePin() {
8686
assertEquals 'set-mgm-key' 0 $?
8787
}
8888

89-
test_RSA2048() {
90-
for s in 9a 9c 9d 9e; do PIVGenKeyCert $s "/CN=CertAtSlot$s/" RSA2048; done
89+
rsa_tests() {
90+
for s in 9a 9c 9d 9e; do PIVGenKeyCert $s "/CN=CertAtSlot$s/" $1; done
9191
YPT -a status
9292
PIVSignDec 9e # PIN not required for key 9e
9393
for s in 9a 9c 9d; do PIVSignDec $s 1; done
@@ -101,6 +101,18 @@ test_RSA2048() {
101101
assertEquals 'openssl dgst verify' 0 $?
102102
}
103103

104+
test_RSA2048() {
105+
rsa_tests RSA2048
106+
}
107+
108+
test_RSA3072() {
109+
rsa_tests RSA3072
110+
}
111+
112+
test_RSA4096() {
113+
rsa_tests RSA4096
114+
}
115+
104116
test_ECC256() {
105117
for s in 9a 9c 9d 9e; do PIVGenKeyCert $s "/CN=CertAtSlot$s/" ECCP256; done
106118
YPT -a status
@@ -119,6 +131,16 @@ test_ECC384() {
119131
assertContains 'CERT' "$out" 'CN = CertAtSlot9c'
120132
}
121133

134+
test_25519() {
135+
for s in 9a 9c 9e; do PIVGenKeyCert $s "/CN=CertAtSlot$s/" ED25519; done
136+
for s in 9d; do PIVGenKeyCert $s "/CN=CertAtSlot$s/" X25519; done
137+
YPT -a status
138+
for s in 9a 9c 9e; do PIVSignDec $s 1 s; done # 9a/9c/9e only do the EDDSA
139+
# PIVSignDec 9d 1 d # 9d only do the EDDH
140+
# out=$(pkcs15-tool --reader "$RDID" --read-certificate 01 | openssl x509 -text)
141+
# assertContains 'CERT' "$out" 'CN = CertAtSlot9a'
142+
}
143+
122144
test_PinBlock() {
123145
out=$(YPT -a verify-pin -P 222222 2>&1)
124146
assertContains 'verify-pin' "$out" '2 tries left before pin is blocked.'

0 commit comments

Comments
 (0)