From 44f58b08703713eb04bce1e38159c8b006b211d7 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 11 May 2023 20:09:47 +0200 Subject: [PATCH 1/2] low_level crypto: minor cleanup HMAC is not used, we use hmac from py stdlib. --- src/borg/crypto/low_level.pyx | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/borg/crypto/low_level.pyx b/src/borg/crypto/low_level.pyx index c5b8c7c3f..bd9c3f8d2 100644 --- a/src/borg/crypto/low_level.pyx +++ b/src/borg/crypto/low_level.pyx @@ -63,6 +63,8 @@ cdef extern from "openssl/evp.h": const EVP_CIPHER *EVP_aes_256_ocb() const EVP_CIPHER *EVP_chacha20_poly1305() + EVP_CIPHER_CTX *EVP_CIPHER_CTX_new() + void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a) void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a) void EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a) @@ -82,17 +84,6 @@ cdef extern from "openssl/evp.h": int EVP_CTRL_AEAD_SET_TAG int EVP_CTRL_AEAD_SET_IVLEN - const EVP_MD *EVP_sha256() nogil - - EVP_CIPHER_CTX *EVP_CIPHER_CTX_new() - void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a) - -cdef extern from "openssl/hmac.h": - unsigned char *HMAC(const EVP_MD *evp_md, - const void *key, int key_len, - const unsigned char *data, int data_len, - unsigned char *md, unsigned int *md_len) nogil - import struct From f970679b6247b3c1e762cc05931d261427e1a5d5 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 11 May 2023 20:10:55 +0200 Subject: [PATCH 2/2] low_level crypto: fix borg version in comments --- src/borg/crypto/low_level.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/borg/crypto/low_level.pyx b/src/borg/crypto/low_level.pyx index bd9c3f8d2..aa28aa143 100644 --- a/src/borg/crypto/low_level.pyx +++ b/src/borg/crypto/low_level.pyx @@ -166,7 +166,7 @@ class UNENCRYPTED: cdef class AES256_CTR_BASE: - # Layout: HEADER + MAC 32 + IV 8 + CT (same as attic / borg < 1.3 IF HEADER = TYPE_BYTE, no AAD) + # Layout: HEADER + MAC 32 + IV 8 + CT (same as attic / borg < 2.0 IF HEADER = TYPE_BYTE, no AAD) cdef EVP_CIPHER_CTX *ctx cdef unsigned char enc_key[32] @@ -398,7 +398,7 @@ ctypedef const EVP_CIPHER * (* CIPHER)() cdef class _AEAD_BASE: - # new crypto used in borg >= 1.3 + # new crypto used in borg >= 2.0 # Layout: HEADER + MAC 16 + CT cdef CIPHER cipher