From dcb6092eb861864614db5194f7cc651cfa6bfc1b Mon Sep 17 00:00:00 2001 From: Student Main Date: Sun, 5 Jan 2020 22:53:04 +0800 Subject: [PATCH 1/3] set default method to chacha20-ietf-poly1305 in all place... --- shadowsocks-csharp/Encryption/EncryptorFactory.cs | 2 +- shadowsocks-csharp/Model/Server.cs | 7 +++++-- shadowsocks-csharp/View/ConfigForm.cs | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/shadowsocks-csharp/Encryption/EncryptorFactory.cs b/shadowsocks-csharp/Encryption/EncryptorFactory.cs index 169a67ce..fcae221a 100644 --- a/shadowsocks-csharp/Encryption/EncryptorFactory.cs +++ b/shadowsocks-csharp/Encryption/EncryptorFactory.cs @@ -70,7 +70,7 @@ namespace Shadowsocks.Encryption { if (method.IsNullOrEmpty()) { - method = "aes-256-cfb"; + method = Model.Server.DefaultMethod; } method = method.ToLowerInvariant(); diff --git a/shadowsocks-csharp/Model/Server.cs b/shadowsocks-csharp/Model/Server.cs index 88f72c2c..6e08f50e 100755 --- a/shadowsocks-csharp/Model/Server.cs +++ b/shadowsocks-csharp/Model/Server.cs @@ -11,6 +11,9 @@ namespace Shadowsocks.Model [Serializable] public class Server { + public const string DefaultMethod = "chacha20-ietf-poly1305"; + public const int DefaultPort = 8388; + #region ParseLegacyURL public static readonly Regex UrlFinder = new Regex(@"ss://(?[A-Za-z0-9+-/=_]+)(?:#(?\S+))?", RegexOptions.IgnoreCase), @@ -69,8 +72,8 @@ namespace Shadowsocks.Model public Server() { server = ""; - server_port = 8388; - method = "chacha20-ietf-poly1305"; + server_port = DefaultPort; + method = DefaultMethod; plugin = ""; plugin_opts = ""; plugin_args = ""; diff --git a/shadowsocks-csharp/View/ConfigForm.cs b/shadowsocks-csharp/View/ConfigForm.cs index 8151dc58..379edc29 100755 --- a/shadowsocks-csharp/View/ConfigForm.cs +++ b/shadowsocks-csharp/View/ConfigForm.cs @@ -316,7 +316,7 @@ namespace Shadowsocks.View IPTextBox.Text = server.server; ServerPortTextBox.Text = server.server_port.ToString(); PasswordTextBox.Text = server.password; - EncryptionSelect.Text = server.method ?? "aes-256-cfb"; + EncryptionSelect.Text = server.method ?? Server.DefaultMethod; PluginTextBox.Text = server.plugin; PluginOptionsTextBox.Text = server.plugin_opts; PluginArgumentsTextBox.Text = server.plugin_args; From 054f9e7f2b88cd839e83b62445b3f442ae04edf9 Mon Sep 17 00:00:00 2001 From: Student Main Date: Sun, 5 Jan 2020 23:08:23 +0800 Subject: [PATCH 2/3] bump copyright year --- LICENSE.txt | 1 + shadowsocks-csharp/Properties/AssemblyInfo.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index 46bfdcb4..4be89ce9 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -624,6 +624,7 @@ copy of the Program in return for a fee. END OF TERMS AND CONDITIONS Copyright (C) 2015 clowwindy +Copyright (C) 2020 Shadowsocks Project This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/shadowsocks-csharp/Properties/AssemblyInfo.cs b/shadowsocks-csharp/Properties/AssemblyInfo.cs index bbb3a28a..b140accf 100755 --- a/shadowsocks-csharp/Properties/AssemblyInfo.cs +++ b/shadowsocks-csharp/Properties/AssemblyInfo.cs @@ -11,7 +11,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Shadowsocks")] -[assembly: AssemblyCopyright("clowwindy & community 2019")] +[assembly: AssemblyCopyright("clowwindy & community 2020")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] From 49cc9226319d4bffca0609d674719f049d83e676 Mon Sep 17 00:00:00 2001 From: Student Main Date: Wed, 8 Jan 2020 13:02:18 +0800 Subject: [PATCH 3/3] Use mbedtls MD5 in PACServer, close #2759 Workaround FIPS, there is no security concern as it's only a "cache key". --- .../Controller/Service/PACServer.cs | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/shadowsocks-csharp/Controller/Service/PACServer.cs b/shadowsocks-csharp/Controller/Service/PACServer.cs index 7833e01a..57e64ca2 100644 --- a/shadowsocks-csharp/Controller/Service/PACServer.cs +++ b/shadowsocks-csharp/Controller/Service/PACServer.cs @@ -1,15 +1,10 @@ -using System; -using System.Collections; -using System.Globalization; -using System.IO; +using Shadowsocks.Encryption; +using Shadowsocks.Model; +using Shadowsocks.Util; +using System; using System.Net; using System.Net.Sockets; using System.Text; -using Shadowsocks.Encryption; -using Shadowsocks.Model; -using Shadowsocks.Properties; -using Shadowsocks.Util; -using System.Threading.Tasks; using System.Web; namespace Shadowsocks.Controller @@ -53,12 +48,7 @@ namespace Shadowsocks.Controller private static string GetHash(string content) { - var contentBytes = Encoding.ASCII.GetBytes(content); - using (var md5 = System.Security.Cryptography.MD5.Create()) - { - var md5Bytes = md5.ComputeHash(contentBytes); - return HttpServerUtility.UrlTokenEncode(md5Bytes); - }; + return HttpServerUtility.UrlTokenEncode(MbedTLS.MD5(Encoding.ASCII.GetBytes(content))); } public override bool Handle(byte[] firstPacket, int length, Socket socket, object state)