// 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, Cryptography.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 != Cryptography.OidGroup.All) { info = FindOidInfo(key, value, Cryptography.OidGroup.All); } return(info); }
internal static string FindOidInfo(uint keyType, string keyValue, Cryptography.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(); } }