AKushWarrior / steel_crypt

A collection of high-level API's exposing PointyCastle to perform hashing and encrypting in popular/secure algorithms.
https://pub.dev/packages/steel_crypt
Mozilla Public License 2.0
40 stars 10 forks source link

Decrypting using either RSAKeys #18

Closed KenV1040 closed 4 years ago

KenV1040 commented 4 years ago

Hello,

Looking through the documentation and examples, I can't find a way of decrypting an RSA encrypted message with someone's public key, since the decrypt function specifically specifies RSAPrivateKey. This function would be useful for when implementing end-to-end encryption where the sender encrypts with their private key, and the other receiver decrypts with the sender's public key. Is it possible for you to implement this feature? And hopefully also on the encryption function as well so it supports encrypting/decrypting with both RSAPublicKey and RSAPrivateKey.

Thanks!

Edit: I just made my own function to do this, so no need to rush this

AKushWarrior commented 4 years ago

Hmmm... You should never be able to decrypt with a Public Key. That's one of the core tenets of asymmetric encryption.

akshat-khare commented 4 years ago

But isn't the whole purpose of signing involves decrypting with public key?

AKushWarrior commented 4 years ago

You encrypt with a publicKey. Decrypt with a privateKey.

If you could decrypt with the same key that you encrypt with, it's no longer asymmetric. It's a symmetric algorithm.