@@ -0,0 +1,51 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace Shadowsocks.Encryption.AEAD | |||||
{ | |||||
public class AEADNativeEncryptor : AEADEncryptor | |||||
{ | |||||
public AEADNativeEncryptor(string method, string password) | |||||
: base(method, password) | |||||
{ | |||||
} | |||||
public override void cipherDecrypt(byte[] ciphertext, uint clen, byte[] plaintext, ref uint plen) | |||||
{ | |||||
Array.Copy(ciphertext, plaintext, 0); | |||||
plen = clen; | |||||
} | |||||
public override void cipherEncrypt(byte[] plaintext, uint plen, byte[] ciphertext, ref uint clen) | |||||
{ | |||||
Array.Copy(plaintext, ciphertext, 0); | |||||
clen = plen; | |||||
} | |||||
public override void Dispose() | |||||
{ | |||||
return; | |||||
} | |||||
private static Dictionary<string, EncryptorInfo> _ciphers = new Dictionary<string, EncryptorInfo>() | |||||
{ | |||||
{"plain-aeadfmt",new EncryptorInfo("PLAIN",0,0,0,0,0) } | |||||
}; | |||||
protected override Dictionary<string, EncryptorInfo> getCiphers() | |||||
{ | |||||
return _ciphers; | |||||
} | |||||
public static IEnumerable<string> SupportedCiphers() | |||||
{ | |||||
return _ciphers.Keys; | |||||
} | |||||
} | |||||
} |
@@ -52,6 +52,11 @@ namespace Shadowsocks.Encryption | |||||
_registeredEncryptors.Add(method, typeof(StreamMbedTLSEncryptor)); | _registeredEncryptors.Add(method, typeof(StreamMbedTLSEncryptor)); | ||||
} | } | ||||
foreach (string method in AEADNativeEncryptor.SupportedCiphers()) | |||||
{ | |||||
if (!_registeredEncryptors.ContainsKey(method)) | |||||
_registeredEncryptors.Add(method, typeof(AEADNativeEncryptor)); | |||||
} | |||||
foreach (string method in AEADOpenSSLEncryptor.SupportedCiphers()) | foreach (string method in AEADOpenSSLEncryptor.SupportedCiphers()) | ||||
{ | { | ||||
@@ -93,7 +93,7 @@ namespace Shadowsocks.Encryption.Stream | |||||
{ | { | ||||
{"plain", new EncryptorInfo("PLAIN", 0, 0, Plain) }, | {"plain", new EncryptorInfo("PLAIN", 0, 0, Plain) }, | ||||
{"table", new EncryptorInfo("TABLE", 0, 0, Table) }, | {"table", new EncryptorInfo("TABLE", 0, 0, Table) }, | ||||
{ "rc4", new EncryptorInfo("RC4", 16, 16, Rc4) }, | |||||
{ "rc4", new EncryptorInfo("RC4", 16, 0, Rc4) }, // original RC4 doesn't use IV | |||||
{ "rc4-md5", new EncryptorInfo("RC4", 16, 16, Rc4Md5) }, | { "rc4-md5", new EncryptorInfo("RC4", 16, 16, Rc4Md5) }, | ||||
}; | }; | ||||
@@ -116,6 +116,7 @@ | |||||
<Compile Include="Controller\System\Hotkeys\HotkeyCallbacks.cs" /> | <Compile Include="Controller\System\Hotkeys\HotkeyCallbacks.cs" /> | ||||
<Compile Include="Encryption\AEAD\AEADEncryptor.cs" /> | <Compile Include="Encryption\AEAD\AEADEncryptor.cs" /> | ||||
<Compile Include="Encryption\AEAD\AEADMbedTLSEncryptor.cs" /> | <Compile Include="Encryption\AEAD\AEADMbedTLSEncryptor.cs" /> | ||||
<Compile Include="Encryption\AEAD\AEADNativeEncryptor.cs" /> | |||||
<Compile Include="Encryption\AEAD\AEADOpenSSLEncryptor.cs" /> | <Compile Include="Encryption\AEAD\AEADOpenSSLEncryptor.cs" /> | ||||
<Compile Include="Encryption\AEAD\AEADSodiumEncryptor.cs" /> | <Compile Include="Encryption\AEAD\AEADSodiumEncryptor.cs" /> | ||||
<Compile Include="Encryption\CircularBuffer\ByteCircularBuffer.cs" /> | <Compile Include="Encryption\CircularBuffer\ByteCircularBuffer.cs" /> | ||||