mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-21 21:57:36 +00:00
crypto: add functions missing in openssl 1.0.x
This commit is contained in:
parent
ee604ab390
commit
92080f9572
4 changed files with 48 additions and 1 deletions
3
setup.py
3
setup.py
|
@ -52,6 +52,7 @@
|
|||
|
||||
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 @@ def run(self):
|
|||
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]),
|
||||
|
|
27
src/borg/crypto/_crypto_helpers.c
Normal file
27
src/borg/crypto/_crypto_helpers.c
Normal 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
|
11
src/borg/crypto/_crypto_helpers.h
Normal file
11
src/borg/crypto/_crypto_helpers.h
Normal 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
|
|
@ -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')
|
||||
|
|
Loading…
Reference in a new issue