-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revise module architecture and define clear API modules and functions #270
Comments
💯 💯 💯 |
Following discussion in #409 (comment) and recent developments related to the python-tuf v1 refactor, I suggest to shift signature-related API to Why classes?
Details about these classes
More thoughts
|
I am thinking of classes like from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey
class RSASigner(Signer):
key: RSAPrivateKey
...
def sign(self, payload: bytes) -> Signature:
_sig = self.key.sign(payload, *opinionated_args)
return Signature.from_pyca_crypto(_sig)
or with multi-inheritance class RSASigner(Signer, RSAPrivateKey):
...
def sign(self, payload: bytes) -> Signature:
_sig = RSAPrivateKey.sign(self, payload, *opinionated_args)
return Signature.from_pyca_crypto(_sig) I think this could save many lines of abstraction-layer code in securesystemslib. |
Overall the suggestions sound good. On the topic of One minor naming suggestion - why don't we use |
Agreed, the class in securesystemslib is actually called |
The connection is that there is a 1-to-1 relationship between signing and private key (for tuf/in-toto), so it is possible to combine them in one class. Of course, you could create an |
Inline-disable all non-error/fatal pylint issues raised by running `pylint -j 0 --rcfile=pylintrc securesystemslib tests`, by adding inline comments a la `"# pylint: disable=<issue>[, ...]"`. This allows running pylint on future PRs without spending much effort on existing code, whose future is uncertain (see secure-systems-lab#270). The patch was created mostly automatically with this script: https://gist.github.com/lukpueh/41026a3a7a594164150faf5afce94774 Unfortunately, both black and isort reformat inline comments in a way that pylint won't consider them anymore. Thus, some manual adjustments after running above script were necessary. https://black.readthedocs.io/en/stable/faq.html#why-does-my-linter-or-typechecker-complain-after-i-format-my-code Signed-off-by: Lukas Puehringer <[email protected]>
Inline-disable low/medium-severity bandit issues raised by running `bandit --recursive securesystemslib --exclude _vendor`, by adding inline comments a la `"# nosec"`. This allows running bandit on future PRs without spending much effort on existing code, whose future is uncertain (see secure-systems-lab#270). Signed-off-by: Lukas Puehringer <[email protected]>
my improvement ideas are in https://docs.google.com/document/d/1KQY5v1ASXpZM5GhfATV_WJf7GaMJrfBOXr06dtxc-ps/ but I'll summarize here -- just adding to what Lukas already listed. I believe this leads us to an API that is complete: users only need Key + Signer, there is no need to import any other securesystemslib modules. Signer
Key
The core idea is: The specific implementations of Key and Signer are 99% implementation details that securesystemslib users should not need to know about. My understanding is that we can do that: the only exception will be key generation/import, which should be implementation specific. |
I tend to agree that smaller specific implementations (e.g. RSAKey) would be good but note that if we manage what is proposed above, it is only relevant to users for the specific case of key generation/import. Otherwise how the implementation is split is an implementation detail that we can change without breaking API. |
#731 has removed much of the legacy "API" in favour of Apart from
|
Description of issue or feature request:
Securesystemslib lacks of a clear public API. It should be clear and intuitive for users of secureystemslib, which modules and which functions are public API.
Current behavior:
API is scattered across:
for general key operations (generate, import, sign, verify)
keys.py
-- high-level public interface to sign/very (key type independent), and generate and import keys (key type dependent). Calls into low-level non-public{rsa, ecdsa, ed25519}_keys.py
modules, which are (mostly) separated by key type.interface.py
-- higher-level public interface (mostly calls intokey.py
) to generate and import keysfor GPG key operations (import, sign, verify)
gpg/functions.py
-- public interface for gpg subpackage, independent from above key operations.for other other non-key related operations
hash.py
-- facade forhashlib
from stdlib andcryptography.hazmat.primitives.hashes
process.py
-- thin subprocess wrapperstorage.py
-- file system abstractionutil.py
-- mostly I/O related utilsformats.py
-- schema definition constants (likely to be deprecated, see Revise schema and formats facility #183), OLPC canonical json implementationExpected behavior:
Revise module architecture to use mnemonic names for (public) modules (not
interface
orfunctions
) appropriate for the interface functions they contain. Also see discussion about import guidelines.The text was updated successfully, but these errors were encountered: