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

Support key import #59

Merged
merged 24 commits into from
May 27, 2022
Merged

Support key import #59

merged 24 commits into from
May 27, 2022

Conversation

zugzwang
Copy link
Collaborator

@zugzwang zugzwang commented Apr 12, 2022

Private Key Import

This PR adds support for importing and representing an arbitrary OpenPGP Transferable Secret Key (henceforth TSK) in Fortanix DSM. This PGP key can come from other implementations such as Sequoia (locally), the GnuPG keyring, OpenPGPjs, etc.

Because nothing is known about the input key, the corresponding structure of Sobjects has been enhanced to represent it in fair generality. More fields have been added as custom metadata (fingerprint of each subkeys, external creation timestamps, ECDH additional algorithms, etc). Consequently, this next release (0.3.0) is not backwards compatible with previous versions.

The input key is accepted for import under the following assumptions:

  • The primary key is always C or CS,
  • there is at least one Et or Er subkey,
  • if the primary key is C, then there is at least one S subkey, and
  • the given cipher suites and algorithms are supported by Fortanix DSM.

Testing

... against GnuPG

The test script generate_gpg_import_dsm.sh generates a key in the local GnuPG keyring, exports it, imports the TSK to Fortanix DSM, checks signature and encryption roundtrips, exports it from DSM, and imports it back on the local keyring. Phew.

... against known keys

The test script knownkeys_import_dsm.sh attempts to import known keys, some of which are "exotic" (taken from the OpenPGP interoperability test suite. It checks signature and encryption roundtrips.

Fixes #5

@zugzwang zugzwang marked this pull request as draft April 12, 2022 09:45
@zugzwang zugzwang added the enhancement New feature or request label Apr 14, 2022
@zugzwang zugzwang force-pushed the support-key-import branch from cfe0627 to b0f4b2e Compare April 14, 2022 15:51
@zugzwang zugzwang marked this pull request as ready for review April 15, 2022 15:27
openpgp-dsm/src/lib.rs Outdated Show resolved Hide resolved
openpgp-dsm/src/lib.rs Outdated Show resolved Hide resolved
@zugzwang zugzwang force-pushed the support-key-import branch from bc501be to 2dd6af7 Compare April 16, 2022 19:08
Copy link
Member

@MihirLuthra MihirLuthra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially reviewed. Will complete the remaining soon.

openpgp/Cargo.toml Outdated Show resolved Hide resolved
sq/src/commands/key.rs Show resolved Hide resolved
sq/src/sq_cli.rs Show resolved Hide resolved
openpgp-dsm/Cargo.toml Outdated Show resolved Hide resolved
openpgp-dsm/Cargo.toml Outdated Show resolved Hide resolved
sq/Makefile Outdated Show resolved Hide resolved
Copy link
Member

@MihirLuthra MihirLuthra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice PR! Still reviewing.

openpgp-dsm/src/lib.rs Show resolved Hide resolved
openpgp-dsm/src/lib.rs Outdated Show resolved Hide resolved
openpgp-dsm/src/lib.rs Outdated Show resolved Hide resolved
openpgp-dsm/src/lib.rs Outdated Show resolved Hide resolved
openpgp-dsm/src/lib.rs Outdated Show resolved Hide resolved
@zugzwang zugzwang requested a review from MihirLuthra May 20, 2022 12:45
openpgp-dsm/src/der.rs Outdated Show resolved Hide resolved
sq/src/sq_cli.rs Show resolved Hide resolved
openpgp-dsm/src/der.rs Show resolved Hide resolved
openpgp-dsm/src/der.rs Show resolved Hide resolved
openpgp-dsm/src/der.rs Outdated Show resolved Hide resolved
openpgp-dsm/src/lib.rs Outdated Show resolved Hide resolved
openpgp-dsm/src/lib.rs Show resolved Hide resolved
openpgp-dsm/src/lib.rs Outdated Show resolved Hide resolved
@MihirLuthra
Copy link
Member

MihirLuthra commented May 25, 2022

While trying to use sq-dsm, I see that the ops take really long.
For example:

~/sq-dsm support-key-import*
❯ time sq key generate --dsm-key="alice2" --cipher-suite="nistp521" --userid="Alice2 <[email protected]>"
./target/debug/sq key generate --dsm-key="alice2" --cipher-suite="nistp521"   0.20s user 0.02s system 0% cpu 1:58.96 total

key generate almost took 2 mins.
If this is expected, can we please put some message here? I mean, something that tells it is ongoing and may take time.

@MihirLuthra
Copy link
Member

Btw, just wanted to mention this - I was testing this against https://sdkms.test.fortanix.com and I receive SSL errors.

~/sq-dsm support-key-import*
❯ time sq key generate --dsm-key="alice2" --cipher-suite="nistp521" --userid="Alice2 <[email protected]>"                                                                                      
Error: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed:s3_clnt.c:1204: (unable to get local issuer certificate)
./target/debug/sq key generate --dsm-key="alice2" --cipher-suite="nistp521"   0.01s user 0.01s system 2% cpu 0.740 total

I didn't want to get into these, so just put the following for my testing:

let tls_conn = TlsConnector::builder()
    .danger_accept_invalid_certs(true)
    .danger_accept_invalid_hostnames(true)
    .build()?;

This could be an env issue on my side but thought you may want to know.

@zugzwang
Copy link
Collaborator Author

I don't have any TLS issues with that same endpoint, and key generation takes 30 seconds from my end. (It needs to generate 2 keys, produce 2 signatures, and several Sobject updates).

@MihirLuthra
Copy link
Member

I don't have any TLS issues with that same endpoint, and key generation takes 30 seconds from my end. (It needs to generate 2 keys, produce 2 signatures, and several Sobject updates).

Right. I see #60 also addresses this.

@zugzwang zugzwang merged commit 5a38fda into main May 27, 2022
@zugzwang zugzwang mentioned this pull request Jun 24, 2022
@zugzwang zugzwang deleted the support-key-import branch March 3, 2023 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support key import
2 participants