Skip to content

Commit 9b2a69f

Browse files
committed
tests: added FIPS tests for generate
1 parent 4e3aade commit 9b2a69f

File tree

1 file changed

+40
-19
lines changed

1 file changed

+40
-19
lines changed

Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/GenerateTests.cs

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,53 @@ namespace Yubico.YubiKey.Piv
2323
public class GenerateTests : PivSessionIntegrationTestBase
2424
{
2525
[SkippableTheory(typeof(NotSupportedException))]
26-
[InlineData(KeyType.RSA1024)]
27-
[InlineData(KeyType.RSA2048)]
28-
[InlineData(KeyType.RSA3072)]
29-
[InlineData(KeyType.RSA4096)]
30-
[InlineData(KeyType.Ed25519)]
31-
[InlineData(KeyType.X25519)]
32-
[InlineData(KeyType.ECP256)]
33-
[InlineData(KeyType.ECP384)]
34-
[InlineData(KeyType.RSA1024, true)]
35-
[InlineData(KeyType.RSA2048, true)]
36-
[InlineData(KeyType.RSA3072, true)]
37-
[InlineData(KeyType.RSA4096, true)]
38-
[InlineData(KeyType.X25519, true)]
39-
[InlineData(KeyType.Ed25519, true)]
40-
[InlineData(KeyType.ECP256, true)]
41-
[InlineData(KeyType.ECP384, true)]
26+
[InlineData(KeyType.RSA1024, StandardTestDevice.Fw5)]
27+
[InlineData(KeyType.RSA2048, StandardTestDevice.Fw5)]
28+
[InlineData(KeyType.RSA3072, StandardTestDevice.Fw5)]
29+
[InlineData(KeyType.RSA4096, StandardTestDevice.Fw5)]
30+
[InlineData(KeyType.Ed25519, StandardTestDevice.Fw5)]
31+
[InlineData(KeyType.X25519, StandardTestDevice.Fw5)]
32+
[InlineData(KeyType.ECP256, StandardTestDevice.Fw5)]
33+
[InlineData(KeyType.ECP384, StandardTestDevice.Fw5)]
34+
35+
[InlineData(KeyType.RSA1024, StandardTestDevice.Fw5Fips)]
36+
[InlineData(KeyType.RSA2048, StandardTestDevice.Fw5Fips)]
37+
[InlineData(KeyType.RSA3072, StandardTestDevice.Fw5Fips)]
38+
[InlineData(KeyType.RSA4096, StandardTestDevice.Fw5Fips)]
39+
[InlineData(KeyType.Ed25519, StandardTestDevice.Fw5Fips)]
40+
[InlineData(KeyType.X25519, StandardTestDevice.Fw5Fips)]
41+
[InlineData(KeyType.ECP256, StandardTestDevice.Fw5Fips)]
42+
[InlineData(KeyType.ECP384, StandardTestDevice.Fw5Fips)]
43+
44+
[InlineData(KeyType.RSA1024, StandardTestDevice.Fw5Fips, true),]
45+
[InlineData(KeyType.RSA2048, StandardTestDevice.Fw5Fips, true),]
46+
[InlineData(KeyType.RSA3072, StandardTestDevice.Fw5Fips, true),]
47+
[InlineData(KeyType.RSA4096, StandardTestDevice.Fw5Fips, true),]
48+
[InlineData(KeyType.X25519, StandardTestDevice.Fw5Fips, true),]
49+
[InlineData(KeyType.Ed25519, StandardTestDevice.Fw5Fips, true),]
50+
[InlineData(KeyType.ECP256, StandardTestDevice.Fw5Fips, true),]
51+
[InlineData(KeyType.ECP384, StandardTestDevice.Fw5Fips, true),]
4252
public void SimpleGenerate(
43-
KeyType expectedAlgorithm,
53+
KeyType keyType,
54+
StandardTestDevice deviceType,
4455
bool useScp03 = false)
4556
{
4657
using var pivSession = useScp03
4758
? GetSessionScp()
4859
: GetSession();
4960

50-
var result = pivSession.GenerateKeyPair(PivSlot.Retired12, expectedAlgorithm);
51-
Assert.Equal(expectedAlgorithm, result.KeyType);
61+
var pinPolicy = PivPinPolicy.Never;
62+
var touchPolicy = PivTouchPolicy.Never;
63+
if (deviceType == StandardTestDevice.Fw5Fips)
64+
{
65+
FipsTestUtilities.SetFipsApprovedCredentials(Session);
66+
pinPolicy = PivPinPolicy.Always;
67+
touchPolicy = PivTouchPolicy.Always;
68+
}
69+
70+
var result = Session.GenerateKeyPair(PivSlot.Retired12, keyType, pinPolicy, touchPolicy);
71+
72+
Assert.Equal(keyType, result.KeyType);
5273
}
5374
}
5475
}

0 commit comments

Comments
 (0)