Skip to content

Commit 54d0fe0

Browse files
committed
cleanup
Signed-off-by: laurentsimon <laurentsimon@google.com>
1 parent 027087e commit 54d0fe0

File tree

5 files changed

+7
-21
lines changed

5 files changed

+7
-21
lines changed

sigstore/_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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:

sigstore/_utils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
import sys
2424
from 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
2827
from cryptography.hazmat.primitives.asymmetric import ec, rsa
2928
from cryptography.hazmat.primitives.asymmetric.utils import Prehashed
3029
from cryptography.x509 import (
@@ -162,7 +161,7 @@ def key_id(key: PublicKey) -> KeyID:
162161
def 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

177176
def sha256_streaming(io: IO[bytes]) -> bytes:

sigstore/sign.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
VerificationMaterial,
5858
)
5959
from sigstore_protobuf_specs.dev.sigstore.common.v1 import (
60-
HashAlgorithm,
6160
HashOutput,
6261
LogId,
6362
MessageSignature,
@@ -82,11 +81,7 @@
8281
from sigstore._internal.rekor.client import RekorClient
8382
from sigstore._internal.sct import verify_sct
8483
from 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-
>>>>>>> 442469b (backup)
84+
from sigstore._utils import PEMCert, get_digest, sha256_streaming
9085
from sigstore.oidc import ExpiredIdentity, IdentityToken
9186
from 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,

sigstore/verify/models.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
from typing import IO
2727

2828
import rekor_types
29-
from cryptography.hazmat.primitives.serialization import Encoding
3029
from cryptography.hazmat.primitives.asymmetric.utils import Prehashed
30+
from cryptography.hazmat.primitives.serialization import Encoding
3131
from 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
),

sigstore/verify/verifier.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
from typing import List, cast
2525

2626
from cryptography.exceptions import InvalidSignature
27-
from cryptography.hazmat.primitives import hashes
2827
from cryptography.hazmat.primitives.asymmetric import ec
29-
from cryptography.hazmat.primitives.asymmetric.utils import Prehashed
3028
from cryptography.x509 import Certificate, ExtendedKeyUsage, KeyUsage
3129
from cryptography.x509.oid import ExtendedKeyUsageOID
3230
from 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")

0 commit comments

Comments
 (0)