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 for wrapping EC keys + RSA wrapping fixes/comments/questions #5

Merged
merged 8 commits into from
Mar 1, 2024

Conversation

Jakuje
Copy link
Contributor

@Jakuje Jakuje commented Feb 28, 2024

Fixes also unwrapping for RSA keys, but we might need better solution.

I think the DerEncBigUint ensures the BN is unsigned and starts with zero byte, which is something we do not want when we import the BN as a modulus as you are using the modulus size to enforce the buffer size. Without stripping the null byte from the modulus, the operation requires 257 B buffer for signature and verification of this signature does not work.

The RSA wrapping is also using the RSAPrivateKey ASN1 directly, but from my reading of the PKCS#11 specification, we should use PrivateKeyInfo. This not obvious for RSA keys as everything needed is in the inner object, but EC keys needs the privateKeyAlgorithm field to learn what curve is used, if I read it right.

Keeping it as a draft as there is more quesitons to resolve before merging.

@Jakuje Jakuje requested a review from simo5 February 28, 2024 15:56
Copy link
Member

@simo5 simo5 left a comment

Choose a reason for hiding this comment

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

I left some suggestions/comments, the general changes look good to me.

src/rsa.rs Outdated Show resolved Hide resolved
src/ecc.rs Outdated Show resolved Hide resolved
src/ecc.rs Outdated Show resolved Hide resolved
src/rsa.rs Outdated Show resolved Hide resolved
Copy link
Member

@simo5 simo5 left a comment

Choose a reason for hiding this comment

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

Thanks most of the work looks really nice.

There are a few things I think would be beneficial to do slightly differently though.

src/kasn1.rs Show resolved Hide resolved
src/kasn1.rs Outdated Show resolved Hide resolved
src/kasn1.rs Show resolved Hide resolved
src/rsa.rs Show resolved Hide resolved
src/rsa.rs Outdated Show resolved Hide resolved
src/rsa.rs Outdated Show resolved Hide resolved
@Jakuje Jakuje force-pushed the ecc-wrap branch 2 times, most recently from c738707 to 2982d52 Compare March 1, 2024 14:32
@simo5 simo5 changed the title Draft: Support for wrapping EC keys + RSA wrapping fixes/comments/questions Support for wrapping EC keys + RSA wrapping fixes/comments/questions Mar 1, 2024
@Jakuje Jakuje mentioned this pull request Mar 1, 2024
@Jakuje Jakuje merged commit f02ec95 into latchset:main Mar 1, 2024
4 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.

2 participants