I am still exploring Rust and Cryptography, and trying find best possible ways to generate private key with custom input(string) and related public key to be used for encryption/decryption.
Already explored rsa, here key is generated taking some function input. I am looking for something more custom, like if I pass a string as input to generate private key and that yields related public key for encryption/decryption.
This will help in giving control over key generation, and also string can be easily persisted (if needed).
It doesn't take any functions - rather a random number generator which is also cryptographically secure. The term cryptographically secure isn't a random catchphrase but has strict mathematical meaning.
That is most certainly not how you generate a key in a cryptographically secure manner, unless your string is generated with the same random-number generator RSA expects, in which case creating the String adds extra steps.
In addition, since Rust strings are UTF-8, I very much doubt whether they make a proper nonce anyway.
Agreed, my bad, I used 'function' word at wrong place. What I meant is that, there is no direct control over generating private key here. String is just an example, it could be even bytes(slice) if require. So, I was wondering if at all that is possible or not?
I am trying to build authentication system where a message is encrypted (using public key) and decrypted at server end (using private key). To do so, I want keys in a format which user can persist(in a file or something) and can use for encryption when needed. So, I want to re-use key pairs once they're generated and I am not sure it this 'rsa' crate gives me that. I couldn't find any ways to typecast RsaPrivateKey from old generated key stored in a file.