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

refactor(ext/crypto): clean up rust side importKey #13036

Merged

Conversation

lucacasonato
Copy link
Member

This commit cleans up the Rust side of import_key by using a bunch of
enums instead of structs with "type" and "data" fields.

This commit does add some duplicated code for the time being, because
a lot of the other ops still need to get the same cleanup treatment.

This is an alternative to the Rust side changes in #13027.

@lucacasonato
Copy link
Member Author

@seanwykes Does the pattern introduced here work for the JWK implementation?

@cryptographix
Copy link
Contributor

@seanwykes Does the pattern introduced here work for the JWK implementation?

Yes, should do, we'll just add two more members to KeyData enum. :)

This commit cleans up the Rust side of `import_key` by using a bunch of
enums instead of structs with "type" and "data" fields.

This commit does add some duplicated code for the time being, because
a lot of the other ops still need to get the same cleanup treatment.
@lucacasonato lucacasonato force-pushed the refactor_import_key_rust_side branch from 0a5da3d to 82ca50b Compare December 10, 2021 00:12
@lucacasonato
Copy link
Member Author

Yes, should do, we'll just add two more members to KeyData enum. :)

As in two fields inside KeyData::Jwk, or two new enum members? If you mean the latter, what members would those be?

@cryptographix
Copy link
Contributor

Yes, should do, we'll just add two more members to KeyData enum. :)

As in two fields inside KeyData::Jwk, or two new enum members? If you mean the latter, what members would those be?

I personally find new enum members to be cleaner than having a single big ::JwK structure.

In #12022, I use different structs and enum members for Symmetric, RSA and EC JWKs:
JwkSecretKey(SecretKeyComponentB64), JwkRsaKey(RSAKeyComponentsB64) and JwkEcKey(ECKeyComponentsB64).

@lucacasonato
Copy link
Member Author

Makes sense. Let's cross that bridge when we get to it :-)

Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

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

neat

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM

@lucacasonato lucacasonato merged commit 2926827 into denoland:main Dec 10, 2021
@lucacasonato lucacasonato deleted the refactor_import_key_rust_side branch December 10, 2021 14:06
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.

4 participants