libssh2 1.6版更改编译通过(OpenSSL 1.0.2d)

来源:互联网 发布:麻将软件 编辑:程序博客网 时间:2024/05/20 08:25

  转载请注明出处!
最近编译libssh2时,一直不能通过,参照libssh2和openssl源代码,对libssh2做如下修改。
1 在src/openssl.h 文件中增加如下头文件
  #include <openssl/rsa.h>
#include <openssl/dsa.h>

2 在src/openssl.h

src/openssl.h 
Showing the top two matches. Last indexed 

131#define libssh2_hmac_sha1_init(ctx, key, keylen) \
132 HMAC_Init(ctx, key, keylen, EVP_sha1())133#define libssh2_hmac_md5_init(ctx, key, keylen) \
134 HMAC_Init(ctx, key, keylen, EVP_md5())135#define libssh2_hmac_ripemd160_init(ctx, key, keylen) \
改为如下

src/openssl.h 
Showing the top two matches. Last indexed 

131#define libssh2_hmac_sha1_init(ctx, key, keylen) \
132 HMAC_Init_ex(ctx, key, keylen, EVP_sha1(),NULL)133#define libssh2_hmac_md5_init(ctx, key, keylen) \
134 HMAC_Init_ex(ctx, key, keylen, EVP_md5(),NULL)135#define libssh2_hmac_ripemd160_init(ctx, key, keylen) \

src/openssl.h 
Showing the top match. Last indexed 

139#define libssh2_hmac_final(ctx, data) HMAC_Final(&(ctx), data, NULL)
140#define libssh2_hmac_cleanup(ctx) HMAC_cleanup(ctx)141
142#define libssh2_crypto_init() OpenSSL_add_all_algorithms()
改为

src/openssl.h 
Showing the top match. Last indexed 

139#define libssh2_hmac_final(ctx, data) HMAC_Final(&(ctx), data, NULL)
140#define libssh2_hmac_cleanup(ctx) HMAC_CTX_cleanup(ctx)141
142#define libssh2_crypto_init() OpenSSL_add_all_algorithms()
原因:
     可以查看openssl源码 hmac.h文件中(如下):这2个函数是有条件编译的 USE_DEPRECATED,  但是查看openssl的change log , 最新的openssl 默认是NO DEPRECATED, 故在编译libssh2时会报 NO DEFINE REFRENCE .
Changes between 1.0.2 and 1.1.0
  *) config has been changed so that by default OPENSSL_NO_DEPRECATED is used.
     Access to deprecated functions can be re-enabled by running config with     "enable-deprecated". In addition applications wishing to use deprecated     functions must define OPENSSL_USE_DEPRECATED. Note that this new behaviour     will, by default, disable some transitive includes that previously existed     in the header files (e.g. ec.h will no longer, by default, include bn.h)     [Matt Caswell]
void HMAC_CTX_init(HMAC_CTX *ctx);
void HMAC_CTX_cleanup(HMAC_CTX *ctx);


#ifdef OPENSSL_USE_DEPRECATED
/* deprecated */
# define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx)


/* deprecated */
DECLARE_DEPRECATED(__owur int HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
const EVP_MD *md));


#endif
/*__owur*/ int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
const EVP_MD *md, ENGINE *impl);
/*__owur*/ int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data,
size_t len);
/*__owur*/ int HMAC_Final(HMAC_CTX *ctx, unsigned char *md,
最后libssh2编译成功。
更改好的源文件地址: libssh2
0 0
原创粉丝点击