Skip to content

Commit

Permalink
improve device tests running on older YubiKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamVe committed Jan 29, 2025
1 parent 0f0af07 commit 5a64d1d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,8 @@ protected TestState(Builder<?> builder) {
this.usbPid = builder.usbPid;
this.scpKid = builder.scpKid;

if (this.scpKid != null) {
Security.removeProvider("BC");
Security.insertProviderAt(new BouncyCastleProvider(), 1);
}
Security.removeProvider("BC");
Security.insertProviderAt(new BouncyCastleProvider(), 1);

this.scpParameters = new ScpParameters(builder.device, this.scpKid);
this.reconnectDeviceCallback = builder.reconnectDeviceCallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ private static int[] getSupportedRsaKeySizes(OpenPgpSession openpgp) {

public static void testGenerateRequiresAdmin(OpenPgpSession openpgp, OpenPgpTestState state)
throws Exception {
Assume.assumeTrue("Device FW not at least 5.2.0.", openpgp.getVersion().isAtLeast(5, 2, 0));

try {
openpgp.generateEcKey(KeyRef.DEC, OpenPgpCurve.BrainpoolP256R1);
Expand Down Expand Up @@ -537,6 +538,7 @@ public static void testUnverifyPin(OpenPgpSession openpgp, OpenPgpTestState stat

public static void testDeleteKey(OpenPgpSession openpgp, OpenPgpTestState state)
throws Exception {
Assume.assumeTrue("Device FW not at least 4.0.0.", openpgp.getVersion().isAtLeast(4, 0, 0));
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(2048);
KeyPair pair = kpg.generateKeyPair();
Expand All @@ -559,6 +561,7 @@ public static void testDeleteKey(OpenPgpSession openpgp, OpenPgpTestState state)

public static void testCertificateManagement(OpenPgpSession openpgp, OpenPgpTestState state)
throws Exception {
Assume.assumeTrue("Device FW not at least 5.2.0.", openpgp.getVersion().isAtLeast(5, 2, 0));
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(2048);
KeyPair pair = kpg.generateKeyPair();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.yubico.yubikit.testing.piv;

import static com.yubico.yubikit.piv.PivSession.FEATURE_CV25519;
import static com.yubico.yubikit.piv.PivSession.FEATURE_P384;
import static com.yubico.yubikit.piv.PivSession.FEATURE_RSA3072_RSA4096;
import static com.yubico.yubikit.testing.piv.PivJcaUtils.setupJca;
import static com.yubico.yubikit.testing.piv.PivJcaUtils.tearDownJca;
Expand Down Expand Up @@ -87,6 +88,10 @@ public static void testSign(PivSession piv, PivTestState state, KeyType keyType)
return;
}

if (!piv.supports(FEATURE_P384) && keyType == KeyType.ECCP384) {
return;
}

if (state.isInvalidKeyType(keyType)) {
return;
}
Expand Down

0 comments on commit 5a64d1d

Please sign in to comment.