From a30c9e487782e1c8c296491ac6efb5bbe725613c Mon Sep 17 00:00:00 2001 From: "Jonas Brand (8R0WNI3)" Date: Fri, 11 Oct 2024 13:26:25 +0200 Subject: [PATCH] Add helper function to parse signing algorithm according to rfc 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 --- model/signing_server.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/model/signing_server.py b/model/signing_server.py index 1fe15e433..00ff689e2 100644 --- a/model/signing_server.py +++ b/model/signing_server.py @@ -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) -> 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: