1+ from communication .sca_hmac_commands import OTHMAC
2+ from communication .sca_prng_commands import OTPRNG
3+ from communication .sca_trigger_commands import OTTRIGGER
4+ from communication .chip import *
5+ from communication .dut import DUT
6+ import time
7+
8+ def char_hmac_single (opentitantool , iterations , trigger , key , text ):
9+ target = DUT ()
10+ reset_target (opentitantool )
11+ # Clear the output from the reset
12+ target .dump_all ()
13+
14+ hmacsca = OTHMAC (target , "ujson" )
15+ # Initialize our chip and catch its output
16+ device_id , owner_page , boot_log , boot_measurements , version = hmacsca .init ()
17+
18+ # Set the trigger
19+ triggersca = OTTRIGGER (target , "ujson" )
20+ triggersca .select_trigger (0 )
21+
22+ for _ in range (iterations ):
23+ hmacsca .single (text , key , trigger )
24+ response = target .read_response ()
25+ return response
26+
27+ def char_hmac_daisy_chain (opentitantool , iterations , num_segments , trigger , key , text ):
28+ target = DUT ()
29+ reset_target (opentitantool )
30+ # Clear the output from the reset
31+ target .dump_all ()
32+
33+ hmacsca = OTHMAC (target , "ujson" )
34+ # Initialize our chip and catch its output
35+ device_id , owner_page , boot_log , boot_measurements , version = hmacsca .init ()
36+
37+ # Set the trigger
38+ triggersca = OTTRIGGER (target , "ujson" )
39+ triggersca .select_trigger (0 )
40+
41+ for _ in range (iterations ):
42+ hmacsca .daisy_chain (text , key , num_segments , trigger )
43+ response = target .read_response ()
44+ return response
45+
46+ def char_hmac_random_batch (opentitantool , iterations , num_segments , trigger ):
47+ target = DUT ()
48+ reset_target (opentitantool )
49+ # Clear the output from the reset
50+ target .dump_all ()
51+
52+ hmacsca = OTHMAC (target , "ujson" )
53+ # Initialize our chip and catch its output
54+ device_id , owner_page , boot_log , boot_measurements , version = hmacsca .init ()
55+
56+ # Set the trigger
57+ triggersca = OTTRIGGER (target , "ujson" )
58+ triggersca .select_trigger (0 )
59+
60+ # Set the internal prng
61+ ot_prng = OTPRNG (target = target , protocol = "ujson" )
62+ ot_prng .seed_prng ([0 ,0 ,0 ,0 ])
63+
64+ for _ in range (iterations ):
65+ hmacsca .random_batch (num_segments , trigger )
66+ response = target .read_response ()
67+ return response
68+
69+ def char_hmac_fvsr_batch (opentitantool , iterations , num_segments , trigger , key ):
70+ target = DUT ()
71+ reset_target (opentitantool )
72+ # Clear the output from the reset
73+ target .dump_all ()
74+
75+ hmacsca = OTHMAC (target , "ujson" )
76+ # Initialize our chip and catch its output
77+ device_id , owner_page , boot_log , boot_measurements , version = hmacsca .init ()
78+
79+ # Set the trigger
80+ triggersca = OTTRIGGER (target , "ujson" )
81+ triggersca .select_trigger (0 )
82+
83+ # Set the internal prng
84+ ot_prng = OTPRNG (target = target , protocol = "ujson" )
85+ ot_prng .seed_prng ([0 ,0 ,0 ,0 ])
86+
87+ for _ in range (iterations ):
88+ hmacsca .fvsr_batch (key , num_segments , trigger )
89+ response = target .read_response ()
90+ return response
0 commit comments