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.

OpenSSL.cs 2.0 kB

10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.InteropServices;
  4. using System.Text;
  5. namespace shadowsocks_csharp.Encrypt
  6. {
  7. public class OpenSSL
  8. {
  9. const string DLLNAME = "libeay32";
  10. [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
  11. public extern static void OpenSSL_add_all_ciphers();
  12. [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
  13. public extern static IntPtr EVP_md5();
  14. [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
  15. public extern static int EVP_BytesToKey(IntPtr type, IntPtr md, IntPtr salt, byte[] data, int datal, int count, byte[] key, byte[] iv);
  16. [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
  17. public extern static int RAND_bytes(byte[] buf, int num);
  18. [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
  19. public extern static IntPtr EVP_get_cipherbyname(byte[] name);
  20. [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
  21. public extern static IntPtr EVP_CIPHER_CTX_new();
  22. [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
  23. public extern static int EVP_CipherInit_ex(IntPtr ctx, IntPtr type, IntPtr impl, byte[] key, byte[] iv, int enc);
  24. [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
  25. public extern static int EVP_CIPHER_CTX_cleanup(IntPtr a);
  26. [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
  27. public extern static int EVP_CIPHER_CTX_free(IntPtr a);
  28. [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
  29. public extern static int EVP_CipherUpdate(IntPtr ctx, byte[] outb, out int outl, byte[] inb, int inl);
  30. [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
  31. public extern static IntPtr MD5(byte[] d, long n, byte[] md);
  32. }
  33. }