mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-03-07 14:18:15 +08:00
ITS#8709 contrib/slapd-modules/passwd/totp: OpenSSL 1.1.0 compatibility
This commit is contained in:
parent
afa861bf22
commit
2c36a37f90
@ -41,11 +41,34 @@
|
||||
#define TOTP_SHA1 EVP_sha1()
|
||||
#define TOTP_SHA256 EVP_sha256()
|
||||
#define TOTP_SHA512 EVP_sha512()
|
||||
#define TOTP_HMAC_CTX HMAC_CTX
|
||||
#define TOTP_HMAC_CTX HMAC_CTX *
|
||||
|
||||
#define HMAC_setup(ctx, key, len, hash) HMAC_CTX_init(&ctx); HMAC_Init_ex(&ctx, key, len, hash, 0)
|
||||
#define HMAC_crunch(ctx, buf, len) HMAC_Update(&ctx, buf, len)
|
||||
#define HMAC_finish(ctx, dig, dlen) HMAC_Final(&ctx, dig, &dlen); HMAC_CTX_cleanup(&ctx)
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
static HMAC_CTX *HMAC_CTX_new(void)
|
||||
{
|
||||
HMAC_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
|
||||
if (ctx != NULL) {
|
||||
HMAC_CTX_init(ctx);
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static void HMAC_CTX_free(HMAC_CTX *ctx)
|
||||
{
|
||||
if (ctx != NULL) {
|
||||
HMAC_CTX_cleanup(ctx);
|
||||
OPENSSL_free(ctx);
|
||||
}
|
||||
}
|
||||
#endif /* OPENSSL_VERSION_NUMBER < 0x10100000L */
|
||||
|
||||
#define HMAC_setup(ctx, key, len, hash) \
|
||||
ctx = HMAC_CTX_new(); \
|
||||
HMAC_Init_ex(ctx, key, len, hash, 0)
|
||||
#define HMAC_crunch(ctx, buf, len) HMAC_Update(ctx, buf, len)
|
||||
#define HMAC_finish(ctx, dig, dlen) \
|
||||
HMAC_Final(ctx, dig, &dlen); \
|
||||
HMAC_CTX_free(ctx)
|
||||
|
||||
#elif HAVE_GNUTLS
|
||||
#include <nettle/hmac.h>
|
||||
|
Loading…
Reference in New Issue
Block a user