• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# OidGroup类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中OidGroup的典型用法代码示例。如果您正苦于以下问题:C# OidGroup类的具体用法?C# OidGroup怎么用?C# OidGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OidGroup类属于命名空间,在下文中一共展示了OidGroup类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ToFriendlyName

        //
        // Attempts to map a friendly name to an OID. Returns null if not a known name.
        //
        public static string ToFriendlyName(string oid, OidGroup oidGroup, bool fallBackToAllGroups)
        {
            if (oid == null)
                throw new ArgumentNullException("oid");

            string mappedName;
            bool shouldUseCache = ShouldUseCache(oidGroup);

            // On Unix shouldUseCache is always true, so no matter what OidGroup is passed in the Windows
            // friendly name will be returned.
            //
            // On Windows shouldUseCache is only true for OidGroup.All, because otherwise the OS may filter
            // out the answer based on the group criteria.
            if (shouldUseCache)
            {
                if (s_oidToFriendlyName.TryGetValue(oid, out mappedName) ||
                    s_compatOids.TryGetValue(oid, out mappedName) ||
                    s_lateBoundOidToFriendlyName.TryGetValue(oid, out mappedName))
                {
                    return mappedName;
                }
            }

            mappedName = NativeOidToFriendlyName(oid, oidGroup, fallBackToAllGroups);

            if (shouldUseCache && mappedName != null)
            {
                s_lateBoundOidToFriendlyName.TryAdd(oid, mappedName);

                // Don't add the reverse here.  Just because oid => name doesn't mean name => oid.
                // And don't bother doing the reverse lookup proactively, just wait until they ask for it.
            }

            return mappedName;
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:38,代码来源:OidLookup.cs


示例2: ToOid

        //
        // Attempts to retrieve the friendly name for an OID. Returns null if not a known or valid OID.
        //
        public static string ToOid(string friendlyName, OidGroup oidGroup, bool fallBackToAllGroups)
        {
            if (friendlyName == null)
                throw new ArgumentNullException("friendlyName");
            if (friendlyName.Length == 0)
                return null;

            string mappedOid;
            bool shouldUseCache = ShouldUseCache(oidGroup);

            if (shouldUseCache)
            {
                if (s_friendlyNameToOid.TryGetValue(friendlyName, out mappedOid) ||
                    s_lateBoundFriendlyNameToOid.TryGetValue(friendlyName, out mappedOid))
                {
                    return mappedOid;
                }
            }

            mappedOid = NativeFriendlyNameToOid(friendlyName, oidGroup, fallBackToAllGroups);

            if (shouldUseCache && mappedOid != null)
            {
                s_lateBoundFriendlyNameToOid.TryAdd(friendlyName, mappedOid);

                // Don't add the reverse here.  Friendly Name => OID is a case insensitive search,
                // so the casing provided as input here may not be the 'correct' one.  Just let
                // ToFriendlyName capture the response and cache it itself.
            }

            return mappedOid;
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:35,代码来源:OidLookup.cs


示例3: ToFriendlyName

        //
        // Attempts to map a friendly name to an OID. Returns null if not a known name.
        //
        public static string ToFriendlyName(string oid, OidGroup oidGroup, bool fallBackToAllGroups)
        {
            if (oid == null)
                throw new ArgumentNullException("oid");

            return NativeOidToFriendlyName(oid, oidGroup, fallBackToAllGroups);
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:10,代码来源:OidLookup.cs


示例4: FromOidValue

        public static Oid FromOidValue(String oidValue, OidGroup group)
        {
            if (oidValue == null)
                throw new ArgumentNullException("oidValue");

            String friendlyName = OidLookup.ToFriendlyName(oidValue, group, fallBackToAllGroups: false);
            if (friendlyName == null)
                throw new CryptographicException(SR.Cryptography_Oid_InvalidValue);

            return new Oid(oidValue, friendlyName, group);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:11,代码来源:Oid.cs


示例5: NativeFriendlyNameToOid

        private static string NativeFriendlyNameToOid(string friendlyName, OidGroup oidGroup, bool fallBackToAllGroups)
        {
            IntPtr sharedObject = Interop.Crypto.GetObjectDefinitionByName(friendlyName);

            if (sharedObject == IntPtr.Zero)
            {
                return null;
            }

            return Interop.Crypto.GetOidValue(sharedObject);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:11,代码来源:OidLookup.Unix.cs


示例6: NormalizeOid

        public string NormalizeOid(string maybeOid, OidGroup expectedGroup)
        {
            string oidValue = OidInfo.FindOidInfo(CryptOidInfoKeyType.CRYPT_OID_INFO_NAME_KEY, maybeOid, expectedGroup, fallBackToAllGroups: true).OID;

            if (oidValue == null)
            {
                oidValue = maybeOid;
                ValidateOidValue(oidValue);
            }

            return oidValue;
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:12,代码来源:FindPal.cs


示例7: FromFriendlyName

        public static Oid FromFriendlyName(string friendlyName, OidGroup group) {
            if (friendlyName == null) {
                throw new ArgumentNullException("friendlyName");
            }

            string oidValue = X509Utils.FindOidInfo(CAPI.CRYPT_OID_INFO_NAME_KEY, friendlyName, group);
            if (oidValue == null) {
                throw new CryptographicException(SR.GetString(SR.Cryptography_Oid_InvalidValue));
            }

            return new Oid(oidValue, friendlyName, group);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:12,代码来源:Oid.cs


示例8: NormalizeOid

        public string NormalizeOid(string maybeOid, OidGroup expectedGroup)
        {
            Oid oid = new Oid(maybeOid);

            // If maybeOid is interpreted to be a FriendlyName, return the OID.
            if (!StringComparer.OrdinalIgnoreCase.Equals(oid.Value, maybeOid))
            {
                return oid.Value;
            }

            FindPal.ValidateOidValue(maybeOid);
            return maybeOid;
        }
开发者ID:Corillian,项目名称:corefx,代码行数:13,代码来源:OpenSslCertificateFinder.cs


示例9: Oid2

        /// <summary>
        ///     Create an Oid2 object for an OID which has no CAPI algorithm representation
        /// </summary>
        public Oid2(string oid,
                    string friendlyName,
                    OidGroup group,
                    CngAlgorithm cngAlgorithm,
                    CngAlgorithm extraCngAlgorithm)
        {
            if (oid == null)
                throw new ArgumentNullException("oid");
            if (friendlyName == null)
                throw new ArgumentNullException("friendlyName");

            m_oid = oid;
            m_name = friendlyName;
            m_group = group;
            m_cngAlgorithm = cngAlgorithm;
            m_cngExtraAlgorithm = extraCngAlgorithm;
        }
开发者ID:scholtz,项目名称:FastZep,代码行数:20,代码来源:Oid2.cs


示例10: NativeOidToFriendlyName

        private static string NativeOidToFriendlyName(string oid, OidGroup oidGroup, bool fallBackToAllGroups)
        {
            IntPtr friendlyNamePtr = IntPtr.Zero;
            int result = Interop.Crypto.LookupFriendlyNameByOid(oid, ref friendlyNamePtr);

            switch (result)
            {
                case 1: /* Success */
                    Debug.Assert(friendlyNamePtr != IntPtr.Zero, "friendlyNamePtr != IntPtr.Zero");

                    // The pointer is to a shared string, so marshalling it out is all that's required.
                    return Marshal.PtrToStringAnsi(friendlyNamePtr);
                case -1: /* OpenSSL internal error */
                    throw Interop.Crypto.CreateOpenSslCryptographicException();
                default:
                    Debug.Assert(result == 0, "LookupFriendlyNameByOid returned unexpected result " + result);
                    return null;
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:19,代码来源:OidLookup.Unix.cs


示例11: ToOid

        //
        // Attempts to retrieve the friendly name for an OID. Returns null if not a known or valid OID.
        //
        public static string ToOid(string friendlyName, OidGroup oidGroup, bool fallBackToAllGroups)
        {
            if (friendlyName == null)
                throw new ArgumentNullException("friendlyName");

            string oid = NativeFriendlyNameToOid(friendlyName, oidGroup, fallBackToAllGroups);

            if (oid == null)
            {
                string alias = FindFriendlyNameAlias(friendlyName);

                if (alias != null)
                {
                    oid = NativeFriendlyNameToOid(alias, oidGroup, fallBackToAllGroups);
                }
            }

            return oid;
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:22,代码来源:OidLookup.cs


示例12: NativeFriendlyNameToOid

        private static string NativeFriendlyNameToOid(string friendlyName, OidGroup oidGroup, bool fallBackToAllGroups)
        {
            int nid = Interop.libcrypto.OBJ_ln2nid(friendlyName);

            if (nid == Interop.libcrypto.NID_undef)
            {
                nid = Interop.libcrypto.OBJ_sn2nid(friendlyName);
            }

            if (nid == Interop.libcrypto.NID_undef)
            {
                return null;
            }

            IntPtr sharedObject = Interop.libcrypto.OBJ_nid2obj(nid);

            if (sharedObject == IntPtr.Zero)
            {
                return null;
            }

            return Interop.libcrypto.OBJ_obj2txt_helper(sharedObject);
        }
开发者ID:Kagamine,项目名称:corefx,代码行数:23,代码来源:OidLookup.Unix.cs


示例13: GetAlgIdFromOid

        internal static int GetAlgIdFromOid(string oid, OidGroup oidGroup) {
            Contract.Requires(oid != null);

            // CAPI does not have ALGID mappings for all of the hash algorithms - see if we know the mapping
            // first to avoid doing an AD lookup on these values
            if (String.Equals(oid, Constants.OID_OIWSEC_SHA256, StringComparison.Ordinal)) {
                return Constants.CALG_SHA_256;
            }
            else if (String.Equals(oid, Constants.OID_OIWSEC_SHA384, StringComparison.Ordinal)) {
                return Constants.CALG_SHA_384;
            }
            else if (String.Equals(oid, Constants.OID_OIWSEC_SHA512, StringComparison.Ordinal)) {
                return Constants.CALG_SHA_512;
            }
            else {
                return FindOidInfo(OidKeyType.Oid, oid, oidGroup).AlgId;
            }
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:18,代码来源:x509utils.cs


示例14: GetAlgIdFromOid

        /// <summary>
        /// Convert an OID into a CAPI-1 CALG ID.
        /// </summary>
        private static int GetAlgIdFromOid(string oid, OidGroup oidGroup)
        {
            Contract.Requires(oid != null);

            // CAPI does not have ALGID mappings for all of the hash algorithms - see if we know the mapping
            // first to avoid doing an AD lookup on these values
            if (String.Equals(oid, CapiHelper.OID_OIWSEC_SHA256, StringComparison.Ordinal))
            {
                return CapiHelper.CALG_SHA_256;
            }
            else if (String.Equals(oid, CapiHelper.OID_OIWSEC_SHA384, StringComparison.Ordinal))
            {
                return CapiHelper.CALG_SHA_384;
            }
            else if (String.Equals(oid, CapiHelper.OID_OIWSEC_SHA512, StringComparison.Ordinal))
            {
                return CapiHelper.CALG_SHA_512;
            }
            else
            {
                return OidInfo.FindOidInfo(CryptOidInfoKeyType.CRYPT_OID_INFO_OID_KEY, oid, OidGroup.HashAlgorithm, fallBackToAllGroups: false).AlgId;
            }
        }
开发者ID:SGuyGe,项目名称:corefx,代码行数:26,代码来源:CapiHelper.cs


示例15: NameOrOidToHashAlgId

        /// <summary>
        /// Helper for signing and verifications that accept a string to specify a hashing algorithm.
        /// </summary>
        public static int NameOrOidToHashAlgId(string nameOrOid, OidGroup oidGroup)
        {
            // Default Algorithm Id is CALG_SHA1
            if (nameOrOid == null)
                return CapiHelper.CALG_SHA1;

            string oidValue = CryptoConfig.MapNameToOID(nameOrOid);
            if (oidValue == null)
                oidValue = nameOrOid; // we were probably passed an OID value directly

            int algId = GetAlgIdFromOid(oidValue, oidGroup);
            if (algId == 0 || algId == -1)
                throw new CryptographicException(SR.Cryptography_InvalidOID);

            return algId;
        }
开发者ID:chcosta,项目名称:corefx,代码行数:19,代码来源:CapiHelper.cs


示例16: FindOidInfoWithFallback

        // Try to find OID info within a specific group, and if that doesn't work fall back to all
        // groups for compatibility with previous frameworks
        internal static string FindOidInfoWithFallback(uint key, string value, OidGroup group) {
            string info = FindOidInfo(key, value, group);

            // If we couldn't find it in the requested group, then try again in all groups
            if (info == null && group != OidGroup.All) {
                info = FindOidInfo(key, value, OidGroup.All);
            }

            return info;
        }
开发者ID:uQr,项目名称:referencesource,代码行数:12,代码来源:x509utils.cs


示例17: FindOidInfo

        internal static string FindOidInfo(uint keyType, string keyValue, OidGroup oidGroup) {
            if (keyValue == null)
                throw new ArgumentNullException("keyValue");
            if (keyValue.Length == 0)
                return null;

            SafeLocalAllocHandle pvKey = SafeLocalAllocHandle.InvalidHandle;

            try {
                switch(keyType) {
                case CAPI.CRYPT_OID_INFO_OID_KEY:
                    pvKey = StringToAnsiPtr(keyValue);
                    break;

                case CAPI.CRYPT_OID_INFO_NAME_KEY:
                    pvKey = StringToUniPtr(keyValue);
                    break;

                default:
                    Debug.Assert(false);
                    break;
                }

                CAPI.CRYPT_OID_INFO pOidInfo = CAPI.CryptFindOIDInfo(keyType, pvKey, oidGroup);


                if (keyType == CAPI.CRYPT_OID_INFO_OID_KEY) {
                    return pOidInfo.pwszName;
                }
                else {
                    return pOidInfo.pszOID;
                }
            }
            finally {
                pvKey.Dispose();
            }
        }
开发者ID:uQr,项目名称:referencesource,代码行数:37,代码来源:x509utils.cs


示例18: CryptFindOIDInfo

 private static extern IntPtr CryptFindOIDInfo(OidKeyType dwKeyType, IntPtr pvKey, OidGroup dwGroupId);
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:1,代码来源:x509utils.cs


示例19: CryptFindOIDInfo

 private static extern IntPtr CryptFindOIDInfo(CryptOidInfoKeyType dwKeyType, IntPtr pvKey, OidGroup group);
开发者ID:noahfalk,项目名称:corefx,代码行数:1,代码来源:OidInfo.cs


示例20: MapNameToOID

        internal static string MapNameToOID(string name, OidGroup oidGroup) {
            if (name == null) 
                throw new ArgumentNullException("name");
            Contract.EndContractBlock();

            // First we'll do the machine-wide stuff, initializing if necessary
            InitializeConfigInfo();

            string oid = null;

            // Check to see if we have an application defined mapping
            lock (InternalSyncObject) {
                oid = appOidHT.GetValueOrDefault(name);
            }

            // If we didn't find an application defined mapping, search the machine table
            if (oid == null)
                oid = machineOidHT.GetValueOrDefault(name);

            // If we didn't find it in the machine-wide table, look in the default table
            if (oid == null)
                oid = DefaultOidHT.GetValueOrDefault(name);

#if FEATURE_CRYPTO || FEATURE_LEGACYNETCFCRYPTO
            // Try the CAPI table association
            if (oid == null)
                oid = X509Utils.GetOidFromFriendlyName(name, oidGroup);
#endif // FEATURE_CRYPTO

            return oid;
        }
开发者ID:enavro,项目名称:coreclr,代码行数:31,代码来源:CryptoConfig.cs



注:本文中的OidGroup类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# OleDbType类代码示例发布时间:2022-05-24
下一篇:
C# Oid类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap