diff --git a/src/borg/crypto/_crypto_helpers.c b/src/borg/crypto/_crypto_helpers.c index ae61af012..8a6460640 100644 --- a/src/borg/crypto/_crypto_helpers.c +++ b/src/borg/crypto/_crypto_helpers.c @@ -7,4 +7,8 @@ const EVP_CIPHER *EVP_aes_256_ocb(void){ /* dummy, so that code compiles */ return NULL; } + +const EVP_CIPHER *EVP_chacha20_poly1305(void){ /* dummy, so that code compiles */ + return NULL; +} #endif diff --git a/src/borg/crypto/_crypto_helpers.h b/src/borg/crypto/_crypto_helpers.h index dbaf498e6..62517c115 100644 --- a/src/borg/crypto/_crypto_helpers.h +++ b/src/borg/crypto/_crypto_helpers.h @@ -5,6 +5,7 @@ #if defined(LIBRESSL_VERSION_NUMBER) const EVP_CIPHER *EVP_aes_256_ocb(void); /* dummy, so that code compiles */ +const EVP_CIPHER *EVP_chacha20_poly1305(void); /* dummy, so that code compiles */ #endif #if !defined(LIBRESSL_VERSION_NUMBER) diff --git a/src/borg/crypto/low_level.pyx b/src/borg/crypto/low_level.pyx index c6c9e0f1f..f726f3150 100644 --- a/src/borg/crypto/low_level.pyx +++ b/src/borg/crypto/low_level.pyx @@ -97,6 +97,7 @@ cdef extern from "_crypto_helpers.h": long LIBRESSL_VERSION_NUMBER const EVP_CIPHER *EVP_aes_256_ocb() # dummy + const EVP_CIPHER *EVP_chacha20_poly1305() # dummy is_libressl = bool(LIBRESSL_VERSION_NUMBER) @@ -640,7 +641,8 @@ cdef class AES256_OCB(_AES_BASE): cdef class CHACHA20_POLY1305(_CHACHA_BASE): @classmethod def requirements_check(cls): - pass + if is_libressl: + raise ValueError('CHACHA20-POLY1305 is not implemented by LibreSSL (yet?).') def __init__(self, mac_key, enc_key, iv=None, header_len=1, aad_offset=1): self.requirements_check() diff --git a/src/borg/testsuite/crypto.py b/src/borg/testsuite/crypto.py index b8d40ce89..89d715bfe 100644 --- a/src/borg/testsuite/crypto.py +++ b/src/borg/testsuite/crypto.py @@ -98,15 +98,15 @@ def test_AE(self): header = b'\x23' tests = [ # (ciphersuite class, exp_mac, exp_cdata) - (CHACHA20_POLY1305, - b'fd08594796e0706cde1e8b461e3e0555', - b'a093e4b0387526f085d3c40cca84a35230a5c0dd766453b77ba38bcff775',) ] if not is_libressl: tests += [ (AES256_OCB, b'b6909c23c9aaebd9abbe1ff42097652d', b'877ce46d2f62dee54699cebc3ba41d9ab613f7c486778c1b3636664b1493', ), + (CHACHA20_POLY1305, + b'fd08594796e0706cde1e8b461e3e0555', + b'a093e4b0387526f085d3c40cca84a35230a5c0dd766453b77ba38bcff775', ) ] for cs_cls, exp_mac, exp_cdata in tests: # print(repr(cs_cls)) @@ -142,15 +142,15 @@ def test_AEAD(self): header = b'\x12\x34\x56' tests = [ # (ciphersuite class, exp_mac, exp_cdata) - (CHACHA20_POLY1305, - b'b7e7c9a79f2404e14f9aad156bf091dd', - b'a093e4b0387526f085d3c40cca84a35230a5c0dd766453b77ba38bcff775',) ] if not is_libressl: tests += [ (AES256_OCB, b'f2748c412af1c7ead81863a18c2c1893', b'877ce46d2f62dee54699cebc3ba41d9ab613f7c486778c1b3636664b1493', ), + (CHACHA20_POLY1305, + b'b7e7c9a79f2404e14f9aad156bf091dd', + b'a093e4b0387526f085d3c40cca84a35230a5c0dd766453b77ba38bcff775', ) ] for cs_cls, exp_mac, exp_cdata in tests: # print(repr(cs_cls))