我正在从openssl 1.0.2s迁移到1.1.1d,并得到以下错误。
我在openssl文档上搜索了一下,似乎调用字段已经改变了。我不确定我需要如何在代码中实现它。
const BIGNUM * const *KeyPairImpl::getField(const string &field) const
{
if (field == "P")
return &dsa_->p;
else if (field == "Q")
return &dsa_->q;
else if (field == "G")
return &dsa_->g;
else if (field == "X")
return &dsa_->priv_key;
else if (field == "Y")
return &dsa_->pub_key;
else
// unknown field name
return NULL;
}
错误
KeyPair.cpp: In member function ‘const BIGNUM* const* KeyPairImpl::getField(const std::string&) const’:
KeyPair.cpp:84: error: invalid use of incomplete type ‘struct dsa_st’
/usr/local/ssl_1.1.1d/include/openssl/ossl_typ.h:107: error: forward declaration of ‘struct dsa_st’
KeyPair.cpp:86: error: invalid use of incomplete type ‘struct dsa_st’
/usr/local/ssl_1.1.1d/include/openssl/ossl_typ.h:107: error: forward declaration of ‘struct dsa_st’
KeyPair.cpp:88: error: invalid use of incomplete type ‘struct dsa_st’
/usr/local/ssl_1.1.1d/include/openssl/ossl_typ.h:107: error: forward declaration of ‘struct dsa_st’
KeyPair.cpp:90: error: invalid use of incomplete type ‘struct dsa_st’
/usr/local/ssl_1.1.1d/include/openssl/ossl_typ.h:107: error: forward declaration of ‘struct dsa_st’
KeyPair.cpp:92: error: invalid use of incomplete type ‘struct dsa_st’
/usr/local/ssl_1.1.1d/include/openssl/ossl_typ.h:107: error: forward declaration of ‘struct dsa_st’
cc1plus: warnings being treated as errors
Openssl 1.1.1不再允许直接访问内部结构。您需要使用提供的API函数来访问内部数据(如果提供(。
对于dsa_->p,请使用dsa_get0_p
对于dsa_->q,使用dsa_get0_q
对于dsa_->g,请使用dsa_get0_g
对于dsa_->priva_key,请使用dsa_get0_prival_key
对于dsa_->pub_key,请使用dsa_get0_pub_key
例如
return DSA_get0_p(dsa_);