@@ -102,7 +102,7 @@ def _check_pairing_key_slot_access_privileges(
102
102
if address == int (name .rsplit ("_" , maxsplit = 1 )[- 1 ]):
103
103
self .check_access_privileges (name , value )
104
104
return
105
- raise RuntimeError (f"Slot index { address = :#06x} out of range." )
105
+ raise L3ProcessingErrorUnauthorized (f"Slot index { address = :#06x} out of range." )
106
106
107
107
def ts_l3_pairing_key_write (
108
108
self , command : TsL3PairingKeyWriteCommand
@@ -352,6 +352,7 @@ def ts_l3_r_mem_data_write(
352
352
("write_udata_slot_256_383" , config .write_udata_slot_256_383 ),
353
353
("write_udata_slot_384_511" , config .write_udata_slot_384_511 ),
354
354
],
355
+ raise_on_failure = L3ProcessingErrorUnauthorized ,
355
356
)
356
357
357
358
self .logger .debug ("User data slot address: %#06x." , address )
@@ -380,6 +381,7 @@ def ts_l3_r_mem_data_read(
380
381
("read_udata_slot_256_383" , config .read_udata_slot_256_383 ),
381
382
("read_udata_slot_384_511" , config .read_udata_slot_384_511 ),
382
383
],
384
+ raise_on_failure = L3ProcessingErrorUnauthorized ,
383
385
)
384
386
385
387
self .logger .debug ("User data slot address: %#06x." , address )
@@ -400,6 +402,7 @@ def ts_l3_r_mem_data_erase(
400
402
("erase_udata_slot_256_383" , config .erase_udata_slot_256_383 ),
401
403
("erase_udata_slot_384_511" , config .erase_udata_slot_384_511 ),
402
404
],
405
+ raise_on_failure = L3ProcessingErrorUnauthorized ,
403
406
)
404
407
405
408
self .logger .debug ("User data slot address: %#06x." , address )
@@ -513,11 +516,6 @@ def ts_l3_mcounter_get(
513
516
def ts_l3_ecc_key_generate (
514
517
self , command : TsL3EccKeyGenerateCommand
515
518
) -> TsL3EccKeyGenerateResult :
516
- try :
517
- curve = TsL3EccKeyGenerateCommand .CurveEnum (command .curve .value )
518
- except ValueError as exc :
519
- raise L3ProcessingErrorFail (exc ) from None
520
-
521
519
config = self .config .cfg_uap_ecc_key_generate
522
520
self ._check_ranged_access_privileges (
523
521
(slot := command .slot .value ),
@@ -527,9 +525,15 @@ def ts_l3_ecc_key_generate(
527
525
("gen_ecckey_slot_16_23" , config .gen_ecckey_slot_16_23 ),
528
526
("gen_ecckey_slot_24_31" , config .gen_ecckey_slot_24_31 ),
529
527
],
528
+ raise_on_failure = L3ProcessingErrorUnauthorized ,
530
529
)
531
530
532
531
self .logger .debug ("ECC key slot: %d." , slot )
532
+ try :
533
+ curve = TsL3EccKeyGenerateCommand .CurveEnum (command .curve .value )
534
+ except ValueError as exc :
535
+ raise L3ProcessingErrorFail (exc ) from None
536
+
533
537
try :
534
538
self .r_ecc_keys .generate (slot , curve , self .trng2 )
535
539
except ECCKeyExistsInSlotError as exc :
@@ -541,11 +545,6 @@ def ts_l3_ecc_key_generate(
541
545
def ts_l3_ecc_key_store (
542
546
self , command : TsL3EccKeyStoreCommand
543
547
) -> TsL3EccKeyStoreResult :
544
- try :
545
- curve = TsL3EccKeyStoreCommand .CurveEnum (command .curve .value )
546
- except ValueError as exc :
547
- raise L3ProcessingErrorFail (exc ) from None
548
-
549
548
config = self .config .cfg_uap_ecc_key_store
550
549
self ._check_ranged_access_privileges (
551
550
(slot := command .slot .value ),
@@ -555,9 +554,16 @@ def ts_l3_ecc_key_store(
555
554
("store_ecckey_slot_16_23" , config .store_ecckey_slot_16_23 ),
556
555
("store_ecckey_slot_24_31" , config .store_ecckey_slot_24_31 ),
557
556
],
557
+ raise_on_failure = L3ProcessingErrorUnauthorized ,
558
558
)
559
559
560
560
self .logger .debug ("ECC key slot: %d." , slot )
561
+ try :
562
+ curve = TsL3EccKeyStoreCommand .CurveEnum (command .curve .value )
563
+ except ValueError as exc :
564
+ raise L3ProcessingErrorFail (exc ) from None
565
+
566
+
561
567
try :
562
568
self .r_ecc_keys .store (slot , curve , command .k .to_bytes ())
563
569
except (ECCKeyExistsInSlotError , ECCKeySetupError ) as exc :
@@ -578,6 +584,7 @@ def ts_l3_ecc_key_read(
578
584
("read_ecckey_slot_16_23" , config .read_ecckey_slot_16_23 ),
579
585
("read_ecckey_slot_24_31" , config .read_ecckey_slot_24_31 ),
580
586
],
587
+ raise_on_failure = L3ProcessingErrorUnauthorized ,
581
588
)
582
589
583
590
self .logger .debug ("ECC key slot: %d." , slot )
@@ -614,6 +621,7 @@ def ts_l3_ecc_key_erase(
614
621
("erase_ecckey_slot_16_23" , config .erase_ecckey_slot_16_23 ),
615
622
("erase_ecckey_slot_24_31" , config .erase_ecckey_slot_24_31 ),
616
623
],
624
+ raise_on_failure = L3ProcessingErrorUnauthorized ,
617
625
)
618
626
619
627
self .logger .debug ("ECC key slot: %d." , slot )
@@ -632,6 +640,7 @@ def ts_l3_ecdsa_sign(self, command: TsL3EcdsaSignCommand) -> TsL3EcdsaSignResult
632
640
("ecdsa_ecckey_slot_16_23" , config .ecdsa_ecckey_slot_16_23 ),
633
641
("ecdsa_ecckey_slot_24_31" , config .ecdsa_ecckey_slot_24_31 ),
634
642
],
643
+ raise_on_failure = L3ProcessingErrorUnauthorized ,
635
644
)
636
645
637
646
msg_hash = command .msg_hash .to_bytes ()
@@ -671,6 +680,7 @@ def ts_l3_eddsa_sign(self, command: TsL3EddsaSignCommand) -> TsL3EddsaSignResult
671
680
("eddsa_ecckey_slot_16_23" , config .eddsa_ecckey_slot_16_23 ),
672
681
("eddsa_ecckey_slot_24_31" , config .eddsa_ecckey_slot_24_31 ),
673
682
],
683
+ raise_on_failure = L3ProcessingErrorUnauthorized ,
674
684
)
675
685
676
686
msg_bytes = command .msg .to_bytes ()
@@ -710,6 +720,7 @@ def ts_l3_mac_and_destroy(
710
720
("macandd_64_95" , config .macandd_64_95 ),
711
721
("macandd_96_127" , config .macandd_96_127 ),
712
722
],
723
+ raise_on_failure = L3ProcessingErrorUnauthorized ,
713
724
)
714
725
self .logger .info ("Executing Mac-and-Destroy sequence." )
715
726
slot_bytes = bytes ([command .slot .value ])
0 commit comments