@@ -32,7 +32,7 @@ static boolean parseBoolean(String value)
3232
3333 public interface KeyGenerationOperation
3434 {
35- SecureRandom getSecureRanom (byte [] seed );
35+ SecureRandom getSecureRandom (byte [] seed );
3636
3737 AsymmetricCipherKeyPairGenerator getAsymmetricCipherKeyPairGenerator (int fileIndex , SecureRandom random );
3838
@@ -45,17 +45,19 @@ public interface KeyGenerationOperation
4545 MessageSigner getMessageSigner ();
4646 }
4747
48- public static void testTestVector (boolean enableFactory , boolean isSigner , String homeDir , String [] files , KeyGenerationOperation operation )
48+ public static void testTestVector (boolean sampleOnly , boolean enableFactory , boolean isSigner , String homeDir , String [] files , KeyGenerationOperation operation )
4949 throws Exception
5050 {
5151 for (int fileIndex = 0 ; fileIndex != files .length ; fileIndex ++)
5252 {
5353 String name = files [fileIndex ];
54+
5455 InputStream src = TestResourceFinder .findTestResource (homeDir , name );
5556 BufferedReader bin = new BufferedReader (new InputStreamReader (src ));
56- //System.out.println(files[fileIndex]);
57+
5758 String line ;
5859 HashMap <String , String > buf = new HashMap <String , String >();
60+ TestSampler sampler = sampleOnly ? new TestSampler () : null ;
5961 while ((line = bin .readLine ()) != null )
6062 {
6163 line = line .trim ();
@@ -68,18 +70,19 @@ public static void testTestVector(boolean enableFactory, boolean isSigner, Strin
6870 {
6971 if (buf .size () > 0 )
7072 {
71- int count = Integer .parseInt (buf .get ("count" ));
72- // if (count == 99)
73- // {
74- // System.out.println("break");
75- // }
73+ String count = (String )buf .get ("count" );
74+ if (sampler != null && sampler .skipTest (count ))
75+ {
76+ continue ;
77+ }
78+
7679 byte [] seed = Hex .decode ((String )buf .get ("seed" ));
7780 byte [] pk = Hex .decode ((String )buf .get ("pk" ));
7881 byte [] sk = Hex .decode ((String )buf .get ("sk" ));
7982 byte [] message = Hex .decode ((String )buf .get ("msg" ));
8083 byte [] signature = Hex .decode ((String )buf .get ("sm" ));
8184
82- SecureRandom random = operation .getSecureRanom (seed );
85+ SecureRandom random = operation .getSecureRandom (seed );
8386
8487 AsymmetricCipherKeyPairGenerator kpGen = operation .getAsymmetricCipherKeyPairGenerator (fileIndex , random );
8588
0 commit comments