Skip to content

Commit f80d21f

Browse files
siemen11nasahlpa
authored andcommitted
[pentest] Reformat cryptolib pentest functions
Source format the python files in host penetrationtests. Signed-off-by: Siemen Dhooghe <[email protected]>
1 parent d404a43 commit f80d21f

File tree

10 files changed

+47
-158
lines changed

10 files changed

+47
-158
lines changed

sw/host/penetrationtests/python/fi/communication/fi_asym_cryptolib_commands.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
Communication with OpenTitan happens over the uJSON command interface.
77
"""
8+
89
import json
910
import time
1011
from sw.host.penetrationtests.python.util import common_library

sw/host/penetrationtests/python/fi/communication/fi_sym_cryptolib_commands.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
Communication with OpenTitan happens over the uJSON command interface.
77
"""
8+
89
import json
910
import time
1011
from sw.host.penetrationtests.python.util import common_library
@@ -94,9 +95,7 @@ def handle_aes(
9495
}
9596
self.target.write(json.dumps(input_data).encode("ascii"))
9697

97-
def handle_cmac(
98-
self, data, data_len, key, key_len, iv, cfg, trigger
99-
) -> None:
98+
def handle_cmac(self, data, data_len, key, key_len, iv, cfg, trigger) -> None:
10099
"""Call the cryptolib CMAC.
101100
102101
Args:
@@ -186,7 +185,15 @@ def handle_hmac(
186185
self.target.write(json.dumps(input_data).encode("ascii"))
187186

188187
def handle_drbg_reseed(
189-
self, entropy, entropy_len, nonce, nonce_len, reseed_interval, mode, cfg, trigger
188+
self,
189+
entropy,
190+
entropy_len,
191+
nonce,
192+
nonce_len,
193+
reseed_interval,
194+
mode,
195+
cfg,
196+
trigger,
190197
) -> None:
191198
"""Call the cryptolib DRBG to reseed.
192199
@@ -240,9 +247,7 @@ def handle_drbg_generate(
240247
}
241248
self.target.write(json.dumps(input_data).encode("ascii"))
242249

243-
def handle_trng_init(
244-
self, mode, cfg, trigger
245-
) -> None:
250+
def handle_trng_init(self, mode, cfg, trigger) -> None:
246251
"""Call the cryptolib TRNG to init.
247252
248253
Args:
@@ -259,9 +264,7 @@ def handle_trng_init(
259264
}
260265
self.target.write(json.dumps(input_data).encode("ascii"))
261266

262-
def handle_trng_generate(
263-
self, cfg, trigger
264-
) -> None:
267+
def handle_trng_generate(self, cfg, trigger) -> None:
265268
"""Call the cryptolib TRNG to generate randomness.
266269
267270
Args:

sw/host/penetrationtests/python/fi/test_scripts/fi_asym_cryptolib_python_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939

4040
class SymCryptolibFiTest(unittest.TestCase):
41-
4241
def test_init(self):
4342
asymfi = OTFIAsymCrypto(target)
4443
device_id, sensors, alerts, owner_page, boot_log, boot_measurements, version = (

sw/host/penetrationtests/python/fi/test_scripts/fi_sym_cryptolib_python_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737

3838

3939
class SymCryptolibFiTest(unittest.TestCase):
40-
4140
def test_init(self):
4241
symfi = OTFISymCrypto(target)
4342
device_id, sensors, alerts, owner_page, boot_log, boot_measurements, version = (

sw/host/penetrationtests/python/sca/communication/sca_asym_cryptolib_commands.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Communication with OpenTitan happens over the uJson
77
command interface.
88
"""
9+
910
import json
1011
import time
1112
from sw.host.penetrationtests.python.util import common_library
@@ -94,17 +95,7 @@ def handle_rsa_dec(
9495
self.target.write(json.dumps(input_data).encode("ascii"))
9596

9697
def handle_rsa_sign(
97-
self,
98-
data,
99-
data_len,
100-
e,
101-
n,
102-
n_len,
103-
d,
104-
padding,
105-
hashing,
106-
cfg,
107-
trigger
98+
self, data, data_len, e, n, n_len, d, padding, hashing, cfg, trigger
10899
) -> None:
109100
"""Call the cryptolib RSA to sign.
110101
@@ -168,7 +159,7 @@ def handle_p256_base_mult_fvsr(self, scalar, cfg, trigger, num_iterations) -> No
168159
"scalar": scalar,
169160
"cfg": cfg,
170161
"trigger": trigger,
171-
"num_iterations": num_iterations
162+
"num_iterations": num_iterations,
172163
}
173164
self.target.write(json.dumps(input_data).encode("ascii"))
174165

@@ -187,7 +178,7 @@ def handle_p256_base_mult_daisy(self, scalar, cfg, trigger, num_iterations) -> N
187178
"scalar": scalar,
188179
"cfg": cfg,
189180
"trigger": trigger,
190-
"num_iterations": num_iterations
181+
"num_iterations": num_iterations,
191182
}
192183
self.target.write(json.dumps(input_data).encode("ascii"))
193184

@@ -269,7 +260,7 @@ def handle_p384_base_mult_fvsr(self, scalar, cfg, trigger, num_iterations) -> No
269260
"scalar": scalar,
270261
"cfg": cfg,
271262
"trigger": trigger,
272-
"num_iterations": num_iterations
263+
"num_iterations": num_iterations,
273264
}
274265
self.target.write(json.dumps(input_data).encode("ascii"))
275266

@@ -288,7 +279,7 @@ def handle_p384_base_mult_daisy(self, scalar, cfg, trigger, num_iterations) -> N
288279
"scalar": scalar,
289280
"cfg": cfg,
290281
"trigger": trigger,
291-
"num_iterations": num_iterations
282+
"num_iterations": num_iterations,
292283
}
293284
self.target.write(json.dumps(input_data).encode("ascii"))
294285

sw/host/penetrationtests/python/sca/communication/sca_sym_cryptolib_commands.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Communication with OpenTitan happens over the uJson
77
command interface.
88
"""
9+
910
import json
1011
import time
1112
from sw.host.penetrationtests.python.util import common_library

0 commit comments

Comments
 (0)