Skip to content
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

SSlibKey: make '_from_crypto_public_key' public API and remove 'from_pem' #678

Merged

Conversation

lukpueh
Copy link
Member

@lukpueh lukpueh commented Nov 23, 2023

Fixes #616

This newly public SSlibKey factory allows more flexible usage than the existing from_pem, which was just a thin wrapper on top of it.

Additional use cases are creating a key from an pyca/crypto private key object (see CryptoSigner) or from a different serialization format than PEM.

To keep the API small, this PR removes from_pem. It seems reasonable to just have application code call pyca/cryptography's "from pem" function themselves.

Allows more use cases, e.g. create SSlibKey
- from pyca/crypto private key (see CryptoSigner), or
- from some serialization format, supported by pyca/crypto (see
  SSlibKey.from_pem)

The commit adds tests to check if the interface correctly raises
UnsupportedLibraryError if pyca/cryptography is not installed.

Functionality is tested implicitly via SSlibKey.from_pem.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
The more flexible SSLibKey.from_crypto can be used instead.

The additional call to pyca/crypto's "from pem" method can
easily be done in application code.

This commit updates tests and docs to use from_crypto instead.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
lukpueh added a commit to lukpueh/in-toto that referenced this pull request Nov 23, 2023
blocks on:
- in-toto#649, and
- secure-systems-lab/securesystemslib#678 + release

---

This is meant as replacement for `--layout-keys`, supporting a
consistent standard key file format (subjectPublicKeyInfo/pem).

It is part of a series of patches to prepare for deprecation of legacy
securesystemslib interfaces and key file formats.

**Change details**

Adds helper to load public key file as SSlibKey and uses it in
in-toto-verify for keys passed with --subjectPublicKeyInfo.
NOTE: uses unreleased securesystemslib API, which **blocks** this PR.

SSlibKey is converted to its dictionary representation with the keyid
included, to make it compatible with verifylib.in_toto_verify.

In the future we might want to support Key (SSlibKey's base class)
natively in in_toto_verify.

This PR also adds a deprecation warning for --layout-keys and tests
using the demo supply chain.

Test public key files come from secure-systems-lab/securesystemslib#604.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
lukpueh added a commit to lukpueh/in-toto that referenced this pull request Nov 23, 2023
blocks on:
- in-toto#649, and
- secure-systems-lab/securesystemslib#678 + release

---

This is meant as replacement for `--layout-keys`, supporting a
consistent standard key file format (subjectPublicKeyInfo/pem).

It is part of a series of patches to prepare for deprecation of legacy
securesystemslib interfaces and key file formats.

**Change details**

Adds helper to load public key file as SSlibKey and uses it in
in-toto-verify for keys passed with --subjectPublicKeyInfo.
NOTE: uses unreleased securesystemslib API, which **blocks** this PR.

SSlibKey is converted to its dictionary representation with the keyid
included, to make it compatible with verifylib.in_toto_verify.

In the future we might want to support Key (SSlibKey's base class)
natively in in_toto_verify.

This PR also adds a deprecation warning for --layout-keys and tests
using the demo supply chain.

Test public key files come from secure-systems-lab/securesystemslib#604.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
lukpueh added a commit to lukpueh/in-toto that referenced this pull request Nov 24, 2023
blocks on:
- in-toto#649, and
- secure-systems-lab/securesystemslib#678 + release

---

This is meant as replacement for `--layout-keys`, supporting a
consistent standard key file format (subjectPublicKeyInfo/pem).

It is part of a series of patches to prepare for deprecation of legacy
securesystemslib interfaces and key file formats.

**Change details**

Adds helper to load public key file as SSlibKey and uses it in
in-toto-verify for keys passed with --subjectPublicKeyInfo.
NOTE: uses unreleased securesystemslib API, which **blocks** this PR.

SSlibKey is converted to its dictionary representation with the keyid
included, to make it compatible with verifylib.in_toto_verify.

In the future we might want to support Key (SSlibKey's base class)
natively in in_toto_verify.

This PR also adds a deprecation warning for --layout-keys and tests
using the demo supply chain.

Test public key files come from secure-systems-lab/securesystemslib#604.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
lukpueh added a commit to lukpueh/in-toto that referenced this pull request Nov 24, 2023
blocks on:
- in-toto#649, and
- secure-systems-lab/securesystemslib#678 + release

---

This is meant as replacement for `--layout-keys`, supporting a
consistent standard key file format (subjectPublicKeyInfo/pem).

It is part of a series of patches to prepare for deprecation of legacy
securesystemslib interfaces and key file formats.

**Change details**

Adds helper to load public key file as SSlibKey and convert it to its
dictionary representation with the keyid included, to make it compatible
with verifylib.in_toto_verify.

in-toto-verify uses this for keys passed with --subjectPublicKeyInfo.

NOTE: requires unreleased securesystemslib API, which **blocks** this PR.

In the future we might want to support Key (SSlibKey's base class)
natively in in_toto_verify.

This PR also adds a deprecation warning for --layout-keys and tests
using the demo supply chain.

Test public key files come from secure-systems-lab/securesystemslib#604.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
lukpueh added a commit to lukpueh/in-toto that referenced this pull request Nov 24, 2023
blocks on:
- in-toto#649, and
- secure-systems-lab/securesystemslib#678 + release

---

This is meant as replacement for `--layout-keys`, supporting a
consistent standard key file format (subjectPublicKeyInfo/pem).

It is part of a series of patches to prepare for deprecation of legacy
securesystemslib interfaces and key file formats.

**Change details**

Adds helper to load public key file as SSlibKey and convert it to its
dictionary representation with the keyid included, to make it compatible
with verifylib.in_toto_verify.

in-toto-verify uses this for keys passed with --subjectPublicKeyInfo.

NOTE: requires unreleased securesystemslib API, which **blocks** this PR.

In the future we might want to support Key (SSlibKey's base class)
natively in in_toto_verify.

This PR also adds a deprecation warning for --layout-keys and tests
using the demo supply chain.

Test public key files come from secure-systems-lab/securesystemslib#604.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
@lukpueh lukpueh merged commit a3651a1 into secure-systems-lab:main Nov 28, 2023
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

key: consider making SSlibKey._from_crypto_public_key public API
2 participants