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

Add Sphincs+ To Signer Interface #427

Merged
merged 15 commits into from
Nov 3, 2022

Conversation

rugo
Copy link
Contributor

@rugo rugo commented Sep 15, 2022

Fixes:
Updates: #169

Description of the changes being introduced by the pull request:

The PRs #160 and #169 tried to include the PQC scheme SPHINCS+, which is about to be NIST standardized.
However, work has stalled as people were busy with other stuff.

After talking to @lukpueh we decided to directly include SPHINCS+ into the "new" Signer API.

I welcome feedback and additional TODOs.

Copy link
Collaborator

@jku jku left a comment

Choose a reason for hiding this comment

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

I don't know anything about sphincs so just commenting on cosmetics: there's a couple of code comments that do not seem to match code. I think it would be best to not duplicate information like bytearray length in the comments if the code is clear as it seems to be here

Comment on lines 265 to 299
# An SPHINCS raw public key, which must be 32 bytes.
SPHINCSPRIVATE_SCHEMA = SCHEMA.LengthBytes(64)
Copy link
Collaborator

Choose a reason for hiding this comment

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

comment seems incorrect

Comment on lines 271 to 304
# An SPHINCS raw signature, which must be 64 bytes.
SPHINCSSIGNATURE_SCHEMA = SCHEMA.LengthBytes(7_856)
Copy link
Collaborator

Choose a reason for hiding this comment

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

comment byte length mismatch?

@rugo
Copy link
Contributor Author

rugo commented Sep 27, 2022

I don't know anything about sphincs so just commenting on cosmetics: there's a couple of code comments that do not seem to match code. I think it would be best to not duplicate information like bytearray length in the comments if the code is clear as it seems to be here

Makes sense. I removed them.

Copy link
Member

@lukpueh lukpueh left a comment

Choose a reason for hiding this comment

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

Thanks for the patch, @rugo! I think what's there is great. There are a few peculiarities that were likely inspired from the existing interfaces (e.g. passing args that are not used, keytype/scheme redundancy), but I think it's okay for the sake of consistency.

Would you mind adding tests to check_public_interfaces.TestPublicInterfaces.test_keys, to assert that we fail gracefully if PySPX is not installed?

It would also be good to have interface.generate_and_write_sphincs*, and interface.import_sphincs* functions as we have for other key types. But that can be added in a separate PR.

@@ -193,7 +193,7 @@
# Supported securesystemslib key types.
KEYTYPE_SCHEMA = SCHEMA.OneOf(
[SCHEMA.String('rsa'), SCHEMA.String('ed25519'), SCHEMA.String('ecdsa'),
SCHEMA.RegularExpression(r'ecdsa-sha2-nistp(256|384)')])
SCHEMA.RegularExpression(r'ecdsa-sha2-nistp(256|384)'), SCHEMA.String('sphincs-shake-128s')])
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense to call the keytype just sphincs? (see discussion about keytype vs. scheme in #239 and #308)

# be tested by running 'ed25519_keys.py' as a standalone module.
# python -B ed25519_keys.py
import doctest
doctest.testmod()
Copy link
Member

Choose a reason for hiding this comment

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

No need to add doctest boilerplate, there are no doctests in this module, and we wouldn't even run them in CI.

@rugo
Copy link
Contributor Author

rugo commented Oct 17, 2022

@lukpueh Thanks for the feedback. I added the required tests, changed the keytype and removed doctest.

Regadring interface.generate_and_write_sphincs: I would prefer to address this in a separate PR. This would need more coordination as SPHINCS+ does not have a standardized key OID yet (AFAIK). Decoding a SPHINCS+ key from PEM would therefore require us to create our own non-standard key identifier and format.

@rugo
Copy link
Contributor Author

rugo commented Oct 18, 2022

@lukpueh Could you check the failing test and give me some more insights? I don't really understand what is happening as the error says:

subprocess.TimeoutExpired: Command '['gpg', '--detach-sign', '--digest-algo', 'SHA256', '--local-user', 'E8AC80C924116DABB51D4B987CB07D6D2C199C7C', '--homedir', '/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/tmpuwgkkmy9/rsa']' timed out after 3 seconds

Which doesn't seem related to what I did. Did the macos test case break or am I missing something?

@lukpueh
Copy link
Member

lukpueh commented Oct 18, 2022

This is an unrelated test failure (#428). We are working on a fix.

Copy link
Member

@lukpueh lukpueh left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my comments! Just left a few more. May I also ask that you get rid of the merge commit in the PR? Otherwise, I think we can merge this and try using it with TUF and/or in-toto.

securesystemslib/keys.py Outdated Show resolved Hide resolved
requirements.txt Show resolved Hide resolved
tests/test_keys.py Outdated Show resolved Hide resolved
@lukpueh
Copy link
Member

lukpueh commented Oct 21, 2022

@rugo: I just merged #439, which auto-formats the entire code base. The easiest thing might be to re-apply your changes manually on top of the updated master branch, run auto-formatters commands (w/o --check --diff options) over them, and push them in a single commit to this branch. I apologize for the inconvenience, and am happy to help resolve any conflicts.

@rugo
Copy link
Contributor Author

rugo commented Oct 24, 2022

Alright. I think I have addressed your points. Additional feedback welcome.

@rugo
Copy link
Contributor Author

rugo commented Oct 25, 2022

Since the pylint test case complained about some minor things I fixed them now.

@rugo
Copy link
Contributor Author

rugo commented Oct 27, 2022

I rebased again to avoid the requirements.txt merge conflict.

Copy link
Member

@lukpueh lukpueh left a comment

Choose a reason for hiding this comment

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

Great work! I think there's one mistake in a docstring (see inline comment). Otherwise, LGTM!

securesystemslib/keys.py Outdated Show resolved Hide resolved
Copy link
Member

@lukpueh lukpueh left a comment

Choose a reason for hiding this comment

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

💯

@lukpueh lukpueh merged commit 4e63f99 into secure-systems-lab:master Nov 3, 2022
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.

3 participants