Esempio n. 1
0
        internal static IntPtr ImportRsaPublicKey(byte[] rawData)
        {
            CryptoProvider provider            = new CryptoProvider();
            IntPtr         nativeStructure     = IntPtr.Zero;
            int            nativeStructureSize = 0;

            try {
                if (!Advapi32.CryptDecodeObjectEx(CertificateEncodingType.X509Asn,
                                                  InteropHelpers.GetWellKnownOIDPointer(InteropHelpers.WellKnownOIDs.X509PublicKeyInfo),
                                                  rawData, rawData.Length, Advapi32.EncodingFlags.AllocateMemory, IntPtr.Zero,
                                                  ref nativeStructure, ref nativeStructureSize))
                {
                    throw new CryptographyException((WinErrors)(uint)Marshal.GetLastWin32Error());
                }
                IntPtr result = IntPtr.Zero;
                if (!Crypt32.CryptImportPublicKeyInfo(provider.Handle, CertificateEncodingType.X509Asn,
                                                      nativeStructure, out result))
                {
                    throw new CryptographyException((WinErrors)(uint)Marshal.GetLastWin32Error());
                }
                return(result);
            }
            finally {
                if (IntPtr.Zero != nativeStructure)
                {
                    if (IntPtr.Zero != Kernel32.LocalFree(nativeStructure))
                    {
                        throw new InteropException(Marshal.GetLastWin32Error());
                    }
                }
                provider.Dispose();
            }
        }
Esempio n. 2
0
 internal RSA(CryptoProvider crypto_provider)
 {
     _provider = crypto_provider;
 }
Esempio n. 3
0
 internal Randomizer(CryptoProvider provider)
 {
     _provider = provider;
 }
Esempio n. 4
0
 internal AES(CryptoProvider crypto_provider)
 {
     this._provider = crypto_provider;
     this._key      = IntPtr.Zero;
 }
Esempio n. 5
0
 internal SHA1(CryptoProvider crypto_provider)
 {
     _provider = crypto_provider;
     init();
 }
Esempio n. 6
0
 internal SHA1(CryptoProvider crypto_provider, SHA1 other)
 {
     _provider = crypto_provider;
     duplicate_internal(other);
 }