You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

CryptoProvider.cs 1.4 kB

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Shadowsocks.Protocol.Shadowsocks.Crypto
  4. {
  5. static class CryptoProvider
  6. {
  7. static Dictionary<string, CryptoParameter> parameters = new Dictionary<string, CryptoParameter>
  8. {
  9. ["aes-256-gcm"] = new CryptoParameter { KeySize = 32, NonceSize = 12, TagSize = 16, Crypto = typeof(AeadAesGcmCrypto) },
  10. ["aes-192-gcm"] = new CryptoParameter { KeySize = 24, NonceSize = 12, TagSize = 16, Crypto = typeof(AeadAesGcmCrypto) },
  11. ["aes-128-gcm"] = new CryptoParameter { KeySize = 16, NonceSize = 12, TagSize = 16, Crypto = typeof(AeadAesGcmCrypto) },
  12. ["none"] = new CryptoParameter { KeySize = 0, NonceSize = 0, TagSize = 0, Crypto = typeof(UnsafeNoneCrypto) }
  13. };
  14. public static CryptoParameter GetCrypto(string method)
  15. {
  16. if (string.IsNullOrEmpty(method))
  17. {
  18. // todo
  19. //method = IoCManager.Container.Resolve<IDefaultCrypto>().GetDefaultMethod();
  20. }
  21. method = method.ToLowerInvariant();
  22. var ok = parameters.TryGetValue(method, out var t);
  23. if (!ok)
  24. {
  25. //t = parameters[DefaultCipher];
  26. throw new NotImplementedException();
  27. }
  28. return t;
  29. }
  30. }
  31. }