From 0cbbf85345f22095673a4ce16afcb33bf9a2e9c5 Mon Sep 17 00:00:00 2001 From: Prashant Patil Date: Mon, 19 Dec 2022 14:48:33 +0000 Subject: Keystore: StrongBox assumption added in EcdsaTest Test EcdsaTest#testNullRandomSecp256r1_StrongBox is assumed to run against StrongBox. Bug: 263084189 Test: atest CtsKeystoreWycheproofTestCases: com.google.security.wycheproof.EcdsaTest#testNullRandomSecp256r1_StrongBox Change-Id: I3b117f31303008a3f44ff4f3e04a7371786b36e1 --- .../google/security/wycheproof/testcases/EcdsaTest.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/keystore-cts/java/com/google/security/wycheproof/testcases/EcdsaTest.java b/keystore-cts/java/com/google/security/wycheproof/testcases/EcdsaTest.java index b454b84..3a758f3 100644 --- a/keystore-cts/java/com/google/security/wycheproof/testcases/EcdsaTest.java +++ b/keystore-cts/java/com/google/security/wycheproof/testcases/EcdsaTest.java @@ -195,6 +195,9 @@ public class EcdsaTest { return testParameters(algorithm, curve, false); } boolean testParameters(String algorithm, String curve, boolean isStrongBox) throws Exception { + if (isStrongBox) { + KeyStoreUtil.assumeStrongBox(); + } String message = "123400"; KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC"); @@ -245,7 +248,6 @@ public class EcdsaTest { } @Test public void testBasic_StrongBox() throws Exception { - KeyStoreUtil.assumeStrongBox(); String algorithm = "SHA256WithECDSA"; String curve = "secp256r1"; assertTrue(testParameters(algorithm, curve, true)); @@ -257,6 +259,9 @@ public class EcdsaTest { } public void testBias(String algorithm, String curve, boolean isStrongBox) throws Exception { + if (isStrongBox) { + KeyStoreUtil.assumeStrongBox(); + } Signature signer = Signature.getInstance(algorithm, EXPECTED_PROVIDER_NAME); KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC"); keyGen.initialize(new ECGenParameterSpec(curve)); @@ -364,7 +369,6 @@ public class EcdsaTest { @Test public void testBiasSecp521r1_StrongBox() throws Exception { - KeyStoreUtil.assumeStrongBox(); testBias("SHA256WithECDSA", "secp256r1", true); } @@ -398,7 +402,11 @@ public class EcdsaTest { public void testNullRandom(String algorithm, String curve) throws Exception { testNullRandom(algorithm, curve, false); } - public void testNullRandom(String algorithm, String curve, boolean isStrongBox) throws Exception { + public void testNullRandom(String algorithm, String curve, boolean isStrongBox) + throws Exception { + if (isStrongBox) { + KeyStoreUtil.assumeStrongBox(); + } int samples = 8; Signature signer = Signature.getInstance(algorithm); KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC"); -- cgit v1.2.3