File tree Expand file tree Collapse file tree 5 files changed +7
-21
lines changed
Expand file tree Collapse file tree 5 files changed +7
-21
lines changed Original file line number Diff line number Diff line change @@ -686,7 +686,7 @@ def _sign(args: argparse.Namespace) -> None:
686686 with signing_ctx .signer (identity ) as signer :
687687 for file , outputs in output_map .items ():
688688 logger .debug (f"signing for { file .name } " )
689- with file .open (mode = "rb" , buffering = 0 ) as io :
689+ with file .open (mode = "rb" , buffering = 0 ) as fio :
690690 try :
691691 result = signer .sign (input_ = io )
692692 except ExpiredIdentity as exp_identity :
Original file line number Diff line number Diff line change 2323import sys
2424from typing import IO , NewType , Union
2525
26- import rekor_types
27- from cryptography .hazmat .primitives import serialization , hashes
26+ from cryptography .hazmat .primitives import hashes , serialization
2827from cryptography .hazmat .primitives .asymmetric import ec , rsa
2928from cryptography .hazmat .primitives .asymmetric .utils import Prehashed
3029from cryptography .x509 import (
@@ -162,7 +161,7 @@ def key_id(key: PublicKey) -> KeyID:
162161def get_digest (
163162 input_ : IO [bytes ],
164163 algorithm_ : Prehashed = None ,
165- ) -> (bytes , Prehashed ):
164+ ) -> (bytes , Prehashed ):
166165 if algorithm_ is None :
167166 return sha256_streaming (input_ ), Prehashed (hashes .SHA256 ())
168167
@@ -171,7 +170,7 @@ def get_digest(
171170 if algorithm_ .digest_size != 32 :
172171 return ValueError (f"invalid digest size ({ algorithm_ .digest_size ()} ), expected 32" )
173172 return input_ .getvalue (), algorithm_
174-
173+
175174 raise ValueError ("invalid arguments" )
176175
177176def sha256_streaming (io : IO [bytes ]) -> bytes :
Original file line number Diff line number Diff line change 5757 VerificationMaterial ,
5858)
5959from sigstore_protobuf_specs .dev .sigstore .common .v1 import (
60- HashAlgorithm ,
6160 HashOutput ,
6261 LogId ,
6362 MessageSignature ,
8281from sigstore ._internal .rekor .client import RekorClient
8382from sigstore ._internal .sct import verify_sct
8483from sigstore ._internal .trustroot import TrustedRoot
85- < << << << HEAD
86- from sigstore ._utils import PEMCert , sha256_streaming
87- == == == =
88- from sigstore ._utils import B64Str , HexStr , PEMCert , get_digest
89- > >> >> >> 442469 b (backup )
84+ from sigstore ._utils import PEMCert , get_digest , sha256_streaming
9085from sigstore .oidc import ExpiredIdentity , IdentityToken
9186from sigstore .transparency import LogEntry
9287
@@ -178,10 +173,6 @@ def _signing_cert(
178173
179174 return certificate_response
180175
181- # https://github.com/sigstore/rekor/issues/1299
182- # https://github.com/pyca/cryptography/blob/00f8304a3dfe7a2aab6f3150a3c620e87d848044/src/cryptography/hazmat/primitives/hashes.py
183- # https://github.com/pyca/cryptography/blob/00f8304a3dfe7a2aab6f3150a3c620e87d848044/src/cryptography/hazmat/primitives/asymmetric/utils.py#L14
184- # https://github.com/pyca/cryptography/blob/main/src/cryptography/hazmat/primitives/asymmetric/rsa.py#L42
185176 def sign (
186177 self ,
187178 input_ : IO [bytes ] | Statement ,
Original file line number Diff line number Diff line change 2626from typing import IO
2727
2828import rekor_types
29- from cryptography .hazmat .primitives .serialization import Encoding
3029from cryptography .hazmat .primitives .asymmetric .utils import Prehashed
30+ from cryptography .hazmat .primitives .serialization import Encoding
3131from cryptography .x509 import (
3232 Certificate ,
3333 load_der_x509_certificate ,
@@ -184,7 +184,7 @@ class VerificationMaterials:
184184 """
185185 The digest algorithm to use for the hash.
186186 """
187-
187+
188188 input_digest : bytes
189189 """
190190 The 'digest_algorithm' hash of the verification input, as raw bytes.
@@ -424,7 +424,6 @@ def rekor_entry(self, client: RekorClient) -> LogEntry:
424424 ),
425425 data = rekor_types .hashedrekord .Data (
426426 hash = rekor_types .hashedrekord .Hash (
427- #algorithm=sigstore_rekor_types.Algorithm.SHA256,
428427 algorithm = self .digest_algorithm ._algorithm .name ,
429428 value = self .input_digest .hex (),
430429 ),
Original file line number Diff line number Diff line change 2424from typing import List , cast
2525
2626from cryptography .exceptions import InvalidSignature
27- from cryptography .hazmat .primitives import hashes
2827from cryptography .hazmat .primitives .asymmetric import ec
29- from cryptography .hazmat .primitives .asymmetric .utils import Prehashed
3028from cryptography .x509 import Certificate , ExtendedKeyUsage , KeyUsage
3129from cryptography .x509 .oid import ExtendedKeyUsageOID
3230from OpenSSL .crypto import (
@@ -227,7 +225,6 @@ def verify(
227225 materials .signature ,
228226 materials .input_digest ,
229227 ec .ECDSA (materials .digest_algorithm ),
230- #ec.ECDSA(Prehashed(hashes.SHA256())),
231228 )
232229 except InvalidSignature :
233230 return VerificationFailure (reason = "Signature is invalid for input" )
You can’t perform that action at this time.
0 commit comments