Skip to content

Commit 049465e

Browse files
authored
Fix issues found by ckman test cases (#125)
- Fix ed25519 signing in PIV - Fix length encoding of Algorithm Info DO in OpenPGP - Test with ckman on CI
1 parent 15aad40 commit 049465e

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

.github/workflows/tests.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ jobs:
8282
repository: canokeys/piv-go
8383
path: piv-go
8484

85+
- name: Prepare - Checkout ckman
86+
uses: actions/checkout@v4
87+
with:
88+
repository: canokeys/yubikey-manager
89+
ref: canokey-next
90+
path: yubikey-manager
91+
8592
- name: Cache - GO Modules
8693
uses: actions/cache@v4
8794
env:
@@ -390,6 +397,14 @@ jobs:
390397
gpgconf --kill gpg-agent
391398
go test -v test-via-pcsc/openpgp_test.go -run TestOpenPGPCerts
392399
400+
- name: Tests - Interoperate with ckman openpgp
401+
run: |
402+
cd yubikey-manager
403+
pipx install poetry
404+
poetry install
405+
poetry run pytest --reader 'Canokey ' --no-serial --use-version 5.7.0 -s ./tests/device/test_openpgp.py -v
406+
poetry run pytest --reader 'Canokey ' --no-serial --use-version 5.7.0 -s ./tests/device/test_piv.py -v
407+
393408
- name: Tests - PIV applet
394409
run: |
395410
set -o xtrace
@@ -547,6 +562,7 @@ jobs:
547562
diff -s /tmp/rand-pi /tmp/read-pi
548563
diff -s /tmp/rand-face /tmp/read-face
549564
diff -s /tmp/rand-fig /tmp/read-fig
565+
yubico-piv-tool -r "$RDID" -a change-pin -N 123456 -P 654321
550566
551567
- name: Wrap-up - Prepare test coverage report
552568
run: |

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
cmake-build-*
2-
build/
2+
build*/
33
lfs-root
44
virt-card/git-rev.h

applets/openpgp/openpgp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,9 @@ static int openpgp_get_data(const CAPDU *capdu, RAPDU *rapdu) {
589589

590590
case TAG_ALGORITHM_INFORMATION:
591591
RDATA[0] = TAG_ALGORITHM_INFORMATION;
592-
RDATA[1] = add_all_algorithm_info(RDATA + 2);
593-
LL = RDATA[1] + 2;
592+
RDATA[1] = 0x81;
593+
RDATA[2] = add_all_algorithm_info(RDATA + 3);
594+
LL = RDATA[2] + 3;
594595
break;
595596

596597
case TAG_UIF_CACHE_TIME:

applets/piv/piv.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,14 +632,16 @@ static int piv_general_authenticate(const CAPDU *capdu, RAPDU *rapdu) {
632632

633633
memzero(&key, sizeof(key));
634634
} else if (IS_ECC(key.meta.type)) {
635+
size_t input_len = len[IDX_CHALLENGE];
635636
if (IS_SHORT_WEIERSTRASS(key.meta.type)) {
636637
// prepend zeros
637638
memmove(DATA + pos[IDX_CHALLENGE] + (PRIVATE_KEY_LENGTH[key.meta.type] - len[IDX_CHALLENGE]),
638639
DATA + pos[IDX_CHALLENGE],
639640
len[IDX_CHALLENGE]);
640641
memzero(DATA + pos[IDX_CHALLENGE], PRIVATE_KEY_LENGTH[key.meta.type] - len[IDX_CHALLENGE]);
642+
input_len = PRIVATE_KEY_LENGTH[key.meta.type];
641643
}
642-
int sig_len = ck_sign(&key, DATA + pos[IDX_CHALLENGE], PRIVATE_KEY_LENGTH[key.meta.type], RDATA + 4);
644+
int sig_len = ck_sign(&key, DATA + pos[IDX_CHALLENGE], input_len, RDATA + 4);
643645
if (sig_len < 0) {
644646
ERR_MSG("Sign failed\n");
645647
return -1;

0 commit comments

Comments
 (0)