summaryrefslogtreecommitdiff
path: root/archivers/libunrar
diff options
context:
space:
mode:
Diffstat (limited to 'archivers/libunrar')
-rw-r--r--archivers/libunrar/Makefile49
-rw-r--r--archivers/libunrar/distinfo3
-rw-r--r--archivers/libunrar/files/patch-os.hpp13
-rw-r--r--archivers/libunrar/files/patch-rijndael.cpp136
-rw-r--r--archivers/libunrar/files/patch-rijndael.hpp24
-rw-r--r--archivers/libunrar/pkg-descr4
6 files changed, 229 insertions, 0 deletions
diff --git a/archivers/libunrar/Makefile b/archivers/libunrar/Makefile
new file mode 100644
index 000000000000..9f6a60bf0732
--- /dev/null
+++ b/archivers/libunrar/Makefile
@@ -0,0 +1,49 @@
+PORTNAME= libunrar
+PORTVERSION= 6.2.8
+CATEGORIES= archivers
+MASTER_SITES= http://www.rarlab.com/rar/
+DISTNAME= unrarsrc-${PORTVERSION}
+
+MAINTAINER= jhale@FreeBSD.org
+COMMENT= RAR archive extraction library
+WWW= https://www.rarlab.com/
+
+LICENSE= UNRAR
+LICENSE_NAME= UnRAR License
+LICENSE_FILE= ${WRKSRC}/license.txt
+LICENSE_PERMS= dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
+
+USES= compiler:c++11-lang gmake
+USE_LDCONFIG= yes
+
+ALL_TARGET= lib
+MAKEFILE= makefile
+MAKE_ARGS= AR="${AR}" \
+ CXX="${CXX}" \
+ CXXFLAGS="${CXXFLAGS} -fPIC" \
+ LDFLAGS="-Wl,-soname,${SONAME} -pthread ${LDFLAGS}" \
+ STRIP="${STRIP_CMD}"
+SONAME= libunrar.so.6
+WRKSRC= ${WRKDIR}/unrar
+
+OPTIONS_DEFINE= OPENSSL_AES
+OPTIONS_DEFAULT= OPENSSL_AES
+
+OPENSSL_AES_DESC= Use OpenSSL implementation of AES
+OPENSSL_AES_CPPFLAGS= -DOPENSSL_AES -I${OPENSSLINC}
+OPENSSL_AES_LDFLAGS= -L${OPENSSLLIB} -lcrypto
+OPENSSL_AES_USES= ssl
+
+PLIST_FILES= lib/libunrar.a \
+ lib/libunrar.so \
+ lib/${SONAME} \
+ include/${PORTNAME}/dll.hpp
+
+do-install:
+ ${INSTALL_DATA} ${WRKSRC}/libunrar.a ${STAGEDIR}${PREFIX}/lib/libunrar.a
+ ${INSTALL_LIB} ${WRKSRC}/libunrar.so ${STAGEDIR}${PREFIX}/lib/${SONAME}
+ ${RLN} ${STAGEDIR}${PREFIX}/lib/${SONAME} ${STAGEDIR}${PREFIX}/lib/${SONAME:R}
+ @${MKDIR} ${STAGEDIR}${PREFIX}/include/${PORTNAME}
+ ${INSTALL_DATA} ${WRKSRC}/dll.hpp ${STAGEDIR}${PREFIX}/include/${PORTNAME}/dll.hpp
+
+.include <bsd.port.mk>
diff --git a/archivers/libunrar/distinfo b/archivers/libunrar/distinfo
new file mode 100644
index 000000000000..b35936afea0e
--- /dev/null
+++ b/archivers/libunrar/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1686905718
+SHA256 (unrarsrc-6.2.8.tar.gz) = 1777e3d3b073815ff68a411ddb1ab76d0a4e1f58ecc7080035b27b52967ff911
+SIZE (unrarsrc-6.2.8.tar.gz) = 246249
diff --git a/archivers/libunrar/files/patch-os.hpp b/archivers/libunrar/files/patch-os.hpp
new file mode 100644
index 000000000000..ef633fb42257
--- /dev/null
+++ b/archivers/libunrar/files/patch-os.hpp
@@ -0,0 +1,13 @@
+--- os.hpp.orig 2023-01-17 16:25:54 UTC
++++ os.hpp
+@@ -173,6 +173,10 @@
+ #include <locale.h>
+
+
++#ifdef OPENSSL_AES
++#include <openssl/evp.h>
++#endif // OPENSSL_AES
++
+ #ifdef S_IFLNK
+ #define SAVE_LINKS
+ #endif
diff --git a/archivers/libunrar/files/patch-rijndael.cpp b/archivers/libunrar/files/patch-rijndael.cpp
new file mode 100644
index 000000000000..92b411d99b5c
--- /dev/null
+++ b/archivers/libunrar/files/patch-rijndael.cpp
@@ -0,0 +1,136 @@
+--- rijndael.cpp.orig 2023-01-17 16:25:54 UTC
++++ rijndael.cpp
+@@ -3,6 +3,8 @@
+ **************************************************************************/
+ #include "rar.hpp"
+
++#ifndef OPENSSL_AES
++
+ #ifdef USE_SSE
+ #include <wmmintrin.h>
+ #endif
+@@ -75,6 +77,7 @@ inline void Copy128(byte *dest,const byte *src)
+ #endif
+ }
+
++#endif // OPENSSL_AES
+
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // API
+@@ -82,14 +85,41 @@ inline void Copy128(byte *dest,const byte *src)
+
+ Rijndael::Rijndael()
+ {
++#ifndef OPENSSL_AES
+ if (S5[0]==0)
+ GenerateTables();
++#endif // OPENSSL_AES
+ CBCMode = true; // Always true for RAR.
+ }
+
+
+ void Rijndael::Init(bool Encrypt,const byte *key,uint keyLen,const byte * initVector)
+ {
++#ifdef OPENSSL_AES
++ const EVP_CIPHER *cipher;
++ switch(keyLen)
++ {
++ case 128:
++ cipher = EVP_aes_128_cbc();
++ break;
++ case 192:
++ cipher = EVP_aes_192_cbc();
++ break;
++ case 256:
++ cipher = EVP_aes_256_cbc();
++ break;
++ }
++
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
++ EVP_CIPHER_CTX_init(&ctx);
++ EVP_CipherInit_ex(&ctx, cipher, NULL, key, initVector, Encrypt);
++ EVP_CIPHER_CTX_set_padding(&ctx, 0);
++#else
++ EVP_CIPHER_CTX_init(ctx);
++ EVP_CipherInit_ex(ctx, cipher, NULL, key, initVector, Encrypt);
++ EVP_CIPHER_CTX_set_padding(ctx, 0);
++#endif
++#else // OPENSSL_AES
+ // 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)
+@@ -141,6 +171,7 @@ void Rijndael::Init(bool Encrypt,const byte *key,uint
+
+ if(!Encrypt)
+ keyEncToDec();
++#endif // OPENSSL_AES
+ }
+
+
+@@ -149,6 +180,15 @@ void Rijndael::blockEncrypt(const byte *input,size_t i
+ if (inputLen <= 0)
+ return;
+
++#ifdef OPENSSL_AES
++ int outLen;
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
++ EVP_CipherUpdate(&ctx, outBuffer, &outLen, input, inputLen);
++#else
++ EVP_CipherUpdate(ctx, outBuffer, &outLen, input, inputLen);
++#endif
++ return;
++#else // OPENSSL_AES
+ size_t numBlocks = inputLen/16;
+ #if defined(USE_SSE)
+ if (AES_NI)
+@@ -213,6 +253,7 @@ void Rijndael::blockEncrypt(const byte *input,size_t i
+ input += 16;
+ }
+ Copy128(m_initVector,prevBlock);
++#endif // OPENSSL_AES
+ }
+
+
+@@ -288,6 +329,15 @@ void Rijndael::blockDecrypt(const byte *input, size_t
+ if (inputLen <= 0)
+ return;
+
++#ifdef OPENSSL_AES
++ int outLen;
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
++ EVP_CipherUpdate(&ctx, outBuffer, &outLen, input, inputLen);
++#else
++ EVP_CipherUpdate(ctx, outBuffer, &outLen, input, inputLen);
++#endif
++ return;
++#else // OPENSSL_AES
+ size_t numBlocks=inputLen/16;
+ #if defined(USE_SSE)
+ if (AES_NI)
+@@ -356,6 +406,8 @@ void Rijndael::blockDecrypt(const byte *input, size_t
+ }
+
+ memcpy(m_initVector,iv,16);
++
++#endif // OPENSSL_AES
+ }
+
+
+@@ -426,7 +478,7 @@ void Rijndael::blockDecryptNeon(const byte *input, siz
+ }
+ #endif
+
+-
++#ifndef OPENSSL_AES
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // ALGORITHM
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+@@ -555,7 +607,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();
diff --git a/archivers/libunrar/files/patch-rijndael.hpp b/archivers/libunrar/files/patch-rijndael.hpp
new file mode 100644
index 000000000000..0e1ccbfbd379
--- /dev/null
+++ b/archivers/libunrar/files/patch-rijndael.hpp
@@ -0,0 +1,24 @@
+--- rijndael.hpp.orig 2023-01-17 16:25:54 UTC
++++ rijndael.hpp
+@@ -12,6 +12,13 @@
+ class Rijndael
+ {
+ private:
++#ifdef OPENSSL_AES
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
++ EVP_CIPHER_CTX ctx;
++#else
++ EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
++#endif
++#else // OPENSSL_AES
+ #ifdef USE_SSE
+ void blockEncryptSSE(const byte *input,size_t numBlocks,byte *outBuffer);
+ void blockDecryptSSE(const byte *input, size_t numBlocks, byte *outBuffer);
+@@ -31,6 +38,7 @@ class Rijndael
+ void keySched(byte key[_MAX_KEY_COLUMNS][4]);
+ void keyEncToDec();
+ void GenerateTables();
++#endif // OPENSSL_AES
+
+ // RAR always uses CBC, but we may need to turn it off when calling
+ // this code from other archive formats with CTR and other modes.
diff --git a/archivers/libunrar/pkg-descr b/archivers/libunrar/pkg-descr
new file mode 100644
index 000000000000..799db1eedf95
--- /dev/null
+++ b/archivers/libunrar/pkg-descr
@@ -0,0 +1,4 @@
+The UnRAR library is a minor part of the RAR archiver and contains
+the RAR uncompression algorithm. UnRAR requires a very small amount
+of memory to operate. It can be used by other programs to extract
+RAR archives.