Example #1
0
File: Main.cs Project: sotaria/gsf
        // Determines whether the given OID is already registered.
        private bool IsRegistered(string oid)
        {
            IntPtr info;

            WindowsApi.CRYPT_OID_INFO oidInfo;

            info = WindowsApi.CryptFindOIDInfo(WindowsApi.CRYPT_OID_INFO_OID_KEY, oid, WindowsApi.CRYPT_OID_DISABLE_SEARCH_DS_FLAG);

            if (!info.Equals(IntPtr.Zero))
            {
                oidInfo = new WindowsApi.CRYPT_OID_INFO();
                Marshal.PtrToStructure(info, oidInfo);

                using (RegistryKey oidKey = Registry.LocalMachine.OpenSubKey(string.Format(@"Software\Microsoft\Cryptography\OID\EncodingType 0\CryptDllFindOIDInfo\{0}!{1}", oidInfo.pszOID, oidInfo.dwGroupId)))
                {
                    if ((object)oidKey != null)
                    {
                        return(true);
                    }
                }

                using (RegistryKey oidKey = Registry.LocalMachine.OpenSubKey(string.Format(@"Software\Wow6432Node\Microsoft\Cryptography\OID\EncodingType 0\CryptDllFindOIDInfo\{0}!{1}", oidInfo.pszOID, oidInfo.dwGroupId)))
                {
                    if ((object)oidKey != null)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #2
0
File: Main.cs Project: sotaria/gsf
        // Registers the given OID.
        private void RegisterOID(string oid)
        {
            IntPtr info;

            WindowsApi.CRYPT_OID_INFO oidInfo;

            // Look up the OID
            info = WindowsApi.CryptFindOIDInfo(WindowsApi.CRYPT_OID_INFO_OID_KEY, oid, WindowsApi.CRYPT_OID_DISABLE_SEARCH_DS_FLAG);

            if (!info.Equals(IntPtr.Zero))
            {
                // Register the OID
                oidInfo = new WindowsApi.CRYPT_OID_INFO();
                Marshal.PtrToStructure(info, oidInfo);
                WindowsApi.CryptRegisterOIDInfo(info, WindowsApi.CRYPT_INSTALL_OID_INFO_BEFORE_FLAG);

                // Add the name of the OID to the registry since the .NET libraries lookup by name
                using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(string.Format(@"Software\Wow6432Node\Microsoft\Cryptography\OID\EncodingType 0\CryptDllFindOIDInfo\{0}!{1}", oidInfo.pszOID, oidInfo.dwGroupId), true))
                {
                    if ((object)registryKey != null)
                    {
                        registryKey.SetValue("Name", oidInfo.pszOID);
                    }
                }

                using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(string.Format(@"Software\Microsoft\Cryptography\OID\EncodingType 0\CryptDllFindOIDInfo\{0}!{1}", oidInfo.pszOID, oidInfo.dwGroupId), true))
                {
                    if ((object)registryKey != null)
                    {
                        registryKey.SetValue("Name", oidInfo.pszOID);
                    }
                }
            }
        }
Example #3
0
File: Main.cs Project: rmc00/gsf
        // Determines whether the given OID is already registered.
        private bool IsRegistered(string oid)
        {
            IntPtr info;
            WindowsApi.CRYPT_OID_INFO oidInfo;

            info = WindowsApi.CryptFindOIDInfo(WindowsApi.CRYPT_OID_INFO_OID_KEY, oid, WindowsApi.CRYPT_OID_DISABLE_SEARCH_DS_FLAG);

            if (!info.Equals(IntPtr.Zero))
            {
                oidInfo = new WindowsApi.CRYPT_OID_INFO();
                Marshal.PtrToStructure(info, oidInfo);

                using (RegistryKey oidKey = Registry.LocalMachine.OpenSubKey(string.Format(@"Software\Microsoft\Cryptography\OID\EncodingType 0\CryptDllFindOIDInfo\{0}!{1}", oidInfo.pszOID, oidInfo.dwGroupId)))
                {
                    if ((object)oidKey != null)
                        return true;
                }

                using (RegistryKey oidKey = Registry.LocalMachine.OpenSubKey(string.Format(@"Software\Wow6432Node\Microsoft\Cryptography\OID\EncodingType 0\CryptDllFindOIDInfo\{0}!{1}", oidInfo.pszOID, oidInfo.dwGroupId)))
                {
                    if ((object)oidKey != null)
                        return true;
                }
            }

            return false;
        }
Example #4
0
File: Main.cs Project: rmc00/gsf
        // Registers the given OID.
        private void RegisterOID(string oid)
        {
            IntPtr info;
            WindowsApi.CRYPT_OID_INFO oidInfo;

            // Look up the OID
            info = WindowsApi.CryptFindOIDInfo(WindowsApi.CRYPT_OID_INFO_OID_KEY, oid, WindowsApi.CRYPT_OID_DISABLE_SEARCH_DS_FLAG);

            if (!info.Equals(IntPtr.Zero))
            {
                // Register the OID
                oidInfo = new WindowsApi.CRYPT_OID_INFO();
                Marshal.PtrToStructure(info, oidInfo);
                WindowsApi.CryptRegisterOIDInfo(info, WindowsApi.CRYPT_INSTALL_OID_INFO_BEFORE_FLAG);

                // Add the name of the OID to the registry since the .NET libraries lookup by name
                using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(string.Format(@"Software\Wow6432Node\Microsoft\Cryptography\OID\EncodingType 0\CryptDllFindOIDInfo\{0}!{1}", oidInfo.pszOID, oidInfo.dwGroupId), true))
                {
                    if ((object)registryKey != null)
                        registryKey.SetValue("Name", oidInfo.pszOID);
                }

                using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(string.Format(@"Software\Microsoft\Cryptography\OID\EncodingType 0\CryptDllFindOIDInfo\{0}!{1}", oidInfo.pszOID, oidInfo.dwGroupId), true))
                {
                    if ((object)registryKey != null)
                        registryKey.SetValue("Name", oidInfo.pszOID);
                }
            }
        }