@@ -57,6 +57,7 @@ def __init__(self, sha_type: t.Literal[256, 384, 512], recommended: bool = False
5757 self .description = f"HMAC using SHA-{ sha_type } "
5858 self .recommended = recommended
5959 self .hash_alg = getattr (self , f"SHA{ sha_type } " )
60+ self .algorithm_security = sha_type
6061
6162 def sign (self , msg : bytes , key : OctKey ) -> bytes :
6263 # it is faster than the one in cryptography
@@ -89,6 +90,7 @@ def __init__(self, sha_type: t.Literal[256, 384, 512], recommended: bool = False
8990 self .description = f"RSASSA-PKCS1-v1_5 using SHA-{ sha_type } "
9091 self .recommended = recommended
9192 self .hash_alg = getattr (self , f"SHA{ sha_type } " )
93+ self .algorithm_security = sha_type
9294
9395 def sign (self , msg : bytes , key : RSAKey ) -> bytes :
9496 op_key = key .get_op_key ("sign" )
@@ -103,7 +105,7 @@ def verify(self, msg: bytes, sig: bytes, key: RSAKey) -> bool:
103105 return False
104106
105107
106- class ECAlgorithm (JWSAlgModel ):
108+ class ESAlgorithm (JWSAlgModel ):
107109 """ECDSA using SHA algorithms for JWS. Available algorithms:
108110
109111 - ES256: ECDSA using P-256 and SHA-256
@@ -123,6 +125,7 @@ def __init__(self, name: str, curve: str, sha_type: t.Literal[256, 384, 512], re
123125 self .description = f"ECDSA using { self .curve } and SHA-{ sha_type } "
124126 self .recommended = recommended
125127 self .hash_alg = getattr (self , f"SHA{ sha_type } " )
128+ self .algorithm_security = sha_type
126129
127130 def check_key (self , key : ECKey ) -> None :
128131 super ().check_key (key )
@@ -174,6 +177,7 @@ def __init__(self, sha_type: t.Literal[256, 384, 512]):
174177 self .description = f"RSASSA-PSS using SHA-{ sha_type } and MGF1 with SHA-{ sha_type } "
175178 self .hash_alg = getattr (self , f"SHA{ sha_type } " )
176179 self .padding = padding .PSS (mgf = padding .MGF1 (self .hash_alg ()), salt_length = self .hash_alg .digest_size )
180+ self .algorithm_security = sha_type
177181
178182 def sign (self , msg : bytes , key : RSAKey ) -> bytes :
179183 op_key = key .get_op_key ("sign" )
@@ -196,9 +200,9 @@ def verify(self, msg: bytes, sig: bytes, key: RSAKey) -> bool:
196200 RSAAlgorithm (256 , True ), # RS256
197201 RSAAlgorithm (384 ), # RS384
198202 RSAAlgorithm (512 ), # RS512
199- ECAlgorithm ("ES256" , "P-256" , 256 , True ),
200- ECAlgorithm ("ES384" , "P-384" , 384 ),
201- ECAlgorithm ("ES512" , "P-521" , 512 ),
203+ ESAlgorithm ("ES256" , "P-256" , 256 , True ),
204+ ESAlgorithm ("ES384" , "P-384" , 384 ),
205+ ESAlgorithm ("ES512" , "P-521" , 512 ),
202206 RSAPSSAlgorithm (256 ), # PS256
203207 RSAPSSAlgorithm (384 ), # PS384
204208 RSAPSSAlgorithm (512 ), # PS512
@@ -208,5 +212,5 @@ def verify(self, msg: bytes, sig: bytes, key: RSAKey) -> bool:
208212NoneAlgModel = NoneAlgorithm
209213HMACAlgModel = HMACAlgorithm
210214RSAAlgModel = RSAAlgorithm
211- ECAlgModel = ECAlgorithm
215+ ECAlgModel = ESAlgorithm
212216RSAPSSAlgModel = RSAPSSAlgorithm
0 commit comments