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

Is it possible to have only the public key? #1

Closed ukeOnFire closed 5 years ago

ukeOnFire commented 5 years ago

I think I am missing something, so enjoy a casual "I'm sorry, but" ... I'm kinda new to encrypting and this is my last straw. So: is it possible to have only the public key in my dart code, because I only want to encrypt here - the private key should be placed somewhere in my backend.

Also, is it possible to read the keys from somewhere? I can only get the 'Instance of RSAPublicKey' and the API does not give me any information on how to do that.

I've read that you are busy, I'd feel honored if you come back to me about this!

AKushWarrior commented 5 years ago

1) As for keeping only the public key, it's fairly simple, only fetch the public key. The private key will still be encoded into a keypair in the class itself, meaning you only need the one. However, I might ask, why do you need to encrypt only and not decrypt? (This is so that I might be able to improve runtime efficiency and/or features of the package.)

2) Alright, so I assume you did something like this (post a code snippet if it's a different issue): var encrypter = new RsaCrypt(); var pubKey = encrypter.pubKey; print(pubKey); //Which prints "Instance of RSAPublicKey" SteelCrypt exposes PointyCastle's RSA AsymmetricKeyPair class, which in turn contains two keys, one of which is an RSAPublicKey and the other is an RSAPrivateKey. However, both of these classes contain no useful string representation, meaning that there is no way to "see" the value of the keys. The keys still exist, so, while you can't really print them, you can definitely use the public key to encrypt by using the .pubKey getter of the RsaCrypt() class.

I hope this answers your questions, but on the chance it didn't, make sure to comment back ASAP, as I have a relatively free schedule the next couple days. Cheers!

ukeOnFire commented 5 years ago

Thanks for your kind reply. I will try to explain the situation more detailed and as simple as I can: I have a mobile app. The user has to login and send his credentials. I am not using firebase, so I have to ensure myself that those credentials are sent securely. To do that, I want the mobile app to get the public key from my backend, encrypt the credentials with it, and send them back to the backend. So what I really want to do is have a RsaCrypt()-object that uses the public key sent from my backend.

Cheers!

ukeOnFire commented 5 years ago

Just wanted to let you know that I found a work around (sadly, not by using this package...). Anyway, thanks and jolly coding!

AKushWarrior commented 5 years ago

And to you. Quite honestly, I don't really care if you used this package. What matters is that you were able to achieve the functionality on dart, which you did. Good luck on all your future coding endeavors.