File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/python
2
+
3
+ import json
4
+ import sys
5
+ import typing
6
+
7
+ ML_KEM_512_ACVP_KAT_FILE_NAME = "ml_kem_512.acvp.kat"
8
+ ML_KEM_768_ACVP_KAT_FILE_NAME = "ml_kem_768.acvp.kat"
9
+ ML_KEM_1024_ACVP_KAT_FILE_NAME = "ml_kem_1024.acvp.kat"
10
+
11
+ def extract_and_write_ml_kem_keygen_kats (test_group : dict [str , typing .Any ], write_to_file : str ):
12
+ assert test_group ["testType" ] == "AFT"
13
+
14
+ with open (write_to_file , "wt" ) as fd :
15
+ for test in test_group ["tests" ]:
16
+ fd .write (f'd = { test ["d" ]} \n ' )
17
+ fd .write (f'z = { test ["z" ]} \n ' )
18
+ fd .write (f'pk = { test ["ek" ]} \n ' )
19
+ fd .write (f'sk = { test ["dk" ]} \n ' )
20
+
21
+ fd .write ('\n ' )
22
+
23
+ fd .flush ()
24
+
25
+
26
+ def main ():
27
+ json_as_str = ''
28
+ for line in sys .stdin :
29
+ json_as_str += line
30
+
31
+ acvp_kats = json .loads (json_as_str )
32
+
33
+ ml_kem_512_param_set = acvp_kats ["testGroups" ][0 ]
34
+ ml_kem_768_param_set = acvp_kats ["testGroups" ][1 ]
35
+ ml_kem_1024_param_set = acvp_kats ["testGroups" ][2 ]
36
+
37
+ extract_and_write_ml_kem_keygen_kats (ml_kem_512_param_set , ML_KEM_512_ACVP_KAT_FILE_NAME )
38
+ extract_and_write_ml_kem_keygen_kats (ml_kem_768_param_set , ML_KEM_768_ACVP_KAT_FILE_NAME )
39
+ extract_and_write_ml_kem_keygen_kats (ml_kem_1024_param_set , ML_KEM_1024_ACVP_KAT_FILE_NAME )
40
+
41
+
42
+ if __name__ == '__main__' :
43
+ main ()
You can’t perform that action at this time.
0 commit comments