File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 3535from cryptography .x509 .oid import ExtendedKeyUsageOID , ExtensionOID
3636
3737from sigstore .errors import Error
38+ from sigstore_protobuf_specs .dev .sigstore .common .v1 import HashAlgorithm
3839
3940if sys .version_info < (3 , 11 ):
4041 import importlib_resources as resources
@@ -158,6 +159,12 @@ def key_id(key: PublicKey) -> KeyID:
158159
159160 return KeyID (hashlib .sha256 (public_bytes ).digest ())
160161
162+ def hazmat_digest_to_bundle (algo : str ):
163+ lookup = {"sha256" : HashAlgorithm .SHA2_256 }
164+ if algo in lookup :
165+ return lookup [algo ]
166+ return algo
167+
161168def get_digest (
162169 input_ : IO [bytes ],
163170 algorithm_ : Prehashed = None ,
Original file line number Diff line number Diff line change 6363 cert_is_leaf ,
6464 cert_is_root_ca ,
6565 get_digest ,
66+ hazmat_digest_to_bundle ,
6667)
6768from sigstore .errors import Error
6869from sigstore .transparency import LogEntry , LogInclusionProof
@@ -518,7 +519,7 @@ def to_bundle(self) -> Bundle:
518519 ),
519520 message_signature = MessageSignature (
520521 message_digest = HashOutput (
521- algorithm = HashAlgorithm . SHA2_256 ,
522+ algorithm = hazmat_digest_to_bundle ( self . digest_algorithm . _algorithm . name ) ,
522523 digest = self .input_digest ,
523524 ),
524525 signature = self .signature ,
You can’t perform that action at this time.
0 commit comments