Skip to content

Commit

Permalink
Remove deprecated from/to_securesystemslib_key methods
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Puehringer <[email protected]>
  • Loading branch information
lukpueh committed Apr 10, 2024
1 parent 6291709 commit bb17467
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 51 deletions.
24 changes: 1 addition & 23 deletions securesystemslib/signer/_crypto_signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import logging
from dataclasses import astuple, dataclass
from typing import Any, Dict, Optional, Union
from typing import Optional, Union
from urllib import parse

from securesystemslib.exceptions import UnsupportedLibraryError
Expand Down Expand Up @@ -189,28 +189,6 @@ def __init__(
def public_key(self) -> Key:
return self._public_key

@classmethod
def from_securesystemslib_key(
cls, key_dict: Dict[str, Any]
) -> "CryptoSigner":
"""Factory to create CryptoSigner from securesystemslib private key dict."""
private = key_dict["keyval"]["private"]
public_key = SSlibKey.from_securesystemslib_key(key_dict)

private_key: PrivateKeyTypes
if public_key.keytype in ["rsa"] + _ECDSA_KEYTYPES:
private_key = load_pem_private_key(private.encode(), password=None)

elif public_key.keytype == "ed25519":
private_key = Ed25519PrivateKey.from_private_bytes(
bytes.fromhex(private)
)

else:
raise ValueError(f"unsupported keytype: {public_key.keytype}")

return CryptoSigner(private_key, public_key)

@classmethod
def from_priv_key_uri(
cls,
Expand Down
28 changes: 0 additions & 28 deletions securesystemslib/signer/_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,34 +198,6 @@ def verify_signature(self, signature: Signature, data: bytes) -> None:
class SSlibKey(Key):
"""Key implementation for RSA, Ed25519, ECDSA keys"""

def to_securesystemslib_key(self) -> Dict[str, Any]:
"""Internal helper, returns a classic securesystemslib keydict.
.. deprecated:: 0.28.0
Please use ``CryptoSigner`` instead of securesystemslib keydicts.
"""
return {
"keyid": self.keyid,
"keytype": self.keytype,
"scheme": self.scheme,
"keyval": self.keyval,
}

@classmethod
def from_securesystemslib_key(cls, key_dict: Dict[str, Any]) -> "SSlibKey":
"""Constructor from classic securesystemslib keydict
.. deprecated:: 0.28.0
Please use ``CryptoSigner`` instead of securesystemslib keydicts.
"""
# ensure possible private keys are not included in keyval
return SSlibKey(
key_dict["keyid"],
key_dict["keytype"],
key_dict["scheme"],
{"public": key_dict["keyval"]["public"]},
)

@classmethod
def from_dict(cls, keyid: str, key_dict: Dict[str, Any]) -> "SSlibKey":
keytype, scheme, keyval = cls._from_dict(key_dict)
Expand Down

0 comments on commit bb17467

Please sign in to comment.