diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2024-10-31 18:39:41 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2024-11-04 21:20:14 +0100 |
commit | 29fb374c5260898b081aa8993bc68f6ab66b6057 (patch) | |
tree | 52a1d7896985c62b1fd39c4120214c11585c2fa7 /oox/source | |
parent | d9a0beb0b4dc22cf57ccb53ea0a4ab5442c43550 (diff) |
CryptTools: simplify the define conditions a bit
Change-Id: I6ef207eae6fbeec2ba77fa46a3274e43d02fe1e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176022
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'oox/source')
-rw-r--r-- | oox/source/crypto/CryptTools.cxx | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/oox/source/crypto/CryptTools.cxx b/oox/source/crypto/CryptTools.cxx index a7d76b375c39..32aefab57fac 100644 --- a/oox/source/crypto/CryptTools.cxx +++ b/oox/source/crypto/CryptTools.cxx @@ -266,6 +266,16 @@ struct CryptoImpl return mSymKey; } + void setupEncryptContext(std::vector<sal_uInt8>& key, std::vector<sal_uInt8>& iv, Crypto::CryptoType type) + { + setupCryptoContext(key, iv, type, CKA_ENCRYPT); + } + + void setupDecryptContext(std::vector<sal_uInt8>& key, std::vector<sal_uInt8>& iv, Crypto::CryptoType type) + { + setupCryptoContext(key, iv, type, CKA_DECRYPT); + } + void setupCryptoContext(std::vector<sal_uInt8>& key, std::vector<sal_uInt8>& iv, Crypto::CryptoType type, CK_ATTRIBUTE_TYPE operation) { CK_MECHANISM_TYPE mechanism = static_cast<CK_ULONG>(-1); @@ -373,15 +383,9 @@ Decrypt::Decrypt(std::vector<sal_uInt8>& key, std::vector<sal_uInt8>& iv, Crypto (void)key; (void)iv; (void)type; -#endif - -#if USE_TLS_OPENSSL +#else mpImpl->setupDecryptContext(key, iv, type); #endif - -#if USE_TLS_NSS - mpImpl->setupCryptoContext(key, iv, type, CKA_DECRYPT); -#endif // USE_TLS_NSS } sal_uInt32 Decrypt::update(std::vector<sal_uInt8>& output, std::vector<sal_uInt8>& input, sal_uInt32 inputLength) @@ -426,13 +430,9 @@ Encrypt::Encrypt(std::vector<sal_uInt8>& key, std::vector<sal_uInt8>& iv, Crypto (void)key; (void)iv; (void)type; -#endif - -#if USE_TLS_OPENSSL +#else mpImpl->setupEncryptContext(key, iv, type); -#elif USE_TLS_NSS - mpImpl->setupCryptoContext(key, iv, type, CKA_ENCRYPT); -#endif // USE_TLS_NSS +#endif } sal_uInt32 Encrypt::update(std::vector<sal_uInt8>& output, std::vector<sal_uInt8>& input, sal_uInt32 inputLength) @@ -480,11 +480,13 @@ sal_Int32 getSizeForHashType(CryptoHashType eType) CryptoHash::CryptoHash(std::vector<sal_uInt8>& rKey, CryptoHashType eType) : mnHashSize(getSizeForHashType(eType)) { -#if USE_TLS_OPENSSL - mpImpl->setupCryptoHashContext(rKey, eType); -#elif USE_TLS_NSS +#if USE_TLS_OPENSSL + USE_TLS_NSS > 0 mpImpl->setupCryptoHashContext(rKey, eType); + +#if USE_TLS_NSS PK11_DigestBegin(mpImpl->mContext); +#endif + #else (void)rKey; #endif |