File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -335,11 +335,24 @@ class InvalidEncodedSignatureError(DSKEException):
335335 def __init__ (self , encoded_signature : str ):
336336 super ().__init__ (
337337 status_code = status .HTTP_400_BAD_REQUEST ,
338- message = "Invalid encoded fragment ." ,
338+ message = "Invalid encoded signature ." ,
339339 details = {"encoded_signature" : encoded_signature },
340340 )
341341
342342
343+ class InvalidEncodedSigningKeyError (DSKEException ):
344+ """
345+ Exception raised when trying to parse an encoded signing key string that is invalid.
346+ """
347+
348+ def __init__ (self , encoded_signing_key : str ):
349+ super ().__init__ (
350+ status_code = status .HTTP_400_BAD_REQUEST ,
351+ message = "Invalid encoded signing key." ,
352+ details = {"encoded_signing_key" : encoded_signing_key },
353+ )
354+
355+
343356class EncryptorNotRegisteredForClientError (DSKEException ):
344357 """
345358 Exception raised when an encryptor is not registered for a client.
Original file line number Diff line number Diff line change 55import hashlib
66import hmac
77from .allocation import Allocation
8+ from .exceptions import InvalidEncodedSigningKeyError
89from .pool import Pool
910from .signature import Signature
1011from .utils import bytes_to_str , str_to_bytes
@@ -98,7 +99,7 @@ def from_enc_str(cls, enc_str: str) -> "SigningKey":
9899 """
99100 split_str = enc_str .split (_ENCODING_SEPARATOR )
100101 if len (split_str ) != 2 :
101- assert False # TODO: Raise an exception instead
102+ raise InvalidEncodedSigningKeyError ( enc_str )
102103 allocation_enc_str = split_str [0 ]
103104 key_data_str = split_str [1 ]
104105 key_data = str_to_bytes (key_data_str )
You can’t perform that action at this time.
0 commit comments