简体   繁体   English

如何在OpenSSL中使用预共享密钥

[英]How to use pre-shared keys in OpenSSL

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? 是否可以在系统上生成2个预共享密钥,然后将它们分配给两个主机A和B,以便A和B然后可以将这些密钥用于它们之间的加密连接? I'm not talking about Public Keys like RSA, but 2 pre-shared keys that get handed over to the two parties! 我不是在谈论像RSA这样的公钥,而是2个预共享的密钥,它们已经移交给了两方!

I'd have to implement that in C++, so if possible I'd need a working solution for that. 我必须在C ++中实现它,所以如果可能的话,我需要一个可行的解决方案。

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. 为此,任何加密安全的RNG源都是可以的。 If you're going to use openssl afterwards, RAND_bytes() will work. 如果以后要使用openssl,则RAND_bytes()将起作用。

Also see AES Encryption -Key Generation with OpenSSL 另请参阅AES加密-使用OpenSSL生成密钥

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM