我想讨论一下openssl的写入和读取方法。
假设我有一个如下所示的数据结构:
/-----------------------------------------------------\ | my_header | PAYLOAD | \-----------------------------------------------------/ | | \ / \ / not encrypted encrypted I think the proper algorithm would be like this : SEND: build my_header with my own header. encrypt PAYLOAD with encryption function attach my_header and PAYLOAD (encrypted) to one buffer send it using common POSIX function just like send or sendto RECV: using common POSIX function just like recv or recvfrom. extract my_header and PAYLOAD(encrypted) decrypt PAYLOAD with decryption function at last i got my_header and PAYLOAD(decrypted).
如果您遇到上述问题,您的处理方法是怎样的?由于 openssl 加密了发送到 SSL_write 函数 (CMIIW) 的所有数据。
谢谢。
也许,合适的问题是,openssl 中可用于加密/解密 PAYLOAD 的加解密函数是什么?
最佳答案
您实际上可以让 OpenSSL 为您完成许多繁重的工作。
您可以像以前一样创建网络原语,并将文件描述符与 Open SSL 上下文相关联,该上下文将处理 SSL 握手、加密和解密。我掩盖了很多细节,但 openssl 网站和本书中的示例代码:
http://www.amazon.com/Network-Security-OpenSSL-John-Viega/dp/059600270X
非常有启发性。这本书也可以在网上找到,但我相信你必须付费才能访问它。
在 OpenSSL 的发行版中,您可以找到大量示例代码,准确说明如何执行此操作。
祝你好运。
关于encryption - openssl ssl 加密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2542156/