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

本文介绍了解决libssh2编译失败的方法,通过对源代码进行特定修改使其能够兼容最新版的OpenSSL,包括更新头文件引用及调整HMAC上下文初始化函数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


  转载请注明出处!
最近编译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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值