diff options
author | sunpoet <sunpoet@FreeBSD.org> | 2012-04-25 00:31:16 +0800 |
---|---|---|
committer | sunpoet <sunpoet@FreeBSD.org> | 2012-04-25 00:31:16 +0800 |
commit | 87c8a5c30a0b2721cb417ad4ad449a6ee0b17a25 (patch) | |
tree | 6ab6f4b03ce4b50031a9ae10c53accd3bc2fba37 /archivers/unrar | |
parent | d632a52514be366783f03be23959df99a55c84de (diff) | |
download | freebsd-ports-gnome-87c8a5c30a0b2721cb417ad4ad449a6ee0b17a25.tar.gz freebsd-ports-gnome-87c8a5c30a0b2721cb417ad4ad449a6ee0b17a25.tar.zst freebsd-ports-gnome-87c8a5c30a0b2721cb417ad4ad449a6ee0b17a25.zip |
- Add OPTIONS OPENSSL_AES: use OpenSSL implementation of AES instead of bundled
one to speed up extraction of encrypted archives
- Bump PORTREVISION for package change
PR: ports/166968 (based on)
Submitted by: naddy
Diffstat (limited to 'archivers/unrar')
-rw-r--r-- | archivers/unrar/Makefile | 12 | ||||
-rw-r--r-- | archivers/unrar/files/patch-os.hpp | 13 | ||||
-rw-r--r-- | archivers/unrar/files/patch-rijndael.cpp | 79 | ||||
-rw-r--r-- | archivers/unrar/files/patch-rijndael.hpp | 24 |
4 files changed, 127 insertions, 1 deletions
diff --git a/archivers/unrar/Makefile b/archivers/unrar/Makefile index 2ae0787eecc1..3434c406910c 100644 --- a/archivers/unrar/Makefile +++ b/archivers/unrar/Makefile @@ -7,7 +7,7 @@ PORTNAME= unrar PORTVERSION= 4.10 -PORTREVISION= 1 +PORTREVISION= 2 PORTEPOCH= 5 CATEGORIES+= archivers MASTER_SITES= http://www.rarlab.com/rar/ \ @@ -17,6 +17,8 @@ DISTNAME= unrarsrc-4.1.4 MAINTAINER?= sunpoet@FreeBSD.org COMMENT= Extract, view & test RAR archives +OPTIONS= OPENSSL_AES "Use OpenSSL implementation of AES" on + CONFLICTS?= zh-unrar-[0-9].* unrar-iconv-[0-9].* MAKEFILE= makefile.unix @@ -26,6 +28,14 @@ WRKSRC= ${WRKDIR}/${PORTNAME} PLIST_FILES= bin/unrar PORTDOCS= license.txt readme.txt +.include <bsd.port.options.mk> + +.if !defined(WITHOUT_OPENSSL_AES) +CPPFLAGS+= -DOPENSSL_AES -I${OPENSSLINC} +LDFLAGS+= -L${OPENSSLLIB} -lcrypto +USE_OPENSSL= yes +.endif + post-patch: @${REINPLACE_CMD} -e '/^CXX/ s|^|#|' ${WRKSRC}/${MAKEFILE} diff --git a/archivers/unrar/files/patch-os.hpp b/archivers/unrar/files/patch-os.hpp new file mode 100644 index 000000000000..eab0a25276c8 --- /dev/null +++ b/archivers/unrar/files/patch-os.hpp @@ -0,0 +1,13 @@ +--- os.hpp.orig 2012-04-05 22:20:56.000000000 +0200 ++++ os.hpp 2012-04-05 22:21:36.000000000 +0200 +@@ -193,6 +193,10 @@ + #include <utime.h> + #include <locale.h> + ++#ifdef OPENSSL_AES ++#include <openssl/evp.h> ++#endif ++ + #ifdef S_IFLNK + #define SAVE_LINKS + #endif diff --git a/archivers/unrar/files/patch-rijndael.cpp b/archivers/unrar/files/patch-rijndael.cpp new file mode 100644 index 000000000000..f135f246a7fd --- /dev/null +++ b/archivers/unrar/files/patch-rijndael.cpp @@ -0,0 +1,79 @@ +--- rijndael.cpp.orig 2012-01-09 14:46:08.000000000 +0100 ++++ rijndael.cpp 2012-04-05 23:36:23.000000000 +0200 +@@ -7,6 +7,8 @@ + **************************************************************************/ + #include "rar.hpp" + ++#ifndef OPENSSL_AES ++ + const int uKeyLenInBytes=16, m_uRounds=10; + + static byte S[256],S5[256],rcon[30]; +@@ -54,6 +56,7 @@ inline void Copy128(byte *dest,const byt + #endif + } + ++#endif // OPENSSL_AES + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // API +@@ -61,13 +64,21 @@ inline void Copy128(byte *dest,const byt + + Rijndael::Rijndael() + { ++#ifndef OPENSSL_AES + if (S[0]==0) + GenerateTables(); ++#endif + } + + + void Rijndael::init(Direction dir,const byte * key,byte * initVector) + { ++#ifdef OPENSSL_AES ++ EVP_CIPHER_CTX_init(&ctx); ++ EVP_CipherInit_ex(&ctx, EVP_aes_128_cbc(), NULL, key, initVector, ++ dir == Decrypt ? 0 : 1); ++ EVP_CIPHER_CTX_set_padding(&ctx, 0); ++#else + m_direction = dir; + + byte keyMatrix[_MAX_KEY_COLUMNS][4]; +@@ -82,6 +93,7 @@ void Rijndael::init(Direction dir,const + + if(m_direction == Decrypt) + keyEncToDec(); ++#endif // OPENSSL_AES + } + + +@@ -91,6 +103,11 @@ size_t Rijndael::blockDecrypt(const byte + if (input == 0 || inputLen <= 0) + return 0; + ++#ifdef OPENSSL_AES ++ int outLen; ++ EVP_CipherUpdate(&ctx, outBuffer, &outLen, input, inputLen); ++ return outLen; ++#else + byte block[16], iv[4][4]; + memcpy(iv,m_initVector,16); + +@@ -113,9 +130,11 @@ size_t Rijndael::blockDecrypt(const byte + memcpy(m_initVector,iv,16); + + return 16*numBlocks; ++#endif // OPENSSL_AES + } + + ++#ifndef OPENSSL_AES + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ALGORITHM + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +@@ -296,3 +315,5 @@ 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); + } + } ++ ++#endif // OPENSSL_AES diff --git a/archivers/unrar/files/patch-rijndael.hpp b/archivers/unrar/files/patch-rijndael.hpp new file mode 100644 index 000000000000..1a9eaa3804f4 --- /dev/null +++ b/archivers/unrar/files/patch-rijndael.hpp @@ -0,0 +1,24 @@ +--- rijndael.hpp.orig 2012-01-09 14:46:08.000000000 +0100 ++++ rijndael.hpp 2012-04-05 22:42:56.000000000 +0200 +@@ -18,15 +18,21 @@ class Rijndael + public: + enum Direction { Encrypt , Decrypt }; + private: ++#ifndef OPENSSL_AES + void keySched(byte key[_MAX_KEY_COLUMNS][4]); + void keyEncToDec(); + void encrypt(const byte a[16], byte b[16]); + void decrypt(const byte a[16], byte b[16]); + void GenerateTables(); ++#endif + ++#ifdef OPENSSL_AES ++ EVP_CIPHER_CTX ctx; ++#else + Direction m_direction; + byte m_initVector[MAX_IV_SIZE]; + byte m_expandedKey[_MAX_ROUNDS+1][4][4]; ++#endif + public: + Rijndael(); + void init(Direction dir,const byte *key,byte *initVector); |