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 rsa_ext #355

Closed
wants to merge 1 commit into from
Closed

add rsa_ext #355

wants to merge 1 commit into from

Conversation

Caisin
Copy link

@Caisin Caisin commented Aug 9, 2023

pri key encrypt long string
pub key decrypt long data

@tarcieri
Copy link
Member

tarcieri commented Aug 9, 2023

I've mostly seen this referred to as RSA in Electronic CodeBook (ECB) mode.

It's a suboptimal way to use RSA as it needs to perform a modpow operation per "block", and generally discouraged.

A better option is to use hybrid encryption, which uses something like RSA-KEM to establish a shared symmetric key, then symmetric cryptography to actually encrypt the message.

HPKE provides a standard protocol for this, although unfortunately we don't yet provide RSA-KEM support: #323

@Caisin
Copy link
Author

Caisin commented Aug 10, 2023

I know what you mean
because this encryption and decryption method is provided in other programming languages
when we interact with other third-party systems, they use this way to verify encryption and decryption of apis,
in order to adapt to their api, we have to use this way to encrypt and decrypt,
I searched for a long time in crates.io and github, but did not find,
so I implement it myself.
I believe that there will be others who have the same needs as me
so I create this pull request

@tarcieri
Copy link
Member

because this encryption and decryption method is provided in other programming languages

That's not a justification for including this feature. The term for that is cargo culting.

I would personally prefer not to include such a feature in the rsa crate because:

  • It is a non-standard construction without an associated standards document like an RFC
  • It is badly designed and including it is something of an endorsement
  • Hybrid encryption should be the preferred solution to this problem

However, feel free to publish your own crate that implements this construction.

@tarcieri tarcieri closed this Aug 18, 2023
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