diff options
author | Jakub Jelen <jjelen@redhat.com> | 2016-11-05 16:51:05 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2016-11-07 11:45:07 +0100 |
commit | cf1e808e2ffa1f26644fb5d2cb82a919f323deba (patch) | |
tree | d4c0b31914494fbe34caa2d23e146bcfcbc818ef /src | |
parent | b6cfde8987d201e3cee942d3368e18545d6c28fb (diff) | |
download | libssh-cf1e808e2ffa1f26644fb5d2cb82a919f323deba.tar.gz libssh-cf1e808e2ffa1f26644fb5d2cb82a919f323deba.tar.xz libssh-cf1e808e2ffa1f26644fb5d2cb82a919f323deba.zip |
libcrypto: Use newer API for HMAC
This is for OpenSSL 1.1.0 support.
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcrypto.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/libcrypto.c b/src/libcrypto.c index 19065bd6..64c92eaa 100644 --- a/src/libcrypto.c +++ b/src/libcrypto.c @@ -378,32 +378,33 @@ void ssh_mac_final(unsigned char *md, ssh_mac_ctx ctx) { HMACCTX hmac_init(const void *key, int len, enum ssh_hmac_e type) { HMACCTX ctx = NULL; - ctx = malloc(sizeof(*ctx)); + ctx = HMAC_CTX_new(); if (ctx == NULL) { return NULL; } #ifndef OLD_CRYPTO - HMAC_CTX_init(ctx); // openssl 0.9.7 requires it. + HMAC_CTX_reset(ctx); // openssl 0.9.7 requires it. #endif switch(type) { case SSH_HMAC_SHA1: - HMAC_Init(ctx, key, len, EVP_sha1()); + HMAC_Init_ex(ctx, key, len, EVP_sha1(), NULL); break; case SSH_HMAC_SHA256: - HMAC_Init(ctx, key, len, EVP_sha256()); + HMAC_Init_ex(ctx, key, len, EVP_sha256(), NULL); break; case SSH_HMAC_SHA384: - HMAC_Init(ctx, key, len, EVP_sha384()); + HMAC_Init_ex(ctx, key, len, EVP_sha384(), NULL); break; case SSH_HMAC_SHA512: - HMAC_Init(ctx, key, len, EVP_sha512()); + HMAC_Init_ex(ctx, key, len, EVP_sha512(), NULL); break; case SSH_HMAC_MD5: - HMAC_Init(ctx, key, len, EVP_md5()); + HMAC_Init_ex(ctx, key, len, EVP_md5(), NULL); break; default: + HMAC_CTX_free(ctx); SAFE_FREE(ctx); ctx = NULL; } @@ -419,7 +420,7 @@ void hmac_final(HMACCTX ctx, unsigned char *hashmacbuf, unsigned int *len) { HMAC_Final(ctx,hashmacbuf,len); #ifndef OLD_CRYPTO - HMAC_CTX_cleanup(ctx); + HMAC_CTX_reset(ctx); #else HMAC_cleanup(ctx); #endif |