我想讨论一下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) 的所有数据。
Thanks.
也许,合适的问题是,openssl 中可用于加密/解密 PAYLOAD 的加密和解密函数是什么?
实际上,您可以让 OpenSSL 为您完成许多繁重的工作。
您可以像以前一样创建网络原语,并将文件描述符与 Open SSL 上下文相关联,该上下文将处理 SSL 握手、加密和解密。我掩盖了很多细节,但 openssl 网站和本书中的示例代码:
http://www.amazon.com/Network-Security-OpenSSL-John-Viega/dp/059600270X
将非常有启发性。这本书也可以在网上找到,但我相信你必须付费才能访问它。
在 OpenSSL 的发行版中,您可以找到大量示例代码,准确说明了如何执行此操作。
祝你好运。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)