Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
那么,问题是如何正确制作 RSA *rsa 密钥的二进制数据?我愿意
RSA *rsa = RSA_generate_key(2048, 65537, 0, 0); uchar *pp = (uchar *)malloc(2560); int bytes = i2d_RSAPublicKey(rsa, &pp); write(client, pp, bytes);
并且接收者执行 d2i_RSAPublicKey 并且程序崩溃。我做错了什么?
不要pp自己 malloc,而是将其设置为 NULL。i2d_RSAPublicKey将为您执行 malloc 并将 pp 设置为指向新分配的公钥。
pp
i2d_RSAPublicKey