Esempio n. 1
0
        private CapiNative.CRYPT_OID_INFO ToOidInfo()
        {
            CapiNative.CRYPT_OID_INFO oidInfo = new CapiNative.CRYPT_OID_INFO();
            oidInfo.cbSize    = Marshal.SizeOf(typeof(CapiNative.CRYPT_OID_INFO));
            oidInfo.pszOID    = m_oid;
            oidInfo.pwszName  = m_name;
            oidInfo.dwGroupId = m_group;

            if (m_algorithmId.HasValue)
            {
                oidInfo.dwValue = m_algorithmId.Value;
            }

            if (m_cngAlgorithm != null)
            {
                oidInfo.pwszCNGAlgid = m_cngAlgorithm.Algorithm;
            }

            if (m_cngExtraAlgorithm != null)
            {
                oidInfo.pwszCNGExtraAlgid = m_cngExtraAlgorithm.Algorithm;
            }

            return(oidInfo);
        }
Esempio n. 2
0
        /// <summary>
        ///     Unpack a CAPI CRYPT_OID_INFO structure into an Oid2
        /// </summary>
        private Oid2(CapiNative.CRYPT_OID_INFO oidInfo)
        {
            m_oid   = oidInfo.pszOID ?? String.Empty;
            m_name  = oidInfo.pwszName ?? String.Empty;
            m_group = oidInfo.dwGroupId;

            // Algorithm information is only set for specific OID groups
            if (oidInfo.dwGroupId == OidGroup.EncryptionAlgorithm ||
                oidInfo.dwGroupId == OidGroup.HashAlgorithm ||
                oidInfo.dwGroupId == OidGroup.PublicKeyAlgorithm ||
                oidInfo.dwGroupId == OidGroup.SignatureAlgorithm)
            {
                // Values of 0 or -1 indicate that there is no CAPI algorithm mapping
                if (oidInfo.dwValue != 0 && oidInfo.dwValue != -1)
                {
                    m_algorithmId = oidInfo.dwValue;
                }

                if (!String.IsNullOrEmpty(oidInfo.pwszCNGAlgid))
                {
                    m_cngAlgorithm = new CngAlgorithm(oidInfo.pwszCNGAlgid);
                }

                if (!String.IsNullOrEmpty(oidInfo.pwszCNGExtraAlgid))
                {
                    m_cngExtraAlgorithm = new CngAlgorithm(oidInfo.pwszCNGExtraAlgid);
                }
            }
        }
Esempio n. 3
0
 public static Oid2 FindByValue(string oid, OidGroup group, bool useNetworkLookup)
 {
     CapiNative.CRYPT_OID_INFO oidInfo = new CapiNative.CRYPT_OID_INFO();
     if (CapiNative.TryFindOidInfo(oid, group, CapiNative.OidKeyType.Oid, useNetworkLookup, out oidInfo))
     {
         return(new Oid2(oidInfo));
     }
     else
     {
         return(null);
     }
 }
Esempio n. 4
0
        private CapiNative.CRYPT_OID_INFO ToOidInfo()
        {
            CapiNative.CRYPT_OID_INFO oidInfo = new CapiNative.CRYPT_OID_INFO();
            oidInfo.cbSize = Marshal.SizeOf(typeof(CapiNative.CRYPT_OID_INFO));
            oidInfo.pszOID = m_oid;
            oidInfo.pwszName = m_name;
            oidInfo.dwGroupId = m_group;

            if (m_algorithmId.HasValue)
            {
                oidInfo.dwValue = m_algorithmId.Value;
            }

            if (m_cngAlgorithm != null)
            {
                oidInfo.pwszCNGAlgid = m_cngAlgorithm.Algorithm;
            }

            if (m_cngExtraAlgorithm != null)
            {
                oidInfo.pwszCNGExtraAlgid = m_cngExtraAlgorithm.Algorithm;
            }

            return oidInfo;
        }
Esempio n. 5
0
 public static Oid2 FindByValue(string oid, OidGroup group, bool useNetworkLookup)
 {
     CapiNative.CRYPT_OID_INFO oidInfo = new CapiNative.CRYPT_OID_INFO();
     if (CapiNative.TryFindOidInfo(oid, group, CapiNative.OidKeyType.Oid, useNetworkLookup, out oidInfo))
     {
         return new Oid2(oidInfo);
     }
     else
     {
         return null;
     }
 }