Skip to content

Commit 9424db5

Browse files
committed
Remove oneliner methods in azure and gcp signers
Signed-off-by: Lukas Puehringer <[email protected]>
1 parent 5fbeeaf commit 9424db5

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

securesystemslib/signer/_azure_signer.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ def __init__(self, az_key_uri: str, public_key: SSlibKey):
9696
az_key_uri,
9797
credential=cred,
9898
)
99-
self.signature_algorithm = self._get_signature_algorithm(
100-
public_key.scheme,
101-
)
99+
self.signature_algorithm = SIGNATURE_ALGORITHMS[public_key.scheme]
102100
self.hash_algorithm = public_key.get_hash_algorithm_name()
103101
self._public_key = public_key
104102

@@ -145,11 +143,6 @@ def _create_crypto_client(
145143
)
146144
raise e
147145

148-
@staticmethod
149-
def _get_signature_algorithm(scheme: str) -> SignatureAlgorithm:
150-
"""Return SignatureAlgorithm after parsing the public key"""
151-
return SIGNATURE_ALGORITHMS[scheme]
152-
153146
@staticmethod
154147
def _get_keytype_and_scheme(crv: str) -> tuple[str, str]:
155148
try:

securesystemslib/signer/_gcp_signer.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def import_(cls, gcp_keyid: str) -> tuple[str, SSlibKey]:
149149
request = {"name": gcp_keyid}
150150
kms_pubkey = client.get_public_key(request)
151151
try:
152-
keytype, scheme = cls._get_keytype_and_scheme(kms_pubkey.algorithm)
152+
keytype, scheme = KEYTYPES_AND_SCHEMES[kms_pubkey.algorithm]
153153
except KeyError as e:
154154
raise exceptions.UnsupportedAlgorithmError(
155155
f"{kms_pubkey.algorithm} is not a supported signing algorithm"
@@ -161,11 +161,6 @@ def import_(cls, gcp_keyid: str) -> tuple[str, SSlibKey]:
161161

162162
return f"{cls.SCHEME}:{gcp_keyid}", public_key
163163

164-
@staticmethod
165-
def _get_keytype_and_scheme(algorithm: int) -> tuple[str, str]:
166-
"""Return keytype and scheme for the KMS algorithm enum"""
167-
return KEYTYPES_AND_SCHEMES[algorithm]
168-
169164
def sign(self, payload: bytes) -> Signature:
170165
"""Signs payload with Google Cloud KMS.
171166

0 commit comments

Comments
 (0)