Coverage for tropicsquare / config / uap_ecc.py: 78%

41 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-03-27 21:24 +0000

1"""UAP ECC Key operation configuration classes""" 

2 

3from tropicsquare.config.uap_base import UapMultiSlotConfig, UapPermissionField 

4from tropicsquare.config.constants import ( 

5 UAP_ECCKEY_SLOT_0_7_POS, 

6 UAP_ECCKEY_SLOT_8_15_POS, 

7 UAP_ECCKEY_SLOT_16_23_POS, 

8 UAP_ECCKEY_SLOT_24_31_POS 

9) 

10 

11 

12class EccKeyConfig(UapMultiSlotConfig): 

13 """UAP ECC Key base configuration""" 

14 

15 @property 

16 def ecckey_slot_0_7(self) -> UapPermissionField: 

17 """Permission field for ECC Key slots 0-7.""" 

18 return self._get_slot_field(UAP_ECCKEY_SLOT_0_7_POS) 

19 

20 @ecckey_slot_0_7.setter 

21 def ecckey_slot_0_7(self, field: UapPermissionField) -> None: 

22 self._set_slot_field(UAP_ECCKEY_SLOT_0_7_POS, field) 

23 

24 @property 

25 def ecckey_slot_8_15(self) -> UapPermissionField: 

26 """Permission field for ECC Key slots 8-15.""" 

27 return self._get_slot_field(UAP_ECCKEY_SLOT_8_15_POS) 

28 

29 @ecckey_slot_8_15.setter 

30 def ecckey_slot_8_15(self, field: UapPermissionField) -> None: 

31 self._set_slot_field(UAP_ECCKEY_SLOT_8_15_POS, field) 

32 

33 @property 

34 def ecckey_slot_16_23(self) -> UapPermissionField: 

35 """Permission field for ECC Key slots 16-23.""" 

36 return self._get_slot_field(UAP_ECCKEY_SLOT_16_23_POS) 

37 

38 @ecckey_slot_16_23.setter 

39 def ecckey_slot_16_23(self, field: UapPermissionField) -> None: 

40 self._set_slot_field(UAP_ECCKEY_SLOT_16_23_POS, field) 

41 

42 @property 

43 def ecckey_slot_24_31(self) -> UapPermissionField: 

44 """Permission field for ECC Key slots 24-31.""" 

45 return self._get_slot_field(UAP_ECCKEY_SLOT_24_31_POS) 

46 

47 @ecckey_slot_24_31.setter 

48 def ecckey_slot_24_31(self, field: UapPermissionField) -> None: 

49 self._set_slot_field(UAP_ECCKEY_SLOT_24_31_POS, field) 

50 

51 def to_dict(self) -> dict: 

52 """Export fields as dictionary.""" 

53 return { 

54 'ecckey_slot_0_7': self.ecckey_slot_0_7.to_dict(), 

55 'ecckey_slot_8_15': self.ecckey_slot_8_15.to_dict(), 

56 'ecckey_slot_16_23': self.ecckey_slot_16_23.to_dict(), 

57 'ecckey_slot_24_31': self.ecckey_slot_24_31.to_dict() 

58 } 

59 

60 def __str__(self) -> str: 

61 """Table row with ECC Key slot specific field names.""" 

62 s0 = str(self.ecckey_slot_0_7) 

63 s1 = str(self.ecckey_slot_8_15) 

64 s2 = str(self.ecckey_slot_16_23) 

65 s3 = str(self.ecckey_slot_24_31) 

66 return "{:26s} | {} || {} || {} || {} |".format( 

67 self.__class__.__name__, 

68 s0, s1, s2, s3 

69 ) 

70 

71 

72class EccKeyGenerateConfig(EccKeyConfig): 

73 """UAP ECC Key Generate configuration (CFG_UAP_ECC_KEY_GENERATE @ 0x130). 

74 

75 Controls which pairing key slots can generate ECC keys. 

76 Has 4 permission fields for ECC Key slot groups 0-7, 8-15, 16-23, 24-31. 

77 """ 

78 

79 

80class EccKeyStoreConfig(EccKeyConfig): 

81 """UAP ECC Key Store configuration (CFG_UAP_ECC_KEY_STORE @ 0x134). 

82 

83 Controls which pairing key slots can store ECC keys. 

84 Has 4 permission fields for ECC Key slot groups 0-7, 8-15, 16-23, 24-31. 

85 """ 

86 

87 

88class EccKeyReadConfig(EccKeyConfig): 

89 """UAP ECC Key Read configuration (CFG_UAP_ECC_KEY_READ @ 0x138). 

90 

91 Controls which pairing key slots can read ECC keys. 

92 Has 4 permission fields for ECC Key slot groups 0-7, 8-15, 16-23, 24-31. 

93 """ 

94 

95 

96class EccKeyEraseConfig(EccKeyConfig): 

97 """UAP ECC Key Erase configuration (CFG_UAP_ECC_KEY_ERASE @ 0x13C). 

98 

99 Controls which pairing key slots can erase ECC keys. 

100 Has 4 permission fields for ECC Key slot groups 0-7, 8-15, 16-23, 24-31. 

101 """ 

102 

103 

104class EcdsaSignConfig(EccKeyConfig): 

105 """UAP ECDSA Sign configuration (CFG_UAP_ECDSA_SIGN @ 0x140). 

106 

107 Controls which pairing key slots can perform ECDSA signing. 

108 Has 4 permission fields for ECC Key slot groups 0-7, 8-15, 16-23, 24-31. 

109 """ 

110 

111 

112class EddsaSignConfig(EccKeyConfig): 

113 """UAP EdDSA Sign configuration (CFG_UAP_EDDSA_SIGN @ 0x144). 

114 

115 Controls which pairing key slots can perform EdDSA signing. 

116 Has 4 permission fields for ECC Key slot groups 0-7, 8-15, 16-23, 24-31. 

117 """