aboutsummaryrefslogtreecommitdiff
path: root/archivers/unrar/files/patch-rijndael.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'archivers/unrar/files/patch-rijndael.cpp')
-rw-r--r--archivers/unrar/files/patch-rijndael.cpp101
1 files changed, 62 insertions, 39 deletions
diff --git a/archivers/unrar/files/patch-rijndael.cpp b/archivers/unrar/files/patch-rijndael.cpp
index 2656ded5d19e..5a4d38cb0abf 100644
--- a/archivers/unrar/files/patch-rijndael.cpp
+++ b/archivers/unrar/files/patch-rijndael.cpp
@@ -1,37 +1,44 @@
---- rijndael.cpp.orig 2019-04-27 20:05:20 UTC
+--- rijndael.cpp.orig 2024-02-26 09:03:53 UTC
+++ rijndael.cpp
-@@ -7,6 +7,8 @@
- ***************************************************************************/
+@@ -3,6 +3,7 @@
+ **************************************************************************/
#include "rar.hpp"
-+#ifndef OPENSSL_AES
-+
++#if !defined(OPENSSL_AES)
#ifdef USE_SSE
#include <wmmintrin.h>
#endif
-@@ -56,6 +58,7 @@ inline void Copy128(byte *dest,const byt
+@@ -74,6 +75,7 @@ inline void Copy128(byte *dest,const byte *src)
+ dest[I]=src[I];
#endif
}
-
+#endif // OPENSSL_AES
+
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // API
-@@ -63,14 +66,41 @@ inline void Copy128(byte *dest,const byt
+@@ -82,20 +84,49 @@ Rijndael::Rijndael()
Rijndael::Rijndael()
{
-+#ifndef OPENSSL_AES
- if (S[0]==0)
++#if !defined(OPENSSL_AES)
+ if (S5[0]==0)
GenerateTables();
+#endif // OPENSSL_AES
CBCMode = true; // Always true for RAR.
++#if !defined(OPENSSL_AES)
+ #ifdef USE_SSE
+ AES_NI=false;
+ #endif
+ #ifdef USE_NEON_AES
+ AES_Neon=false;
+ #endif
++#endif // OPENSSL_AES
}
void Rijndael::Init(bool Encrypt,const byte *key,uint keyLen,const byte * initVector)
{
-+#ifdef OPENSSL_AES
++#if defined(OPENSSL_AES)
+ const EVP_CIPHER *cipher;
+ switch(keyLen)
+ {
@@ -50,40 +57,40 @@
+ EVP_CIPHER_CTX_init(&ctx);
+ EVP_CipherInit_ex(&ctx, cipher, NULL, key, initVector, Encrypt);
+ EVP_CIPHER_CTX_set_padding(&ctx, 0);
-+#else
++#else // OPENSSL_VERSION_NUMBER
+ EVP_CIPHER_CTX_init(ctx);
+ EVP_CipherInit_ex(ctx, cipher, NULL, key, initVector, Encrypt);
+ EVP_CIPHER_CTX_set_padding(ctx, 0);
-+#endif
++#endif // OPENSSL_VERSION_NUMBER
+#else // OPENSSL_AES
- #ifdef USE_SSE
- // Check SSE here instead of constructor, so if object is a part of some
- // structure memset'ed before use, this variable is not lost.
-@@ -114,6 +144,7 @@ void Rijndael::Init(bool Encrypt,const b
+ // Check SIMD here instead of constructor, so if object is a part of some
+ // structure memset'ed before use, these variables are not lost.
+ #if defined(USE_SSE)
+@@ -165,6 +196,7 @@ void Rijndael::Init(bool Encrypt,const byte *key,uint
if(!Encrypt)
keyEncToDec();
+#endif // OPENSSL_AES
}
- void Rijndael::blockEncrypt(const byte *input,size_t inputLen,byte *outBuffer)
-@@ -121,6 +152,15 @@ void Rijndael::blockEncrypt(const byte *
+
+@@ -173,6 +205,15 @@ void Rijndael::blockEncrypt(const byte *input,size_t i
if (inputLen <= 0)
return;
-+#ifdef OPENSSL_AES
++#if defined(OPENSSL_AES)
+ int outLen;
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ EVP_CipherUpdate(&ctx, outBuffer, &outLen, input, inputLen);
-+#else
++#else // OPENSSL_VERSION_NUMBER
+ EVP_CipherUpdate(ctx, outBuffer, &outLen, input, inputLen);
-+#endif
++#endif // OPENSSL_VERSION_NUMBER
+ return;
+#else // OPENSSL_AES
size_t numBlocks = inputLen/16;
- #ifdef USE_SSE
+ #if defined(USE_SSE)
if (AES_NI)
-@@ -179,6 +219,7 @@ void Rijndael::blockEncrypt(const byte *
+@@ -237,9 +278,11 @@ void Rijndael::blockEncrypt(const byte *input,size_t i
input += 16;
}
Copy128(m_initVector,prevBlock);
@@ -91,46 +98,62 @@
}
-@@ -220,6 +261,15 @@ void Rijndael::blockDecrypt(const byte *
++#if !defined(OPENSSL_AES)
+ #ifdef USE_SSE
+ void Rijndael::blockEncryptSSE(const byte *input,size_t numBlocks,byte *outBuffer)
+ {
+@@ -305,6 +348,7 @@ void Rijndael::blockEncryptNeon(const byte *input,size
+ return;
+ }
+ #endif
++#endif // OPENSSL_AES
+
+
+ void Rijndael::blockDecrypt(const byte *input, size_t inputLen, byte *outBuffer)
+@@ -312,6 +356,15 @@ void Rijndael::blockDecrypt(const byte *input, size_t
if (inputLen <= 0)
return;
-+#ifdef OPENSSL_AES
++#if defined(OPENSSL_AES)
+ int outLen;
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ EVP_CipherUpdate(&ctx, outBuffer, &outLen, input, inputLen);
-+#else
++#else // OPENSSL_VERSION_NUMBER
+ EVP_CipherUpdate(ctx, outBuffer, &outLen, input, inputLen);
-+#endif
++#endif // OPENSSL_VERSION_NUMBER
+ return;
+#else // OPENSSL_AES
size_t numBlocks=inputLen/16;
- #ifdef USE_SSE
+ #if defined(USE_SSE)
if (AES_NI)
-@@ -282,6 +332,8 @@ void Rijndael::blockDecrypt(const byte *
+@@ -380,9 +433,11 @@ void Rijndael::blockDecrypt(const byte *input, size_t
}
memcpy(m_initVector,iv,16);
-+
+#endif // OPENSSL_AES
}
-@@ -317,7 +369,7 @@ void Rijndael::blockDecryptSSE(const byt
++#if !defined(OPENSSL_AES)
+ #ifdef USE_SSE
+ void Rijndael::blockDecryptSSE(const byte *input, size_t numBlocks, byte *outBuffer)
+ {
+@@ -449,8 +504,10 @@ void Rijndael::blockDecryptNeon(const byte *input, siz
+ memcpy(m_initVector,iv,16);
}
#endif
++#endif // OPENSSL_AES
+
--
-+#ifndef OPENSSL_AES
++#if !defined(OPENSSL_AES)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ALGORITHM
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-@@ -457,7 +509,7 @@ void Rijndael::GenerateTables()
- U1[b][0]=U2[b][1]=U3[b][2]=U4[b][3]=T5[i][0]=T6[i][1]=T7[i][2]=T8[i][3]=FFmul0e(b);
+@@ -579,6 +636,7 @@ void Rijndael::GenerateTables()
+ U1[b][0]=U2[b][1]=U3[b][2]=U4[b][3]=T5[I][0]=T6[I][1]=T7[I][2]=T8[I][3]=gmul(b,0xe);
}
}
--
+#endif // OPENSSL_AES
+
#if 0
- static void TestRijndael();