@@ -143,11 +143,12 @@ def print_verify_test(case, n, e):
143
143
print ('Result = %s' % case ['Result' ])
144
144
print ('' )
145
145
146
- def main (fn , test_type , padding_alg ):
146
+ def main (fn , test_type , padding_alg , alg ):
147
147
input_file_digest = hashlib .sha384 (open (fn , 'rb' ).read ()).hexdigest ()
148
148
# File header
149
149
print ("# RSA %(padding_alg)s Test Vectors for FIPS 186-4 from %(fn)s in" % \
150
150
{ "fn" : fn , "padding_alg" : padding_alg })
151
+ print ("# http://csrc.nist.gov/groups/STM/cavp/documents/dss/186-2rsatestvectors.zip" )
151
152
print ("# http://csrc.nist.gov/groups/STM/cavp/documents/dss/186-3rsatestvectors.zip" )
152
153
print ("# accessible from" )
153
154
print ("# http://csrc.nist.gov/groups/STM/cavp/digital-signatures.html#test-vectors" )
@@ -180,6 +181,10 @@ def main(fn, test_type, padding_alg):
180
181
last_field = "S"
181
182
182
183
for case in parse (fn , last_field ):
184
+ if alg is not None and case ['SHAAlg' ] != alg :
185
+ debug ("Skipping filtered algorithm" , DEBUG )
186
+ continue
187
+
183
188
if case ['SHAAlg' ] == 'SHA224' :
184
189
# SHA224 not supported in *ring*.
185
190
debug ("Skipping due to use of SHA224" , DEBUG )
@@ -223,10 +228,11 @@ def main(fn, test_type, padding_alg):
223
228
debug ("%d test cases output." % num_cases , True )
224
229
225
230
if __name__ == '__main__' :
226
- if len (sys .argv ) != 2 :
227
- print ("Usage:\n python %s <filename>" % sys .argv [0 ])
231
+ if len (sys .argv ) not in [ 2 , 3 ] :
232
+ print ("Usage:\n python %s <filename> [algorithm] " % sys .argv [0 ])
228
233
else :
229
234
fn = sys .argv [1 ]
235
+ alg = sys .argv [2 ] if len (sys .argv ) > 2 else None
230
236
if 'PSS' in fn :
231
237
pad_alg = 'PSS'
232
238
elif '15' in fn :
@@ -243,4 +249,4 @@ def main(fn, test_type, padding_alg):
243
249
print ("Could not determine test type." )
244
250
quit ()
245
251
246
- main (sys .argv [1 ], test_type , pad_alg )
252
+ main (sys .argv [1 ], test_type , pad_alg , alg )
0 commit comments