Esempio n. 1
0
        internal static unsafe SafeSecKeyRefHandle CreateDataKey(
            ReadOnlySpan <byte> keyData,
            PAL_KeyAlgorithm keyAlgorithm,
            bool isPublic)
        {
            fixed(byte *pKey = keyData)
            {
                int result = AppleCryptoNative_SecKeyCreateWithData(
                    pKey,
                    keyData.Length,
                    keyAlgorithm,
                    isPublic ? 1 : 0,
                    out SafeSecKeyRefHandle dataKey,
                    out SafeCFErrorHandle errorHandle);

                using (errorHandle)
                {
                    switch (result)
                    {
                    case kSuccess:
                        return(dataKey);

                    case kErrorSeeError:
                        throw CreateExceptionForCFError(errorHandle);

                    default:
                        Debug.Fail($"SecKeyCreateWithData returned {result}");
                        throw new CryptographicException();
                    }
                }
            }
        }
Esempio n. 2
0
 private static unsafe extern int AppleCryptoNative_SecKeyCreateWithData(
     byte *pKey,
     int cbKey,
     PAL_KeyAlgorithm keyAlgorithm,
     int isPublic,
     out SafeSecKeyRefHandle pDataKey,
     out SafeCFErrorHandle pErrorOut);
Esempio n. 3
0
 private static extern SafeSslHandle SSLStreamCreateWithCertificates(
     ref byte pkcs8PrivateKey,
     int pkcs8PrivateKeyLen,
     PAL_KeyAlgorithm algorithm,
     IntPtr[] certs,
     int certsLen);
Esempio n. 4
0
 internal static SafeSslHandle SSLStreamCreateWithCertificates(ReadOnlySpan <byte> pkcs8PrivateKey, PAL_KeyAlgorithm algorithm, IntPtr[] certificates)
 {
     return(SSLStreamCreateWithCertificates(
                ref MemoryMarshal.GetReference(pkcs8PrivateKey),
                pkcs8PrivateKey.Length,
                algorithm,
                certificates,
                certificates.Length));
 }
 internal static unsafe partial bool X509StoreAddCertificateWithPrivateKey(
     SafeX509StoreHandle store,
     SafeX509Handle cert,
     SafeKeyHandle key,
     PAL_KeyAlgorithm algorithm,
     string hashString);