1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 
5 using System;
6 using System.Runtime.InteropServices;
7 using System.Security.Cryptography.X509Certificates;
8 
9 using Microsoft.Win32.SafeHandles;
10 
11 internal static partial class Interop
12 {
13     internal static partial class AppleCrypto
14     {
15         [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509ChainCreateDefaultPolicy")]
X509ChainCreateDefaultPolicy()16         internal static extern SafeCreateHandle X509ChainCreateDefaultPolicy();
17 
18         [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509ChainCreateRevocationPolicy")]
X509ChainCreateRevocationPolicy()19         internal static extern SafeCreateHandle X509ChainCreateRevocationPolicy();
20 
21         [DllImport(Libraries.AppleCryptoNative)]
AppleCryptoNative_X509ChainCreate( SafeCreateHandle certs, SafeCreateHandle policies, out SafeX509ChainHandle pTrustOut, out int pOSStatus)22         internal static extern int AppleCryptoNative_X509ChainCreate(
23             SafeCreateHandle certs,
24             SafeCreateHandle policies,
25             out SafeX509ChainHandle pTrustOut,
26             out int pOSStatus);
27 
28         [DllImport(Libraries.AppleCryptoNative)]
AppleCryptoNative_X509ChainEvaluate( SafeX509ChainHandle chain, SafeCFDateHandle cfEvaluationTime, bool allowNetwork, out int pOSStatus)29         internal static extern int AppleCryptoNative_X509ChainEvaluate(
30             SafeX509ChainHandle chain,
31             SafeCFDateHandle cfEvaluationTime,
32             bool allowNetwork,
33             out int pOSStatus);
34 
35         [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509ChainGetChainSize")]
X509ChainGetChainSize(SafeX509ChainHandle chain)36         internal static extern long X509ChainGetChainSize(SafeX509ChainHandle chain);
37 
38         [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509ChainGetCertificateAtIndex")]
X509ChainGetCertificateAtIndex(SafeX509ChainHandle chain, long index)39         internal static extern IntPtr X509ChainGetCertificateAtIndex(SafeX509ChainHandle chain, long index);
40 
41         [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509ChainGetTrustResults")]
X509ChainGetTrustResults(SafeX509ChainHandle chain)42         internal static extern SafeCreateHandle X509ChainGetTrustResults(SafeX509ChainHandle chain);
43 
44         [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_X509ChainGetStatusAtIndex")]
X509ChainGetStatusAtIndex(SafeCreateHandle trustResults, long index, out int pdwStatus)45         internal static extern int X509ChainGetStatusAtIndex(SafeCreateHandle trustResults, long index, out int pdwStatus);
46 
47         [DllImport(Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_GetOSStatusForChainStatus")]
GetOSStatusForChainStatus(X509ChainStatusFlags flag)48         internal static extern int GetOSStatusForChainStatus(X509ChainStatusFlags flag);
49     }
50 }
51