错误:取消引用指向不完整类型'RSA {aka struct rsa_st}'的指针。

问题描述 投票:0回答:1

我有以下代码。

#include <openssl/bn.h>
#include <openssl/rsa.h>

...
RSA *pubkey = RSA_new();
BIGNUM *modulus = BN_new();
...
pubkey->n = BN_new();
BN_copy(pubkey->n, modulus);

遵循这样的。

gcc rsatest.c -o rsatest -lcrypto

我得到了以下的错误。

rsatest.c: In function ‘main’:
rsatest.c:57:8: error: dereferencing pointer to incomplete type ‘RSA {aka struct rsa_st}’
  pubkey->n = BN_new();
        ^~

这是什么问题?

openssl rsa
1个回答
0
投票
RSA_set0_key(pubkey, modulus, exponent, NULL);

而不是

pubkey->n = BN_new();
BN_copy(pubkey->n, modulus);
pubkey->e = BN_new();
BN_copy(pubkey->e, exponent);

解决这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.