我正在从 openssl 1.0.2s 迁移到 1.1.1d 并出现以下错误。
\n\n我搜索了 openssl 文档,似乎调用字段已更改。我不确定如何在我的代码中实现它。
\n\nconst 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\nRun Code Online (Sandbox Code Playgroud)\n\n错误
\n\nKeyPair.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\nRun Code Online (Sandbox Code Playgroud)\n
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)
| 归档时间: |
|
| 查看次数: |
3470 次 |
| 最近记录: |