Skip to content

Commit

Permalink
Merge pull request #806 from lukpueh/rm-stray-globals
Browse files Browse the repository at this point in the history
Remove 3 stray global key type constants
  • Loading branch information
jku authored May 2, 2024
2 parents 402c898 + 6975b81 commit 557378e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
7 changes: 0 additions & 7 deletions securesystemslib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,3 @@
logger = logging.getLogger(__name__)
logger.setLevel(logging.WARNING)
logger.addHandler(logging.StreamHandler())


# Global constants
# TODO: Replace hard-coded key types with these constants (and add more)
KEY_TYPE_RSA = "rsa"
KEY_TYPE_ED25519 = "ed25519"
KEY_TYPE_ECDSA = "ecdsa"
13 changes: 8 additions & 5 deletions securesystemslib/signer/_hsm_signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
from typing import Dict, Iterator, List, Optional, Tuple
from urllib import parse

from securesystemslib import KEY_TYPE_ECDSA
from securesystemslib.exceptions import UnsupportedLibraryError
from securesystemslib.hash import digest
from securesystemslib.signer._key import Key, SSlibKey
from securesystemslib.signer._signature import Signature
from securesystemslib.signer._signer import SecretsHandler, Signer
from securesystemslib.signer._utils import compute_default_keyid

_KEY_TYPE_ECDSA = "ecdsa"

# pylint: disable=wrong-import-position
CRYPTO_IMPORT_ERROR = None
try:
Expand Down Expand Up @@ -217,11 +218,13 @@ def _find_key(
]
)
if not keys:
raise ValueError(f"could not find {KEY_TYPE_ECDSA} key for {keyid}")
raise ValueError(
f"could not find {_KEY_TYPE_ECDSA} key for {keyid}"
)

if len(keys) > 1:
raise ValueError(
f"found more than one {KEY_TYPE_ECDSA} key for {keyid}"
f"found more than one {_KEY_TYPE_ECDSA} key for {keyid}"
)

return keys[0]
Expand Down Expand Up @@ -327,8 +330,8 @@ def import_(

keyval = {"public": public_pem}
scheme = _SCHEME_FOR_CURVE[curve]
keyid = compute_default_keyid(KEY_TYPE_ECDSA, scheme, keyval)
key = SSlibKey(keyid, KEY_TYPE_ECDSA, scheme, keyval)
keyid = compute_default_keyid(_KEY_TYPE_ECDSA, scheme, keyval)
key = SSlibKey(keyid, _KEY_TYPE_ECDSA, scheme, keyval)

return uri, key

Expand Down

0 comments on commit 557378e

Please sign in to comment.