Skip to content

Commit

Permalink
Add helper function to parse signing algorithm according to rfc
Browse files Browse the repository at this point in the history
Altough it is an option, it may not be beneficial to directly adjust the
enum to mirror the standard described in the rfc because
(1) existing cosign signatures would not be reused but instead new
signatures would be appended because it seems the algorithm had changed
(2) OCM cli expects algorithms to be upper case
  • Loading branch information
8R0WNI3 committed Oct 11, 2024
1 parent a0cd371 commit 077898b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions model/signing_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ class SigningAlgorithm(enum.StrEnum):
RSASSA_PSS = 'rsassa-pss'
RSASSA_PKCS1_V1_5 = 'rsassa-pkcs1-v1_5'

@staticmethod
def as_rfc_standard(algorithm: 'SigningAlgorithm') -> str:
# parses the algorithm to the standard format described in
# https://datatracker.ietf.org/doc/html/rfc3447
algorithm = SigningAlgorithm(algorithm.lower())
if algorithm is SigningAlgorithm.RSASSA_PSS:
return 'RSASSA-PSS'
elif algorithm is SigningAlgorithm.RSASSA_PKCS1_V1_5:
return 'RSASSA-PKCS1-v1_5'
else:
raise NotImplementedError(algorithm)


class SigningServerEndpoint(NamedModelElement):
def url(self) -> str:
Expand Down

0 comments on commit 077898b

Please sign in to comment.