Openssl 1.1.1d 无效使用不完整类型“struct dsa_st”

0 c++ openssl

我正在从 openssl 1.0.2s 迁移到 1.1.1d 并出现以下错误。

\n\n

我搜索了 openssl 文档,似乎调用字段已更改。我不确定如何在我的代码中实现它。

\n\n
const BIGNUM * const *KeyPairImpl::getField(const string &field) const\n{\n  if (field == "P")\n    return &dsa_->p;\n  else if (field == "Q")\n    return &dsa_->q;\n  else if (field == "G")\n    return &dsa_->g;\n  else if (field == "X")\n    return &dsa_->priv_key;\n  else if (field == "Y")\n    return &dsa_->pub_key;\n  else\n    // unknown field name\n    return NULL;\n}\n\n
Run Code Online (Sandbox Code Playgroud)\n\n

错误

\n\n
KeyPair.cpp: In member function \xe2\x80\x98const BIGNUM* const* KeyPairImpl::getField(const std::string&) const\xe2\x80\x99:\nKeyPair.cpp:84: error: invalid use of incomplete type \xe2\x80\x98struct dsa_st\xe2\x80\x99\n/usr/local/ssl_1.1.1d/include/openssl/ossl_typ.h:107: error: forward declaration of \xe2\x80\x98struct dsa_st\xe2\x80\x99\nKeyPair.cpp:86: error: invalid use of incomplete type \xe2\x80\x98struct dsa_st\xe2\x80\x99\n/usr/local/ssl_1.1.1d/include/openssl/ossl_typ.h:107: error: forward declaration of \xe2\x80\x98struct dsa_st\xe2\x80\x99\nKeyPair.cpp:88: error: invalid use of incomplete type \xe2\x80\x98struct dsa_st\xe2\x80\x99\n/usr/local/ssl_1.1.1d/include/openssl/ossl_typ.h:107: error: forward declaration of \xe2\x80\x98struct dsa_st\xe2\x80\x99\nKeyPair.cpp:90: error: invalid use of incomplete type \xe2\x80\x98struct dsa_st\xe2\x80\x99\n/usr/local/ssl_1.1.1d/include/openssl/ossl_typ.h:107: error: forward declaration of \xe2\x80\x98struct dsa_st\xe2\x80\x99\nKeyPair.cpp:92: error: invalid use of incomplete type \xe2\x80\x98struct dsa_st\xe2\x80\x99\n/usr/local/ssl_1.1.1d/include/openssl/ossl_typ.h:107: error: forward declaration of \xe2\x80\x98struct dsa_st\xe2\x80\x99\ncc1plus: warnings being treated as errors\n
Run Code Online (Sandbox Code Playgroud)\n

Sha*_*ell 5

Openssl 1.1.1 不再允许您直接访问内部结构。您需要使用提供的 API 函数来访问内部数据(如果提供)。

对于 dsa_->p 使用DSA_get0_p

对于 dsa_->q 使用DSA_get0_q

对于 dsa_->g 使用DSA_get0_g

对于 dsa_->priv_key 使用DSA_get0_priv_key

对于 dsa_->pub_key 使用DSA_get0_pub_key

例如

return DSA_get0_p(dsa_);
Run Code Online (Sandbox Code Playgroud)