From 634fff1238c8e9d105fc1abb25cbc693259dd879 Mon Sep 17 00:00:00 2001 From: m32 Date: Tue, 5 Mar 2024 14:25:38 +0100 Subject: [PATCH] #161 --- endesive/signer.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/endesive/signer.py b/endesive/signer.py index e041883..7294262 100644 --- a/endesive/signer.py +++ b/endesive/signer.py @@ -152,13 +152,14 @@ def sign( ) else: md = getattr(hashes, hashalgo.upper()) - if hsm is not None: - salt_length = md.digest_size - elif isinstance(key, keys.PrivateKeyInfo): + if isinstance(key, keys.PrivateKeyInfo): salt_length = key.byte_size - md.digest_size - 2 salt_length = md.digest_size else: - salt_length = padding.calculate_max_pss_salt_length(key, md) + if key is None: + salt_length = md.digest_size + else: + salt_length = padding.calculate_max_pss_salt_length(key, md) signer["signature_algorithm"] = algos.SignedDigestAlgorithm( { "algorithm": "rsassa_pss",