+++ /dev/null
-From 1fad008e1adba5cb596da6f9ec6a244d49a585cf Mon Sep 17 00:00:00 2001
-From: Davide Beatrici <davidebeatrici@gmail.com>
-Date: Mon, 9 Apr 2018 22:02:34 +0200
-Subject: [PATCH] Encrypt: set default RSA key size to 1024 everywhere, using
- the RSA_KEY_SIZE macro
-
-This commit also fixes the problem described in #31, which was caused by the test key generated in RsaCheck() being too small for newer OpenSSL versions.
----
- src/Mayaqua/Encrypt.c | 8 ++++----
- src/Mayaqua/Encrypt.h | 2 +-
- 2 files changed, 5 insertions(+), 5 deletions(-)
-
---- a/src/Mayaqua/Encrypt.c
-+++ b/src/Mayaqua/Encrypt.c
-@@ -2458,7 +2458,7 @@ bool RsaVerifyEx(void *data, UINT data_s
- }\r
- if (bits == 0)\r
- {\r
-- bits = 1024;\r
-+ bits = RSA_KEY_SIZE;\r
- }\r
- \r
- // Hash the data\r
-@@ -2497,7 +2497,7 @@ bool RsaSignEx(void *dst, void *src, UIN
- }\r
- if (bits == 0)\r
- {\r
-- bits = 1024;\r
-+ bits = RSA_KEY_SIZE;\r
- }\r
- \r
- Zero(dst, bits / 8);\r
-@@ -2684,7 +2684,7 @@ bool RsaCheck()
- BIO *bio;\r
- char errbuf[MAX_SIZE];\r
- UINT size = 0;\r
-- UINT bit = 32;\r
-+ UINT bit = RSA_KEY_SIZE;\r
- // Validate arguments\r
- \r
- // Key generation\r
-@@ -2754,7 +2754,7 @@ bool RsaGen(K **priv, K **pub, UINT bit)
- }\r
- if (bit == 0)\r
- {\r
-- bit = 1024;\r
-+ bit = RSA_KEY_SIZE;\r
- }\r
- \r
- // Key generation\r
---- a/src/Mayaqua/Encrypt.h
-+++ b/src/Mayaqua/Encrypt.h
-@@ -128,7 +128,7 @@ void RAND_Free_For_SoftEther();
- #define DES_IV_SIZE 8 // DES IV size\r
- #define DES_BLOCK_SIZE 8 // DES block size\r
- #define DES3_KEY_SIZE (8 * 3) // 3DES key size\r
--#define RSA_KEY_SIZE 128 // RSA key size\r
-+#define RSA_KEY_SIZE 1024 // RSA key size\r
- #define DH_KEY_SIZE 128 // DH key size\r
- #define RSA_MIN_SIGN_HASH_SIZE (15 + SHA1_HASH_SIZE) // Minimum RSA hash size\r
- #define RSA_SIGN_HASH_SIZE (RSA_MIN_SIGN_HASH_SIZE) // RSA hash size\r
index f3b3908..06b7fea 100644
--- a/src/Mayaqua/Encrypt.c
+++ b/src/Mayaqua/Encrypt.c
-@@ -129,6 +129,7 @@
+@@ -120,6 +120,7 @@
#include <openssl/rand.h>\r
#include <openssl/engine.h>\r
#include <openssl/bio.h>\r
#include <openssl/x509.h>\r
#include <openssl/pkcs7.h>\r
#include <openssl/pkcs12.h>\r
-@@ -137,6 +138,7 @@
+@@ -128,6 +129,7 @@
#include <openssl/md4.h>\r
#include <openssl/hmac.h>\r
#include <openssl/sha.h>\r
#include <openssl/des.h>\r
#include <openssl/aes.h>\r
#include <openssl/dh.h>\r
-@@ -634,7 +636,7 @@ UINT CipherProcess(CIPHER *c, void *iv, void *dest, void *src, UINT size)
+@@ -625,7 +627,7 @@ UINT CipherProcess(CIPHER *c, void *iv, void *dest, void *src, UINT size)
return 0;\r
}\r
\r
{\r
return 0;\r
}\r
-@@ -933,6 +935,7 @@ BUF *BigNumToBuf(const BIGNUM *bn)
+@@ -924,6 +926,7 @@ BUF *BigNumToBuf(const BIGNUM *bn)
// Initialization of the lock of OpenSSL\r
void OpenSSL_InitLock()\r
{\r
UINT i;\r
\r
// Initialization of the lock object\r
-@@ -946,11 +949,13 @@ void OpenSSL_InitLock()
+@@ -937,11 +940,13 @@ void OpenSSL_InitLock()
// Setting the lock function\r
CRYPTO_set_locking_callback(OpenSSL_Lock);\r
CRYPTO_set_id_callback(OpenSSL_Id);\r
UINT i;\r
\r
for (i = 0;i < ssl_lock_num;i++)\r
-@@ -962,11 +967,13 @@ void OpenSSL_FreeLock()
+@@ -953,11 +958,13 @@ void OpenSSL_FreeLock()
\r
CRYPTO_set_locking_callback(NULL);\r
CRYPTO_set_id_callback(NULL);\r
LOCK *lock = ssl_lock_obj[n];\r
\r
if (mode & CRYPTO_LOCK)\r
-@@ -979,12 +986,15 @@ void OpenSSL_Lock(int mode, int n, const char *file, int line)
+@@ -970,12 +977,15 @@ void OpenSSL_Lock(int mode, int n, const char *file, int line)
// Unlock\r
Unlock(lock);\r
}\r
}\r
\r
// Get the display name of the certificate\r
-@@ -1908,8 +1918,8 @@ X509 *NewX509(K *pub, K *priv, X *ca, NAME *name, UINT days, X_SERIAL *serial)
+@@ -1899,8 +1909,8 @@ X509 *NewX509(K *pub, K *priv, X *ca, NAME *name, UINT days, X_SERIAL *serial)
X509_set_version(x509, 2L);\r
\r
// Set the Expiration\r
if (!UINT64ToAsn1Time(t1, notBefore))\r
{\r
FreeX509(x509);\r
-@@ -2050,8 +2060,8 @@ X509 *NewRootX509(K *pub, K *priv, NAME *name, UINT days, X_SERIAL *serial)
+@@ -2041,8 +2051,8 @@ X509 *NewRootX509(K *pub, K *priv, NAME *name, UINT days, X_SERIAL *serial)
X509_set_version(x509, 2L);\r
\r
// Set the Expiration\r
if (!UINT64ToAsn1Time(t1, notBefore))\r
{\r
FreeX509(x509);\r
-@@ -2677,6 +2687,43 @@ bool RsaCheckEx()
+@@ -2697,6 +2707,43 @@ bool RsaCheckEx()
\r
return false;\r
}\r
bool RsaCheck()\r
{\r
RSA *rsa;\r
-@@ -2690,12 +2737,11 @@ bool RsaCheck()
+@@ -2710,12 +2757,11 @@ bool RsaCheck()
// Key generation\r
Lock(openssl_lock);\r
{\r
return false;\r
}\r
\r
-@@ -2760,12 +2806,11 @@ bool RsaGen(K **priv, K **pub, UINT bit)
+@@ -2780,12 +2826,11 @@ bool RsaGen(K **priv, K **pub, UINT bit)
// Key generation\r
Lock(openssl_lock);\r
{\r
return false;\r
}\r
\r
-@@ -3875,7 +3920,7 @@ X *X509ToX(X509 *x509)
+@@ -3895,7 +3940,7 @@ X *X509ToX(X509 *x509)
{\r
if (OBJ_obj2nid(ad->method) == NID_ad_ca_issuers && ad->location->type == GEN_URI)\r
{\r
\r
if (IsEmptyStr(uri) == false)\r
{\r
-@@ -4088,7 +4133,9 @@ void Rand(void *buf, UINT size)
+@@ -4108,7 +4153,9 @@ void Rand(void *buf, UINT size)
// Delete a thread-specific information that OpenSSL has holded\r
void FreeOpenSSLThreadState()\r
{\r
}\r
\r
// Release the Crypt library\r
-@@ -4110,13 +4157,16 @@ void InitCryptLibrary()
+@@ -4130,13 +4177,16 @@ void InitCryptLibrary()
CheckIfIntelAesNiSupportedInit();\r
// RAND_Init_For_SoftEther()\r
openssl_lock = NewLock();\r
index 194f8e6..177129e 100644
--- a/src/Mayaqua/Mayaqua.h
+++ b/src/Mayaqua/Mayaqua.h
-@@ -292,7 +292,7 @@ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, char *CmdLine, int CmdShow)
+@@ -283,7 +283,7 @@ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, char *CmdLine, int CmdShow)
#include <ifaddrs.h>\r
#endif // MAYAQUA_SUPPORTS_GETIFADDRS\r
\r
index 8219d5d..8020290 100644
--- a/src/makefiles/linux_32bit.mak
+++ b/src/makefiles/linux_32bit.mak
-@@ -31,7 +31,7 @@ OPTIONS_LINK_DEBUG=-g -fsigned-char -lm -ldl -lrt -lpthread -lssl -lcrypto -lrea
+@@ -68,7 +68,7 @@ OPTIONS_LINK_DEBUG=-g -fsigned-char -lm -ldl -lrt -lpthread -lssl -lcrypto -lrea
OPTIONS_COMPILE_RELEASE=-DNDEBUG -DVPN_SPEED -DUNIX -DUNIX_LINUX -D_REENTRANT -DREENTRANT -D_THREAD_SAFE -D_THREADSAFE -DTHREAD_SAFE -DTHREADSAFE -D_FILE_OFFSET_BITS=64 -I./src/ -I./src/Cedar/ -I./src/Mayaqua/ -O2 -fsigned-char
index 7f81b58..a36e0de 100644
--- a/src/makefiles/linux_64bit.mak
+++ b/src/makefiles/linux_64bit.mak
-@@ -31,7 +31,7 @@ OPTIONS_LINK_DEBUG=-g -fsigned-char -m64 -lm -ldl -lrt -lpthread -lssl -lcrypto
+@@ -68,7 +68,7 @@ OPTIONS_LINK_DEBUG=-g -fsigned-char -m64 -lm -ldl -lrt -lpthread -lssl -lcrypto
OPTIONS_COMPILE_RELEASE=-DNDEBUG -DVPN_SPEED -DUNIX -DUNIX_LINUX -DCPU_64 -D_REENTRANT -DREENTRANT -D_THREAD_SAFE -D_THREADSAFE -DTHREAD_SAFE -DTHREADSAFE -D_FILE_OFFSET_BITS=64 -I./src/ -I./src/Cedar/ -I./src/Mayaqua/ -O2 -fsigned-char