crypto: add functions missing in openssl 1.0.x

This commit is contained in:
Thomas Waldmann 2016-07-14 22:35:50 +02:00
parent ee604ab390
commit 92080f9572
4 changed files with 48 additions and 1 deletions

View File

@ -52,6 +52,7 @@ from distutils.command.clean import clean
compress_source = 'src/borg/compress.pyx'
crypto_ll_source = 'src/borg/crypto/low_level.pyx'
crypto_helpers = 'src/borg/crypto/_crypto_helpers.c'
chunker_source = 'src/borg/chunker.pyx'
hashindex_source = 'src/borg/hashindex.pyx'
item_source = 'src/borg/item.pyx'
@ -730,7 +731,7 @@ ext_modules = []
if not on_rtd:
ext_modules += [
Extension('borg.compress', [compress_source], libraries=['lz4'], include_dirs=include_dirs, library_dirs=library_dirs, define_macros=define_macros),
Extension('borg.crypto.low_level', [crypto_ll_source], libraries=crypto_libraries, include_dirs=include_dirs, library_dirs=library_dirs, define_macros=define_macros),
Extension('borg.crypto.low_level', [crypto_ll_source, crypto_helpers], libraries=crypto_libraries, include_dirs=include_dirs, library_dirs=library_dirs, define_macros=define_macros),
Extension('borg.hashindex', [hashindex_source]),
Extension('borg.item', [item_source]),
Extension('borg.chunker', [chunker_source]),

View File

@ -0,0 +1,27 @@
/* add missing HMAC functions, so OpenSSL 1.0.x can be used like 1.1 */
#include <string.h>
#include <openssl/opensslv.h>
#include <openssl/hmac.h>
#if OPENSSL_VERSION_NUMBER < 0x10100000L
HMAC_CTX *HMAC_CTX_new(void)
{
HMAC_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
if (ctx != NULL) {
memset(ctx, 0, sizeof *ctx);
HMAC_CTX_cleanup(ctx);
}
return ctx;
}
void HMAC_CTX_free(HMAC_CTX *ctx)
{
if (ctx != NULL) {
HMAC_CTX_cleanup(ctx);
OPENSSL_free(ctx);
}
}
#endif

View File

@ -0,0 +1,11 @@
/* add missing HMAC functions, so OpenSSL 1.0.x can be used like 1.1 */
#include <openssl/opensslv.h>
#include <openssl/hmac.h>
#if OPENSSL_VERSION_NUMBER < 0x10100000L
HMAC_CTX *HMAC_CTX_new(void);
void HMAC_CTX_free(HMAC_CTX *ctx);
#endif

View File

@ -123,6 +123,14 @@ cdef extern from "openssl/hmac.h":
const unsigned char *data, int data_len,
unsigned char *md, unsigned int *md_len) nogil
cdef extern from "_crypto_helpers.h":
ctypedef struct HMAC_CTX:
pass
HMAC_CTX *HMAC_CTX_new()
void HMAC_CTX_free(HMAC_CTX *a)
import struct
_int = struct.Struct('>I')