diff --git a/Shadowsocks.Net/Crypto/AEAD/AEADBouncyCastleCrypto.cs b/Shadowsocks.Net/Crypto/AEAD/AEADBouncyCastleCrypto.cs index 17b6a531..e2f0d37f 100644 --- a/Shadowsocks.Net/Crypto/AEAD/AEADBouncyCastleCrypto.cs +++ b/Shadowsocks.Net/Crypto/AEAD/AEADBouncyCastleCrypto.cs @@ -1,6 +1,7 @@ -using Org.BouncyCastle.Crypto.Engines; +using Org.BouncyCastle.Crypto.Engines; using Org.BouncyCastle.Crypto.Modes; using Org.BouncyCastle.Crypto.Parameters; +using Shadowsocks.Net.Crypto.Extensions; using System; using System.Collections.Generic; @@ -16,6 +17,7 @@ namespace Shadowsocks.Net.Crypto.AEAD { CipherFamily.AesGcm => new GcmBlockCipher(new AesEngine()), CipherFamily.Chacha20Poly1305 => new ChaCha20Poly1305(), + CipherFamily.XChacha20Poly1305 => new XChaCha20Poly1305(), _ => throw new NotSupportedException(), }; } @@ -27,6 +29,7 @@ namespace Shadowsocks.Net.Crypto.AEAD {"aes-192-gcm", new CipherInfo("aes-192-gcm", 24, 24, 12, 16, CipherFamily.AesGcm)}, {"aes-256-gcm", new CipherInfo("aes-256-gcm", 32, 32, 12, 16, CipherFamily.AesGcm)}, {"chacha20-ietf-poly1305", new CipherInfo("chacha20-ietf-poly1305",32, 32, 12, 16, CipherFamily.Chacha20Poly1305)}, + {"xchacha20-ietf-poly1305", new CipherInfo("xchacha20-ietf-poly1305",32, 32, 24, 16, CipherFamily.XChacha20Poly1305)}, }; protected override Dictionary GetCiphers() diff --git a/Shadowsocks.Net/Crypto/AEAD/AEADNaClCrypto.cs b/Shadowsocks.Net/Crypto/AEAD/AEADNaClCrypto.cs deleted file mode 100644 index 6ba1e1c5..00000000 --- a/Shadowsocks.Net/Crypto/AEAD/AEADNaClCrypto.cs +++ /dev/null @@ -1,61 +0,0 @@ -using NaCl.Core; -using NaCl.Core.Base; -using System; -using System.Collections.Generic; - -namespace Shadowsocks.Net.Crypto.AEAD -{ - public class AEADNaClCrypto : AEADCrypto - { - - SnufflePoly1305 enc; - public AEADNaClCrypto(string method, string password) : base(method, password) - { - } - - #region Cipher Info - private static readonly Dictionary _ciphers = new Dictionary - { - {"chacha20-ietf-poly1305", new CipherInfo("chacha20-ietf-poly1305",32, 32, 12, 16, CipherFamily.Chacha20Poly1305)}, - {"xchacha20-ietf-poly1305", new CipherInfo("xchacha20-ietf-poly1305",32, 32, 24, 16, CipherFamily.XChacha20Poly1305)}, - }; - - protected override Dictionary GetCiphers() - { - return _ciphers; - } - - public static Dictionary SupportedCiphers() - { - return _ciphers; - } - #endregion - - public override void InitCipher(byte[] salt, bool isEncrypt) - { - base.InitCipher(salt, isEncrypt); - enc = cipherFamily switch - { - CipherFamily.XChacha20Poly1305 => new XChaCha20Poly1305(sessionKey), - _ => new ChaCha20Poly1305(sessionKey), - }; - } - - public override int CipherEncrypt(ReadOnlySpan plain, Span cipher) - { - //byte[] ct = enc.Encrypt(plain, null, nonce); - //ct.CopyTo(cipher); - //return ct.Length; - - throw new NotImplementedException(); - } - - public override int CipherDecrypt(Span plain, ReadOnlySpan cipher) - { - //byte[] pt = enc.Decrypt(cipher, null, nonce); - //pt.CopyTo(plain); - //return pt.Length; - throw new NotImplementedException(); - } - } -}