@@ -667,15 +667,19 @@ def certificate_extension(self) -> Optional[str]:
667
667
def certificate_extension (self , certificate_extension : Optional [str ]) -> None :
668
668
self ._certificate_extension = certificate_extension
669
669
670
+ def __comparable_tuple (self ) -> _ComparableTuple :
671
+ return _ComparableTuple ((
672
+ self .subject_name , self .issuer_name , self .not_valid_before , self .not_valid_after ,
673
+ self .certificate_format , self .certificate_extension
674
+ ))
675
+
670
676
def __eq__ (self , other : object ) -> bool :
671
677
if isinstance (other , CertificateProperties ):
672
- return hash ( other ) == hash ( self )
678
+ return self . __comparable_tuple ( ) == other . __comparable_tuple ( )
673
679
return False
674
680
675
681
def __hash__ (self ) -> int :
676
- # TODO
677
- return hash ((self .subject_name , self .issuer_name , self .not_valid_before , self .not_valid_after ,
678
- self .certificate_format , self .certificate_extension ))
682
+ return hash (self .__comparable_tuple ())
679
683
680
684
def __repr__ (self ) -> str :
681
685
return f'<CertificateProperties subject_name={ self .subject_name } , certificate_format={ self .certificate_format } >'
@@ -791,14 +795,18 @@ def algorithm_ref(self) -> Optional[BomRef]:
791
795
def algorithm_ref (self , algorithm_ref : Optional [BomRef ]) -> None :
792
796
self ._algorithm_ref = algorithm_ref
793
797
798
+ def __comparable_tuple (self ) -> _ComparableTuple :
799
+ return _ComparableTuple ((
800
+ self .mechanism , self .algorithm_ref
801
+ ))
802
+
794
803
def __eq__ (self , other : object ) -> bool :
795
804
if isinstance (other , RelatedCryptoMaterialSecuredBy ):
796
- return hash ( other ) == hash ( self )
805
+ return self . __comparable_tuple ( ) == other . __comparable_tuple ( )
797
806
return False
798
807
799
808
def __hash__ (self ) -> int :
800
- # TODO
801
- return hash ((self .mechanism , self .algorithm_ref ))
809
+ return hash (self .__comparable_tuple ())
802
810
803
811
def __repr__ (self ) -> str :
804
812
return f'<RelatedCryptoMaterialSecuredBy mechanism={ self .mechanism } , algorithm_ref={ self .algorithm_ref } >'
@@ -1031,15 +1039,19 @@ def secured_by(self) -> Optional[RelatedCryptoMaterialSecuredBy]:
1031
1039
def secured_by (self , secured_by : Optional [RelatedCryptoMaterialSecuredBy ]) -> None :
1032
1040
self ._secured_by = secured_by
1033
1041
1042
+ def __comparable_tuple (self ) -> _ComparableTuple :
1043
+ return _ComparableTuple ((
1044
+ self .type , self .id , self .state , self .algorithm_ref , self .creation_date , self .activation_date ,
1045
+ self .update_date , self .expiration_date , self .value , self .size , self .format , self .secured_by
1046
+ ))
1047
+
1034
1048
def __eq__ (self , other : object ) -> bool :
1035
1049
if isinstance (other , RelatedCryptoMaterialProperties ):
1036
- return hash ( other ) == hash ( self )
1050
+ return self . __comparable_tuple ( ) == other . __comparable_tuple ( )
1037
1051
return False
1038
1052
1039
1053
def __hash__ (self ) -> int :
1040
- # TODO
1041
- return hash ((self .type , self .id , self .state , self .algorithm_ref , self .creation_date , self .activation_date ,
1042
- self .update_date , self .expiration_date , self .value , self .size , self .format , self .secured_by ))
1054
+ return hash (self .__comparable_tuple ())
1043
1055
1044
1056
def __repr__ (self ) -> str :
1045
1057
return f'<RelatedCryptoMaterialProperties type={ self .type } , id={ self .id } state={ self .state } >'
@@ -1140,23 +1152,23 @@ def identifiers(self) -> 'SortedSet[str]':
1140
1152
def identifiers (self , identifiers : Iterable [str ]) -> None :
1141
1153
self ._identifiers = SortedSet (identifiers )
1142
1154
1155
+ def __comparable_tuple (self ) -> _ComparableTuple :
1156
+ return _ComparableTuple ((
1157
+ self .name , _ComparableTuple (self .algorithms ), _ComparableTuple (self .identifiers )
1158
+ ))
1159
+
1143
1160
def __eq__ (self , other : object ) -> bool :
1144
1161
if isinstance (other , ProtocolPropertiesCipherSuite ):
1145
- return hash ( other ) == hash ( self )
1162
+ return self . __comparable_tuple ( ) == other . __comparable_tuple ( )
1146
1163
return False
1147
1164
1148
1165
def __lt__ (self , other : Any ) -> bool :
1149
1166
if isinstance (other , ProtocolPropertiesCipherSuite ):
1150
- return _ComparableTuple ((
1151
- self .name , _ComparableTuple (self .algorithms ), _ComparableTuple (self .identifiers )
1152
- )) < _ComparableTuple ((
1153
- other .name , _ComparableTuple (other .algorithms ), _ComparableTuple (other .identifiers )
1154
- ))
1167
+ return self .__comparable_tuple () < other .__comparable_tuple ()
1155
1168
return NotImplemented
1156
1169
1157
1170
def __hash__ (self ) -> int :
1158
- # TODO
1159
- return hash ((self .name , tuple (self .algorithms ), tuple (self .identifiers )))
1171
+ return hash (self .__comparable_tuple ())
1160
1172
1161
1173
def __repr__ (self ) -> str :
1162
1174
return f'<ProtocolPropertiesCipherSuite name={ self .name } >'
@@ -1282,14 +1294,23 @@ def auth(self) -> 'SortedSet[BomRef]':
1282
1294
def auth (self , auth : Iterable [BomRef ]) -> None :
1283
1295
self ._auth = SortedSet (auth )
1284
1296
1297
+ def __comparable_tuple (self ) -> _ComparableTuple :
1298
+ return _ComparableTuple ((
1299
+ _ComparableTuple (self .encr ),
1300
+ _ComparableTuple (self .prf ),
1301
+ _ComparableTuple (self .integ ),
1302
+ _ComparableTuple (self .ke ),
1303
+ self .esn ,
1304
+ _ComparableTuple (self .auth )
1305
+ ))
1306
+
1285
1307
def __eq__ (self , other : object ) -> bool :
1286
1308
if isinstance (other , Ikev2TransformTypes ):
1287
- return hash ( other ) == hash ( self )
1309
+ return self . __comparable_tuple ( ) == other . __comparable_tuple ( )
1288
1310
return False
1289
1311
1290
1312
def __hash__ (self ) -> int :
1291
- # TODO
1292
- return hash ((tuple (self .encr ), tuple (self .prf ), tuple (self .integ ), tuple (self .ke ), self .esn , tuple (self .auth )))
1313
+ return hash (self .__comparable_tuple ())
1293
1314
1294
1315
def __repr__ (self ) -> str :
1295
1316
return f'<Ikev2TransformTypes esn={ self .esn } >'
@@ -1382,14 +1403,18 @@ def ikev2_transform_types(self) -> Optional[Ikev2TransformTypes]:
1382
1403
def ikev2_transform_types (self , ikev2_transform_types : Optional [Ikev2TransformTypes ]) -> None :
1383
1404
self ._ikev2_transform_types = ikev2_transform_types
1384
1405
1406
+ def __comparable_tuple (self ) -> _ComparableTuple :
1407
+ return _ComparableTuple ((
1408
+ self .type , self .version , _ComparableTuple (self .cipher_suites ), self .ikev2_transform_types
1409
+ ))
1410
+
1385
1411
def __eq__ (self , other : object ) -> bool :
1386
1412
if isinstance (other , ProtocolProperties ):
1387
- return hash ( other ) == hash ( self )
1413
+ return self . __comparable_tuple ( ) == other . __comparable_tuple ( )
1388
1414
return False
1389
1415
1390
1416
def __hash__ (self ) -> int :
1391
- # TODO
1392
- return hash ((self .type , self .version , tuple (self .cipher_suites ), self .ikev2_transform_types ))
1417
+ return hash (self .__comparable_tuple ())
1393
1418
1394
1419
def __repr__ (self ) -> str :
1395
1420
return f'<ProtocolProperties type={ self .type } , version={ self .version } >'
@@ -1520,34 +1545,28 @@ def oid(self) -> Optional[str]:
1520
1545
def oid (self , oid : Optional [str ]) -> None :
1521
1546
self ._oid = oid
1522
1547
1548
+ def __comparable_tuple (self ) -> _ComparableTuple :
1549
+ return _ComparableTuple ((
1550
+ self .asset_type ,
1551
+ self .algorithm_properties ,
1552
+ self .certificate_properties ,
1553
+ self .related_crypto_material_properties ,
1554
+ self .protocol_properties ,
1555
+ self .oid ,
1556
+ ))
1557
+
1523
1558
def __eq__ (self , other : object ) -> bool :
1524
1559
if isinstance (other , CryptoProperties ):
1525
- return hash ( other ) == hash ( self )
1560
+ return self . __comparable_tuple ( ) == other . __comparable_tuple ( )
1526
1561
return False
1527
1562
1528
1563
def __lt__ (self , other : Any ) -> bool :
1529
1564
if isinstance (other , CryptoProperties ):
1530
- return _ComparableTuple ((
1531
- self .asset_type ,
1532
- self .algorithm_properties ,
1533
- self .certificate_properties ,
1534
- self .related_crypto_material_properties ,
1535
- self .protocol_properties ,
1536
- self .oid ,
1537
- )) < _ComparableTuple ((
1538
- other .asset_type ,
1539
- other .algorithm_properties ,
1540
- other .certificate_properties ,
1541
- other .related_crypto_material_properties ,
1542
- other .protocol_properties ,
1543
- other .oid ,
1544
- ))
1565
+ return self .__comparable_tuple () < other .__comparable_tuple ()
1545
1566
return NotImplemented
1546
1567
1547
1568
def __hash__ (self ) -> int :
1548
- # TODO
1549
- return hash ((self .asset_type , self .algorithm_properties , self .certificate_properties ,
1550
- self .related_crypto_material_properties , self .protocol_properties , self .oid ))
1569
+ return hash (self .__comparable_tuple ())
1551
1570
1552
1571
def __repr__ (self ) -> str :
1553
1572
return f'<CryptoProperties asset_type={ self .asset_type } , oid={ self .oid } >'
0 commit comments