1 #if !MONO 2 using System; 3 using System.Runtime.InteropServices; 4 5 namespace agsXMPP.util 6 { 7 /// <summary> 8 /// Crypto API for Windows CE, Pocket PC and Smartphone 9 /// will be used for Hashing and the RandomNumberGenerator 10 /// </summary> 11 internal class WinCeApi 12 { 13 public enum SecurityProviderType 14 { 15 RSA_FULL = 1, 16 HP_HASHVAL = 2, 17 CALG_MD5 = 32771, 18 CALG_SHA1 = 32772 19 } 20 21 [DllImport("coredll.dll")] CryptAcquireContext(out IntPtr hProv, string pszContainer, string pszProvider, int dwProvType,int dwFlags)22 public static extern bool CryptAcquireContext(out IntPtr hProv, string pszContainer, string pszProvider, int dwProvType,int dwFlags); 23 24 [DllImport("coredll.dll")] CryptCreateHash(IntPtr hProv, int Algid, IntPtr hKey, int dwFlags, out IntPtr phHash)25 public static extern bool CryptCreateHash(IntPtr hProv, int Algid, IntPtr hKey, int dwFlags, out IntPtr phHash); 26 27 [DllImport("coredll.dll")] CryptHashData(IntPtr hHash, byte [] pbData, int dwDataLen, int dwFlags)28 public static extern bool CryptHashData(IntPtr hHash, byte [] pbData, int dwDataLen, int dwFlags); 29 30 [DllImport("coredll.dll")] CryptGetHashParam(IntPtr hHash, int dwParam, byte[] pbData, ref int pdwDataLen, int dwFlags)31 public static extern bool CryptGetHashParam(IntPtr hHash, int dwParam, byte[] pbData, ref int pdwDataLen, int dwFlags); 32 33 [DllImport("coredll.dll")] CryptDestroyHash(IntPtr hHash)34 public static extern bool CryptDestroyHash(IntPtr hHash); 35 36 [DllImport("coredll.dll")] CryptReleaseContext(IntPtr hProv, int dwFlags)37 public static extern bool CryptReleaseContext(IntPtr hProv, int dwFlags); 38 39 [DllImport("coredll.dll", EntryPoint="CryptGenRandom", SetLastError=true)] CryptGenRandomCe(IntPtr hProv, int dwLen, byte[] pbBuffer)40 public static extern bool CryptGenRandomCe(IntPtr hProv, int dwLen, byte[] pbBuffer); 41 42 [DllImport("advapi32.dll", EntryPoint="CryptGenRandom", SetLastError=true)] CryptGenRandomXp(IntPtr hProv, int dwLen, byte[] pbBuffer)43 public static extern bool CryptGenRandomXp(IntPtr hProv, int dwLen, byte[] pbBuffer); 44 45 } 46 } 47 #endif