How to use pre-shared keys in OpenSSL

4.9k Views Asked by At

Is it possible to generate 2 pre-shared keys on on system, distribute them to two host A and B, so that A and B can then use those keys for the encrypted connection between them? I'm not talking about Public Keys like RSA, but 2 pre-shared keys that get handed over to the two parties!

I'd have to implement that in C++, so if possible I'd need a working solution for that.

1

There are 1 best solutions below

2
On BEST ANSWER

Yes, it's possible. What you seem to be looking for is the symmetric-key encryption.

In that case, the key is usually just a required number of random bytes. Any cryptographically secure RNG source is ok for that. If you're going to use openssl afterwards, RAND_bytes() will work.

Also see AES Encryption -Key Generation with OpenSSL