Skip to content

Commit

Permalink
PSS salt Auto error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Lion Holler committed Jun 28, 2024
1 parent c6d2729 commit 8c0ff83
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion securesystemslib/signer/_crypto_signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def __init__(
raise ValueError(f"invalid rsa key: {type(private_key)}")

hash_algo = public_key.get_hash_algorithm()
padding = public_key.get_padding_name(hash_algo)
padding = public_key.get_padding_name(hash_algo, False)
self._sign_args = _RSASignArgs(padding, hash_algo)
self._private_key = private_key

Expand Down
4 changes: 3 additions & 1 deletion securesystemslib/signer/_gpg_signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ def get_hash_algorithm(self) -> None:
def get_padding_name_str(self) -> None:
raise NotImplementedError

def get_padding_name(self, hash_algorithm: None) -> None:
def get_padding_name(
self, hash_algorithm: None, pss_salt_auto: bool
) -> None:
raise NotImplementedError


Expand Down
13 changes: 8 additions & 5 deletions securesystemslib/signer/_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def get_padding_name_str(self) -> Any:
raise NotImplementedError

@abstractmethod
def get_padding_name(self, hash_algorithm: Any) -> Any:
def get_padding_name(self, hash_algorithm: Any, pss_salt: bool) -> Any:
"""Return payload padding name used for this key as a AsymmetricPadding"""

raise NotImplementedError
Expand Down Expand Up @@ -475,17 +475,20 @@ def get_hash_algorithm(self) -> "HashAlgorithm":

def get_padding_name_str(self) -> str:
padding_name = self.scheme.split("-")[1]

return padding_name

def get_padding_name(
self, hash_algorithm: "HashAlgorithm"
self, hash_algorithm: "HashAlgorithm", pss_salt_auto=True
) -> "AsymmetricPadding":
name = self.get_padding_name_str()
padding: AsymmetricPadding
if name == "pss":
padding = PSS(mgf=MGF1(hash_algorithm), salt_length=PSS.AUTO)

if pss_salt_auto:
padding = PSS(mgf=MGF1(hash_algorithm), salt_length=PSS.AUTO)
else:
padding = PSS(
mgf=MGF1(hash_algorithm), salt_length=PSS.DIGEST_LENGTH
)
if name == "pkcs1v15":
padding = PKCS1v15()

Expand Down
4 changes: 3 additions & 1 deletion securesystemslib/signer/_sigstore_signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ def get_hash_algorithm(self) -> None:
def get_padding_name_str(self) -> None:
raise NotImplementedError

def get_padding_name(self, hash_algorithm: None) -> None:
def get_padding_name(
self, hash_algorithm: None, pss_salt_auto: bool
) -> None:
raise NotImplementedError


Expand Down
4 changes: 3 additions & 1 deletion securesystemslib/signer/_spx_signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def get_hash_algorithm(self) -> None:
def get_padding_name_str(self) -> None:
raise NotImplementedError

def get_padding_name(self, hash_algorithm: None) -> None:
def get_padding_name(
self, hash_algorithm: None, pss_salt_auto: bool
) -> None:
raise NotImplementedError


Expand Down

0 comments on commit 8c0ff83

Please sign in to comment.