Skip to content

Commit 3d1b16c

Browse files
committed
examples: Use Cryptosigner.private_bytes
private_bytes was just added to CryptoSigner, use it. Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
1 parent 38f309b commit 3d1b16c

2 files changed

Lines changed: 2 additions & 13 deletions

File tree

examples/uploader/_localrepo.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212
from typing import Dict
1313

1414
import requests
15-
from cryptography.hazmat.primitives.serialization import (
16-
Encoding,
17-
NoEncryption,
18-
PrivateFormat,
19-
)
2015
from securesystemslib.signer import CryptoSigner, Signer
2116

2217
from tuf.api.exceptions import RepositoryError
@@ -134,13 +129,7 @@ def add_delegation(self, role: str) -> bool:
134129

135130
# Store the private key using rolename as filename
136131
with open(f"{self.key_dir}/{role}", "wb") as f:
137-
# TODO this is dumb and needs to be securesystemslibs job...
138-
priv_key = signer._private_key.private_bytes(
139-
encoding=Encoding.PEM,
140-
format=PrivateFormat.PKCS8,
141-
encryption_algorithm=NoEncryption(),
142-
)
143-
f.write(priv_key)
132+
f.write(signer.private_bytes)
144133

145134
print(f"Uploaded new delegation, stored key in {self.key_dir}/{role}")
146135
return True

requirements/pinned.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ idna==3.7 # via requests
66
pycparser==2.22 # via cffi
77
pynacl==1.5.0 # via securesystemslib
88
requests==2.31.0
9-
securesystemslib[crypto,pynacl] @ git+https://github.com/secure-systems-lab/securesystemslib@34a42954b5064610ec98406bb55719fd19874089
9+
securesystemslib[crypto,pynacl] @ git+https://github.com/secure-systems-lab/securesystemslib@530411d927c789dd4b6e4c19ce367a78bcea446c
1010
urllib3==2.2.1 # via requests

0 commit comments

Comments
 (0)