public override void DecodeX509EnhancedKeyUsageExtension(byte[] encoded, out OidCollection usages) { OidCollection oids = new OidCollection(); using (SafeEkuExtensionHandle eku = Interop.Crypto.DecodeExtendedKeyUsage(encoded, encoded.Length)) { Interop.Crypto.CheckValidOpenSslHandle(eku); int count = Interop.Crypto.GetX509EkuFieldCount(eku); for (int i = 0; i < count; i++) { IntPtr oidPtr = Interop.Crypto.GetX509EkuField(eku, i); if (oidPtr == IntPtr.Zero) { throw Interop.Crypto.CreateOpenSslCryptographicException(); } string oidValue = Interop.Crypto.GetOidValue(oidPtr); oids.Add(new Oid(oidValue)); } } usages = oids; }
public unsafe void DecodeX509EnhancedKeyUsageExtension(byte[] encoded, out OidCollection usages) { OidCollection oids = new OidCollection(); using (SafeEkuExtensionHandle eku = Interop.libcrypto.OpenSslD2I(Interop.libcrypto.d2i_EXTENDED_KEY_USAGE, encoded)) { Interop.libcrypto.CheckValidOpenSslHandle(eku); int count = Interop.Crypto.GetX509EkuFieldCount(eku); for (int i = 0; i < count; i++) { IntPtr oidPtr = Interop.Crypto.GetX509EkuField(eku, i); if (oidPtr == IntPtr.Zero) { throw Interop.libcrypto.CreateOpenSslCryptographicException(); } string oidValue = Interop.libcrypto.OBJ_obj2txt_helper(oidPtr); oids.Add(new Oid(oidValue)); } } usages = oids; }
internal static extern IntPtr GetX509EkuField(SafeEkuExtensionHandle eku, int loc);
internal static extern int GetX509EkuFieldCount(SafeEkuExtensionHandle eku);