diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-08-22 09:49:25 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-08-23 20:39:39 +0200 |
commit | 4bc16aeb73c1201f187742e0fefe35521fae77ac (patch) | |
tree | c3324a63b842682ad53c1cb4fa7b2581c661e468 /sal/qa | |
parent | 229340812f6e6cc8c868915055583f60c82a8cf3 (diff) |
rhbz#1618703: Allow to use OpenSSL as backend for rtl/cipher.h
...with new configuration option --enable-cipher-openssl-backend
rtl/cipher.h (which is part of the stable URE interface) offers functionality to
en-/decrypt data with Blowfish in ECB, CBC, and streaming CFB mode, and with RC4
(aka ARCFOUR; which is a stream cipher). LO itself only uses Blowfish CFB and
RC4, so only those are wired to OpenSSL for now, for simplicity. Using Blowfish
ECB and CBC, or Blowfish CFB in DirectionBoth mode would cause failures for now
(cf. sal/qa/rtl/cipher/rtl_cipher.cxx); the assumption is that no external code
actually makes use of this functionality.
Using NSS instead of OpenSSL could be an alternative, but there appears to be no
support in NSS for Blowfish in streaming CFB mode, only CKM_BLOWFISH_CBC for
CBC mode.
Change-Id: I0bc042961539ed46844c96cb1c808209578528a0
Reviewed-on: https://gerrit.libreoffice.org/59428
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sal/qa')
-rw-r--r-- | sal/qa/rtl/cipher/rtl_cipher.cxx | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/sal/qa/rtl/cipher/rtl_cipher.cxx b/sal/qa/rtl/cipher/rtl_cipher.cxx index e8877a92c5d5..57c22eb573ac 100644 --- a/sal/qa/rtl/cipher/rtl_cipher.cxx +++ b/sal/qa/rtl/cipher/rtl_cipher.cxx @@ -37,8 +37,12 @@ public: void create_001() { rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB); +#if defined LIBO_CIPHER_OPENSSL_BACKEND + CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher); +#else CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr); rtl_cipher_destroy(aCipher); +#endif } void create_002() { @@ -48,8 +52,12 @@ public: void create_003() { rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeCBC); +#if defined LIBO_CIPHER_OPENSSL_BACKEND + CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher); +#else CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr); rtl_cipher_destroy(aCipher); +#endif } void create_004() { @@ -101,14 +109,22 @@ public: void createBF_001() { rtlCipher aCipher = rtl_cipher_createBF(rtl_Cipher_ModeECB); +#if defined LIBO_CIPHER_OPENSSL_BACKEND + CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher); +#else CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr); rtl_cipher_destroy(aCipher); +#endif } void createBF_002() { rtlCipher aCipher = rtl_cipher_createBF(rtl_Cipher_ModeCBC); +#if defined LIBO_CIPHER_OPENSSL_BACKEND + CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher); +#else CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr); rtl_cipher_destroy(aCipher); +#endif } void createBF_003() { @@ -141,6 +157,12 @@ public: void test_encode(sal_uInt8 _nKeyValue, sal_uInt8 _nArgValue, rtl::OString const& _sPlainTextStr) { rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB); +#if defined LIBO_CIPHER_OPENSSL_BACKEND + CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher); + (void) _nKeyValue; + (void) _nArgValue; + (void) _sPlainTextStr; +#else CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr); sal_uInt32 nKeyLen = 16; @@ -184,11 +206,18 @@ public: delete [] pKeyBuffer; rtl_cipher_destroy(aCipher); +#endif } void test_encode_and_decode(sal_uInt8 _nKeyValue, sal_uInt8 _nArgValue, rtl::OString const& _sPlainTextStr) { rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB); +#if defined LIBO_CIPHER_OPENSSL_BACKEND + CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher); + (void) _nKeyValue; + (void) _nArgValue; + (void) _sPlainTextStr; +#else CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr); sal_uInt32 nKeyLen = 16; @@ -236,6 +265,7 @@ public: delete [] pKeyBuffer; rtl_cipher_destroy(aCipher); +#endif } void decode_001() @@ -286,8 +316,12 @@ public: void destroy_001() { rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeCBC); +#if defined LIBO_CIPHER_OPENSSL_BACKEND + CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher); +#else CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr); rtl_cipher_destroy(aCipher); +#endif } // Change the following lines only, if you add, remove or rename // member functions of the current class, @@ -305,10 +339,14 @@ public: void destroyBF_001() { rtlCipher aCipher = rtl_cipher_createBF(rtl_Cipher_ModeECB); +#if defined LIBO_CIPHER_OPENSSL_BACKEND + CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher); +#else CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr); rtl_cipher_destroyBF(aCipher); // more proforma // should not GPF +#endif } // Change the following lines only, if you add, remove or rename // member functions of the current class, @@ -326,6 +364,12 @@ public: void test_encode(sal_uInt8 _nKeyValue, sal_uInt8 _nArgValue, sal_uInt8 _nDataValue) { rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB); +#if defined LIBO_CIPHER_OPENSSL_BACKEND + CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher); + (void) _nKeyValue; + (void) _nArgValue; + (void) _nDataValue; +#else CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr); sal_uInt32 nKeyLen = 16; @@ -360,6 +404,7 @@ public: delete [] pKeyBuffer; rtl_cipher_destroy(aCipher); +#endif } void encode_001() @@ -407,6 +452,9 @@ public: void init_001() { rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB); +#if defined LIBO_CIPHER_OPENSSL_BACKEND + CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher); +#else CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr); sal_uInt32 nKeyLen = 16; @@ -424,11 +472,15 @@ public: delete [] pKeyBuffer; rtl_cipher_destroy(aCipher); +#endif } void init_002() { rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB); +#if defined LIBO_CIPHER_OPENSSL_BACKEND + CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher); +#else CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr); sal_uInt32 nKeyLen = 16; @@ -447,10 +499,14 @@ public: delete [] pKeyBuffer; rtl_cipher_destroy(aCipher); +#endif } void init_003() { rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB); +#if defined LIBO_CIPHER_OPENSSL_BACKEND + CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher); +#else CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr); sal_uInt32 nKeyLen = 16; @@ -469,10 +525,14 @@ public: delete [] pKeyBuffer; rtl_cipher_destroy(aCipher); +#endif } void init_004() { rtlCipher aCipher = rtl_cipher_create(rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB); +#if defined LIBO_CIPHER_OPENSSL_BACKEND + CPPUNIT_ASSERT_EQUAL(rtlCipher(nullptr), aCipher); +#else CPPUNIT_ASSERT_MESSAGE("create failed.", aCipher != nullptr); sal_uInt32 nKeyLen = 16; @@ -492,6 +552,7 @@ public: delete [] pKeyBuffer; rtl_cipher_destroy(aCipher); +#endif } // Change the following lines only, if you add, remove or rename // member functions of the current class, |