OSDN Git Service

Let save hashes of confirmed certificate cache.
authors_kawamoto <s_kawamoto@users.sourceforge.jp>
Fri, 14 Oct 2011 15:29:48 +0000 (00:29 +0900)
committers_kawamoto <s_kawamoto@users.sourceforge.jp>
Fri, 14 Oct 2011 15:29:48 +0000 (00:29 +0900)
FFFTP_Eng_Release/FFFTP.exe
Release/FFFTP.exe
common.h
main.c
registory.c

index 9cafb4d..deaf886 100644 (file)
Binary files a/FFFTP_Eng_Release/FFFTP.exe and b/FFFTP_Eng_Release/FFFTP.exe differ
index fe228e4..f8cb214 100644 (file)
Binary files a/Release/FFFTP.exe and b/Release/FFFTP.exe differ
index 3757345..0cbc4bf 100644 (file)
--- a/common.h
+++ b/common.h
@@ -879,6 +879,10 @@ LIST_UNIX_70
 #define FEATURE_EPRT           0x00000004\r
 #define FEATURE_EPSV           0x00000008\r
 \r
 #define FEATURE_EPRT           0x00000004\r
 #define FEATURE_EPSV           0x00000008\r
 \r
+// 暗号化通信対応\r
+// REG_SECT_MAXの値を加味する必要がある\r
+#define MAX_CERT_CACHE_HASH 256\r
+\r
 \r
 /*=================================================\r
 *              ストラクチャ\r
 \r
 /*=================================================\r
 *              ストラクチャ\r
diff --git a/main.c b/main.c
index 19a6332..37a0743 100644 (file)
--- a/main.c
+++ b/main.c
@@ -42,6 +42,8 @@
 #include "common.h"\r
 #include "resource.h"\r
 #include "aes.h"\r
 #include "common.h"\r
 #include "resource.h"\r
 #include "aes.h"\r
+// 暗号化通信対応\r
+#include "sha.h"\r
 \r
 #include <htmlhelp.h>\r
 #include "helpid.h"\r
 \r
 #include <htmlhelp.h>\r
 #include "helpid.h"\r
@@ -210,6 +212,8 @@ int FolderAttr = NO;
 int FolderAttrNum = 777;\r
 // 同時接続対応\r
 int MaxThreadCount = 1;\r
 int FolderAttrNum = 777;\r
 // 同時接続対応\r
 int MaxThreadCount = 1;\r
+// 暗号化通信対応\r
+BYTE CertificateCacheHash[MAX_CERT_CACHE_HASH][20];\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -2828,16 +2832,31 @@ BOOL __stdcall SSLTimeoutCallback()
 BOOL __stdcall SSLConfirmCallback(BOOL bVerified, LPCSTR Certificate, LPCSTR CommonName)\r
 {\r
        BOOL bResult;\r
 BOOL __stdcall SSLConfirmCallback(BOOL bVerified, LPCSTR Certificate, LPCSTR CommonName)\r
 {\r
        BOOL bResult;\r
+       int i;\r
+       uint32 Hash[5];\r
        char* pm0;\r
        bResult = FALSE;\r
        char* pm0;\r
        bResult = FALSE;\r
-       pm0 = NULL;\r
-       if(pm0 = AllocateStringM(strlen(Certificate) + 1024))\r
+       sha_memory((char*)Certificate, (uint32)(strlen(Certificate) * sizeof(char)), (uint32*)&Hash);\r
+       for(i = 0; i < MAX_CERT_CACHE_HASH; i++)\r
        {\r
        {\r
-               sprintf(pm0, MSGJPN326, IsHostNameMatched(AskHostAdrs(), CommonName) ? MSGJPN327 : MSGJPN328, bVerified ? MSGJPN327 : MSGJPN328, Certificate);\r
-               if(MessageBox(GetMainHwnd(), pm0, "FFFTP", MB_YESNO) == IDYES)\r
+               if(memcmp(&CertificateCacheHash[i], &Hash, 20) == 0)\r
                        bResult = TRUE;\r
        }\r
                        bResult = TRUE;\r
        }\r
-       FreeDuplicatedString(pm0);\r
+       if(!bResult)\r
+       {\r
+               if(pm0 = AllocateStringM(strlen(Certificate) + 1024))\r
+               {\r
+                       sprintf(pm0, MSGJPN326, IsHostNameMatched(AskHostAdrs(), CommonName) ? MSGJPN327 : MSGJPN328, bVerified ? MSGJPN327 : MSGJPN328, Certificate);\r
+                       if(MessageBox(GetMainHwnd(), pm0, "FFFTP", MB_YESNO) == IDYES)\r
+                       {\r
+                               for(i = MAX_CERT_CACHE_HASH - 1; i >= 1; i--)\r
+                                       memcpy(&CertificateCacheHash[i], &CertificateCacheHash[i - 1], 20);\r
+                               memcpy(&CertificateCacheHash[0], &Hash, 20);\r
+                               bResult = TRUE;\r
+                       }\r
+                       FreeDuplicatedString(pm0);\r
+               }\r
+       }\r
        return bResult;\r
 }\r
 \r
        return bResult;\r
 }\r
 \r
index bdab8a2..94d7a8a 100644 (file)
@@ -182,6 +182,9 @@ extern int MirDownDelNotify;
 extern int FolderAttr;\r
 extern int FolderAttrNum;\r
 \r
 extern int FolderAttr;\r
 extern int FolderAttrNum;\r
 \r
+// 暗号化通信対応\r
+extern BYTE CertificateCacheHash[MAX_CERT_CACHE_HASH][20];\r
+\r
 /*----- マスタパスワードの設定 ----------------------------------------------\r
 *\r
 *      Parameter\r
 /*----- マスタパスワードの設定 ----------------------------------------------\r
 *\r
 *      Parameter\r
@@ -568,6 +571,9 @@ void SaveRegistory(void)
                                if((i = AskCurrentHost()) == HOSTNUM_NOENTRY)\r
                                        i = 0;\r
                                WriteIntValueToReg(hKey4, "CurSet", i);\r
                                if((i = AskCurrentHost()) == HOSTNUM_NOENTRY)\r
                                        i = 0;\r
                                WriteIntValueToReg(hKey4, "CurSet", i);\r
+\r
+                               // 暗号化通信対応\r
+                               WriteBinaryToReg(hKey4, "CertCacheHash", &CertificateCacheHash, sizeof(CertificateCacheHash));\r
                        }\r
                        CloseSubKey(hKey4);\r
                }\r
                        }\r
                        CloseSubKey(hKey4);\r
                }\r
@@ -900,6 +906,9 @@ int LoadRegistory(void)
                        ReadIntValueFromReg(hKey4, "CurSet", &Sets);\r
                        SetCurrentHost(Sets);\r
 \r
                        ReadIntValueFromReg(hKey4, "CurSet", &Sets);\r
                        SetCurrentHost(Sets);\r
 \r
+                       // 暗号化通信対応\r
+                       ReadBinaryFromReg(hKey4, "CertCacheHash", &CertificateCacheHash, sizeof(CertificateCacheHash));\r
+\r
                        CloseSubKey(hKey4);\r
                }\r
                CloseReg(hKey3);\r
                        CloseSubKey(hKey4);\r
                }\r
                CloseReg(hKey3);\r