668 references to Interop
System.Security.Cryptography (668)
src\libraries\Common\src\Interop\Unix\Interop.Errors.cs (6)
123_error = Interop.Sys.ConvertErrorPlatformToPal(errno); 140get { return _rawErrno == -1 ? (_rawErrno = Interop.Sys.ConvertErrorPalToPlatform(_error)) : _rawErrno; } 145return Interop.Sys.StrError(RawErrno); 219public static Interop.ErrorInfo Info(this Interop.Error error) 221return new Interop.ErrorInfo(error);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.GetPwUid.cs (5)
36const int BufLen = Interop.Sys.Passwd.InitialBufferSize; 63Interop.Sys.Passwd passwd; 64int error = Interop.Sys.GetPwUidR(uid, out passwd, buf, bufLen); 82var errorInfo = new Interop.ErrorInfo(error); 86if (errorInfo.Error == Interop.Error.ERANGE)
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.Crypto.cs (3)
149throw Interop.Crypto.CreateOpenSslCryptographicException(); 159throw Interop.Crypto.CreateOpenSslCryptographicException(); 168throw Interop.Crypto.CreateOpenSslCryptographicException();
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.EcDsa.ImportExport.cs (6)
33Interop.Crypto.ErrClearError(); 71SafeEcKeyHandle key = Interop.Crypto.EcKeyCreateByExplicitParameters( 87Exception e = Interop.Crypto.CreateOpenSslCryptographicException(); 94Interop.Crypto.ErrClearError(); 137throw Interop.Crypto.CreateOpenSslCryptographicException(); 234throw Interop.Crypto.CreateOpenSslCryptographicException();
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.EcKey.cs (7)
47throw Interop.Crypto.CreateOpenSslCryptographicException(); 59if (nidCurveName == Interop.Crypto.NID_undef) 65IntPtr objCurveName = Interop.Crypto.ObjNid2Obj(nidCurveName); 68return Interop.Crypto.GetOidValue(objCurveName); 71throw Interop.Crypto.CreateOpenSslCryptographicException(); 81return (nidCurveName != Interop.Crypto.NID_undef); 83throw Interop.Crypto.CreateOpenSslCryptographicException();
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.OCSP.cs (2)
107Interop.Crypto.OcspRequestDestroy(handle); 122Interop.Crypto.OcspResponseDestroy(handle);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.Pkcs7.cs (1)
51throw Interop.Crypto.CreateOpenSslCryptographicException();
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.PooledCrypto.cs (2)
22throw Interop.Crypto.CreateOpenSslCryptographicException(); 33throw Interop.Crypto.CreateOpenSslCryptographicException();
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.X509Stack.cs (1)
73Interop.Crypto.RecursiveFreeX509Stack(handle);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.X509StoreCtx.cs (1)
86Interop.Crypto.X509StoreCtxDestroy(handle);
src\libraries\Common\src\Microsoft\Win32\SafeHandles\Asn1SafeHandles.Unix.cs (3)
18Interop.Crypto.Asn1ObjectFree(handle); 38Interop.Crypto.Asn1BitStringFree(handle); 58Interop.Crypto.Asn1OctetStringFree(handle);
src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeBignumHandle.Unix.cs (1)
24Interop.Crypto.BigNumDestroy(handle);
src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeBioHandle.Unix.cs (1)
34return Interop.Crypto.BioDestroy(h);
src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeDsaHandle.Unix.cs (3)
20Interop.Crypto.DsaDestroy(handle); 38if (!Interop.Crypto.DsaUpRef(handle)) 40Exception e = Interop.Crypto.CreateOpenSslCryptographicException();
src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeEcKeyHandle.Unix.cs (3)
20Interop.Crypto.EcKeyDestroy(handle); 38if (!Interop.Crypto.EcKeyUpRef(handle)) 40Exception e = Interop.Crypto.CreateOpenSslCryptographicException();
src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeEvpCipherCtxHandle.Unix.cs (1)
19Interop.Crypto.EvpCipherDestroy(handle);
src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeEvpMacCtxHandle.Unix.cs (1)
18Interop.Crypto.EvpMacCtxFree(handle);
src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeEvpMacHandle.Unix.cs (1)
18Interop.Crypto.EvpMacFree(handle);
src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeEvpMdCtxHandle.Unix.cs (1)
19Interop.Crypto.EvpMdCtxDestroy(handle);
src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeEvpPkeyCtxHandle.Unix.cs (1)
23Interop.Crypto.EvpPKeyCtxDestroy(handle);
src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeHmacCtxHandle.Unix.cs (1)
18Interop.Crypto.HmacDestroy(handle);
src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafePkcs7Handle.Unix.cs (1)
18Interop.Crypto.Pkcs7Destroy(handle);
src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeX509Handles.Unix.cs (3)
37Interop.Crypto.X509Destroy(handle); 57Interop.Crypto.X509CrlDestroy(handle); 77Interop.Crypto.X509StoreDestroy(handle);
src\libraries\Common\src\Microsoft\Win32\SafeHandles\X509ExtensionSafeHandles.Unix.cs (2)
19Interop.Crypto.X509ExtensionDestroy(handle); 39Interop.Crypto.ExtendedKeyUsageDestroy(handle);
src\libraries\Common\src\System\Security\Cryptography\DSAOpenSsl.cs (14)
90DSAParameters dsaParameters = Interop.Crypto.ExportDsaParameters(key, includePrivateParameters); 121if (!Interop.Crypto.DsaKeyCreateByExplicitParameters( 129Exception e = Interop.Crypto.CreateOpenSslCryptographicException(); 186if (!Interop.Crypto.DsaGenerateKey(out key, KeySize)) 188Exception e = Interop.Crypto.CreateOpenSslCryptographicException(); 201int signatureSize = Interop.Crypto.DsaEncodedSignatureSize(key); 202int signatureFieldSize = Interop.Crypto.DsaSignatureFieldSize(key) * BitsPerByte; 228int maxSignatureSize = Interop.Crypto.DsaEncodedSignatureSize(key); 233int fieldSizeBytes = Interop.Crypto.DsaSignatureFieldSize(key); 293if (!Interop.Crypto.DsaSign(key, hash, destination, out int actualLength)) 295throw Interop.Crypto.CreateOpenSslCryptographicException(); 328int expectedSignatureBytes = Interop.Crypto.DsaSignatureFieldSize(key) * 2; 345return Interop.Crypto.DsaVerify(key, hash, signature); 371ForceSetKeySize(BitsPerByte * Interop.Crypto.DsaKeySize(newKey));
src\libraries\Common\src\System\Security\Cryptography\ECDiffieHellmanOpenSsl.Derive.cs (4)
94bool thisIsNamed = Interop.Crypto.EcKeyHasCurveName(_key.Value); 148using (SafeEvpPKeyCtxHandle ctx = Interop.Crypto.EvpPKeyCtxCreate(ourKey, theirKey, out uint secretLengthU)) 152throw Interop.Crypto.CreateOpenSslCryptographicException(); 173Interop.Crypto.EvpPKeyDeriveSecretAgreement(ctx, secret);
src\libraries\Common\src\System\Security\Cryptography\ECDiffieHellmanOpenSslPublicKey.cs (6)
21SafeEcKeyHandle key = Interop.Crypto.EvpPkeyGetEcKey(pkeyHandle); 25Exception e = Interop.Crypto.CreateOpenSslCryptographicException(); 58internal bool HasCurveName => Interop.Crypto.EcKeyHasCurveName(GetKey()); 83SafeEvpPKeyHandle pkeyHandle = Interop.Crypto.EvpPkeyCreate(); 90if (!Interop.Crypto.EvpPkeySetEcKey(pkeyHandle, currentKey)) 92throw Interop.Crypto.CreateOpenSslCryptographicException();
src\libraries\Common\src\System\Security\Cryptography\ECDsaOpenSsl.cs (5)
90int signatureLength = Interop.Crypto.EcDsaSize(key); 117int signatureLength = Interop.Crypto.EcDsaSize(key); 176if (!Interop.Crypto.EcDsaSign(hash, destination, out int actualLength, key)) 178throw Interop.Crypto.CreateOpenSslCryptographicException(); 246int verifyResult = Interop.Crypto.EcDsaVerify(hash, toVerify, key);
src\libraries\Common\src\System\Security\Cryptography\ECOpenSsl.cs (10)
43internal int KeySize => Interop.Crypto.EcKeyGetSize(_key.Value); 50SafeEvpPKeyHandle pkeyHandle = Interop.Crypto.EvpPkeyCreate(); 57if (!Interop.Crypto.EvpPkeySetEcKey(pkeyHandle, currentKey)) 59throw Interop.Crypto.CreateOpenSslCryptographicException(); 92SafeEcKeyHandle? key = Interop.Crypto.EcKeyCreateByOid(oid); 100if (!Interop.Crypto.EcKeyGenerateKey(key)) 102throw Interop.Crypto.CreateOpenSslCryptographicException(); 109SafeEcKeyHandle key = Interop.Crypto.EcKeyCreateByExplicitCurve(curve); 111if (!Interop.Crypto.EcKeyGenerateKey(key)) 112throw Interop.Crypto.CreateOpenSslCryptographicException();
src\libraries\Common\src\System\Security\Cryptography\ECOpenSsl.ImportExport.cs (12)
41Exception e = Interop.Crypto.CreateOpenSslCryptographicException(); 48Interop.Crypto.ErrClearError(); 61if (Interop.Crypto.EcKeyHasCurveName(currentKey)) 76ECParameters parameters = Interop.Crypto.GetECKeyParameters(key, includePrivateParameters); 86string keyOidValueName = Interop.Crypto.EcKeyGetCurveName(key); 96ECParameters parameters = Interop.Crypto.GetECCurveParameters(key, includePrivateParameters); 115SafeEcKeyHandle key = Interop.Crypto.EcKeyCreateByKeyParameters( 127SafeEcKeyHandle key = Interop.Crypto.EcKeyCreateByExplicitParameters( 147SafeEcKeyHandle key = Interop.Crypto.EcKeyCreateByExplicitParameters( 185SafeEcKeyHandle? key = Interop.Crypto.EcKeyCreateByOid(oid); 193if (!Interop.Crypto.EcKeyGenerateKey(key)) 196throw Interop.Crypto.CreateOpenSslCryptographicException();
src\libraries\Common\src\System\Security\Cryptography\RSAOpenSsl.cs (24)
91int rsaSize = Interop.Crypto.EvpPKeySize(key); 119int keySizeBytes = Interop.Crypto.EvpPKeySize(key); 177int rsaSize = Interop.Crypto.EvpPKeySize(key); 195hashAlgorithm = Interop.Crypto.HashAlgorithmToEvp(padding.OaepHashAlgorithm.Name); 198return Interop.Crypto.RsaDecrypt( 214byte[] buf = new byte[Interop.Crypto.EvpPKeySize(key)]; 249int rsaSize = Interop.Crypto.EvpPKeySize(key); 262hashAlgorithm = Interop.Crypto.HashAlgorithmToEvp(padding.OaepHashAlgorithm.Name); 265int written = Interop.Crypto.RsaEncrypt( 288ArraySegment<byte> p8 = Interop.Crypto.RentEncodePkcs8PrivateKey(key); 306ArraySegment<byte> p8 = Interop.Crypto.RentEncodePkcs8PrivateKey(key); 325ArraySegment<byte> spki = Interop.Crypto.RentEncodeSubjectPublicKeyInfo(key); 345ArraySegment<byte> spki = Interop.Crypto.RentEncodeSubjectPublicKeyInfo(key); 544SafeEvpPKeyHandle newKey = Interop.Crypto.DecodeSubjectPublicKeyInfo( 546Interop.Crypto.EvpAlgorithmId.RSA); 591SafeEvpPKeyHandle newKey = Interop.Crypto.DecodePkcs8PrivateKey( 593Interop.Crypto.EvpAlgorithmId.RSA); 664ForceSetKeySize(BitsPerByte * Interop.Crypto.EvpPKeySize(newKey)); 726return Interop.Crypto.RsaGenerateKey(KeySize); 789IntPtr digestAlgorithm = Interop.Crypto.HashAlgorithmToEvp(hashAlgorithm.Name); 791int bytesRequired = Interop.Crypto.EvpPKeySize(key); 805int written = Interop.Crypto.RsaSignHash(key, padding.Mode, digestAlgorithm, hash, destination); 829IntPtr digestAlgorithm = Interop.Crypto.HashAlgorithmToEvp(hashAlgorithm.Name); 832return Interop.Crypto.RsaVerifyHash(
src\libraries\System.Private.CoreLib\src\System\IO\PersistedFiles.Unix.cs (6)
66const int BufLen = Interop.Sys.Passwd.InitialBufferSize; 95Interop.Sys.Passwd passwd; 96int error = Interop.Sys.GetPwUidR(Interop.Sys.GetEUid(), out passwd, buf, bufLen); 115var errorInfo = new Interop.ErrorInfo(error); 119if (errorInfo.Error == Interop.Error.ERANGE)
System\Security\Cryptography\AesCcm.OpenSsl.cs (30)
14public static bool IsSupported { get; } = Interop.OpenSslNoInit.OpenSslIsAvailable; 40using (SafeEvpCipherCtxHandle ctx = Interop.Crypto.EvpCipherCreatePartial(GetCipher(key.Length * 8))) 42Interop.Crypto.CheckValidOpenSslHandle(ctx); 46Interop.Crypto.EvpCipherSetKeyAndIV(ctx, Span<byte>.Empty, Span<byte>.Empty, Interop.Crypto.EvpCipherDirection.Encrypt); 47Interop.Crypto.EvpCipherSetCcmTagLength(ctx, tag.Length); 48Interop.Crypto.EvpCipherSetCcmNonceLength(ctx, nonce.Length); 49Interop.Crypto.EvpCipherSetKeyAndIV(ctx, key, nonce, Interop.Crypto.EvpCipherDirection.NoChange); 54Interop.Crypto.EvpCipherSetInputLength(ctx, plaintext.Length); 56if (!Interop.Crypto.EvpCipherUpdate(ctx, Span<byte>.Empty, out _, associatedData)) 58throw Interop.Crypto.CreateOpenSslCryptographicException(); 62if (!Interop.Crypto.EvpCipherUpdate(ctx, ciphertext, out int ciphertextBytesWritten, plaintext)) 64throw Interop.Crypto.CreateOpenSslCryptographicException(); 67if (!Interop.Crypto.EvpCipherFinalEx( 72throw Interop.Crypto.CreateOpenSslCryptographicException(); 83Interop.Crypto.EvpCipherGetCcmTag(ctx, tag); 109using (SafeEvpCipherCtxHandle ctx = Interop.Crypto.EvpCipherCreatePartial(GetCipher(key.Length * 8))) 111Interop.Crypto.CheckValidOpenSslHandle(ctx); 112Interop.Crypto.EvpCipherSetCcmNonceLength(ctx, nonce.Length); 113Interop.Crypto.EvpCipherSetCcmTag(ctx, tag); 115Interop.Crypto.EvpCipherSetKeyAndIV(ctx, key, nonce, Interop.Crypto.EvpCipherDirection.Decrypt); 120Interop.Crypto.EvpCipherSetInputLength(ctx, ciphertext.Length); 122if (!Interop.Crypto.EvpCipherUpdate(ctx, Span<byte>.Empty, out _, associatedData)) 124throw Interop.Crypto.CreateOpenSslCryptographicException(); 128if (!Interop.Crypto.EvpCipherUpdate(ctx, plaintext, out int plaintextBytesWritten, ciphertext)) 157case 128: return Interop.Crypto.EvpAes128Ccm(); 158case 192: return Interop.Crypto.EvpAes192Ccm(); 159case 256: return Interop.Crypto.EvpAes256Ccm();
System\Security\Cryptography\AesGcm.OpenSsl.cs (26)
14public static bool IsSupported { get; } = Interop.OpenSslNoInit.OpenSslIsAvailable; 20_ctxHandle = Interop.Crypto.EvpCipherCreatePartial(GetCipher(key.Length * 8)); 22Interop.Crypto.CheckValidOpenSslHandle(_ctxHandle); 23Interop.Crypto.EvpCipherSetKeyAndIV( 27Interop.Crypto.EvpCipherDirection.NoChange); 28Interop.Crypto.EvpCipherSetGcmNonceLength(_ctxHandle, NonceSize); 38Interop.Crypto.EvpCipherSetKeyAndIV( 42Interop.Crypto.EvpCipherDirection.Encrypt); 46if (!Interop.Crypto.EvpCipherUpdate(_ctxHandle, Span<byte>.Empty, out _, associatedData)) 48throw Interop.Crypto.CreateOpenSslCryptographicException(); 52if (!Interop.Crypto.EvpCipherUpdate(_ctxHandle, ciphertext, out int ciphertextBytesWritten, plaintext)) 54throw Interop.Crypto.CreateOpenSslCryptographicException(); 57if (!Interop.Crypto.EvpCipherFinalEx( 62throw Interop.Crypto.CreateOpenSslCryptographicException(); 73Interop.Crypto.EvpCipherGetGcmTag(_ctxHandle, tag); 83Interop.Crypto.EvpCipherSetKeyAndIV( 87Interop.Crypto.EvpCipherDirection.Decrypt); 91if (!Interop.Crypto.EvpCipherUpdate(_ctxHandle, Span<byte>.Empty, out _, associatedData)) 93throw Interop.Crypto.CreateOpenSslCryptographicException(); 97if (!Interop.Crypto.EvpCipherUpdate(_ctxHandle, plaintext, out int plaintextBytesWritten, ciphertext)) 99throw Interop.Crypto.CreateOpenSslCryptographicException(); 102Interop.Crypto.EvpCipherSetGcmTag(_ctxHandle, tag); 104if (!Interop.Crypto.EvpCipherFinalEx( 126case 128: return Interop.Crypto.EvpAes128Gcm(); 127case 192: return Interop.Crypto.EvpAes192Gcm(); 128case 256: return Interop.Crypto.EvpAes256Gcm();
System\Security\Cryptography\AesImplementation.OpenSsl.cs (12)
45(128, CipherMode.CBC) => Interop.Crypto.EvpAes128Cbc(), 46(128, CipherMode.ECB) => Interop.Crypto.EvpAes128Ecb(), 47(128, CipherMode.CFB) when feedback == 8 => Interop.Crypto.EvpAes128Cfb8(), 48(128, CipherMode.CFB) when feedback == 128 => Interop.Crypto.EvpAes128Cfb128(), 50(192, CipherMode.CBC) => Interop.Crypto.EvpAes192Cbc(), 51(192, CipherMode.ECB) => Interop.Crypto.EvpAes192Ecb(), 52(192, CipherMode.CFB) when feedback == 8 => Interop.Crypto.EvpAes192Cfb8(), 53(192, CipherMode.CFB) when feedback == 128 => Interop.Crypto.EvpAes192Cfb128(), 55(256, CipherMode.CBC) => Interop.Crypto.EvpAes256Cbc(), 56(256, CipherMode.ECB) => Interop.Crypto.EvpAes256Ecb(), 57(256, CipherMode.CFB) when feedback == 8 => Interop.Crypto.EvpAes256Cfb8(), 58(256, CipherMode.CFB) when feedback == 128 => Interop.Crypto.EvpAes256Cfb128(),
System\Security\Cryptography\ChaCha20Poly1305.OpenSsl.cs (24)
12public static bool IsSupported { get; } = Interop.OpenSslNoInit.OpenSslIsAvailable && 13Interop.Crypto.EvpChaCha20Poly1305() != IntPtr.Zero; 20_ctxHandle = Interop.Crypto.EvpCipherCreatePartial(GetCipher(key.Length * 8)); 22Interop.Crypto.CheckValidOpenSslHandle(_ctxHandle); 23Interop.Crypto.EvpCipherSetKeyAndIV( 27Interop.Crypto.EvpCipherDirection.NoChange); 37Interop.Crypto.EvpCipherSetKeyAndIV( 41Interop.Crypto.EvpCipherDirection.Encrypt); 45if (!Interop.Crypto.EvpCipherUpdate(_ctxHandle, Span<byte>.Empty, out _, associatedData)) 47throw Interop.Crypto.CreateOpenSslCryptographicException(); 51if (!Interop.Crypto.EvpCipherUpdate(_ctxHandle, ciphertext, out int ciphertextBytesWritten, plaintext)) 53throw Interop.Crypto.CreateOpenSslCryptographicException(); 56if (!Interop.Crypto.EvpCipherFinalEx( 61throw Interop.Crypto.CreateOpenSslCryptographicException(); 72Interop.Crypto.EvpCipherGetAeadTag(_ctxHandle, tag); 82Interop.Crypto.EvpCipherSetKeyAndIV( 86Interop.Crypto.EvpCipherDirection.Decrypt); 90if (!Interop.Crypto.EvpCipherUpdate(_ctxHandle, Span<byte>.Empty, out _, associatedData)) 92throw Interop.Crypto.CreateOpenSslCryptographicException(); 96if (!Interop.Crypto.EvpCipherUpdate(_ctxHandle, plaintext, out int plaintextBytesWritten, ciphertext)) 98throw Interop.Crypto.CreateOpenSslCryptographicException(); 101Interop.Crypto.EvpCipherSetAeadTag(_ctxHandle, tag); 103if (!Interop.Crypto.EvpCipherFinalEx( 125case 256: return Interop.Crypto.EvpChaCha20Poly1305();
System\Security\Cryptography\DesImplementation.OpenSsl.cs (5)
23Interop.Crypto.EnsureLegacyAlgorithmsRegistered(); 41Interop.Crypto.EnsureLegacyAlgorithmsRegistered(); 49CipherMode.CBC => Interop.Crypto.EvpDesCbc(), 50CipherMode.ECB => Interop.Crypto.EvpDesEcb(), 51CipherMode.CFB when feedbackSize == 1 => Interop.Crypto.EvpDesCfb8(),
System\Security\Cryptography\DSAOpenSsl.cs (6)
48SafeDsaHandle key = Interop.Crypto.EvpPkeyGetDsa(pkeyHandle); 52throw Interop.Crypto.CreateOpenSslCryptographicException(); 91SafeEvpPKeyHandle pkeyHandle = Interop.Crypto.EvpPkeyCreate(); 98if (!Interop.Crypto.EvpPkeySetDsa(pkeyHandle, currentKey)) 100throw Interop.Crypto.CreateOpenSslCryptographicException(); 114if (!Interop.OpenSslNoInit.OpenSslIsAvailable)
System\Security\Cryptography\ECDiffieHellmanOpenSsl.cs (6)
34SafeEcKeyHandle key = Interop.Crypto.EvpPkeyGetEcKey(pkeyHandle); 38throw Interop.Crypto.CreateOpenSslCryptographicException(); 79SafeEvpPKeyHandle pkeyHandle = Interop.Crypto.EvpPkeyCreate(); 86if (!Interop.Crypto.EvpPkeySetEcKey(pkeyHandle, currentKey)) 88throw Interop.Crypto.CreateOpenSslCryptographicException(); 102if (!Interop.OpenSslNoInit.OpenSslIsAvailable)
System\Security\Cryptography\ECDsaOpenSsl.cs (6)
34SafeEcKeyHandle key = Interop.Crypto.EvpPkeyGetEcKey(pkeyHandle); 38throw Interop.Crypto.CreateOpenSslCryptographicException(); 80SafeEvpPKeyHandle pkeyHandle = Interop.Crypto.EvpPkeyCreate(); 87if (!Interop.Crypto.EvpPkeySetEcKey(pkeyHandle, currentKey)) 89throw Interop.Crypto.CreateOpenSslCryptographicException(); 103if (!Interop.OpenSslNoInit.OpenSslIsAvailable)
System\Security\Cryptography\HashProviderDispenser.OpenSsl.cs (8)
18HashAlgorithmNames.KMAC128 => Interop.Crypto.EvpMacAlgs.Kmac128 is not null, 19HashAlgorithmNames.KMAC256 => Interop.Crypto.EvpMacAlgs.Kmac256 is not null, 36HashAlgorithmNames.KMAC128 => Interop.Crypto.EvpMacAlgs.Kmac128, 37HashAlgorithmNames.KMAC256 => Interop.Crypto.EvpMacAlgs.Kmac256, 42Interop.Crypto.EvpMacOneShot(macHandle, key, customizationString, source, destination, xof); 47IntPtr evpType = Interop.Crypto.HashAlgorithmToEvp(hashAlgorithmId); 51int ret = Interop.Crypto.EvpDigestXOFOneShot(evpType, source, destination); 56throw Interop.Crypto.CreateOpenSslCryptographicException();
System\Security\Cryptography\HashProviderDispenser.Unix.cs (8)
27return Interop.Crypto.HashAlgorithmSupported(hashAlgorithmId); 40IntPtr evpType = Interop.Crypto.HashAlgorithmToEvp(hashAlgorithmId); 43int hashSize = Interop.Crypto.EvpMdSize(evpType); 51int written = Interop.Crypto.HmacOneShot(evpType, key, source, destination); 58IntPtr evpType = Interop.Crypto.HashAlgorithmToEvp(hashAlgorithmId); 61int hashSize = Interop.Crypto.EvpMdSize(evpType); 71int ret = Interop.Crypto.EvpDigestOneShot(evpType, pSource, source.Length, pDestination, &length); 76throw Interop.Crypto.CreateOpenSslCryptographicException();
System\Security\Cryptography\LiteHash.OpenSsl.cs (8)
17HashAlgorithmNames.KMAC128 => Interop.Crypto.EvpMacAlgs.Kmac128, 18HashAlgorithmNames.KMAC256 => Interop.Crypto.EvpMacAlgs.Kmac256, 41_ctx = Interop.Crypto.EvpMacCtxNew(algorithm); 42Interop.Crypto.EvpMacInit(_ctx, key, customizationString, xof); 52Interop.Crypto.EvpMacUpdate(_ctx, data); 57Interop.Crypto.EvpMacCurrent(_ctx, destination); 63Interop.Crypto.EvpMacFinal(_ctx, destination); 67public void Reset() => Interop.Crypto.EvpMacReset(_ctx);
System\Security\Cryptography\LiteHash.Unix.cs (33)
14IntPtr algorithm = Interop.Crypto.HashAlgorithmToEvp(hashAlgorithmId); 20IntPtr algorithm = Interop.Crypto.HashAlgorithmToEvp(hashAlgorithmId); 26IntPtr algorithm = Interop.Crypto.HashAlgorithmToEvp(hashAlgorithmId); 43_ctx = Interop.Crypto.EvpMdCtxCreate(algorithm); 44Interop.Crypto.CheckValidOpenSslHandle(_ctx); 60Check(Interop.Crypto.EvpDigestUpdate(_ctx, data, data.Length)); 65Check(Interop.Crypto.EvpDigestReset(_ctx, _algorithm)); 70Check(Interop.Crypto.EvpDigestFinalXOF(_ctx, destination)); 76Check(Interop.Crypto.EvpDigestCurrentXOF(_ctx, destination)); 81SafeEvpMdCtxHandle clone = Interop.Crypto.EvpMdCtxCopyEx(_ctx); 82Interop.Crypto.CheckValidOpenSslHandle(clone); 88Check(Interop.Crypto.EvpDigestSqueeze(_ctx, destination)); 103throw Interop.Crypto.CreateOpenSslCryptographicException(); 121_hashSizeInBytes = Interop.Crypto.EvpMdSize(algorithm); 123if (_hashSizeInBytes <= 0 || _hashSizeInBytes > Interop.Crypto.EVP_MAX_MD_SIZE) 125Debug.Fail($"Unexpected hash '{_hashSizeInBytes}' size from {nameof(Interop.Crypto.EvpMdSize)}."); 129_ctx = Interop.Crypto.EvpMdCtxCreate(algorithm); 130Interop.Crypto.CheckValidOpenSslHandle(_ctx); 140Check(Interop.Crypto.EvpDigestUpdate(_ctx, data, data.Length)); 148Check(Interop.Crypto.EvpDigestFinalEx(_ctx, ref MemoryMarshal.GetReference(destination), ref length)); 156Check(Interop.Crypto.EvpDigestReset(_ctx, _algorithm)); 162Check(Interop.Crypto.EvpDigestCurrent(_ctx, ref MemoryMarshal.GetReference(destination), ref length)); 179throw Interop.Crypto.CreateOpenSslCryptographicException(); 194_hashSizeInBytes = Interop.Crypto.EvpMdSize(algorithm); 196if (_hashSizeInBytes <= 0 || _hashSizeInBytes > Interop.Crypto.EVP_MAX_MD_SIZE) 198Debug.Fail($"Unexpected hash '{_hashSizeInBytes}' size from {nameof(Interop.Crypto.EvpMdSize)}."); 202_ctx = Interop.Crypto.HmacCreate(ref MemoryMarshal.GetReference(key), key.Length, algorithm); 203Interop.Crypto.CheckValidOpenSslHandle(_ctx); 213Check(Interop.Crypto.HmacUpdate(_ctx, data, data.Length)); 221Check(Interop.Crypto.HmacCurrent(_ctx, ref MemoryMarshal.GetReference(destination), ref length)); 231Check(Interop.Crypto.HmacFinal(_ctx, ref MemoryMarshal.GetReference(destination), ref length)); 238Check(Interop.Crypto.HmacReset(_ctx)); 253throw Interop.Crypto.CreateOpenSslCryptographicException();
System\Security\Cryptography\OidLookup.OpenSsl.cs (5)
21int result = Interop.Crypto.LookupFriendlyNameByOid(oid, ref friendlyNamePtr); 31throw Interop.Crypto.CreateOpenSslCryptographicException(); 36Interop.Crypto.ErrClearError(); 43IntPtr sharedObject = Interop.Crypto.GetObjectDefinitionByName(friendlyName); 50return Interop.Crypto.GetOidValue(sharedObject);
System\Security\Cryptography\OpenSslAsnFormatter.cs (11)
26using (SafeAsn1ObjectHandle asnOid = Interop.Crypto.ObjTxt2Obj(oid.Value)) 27using (SafeAsn1OctetStringHandle octetString = Interop.Crypto.Asn1OctetStringNew()) 34if (!Interop.Crypto.Asn1OctetStringSet(octetString, rawData, rawData.Length)) 39using (SafeBioHandle bio = Interop.Crypto.CreateMemoryBio()) 40using (SafeX509ExtensionHandle x509Ext = Interop.Crypto.X509ExtensionCreateByObj(asnOid, false, octetString)) 47if (!Interop.Crypto.X509V3ExtPrint(bio, x509Ext)) 53Interop.Crypto.ErrClearError(); 59int printLen = Interop.Crypto.GetMemoryBioSize(bio); 69read = Interop.Crypto.BioGets(bio, current); 73throw Interop.Crypto.CreateOpenSslCryptographicException(); 90Interop.Crypto.ErrClearError();
System\Security\Cryptography\OpenSslCipherLite.cs (8)
36_ctx = Interop.Crypto.EvpCipherCreate( 43Interop.Crypto.CheckValidOpenSslHandle(_ctx); 47CheckBoolReturn(Interop.Crypto.EvpCipherCtxSetPadding(_ctx, 0)); 73CheckBoolReturn(Interop.Crypto.EvpCipherFinalEx(_ctx, outputSpan, out int finalWritten)); 87CheckBoolReturn(Interop.Crypto.EvpCipherFinalEx(_ctx, outputSpan, out int finalWritten)); 127bool status = Interop.Crypto.EvpCipherReset(_ctx, iv); 142Interop.Crypto.EvpCipherUpdate( 155throw Interop.Crypto.CreateOpenSslCryptographicException();
System\Security\Cryptography\Pbkdf2Implementation.OpenSsl.cs (3)
19IntPtr evpHashType = Interop.Crypto.HashAlgorithmToEvp(hashAlgorithmName.Name); 20int result = Interop.Crypto.Pbkdf2(password, salt, iterations, evpHashType, destination); 26throw Interop.Crypto.CreateOpenSslCryptographicException();
System\Security\Cryptography\RandomNumberGeneratorImplementation.OpenSsl.cs (2)
14if (!Interop.Crypto.GetRandomBytes(pbBuffer, count)) 16throw Interop.Crypto.CreateOpenSslCryptographicException();
System\Security\Cryptography\RC2Implementation.OpenSsl.cs (4)
23Interop.Crypto.EnsureLegacyAlgorithmsRegistered(); 40Interop.Crypto.EnsureLegacyAlgorithmsRegistered(); 46CipherMode.CBC => Interop.Crypto.EvpRC2Cbc(), 47CipherMode.ECB => Interop.Crypto.EvpRC2Ecb(),
System\Security\Cryptography\RSAOpenSsl.cs (6)
47SafeEvpPKeyHandle pkey = Interop.Crypto.EvpPKeyCreateRsa(handle); 76SafeEvpPKeyHandle newKey = Interop.Crypto.EvpPKeyDuplicate( 78Interop.Crypto.EvpAlgorithmId.RSA); 90return Interop.Crypto.EvpPKeyDuplicate(GetKey(), Interop.Crypto.EvpAlgorithmId.RSA); 95if (!Interop.OpenSslNoInit.OpenSslIsAvailable)
System\Security\Cryptography\SafeEvpPKeyHandle.OpenSsl.cs (7)
36Interop.Crypto.EvpPkeyDestroy(handle); 60int success = Interop.Crypto.UpRefEvpPkey(this); 65Exception e = Interop.Crypto.CreateOpenSslCryptographicException(); 120if (!Interop.OpenSslNoInit.OpenSslIsAvailable) 125return Interop.Crypto.LoadPrivateKeyFromEngine(engineName, keyId); 173if (!Interop.OpenSslNoInit.OpenSslIsAvailable) 178return Interop.Crypto.LoadPublicKeyFromEngine(engineName, keyId);
System\Security\Cryptography\SafeEvpPKeyHandle.OpenSsl.Unix.cs (1)
22public static long OpenSslVersion { get; } = Interop.OpenSsl.OpenSslVersionNumber();
System\Security\Cryptography\TripleDesImplementation.OpenSsl.cs (4)
50CipherMode.CBC => Interop.Crypto.EvpDes3Cbc(), 51CipherMode.ECB => Interop.Crypto.EvpDes3Ecb(), 52CipherMode.CFB when feedbackSizeInBytes == 1 => Interop.Crypto.EvpDes3Cfb8(), 53CipherMode.CFB when feedbackSizeInBytes == 8 => Interop.Crypto.EvpDes3Cfb64(),
System\Security\Cryptography\X509Certificates\ChainPal.OpenSsl.cs (5)
124Interop.Crypto.X509VerifyStatusCode status = chainPal.FindFirstChain(extraStore); 152if (status == Interop.Crypto.X509VerifyStatusCode.X509_V_OK) 174if (status != Interop.Crypto.X509VerifyStatusCode.X509_V_OK && 175status != Interop.Crypto.X509VerifyStatusCodeUniversal.X509_V_ERR_CERT_NOT_YET_VALID && 176status != Interop.Crypto.X509VerifyStatusCodeUniversal.X509_V_ERR_CERT_HAS_EXPIRED)
System\Security\Cryptography\X509Certificates\OpenSslCachedDirectoryStoreProvider.cs (3)
57SafeX509StackHandle newColl = Interop.Crypto.NewX509Stack(); 58Interop.Crypto.CheckValidOpenSslHandle(newColl); 62Interop.Crypto.X509StackAddDirectoryStore(newColl, info.FullName);
System\Security\Cryptography\X509Certificates\OpenSslCachedSystemStoreProvider.cs (21)
57int count = Interop.Crypto.GetX509StackFieldCount(nativeColl); 61X509Certificate2 clone = new X509Certificate2(Interop.Crypto.GetX509StackField(nativeColl, i)); 148SafeX509StackHandle rootStore = Interop.Crypto.NewX509Stack(); 149Interop.Crypto.CheckValidOpenSslHandle(rootStore); 150SafeX509StackHandle intermedStore = Interop.Crypto.NewX509Stack(); 151Interop.Crypto.CheckValidOpenSslHandle(intermedStore); 223using (SafeBioHandle fileBio = Interop.Crypto.BioNewFile(file, "rb")) 228Interop.Crypto.ErrClearError(); 249using (SafeX509Handle tmp = Interop.Crypto.X509UpRef(pal.Handle)) 251if (!Interop.Crypto.PushX509StackField(rootStore, tmp)) 253throw Interop.Crypto.CreateOpenSslCryptographicException(); 267using (SafeX509Handle tmp = Interop.Crypto.X509UpRef(pal.Handle)) 269if (!Interop.Crypto.PushX509StackField(intermedStore, tmp)) 271throw Interop.Crypto.CreateOpenSslCryptographicException(); 326string? rootFile = Interop.Crypto.GetX509RootStoreFile(); 338string rootDirectory = Interop.Crypto.GetX509RootStorePath(out isDefault) ?? ""; 373=> TryStat(path, Interop.Sys.FileTypes.S_IFDIR, out lastModified, out _); 376=> TryStat(path, Interop.Sys.FileTypes.S_IFREG, out lastModified, out fileId); 383if (Interop.Sys.Stat(path, out Interop.Sys.FileStatus status) < 0 || 384(status.Mode & Interop.Sys.FileTypes.S_IFMT) != fileType)
System\Security\Cryptography\X509Certificates\OpenSslCertificateAssetDownloader.cs (8)
62SafeX509CrlHandle handle = Interop.Crypto.DecodeX509Crl(data, data.Length); 71using (SafeBioHandle bio = Interop.Crypto.CreateMemoryBio()) 73Interop.Crypto.CheckValidOpenSslHandle(bio); 75Interop.Crypto.BioWrite(bio, data, data.Length); 77handle = Interop.Crypto.PemReadBioX509Crl(bio); 81Interop.Crypto.ErrClearError(); 110SafeOcspResponseHandle resp = Interop.Crypto.DecodeOcspResponse(data); 116Interop.Crypto.ErrClearError();
System\Security\Cryptography\X509Certificates\OpenSslCertificateFinder.cs (3)
17byte[] publicKeyInfoBytes = Interop.Crypto.OpenSslEncode( 18Interop.Crypto.GetX509SubjectPublicKeyInfoDerSize, 19Interop.Crypto.EncodeX509SubjectPublicKeyInfo,
System\Security\Cryptography\X509Certificates\OpenSslCrlCache.cs (18)
99using (SafeBioHandle bio = Interop.Crypto.BioNewFile(crlFile, "rb")) 108Interop.Crypto.ErrClearError(); 114using (SafeX509CrlHandle crl = Interop.Crypto.PemReadBioX509Crl(bio)) 123Interop.Crypto.ErrClearError(); 132IntPtr nextUpdatePtr = Interop.Crypto.GetX509CrlNextUpdate(crl); 180if (!Interop.Crypto.X509StoreAddCrl(store, crl)) 183if (X509_R_CERT_ALREADY_IN_HASH_TABLE == Interop.Crypto.ErrPeekLastError()) 185Interop.Crypto.ErrClearError(); 189throw Interop.Crypto.CreateOpenSslCryptographicException(); 216if (!Interop.Crypto.X509StoreAddCrl(store, crl)) 219if (X509_R_CERT_ALREADY_IN_HASH_TABLE == Interop.Crypto.ErrPeekLastError()) 221Interop.Crypto.ErrClearError(); 225throw Interop.Crypto.CreateOpenSslCryptographicException(); 236using (SafeBioHandle bio = Interop.Crypto.BioNewFile(crlFile, "wb")) 238if (bio.IsInvalid || Interop.Crypto.PemWriteBioX509Crl(bio, crl) == 0) 247Interop.Crypto.ErrClearError(); 271ulong persistentHashLong = Interop.Crypto.X509IssuerNameHash(cert); 274Interop.Crypto.ErrClearError();
System\Security\Cryptography\X509Certificates\OpenSslDirectoryBasedStoreProvider.cs (5)
135uint userId = Interop.Sys.GetEUid(); 361Interop.Sys.FileStatus dirStat; 362if (Interop.Sys.Stat(path, out dirStat) != 0) 364Interop.ErrorInfo error = Interop.Sys.GetLastErrorInfo();
System\Security\Cryptography\X509Certificates\OpenSslExportProvider.cs (9)
64using (SafeX509Handle certHandle = Interop.Crypto.X509UpRef(certPtr)) 66if (!Interop.Crypto.PushX509StackField(publicCerts, certHandle)) 68throw Interop.Crypto.CreateOpenSslCryptographicException(); 80using (SafeX509StackHandle certs = Interop.Crypto.NewX509Stack()) 88using (SafePkcs7Handle pkcs7 = Interop.Crypto.Pkcs7CreateCertificateCollection(certs)) 90Interop.Crypto.CheckValidOpenSslHandle(pkcs7); 91return Interop.Crypto.OpenSslEncode( 92Interop.Crypto.GetPkcs7DerSize, 93Interop.Crypto.EncodePkcs7,
System\Security\Cryptography\X509Certificates\OpenSslPkcsFormatReader.cs (25)
18using (SafePkcs7Handle pkcs7 = Interop.Crypto.DecodePkcs7(rawData)) 22Interop.Crypto.ErrClearError(); 31using (SafeBioHandle bio = Interop.Crypto.CreateMemoryBio()) 33Interop.Crypto.CheckValidOpenSslHandle(bio); 35if (Interop.Crypto.BioWrite(bio, rawData) != rawData.Length) 37Interop.Crypto.ErrClearError(); 40using (SafePkcs7Handle pkcs7 = Interop.Crypto.PemReadBioPkcs7(bio)) 44Interop.Crypto.ErrClearError(); 55using (SafePkcs7Handle pkcs7 = Interop.Crypto.D2IPkcs7Bio(fileBio)) 59Interop.Crypto.ErrClearError(); 69using (SafePkcs7Handle pkcs7 = Interop.Crypto.PemReadBioPkcs7(fileBio)) 73Interop.Crypto.ErrClearError(); 107using (SafePkcs7Handle pkcs7 = Interop.Crypto.DecodePkcs7(rawData)) 113Interop.Crypto.ErrClearError(); 127using (SafePkcs7Handle pkcs7 = Interop.Crypto.D2IPkcs7Bio(bio)) 133Interop.Crypto.ErrClearError(); 167using (SafeBioHandle bio = Interop.Crypto.CreateMemoryBio()) 169Interop.Crypto.CheckValidOpenSslHandle(bio); 171if (Interop.Crypto.BioWrite(bio, rawData) != rawData.Length) 173Interop.Crypto.ErrClearError(); 186using (SafePkcs7Handle pkcs7 = Interop.Crypto.PemReadBioPkcs7(bio)) 192Interop.Crypto.ErrClearError(); 208using (SafeSharedX509StackHandle certs = Interop.Crypto.GetPkcs7Certificates(pkcs7)) 210int count = Interop.Crypto.GetX509StackFieldCount(certs); 230IntPtr certHandle = Interop.Crypto.GetX509StackField(certs, i);
System\Security\Cryptography\X509Certificates\OpenSslX509CertificateReader.cs (82)
31return new OpenSslX509CertificateReader(Interop.Crypto.X509UpRef(handle)); 77using (SafeBioHandle fileBio = Interop.Crypto.BioNewFile(fileName, "rb")) 79Interop.Crypto.CheckValidOpenSslHandle(fileBio); 107int bioPosition = Interop.Crypto.BioTell(bio); 146int ret = Interop.Crypto.BioSeek(bio, bioPosition); 150throw Interop.Crypto.CreateOpenSslCryptographicException(); 156SafeX509Handle certHandle = Interop.Crypto.DecodeX509( 164Interop.Crypto.ErrClearError(); 174SafeX509Handle cert = Interop.Crypto.PemReadX509FromBioAux(bio); 180Interop.Crypto.ErrClearError(); 190SafeX509Handle cert = Interop.Crypto.PemReadX509FromBio(bio); 196Interop.Crypto.ErrClearError(); 206using (SafeBioHandle bio = Interop.Crypto.CreateMemoryBio()) 208Interop.Crypto.CheckValidOpenSslHandle(bio); 210if (Interop.Crypto.BioWrite(bio, rawData) != rawData.Length) 212Interop.Crypto.ErrClearError(); 221SafeX509Handle cert = Interop.Crypto.ReadX509AsDerFromBio(bio); 227Interop.Crypto.ErrClearError(); 239bool init = Interop.Crypto.X509CheckPurpose(handle, -1, 0); 243throw Interop.Crypto.CreateOpenSslCryptographicException(); 272return Interop.Crypto.LoadX500Name(Interop.Crypto.X509GetIssuerName(cert)).Name; 285return Interop.Crypto.LoadX500Name(Interop.Crypto.X509GetSubjectName(cert)).Name; 298return Interop.Crypto.GetX509Thumbprint(_cert); 307IntPtr oidPtr = Interop.Crypto.GetX509PublicKeyAlgorithm(cert); 308return Interop.Crypto.GetOidValue(oidPtr); 317return Interop.Crypto.GetX509PublicKeyParameterBytes(_cert); 326IntPtr keyBytesPtr = Interop.Crypto.GetX509PublicKeyBytes(cert); 327return Interop.Crypto.GetAsn1StringBytes(keyBytesPtr); 336using (SafeSharedAsn1IntegerHandle serialNumber = Interop.Crypto.X509GetSerialNumber(_cert)) 338return Interop.Crypto.GetAsn1IntegerBytes(serialNumber); 348IntPtr oidPtr = Interop.Crypto.GetX509SignatureAlgorithm(cert); 349return Interop.Crypto.GetOidValue(oidPtr); 360return ExtractValidityDateTime(Interop.Crypto.GetX509NotAfter(cert)); 370return ExtractValidityDateTime(Interop.Crypto.GetX509NotBefore(cert)); 379return Interop.Crypto.OpenSslEncode( 380Interop.Crypto.GetX509DerSize, 381Interop.Crypto.EncodeX509, 390int version = Interop.Crypto.GetX509Version(_cert); 428return Interop.Crypto.LoadX500Name(Interop.Crypto.X509GetSubjectName(cert)); 438return Interop.Crypto.LoadX500Name(Interop.Crypto.X509GetIssuerName(cert)); 448int extensionCount = Interop.Crypto.X509GetExtCount(cert); 452IntPtr ext = Interop.Crypto.X509GetExt(cert, i); 453Interop.Crypto.CheckValidOpenSslHandle(ext); 455IntPtr oidPtr = Interop.Crypto.X509ExtensionGetOid(ext); 456Interop.Crypto.CheckValidOpenSslHandle(oidPtr); 457string oidValue = Interop.Crypto.GetOidValue(oidPtr); 459IntPtr dataPtr = Interop.Crypto.X509ExtensionGetData(ext); 460Interop.Crypto.CheckValidOpenSslHandle(dataPtr); 465policyData.ApplicationCertPolicies = Interop.Crypto.GetAsn1StringBytes(dataPtr); 468policyData.CertPolicies = Interop.Crypto.GetAsn1StringBytes(dataPtr); 471policyData.CertPolicyMappings = Interop.Crypto.GetAsn1StringBytes(dataPtr); 474policyData.CertPolicyConstraints = Interop.Crypto.GetAsn1StringBytes(dataPtr); 477policyData.EnhancedKeyUsage = Interop.Crypto.GetAsn1StringBytes(dataPtr); 480policyData.InhibitAnyPolicyExtension = Interop.Crypto.GetAsn1StringBytes(dataPtr); 494int extensionCount = Interop.Crypto.X509GetExtCount(cert); 499IntPtr ext = Interop.Crypto.X509GetExt(cert, i); 501Interop.Crypto.CheckValidOpenSslHandle(ext); 503IntPtr oidPtr = Interop.Crypto.X509ExtensionGetOid(ext); 505Interop.Crypto.CheckValidOpenSslHandle(oidPtr); 507string oidValue = Interop.Crypto.GetOidValue(oidPtr); 510IntPtr dataPtr = Interop.Crypto.X509ExtensionGetData(ext); 512Interop.Crypto.CheckValidOpenSslHandle(dataPtr); 514byte[] extData = Interop.Crypto.GetAsn1StringBytes(dataPtr); 515bool critical = Interop.Crypto.X509ExtensionGetCritical(ext); 527int nid = Interop.Crypto.ResolveRequiredNid(oidValue); 529using (SafeSharedAsn1OctetStringHandle data = Interop.Crypto.X509FindExtensionData(cert, nid)) 536return Interop.Crypto.RentAsn1StringBytes(data.DangerousGetHandle()); 572using (SafeEvpPKeyHandle publicKeyHandle = Interop.Crypto.GetX509EvpPublicKey(_cert)) 574Interop.Crypto.CheckValidOpenSslHandle(publicKeyHandle); 582using (SafeEvpPKeyHandle publicKeyHandle = Interop.Crypto.GetX509EvpPublicKey(_cert)) 584Interop.Crypto.CheckValidOpenSslHandle(publicKeyHandle); 614SafeX509Handle certHandle = Interop.Crypto.X509UpRef(_cert); 704using (SafeBioHandle bioHandle = Interop.Crypto.GetX509NameInfo(_cert, (int)nameType, forIssuer)) 711int bioSize = Interop.Crypto.GetMemoryBioSize(bioHandle); 720read = Interop.Crypto.BioGets(bioHandle, current); 724throw Interop.Crypto.CreateOpenSslCryptographicException(); 766SafeX509Handle certHandle = Interop.Crypto.X509UpRef(_cert); 780byte[] bytes = Interop.Crypto.GetAsn1StringBytes(validityDatePtr);
System\Security\Cryptography\X509Certificates\OpenSslX509ChainEventSource.cs (7)
72X500DistinguishedName dn = Interop.Crypto.LoadX500Name(Interop.Crypto.X509GetSubjectName(certHandle)); 124internal void FindFirstChainFinished(Interop.Crypto.X509VerifyStatusCode code) 142internal void FindChainViaAiaFinished(Interop.Crypto.X509VerifyStatusCode code, int downloadCount) 550internal void CrlChainFinished(Interop.Crypto.X509VerifyStatusCode code) 580internal void OcspResponseFromCache(int chainDepth, Interop.Crypto.X509VerifyStatusCode code) 598internal void OcspResponseFromDownload(int chainDepth, Interop.Crypto.X509VerifyStatusCode code)
System\Security\Cryptography\X509Certificates\OpenSslX509ChainProcessor.cs (102)
16using X509VerifyStatusCodeUniversal = Interop.Crypto.X509VerifyStatusCodeUniversal; 24private delegate X509ChainStatusFlags MapVersionSpecificCode(Interop.Crypto.X509VerifyStatusCode code); 113untrusted = Interop.Crypto.NewX509Stack(); 114Interop.Crypto.X509StackAddMultiple(untrusted, s_userIntermediateStore.GetNativeCollection()); 115Interop.Crypto.X509StackAddMultiple(untrusted, s_userPersonalStore.GetNativeCollection()); 119Interop.Crypto.X509StackAddMultiple(untrusted, systemIntermediate); 120Interop.Crypto.X509StoreSetVerifyTime(store, verificationTime); 122storeCtx = Interop.Crypto.X509StoreCtxCreate(); 124if (!Interop.Crypto.X509StoreCtxInit(storeCtx, store, leafHandle, untrusted)) 126throw Interop.Crypto.CreateOpenSslCryptographicException(); 154using (SafeX509StackHandle customTrust = Interop.Crypto.NewX509Stack()) 169return Interop.Crypto.X509ChainNew(customTrust, SafeX509StackHandle.InvalidHandle); 173return Interop.Crypto.X509ChainNew(systemTrust, s_userRootStore.GetNativeCollection()); 176internal Interop.Crypto.X509VerifyStatusCode FindFirstChain(X509Certificate2Collection? extraCerts) 181Interop.Crypto.X509VerifyCert(storeCtx); 182Interop.Crypto.X509VerifyStatusCode statusCode = Interop.Crypto.X509StoreCtxGetError(storeCtx); 198Interop.Crypto.X509StoreCtxRebuildChain(storeCtx); 199statusCode = Interop.Crypto.X509StoreCtxGetError(storeCtx); 205internal static bool IsCompleteChain(Interop.Crypto.X509VerifyStatusCode statusCode) 217internal Interop.Crypto.X509VerifyStatusCode FindChainViaAia( 223Interop.Crypto.X509VerifyStatusCode statusCode = 228using (SafeX509Handle currentCert = Interop.Crypto.X509StoreCtxGetCurrentCert(storeCtx)) 272Interop.Crypto.X509StoreCtxRebuildChain(storeCtx); 273statusCode = Interop.Crypto.X509StoreCtxGetError(storeCtx); 277if (statusCode == Interop.Crypto.X509VerifyStatusCode.X509_V_OK && downloadedCerts != null) 279using (SafeX509StackHandle chainStack = Interop.Crypto.X509StoreCtxGetChain(_storeCtx)) 281int chainSize = Interop.Crypto.GetX509StackFieldCount(chainStack); 298tempChain[i] = Interop.Crypto.GetX509StackField(chainStack, i); 341Interop.Crypto.X509StoreCtxCommitToChain(_storeCtx); 363using (SafeX509StackHandle chainStack = Interop.Crypto.X509StoreCtxGetChain(_storeCtx)) 365chainSize = Interop.Crypto.GetX509StackFieldCount(chainStack); 390if (i == 0 && Interop.Crypto.X509ChainHasStapledOcsp(_storeCtx)) 400Interop.Crypto.X509UpRef(Interop.Crypto.GetX509StackField(chainStack, i))) 413Interop.Crypto.X509StoreSetRevocationFlag(_store, revocationFlag); 414Interop.Crypto.X509StoreCtxRebuildChain(_storeCtx); 417Interop.Crypto.X509VerifyStatusCode errorCode = Interop.Crypto.X509StoreCtxGetError(_storeCtx); 426if (errorCode != Interop.Crypto.X509VerifyStatusCode.X509_V_OK) 467Interop.Crypto.X509VerifyStatusCode statusCode; 489if (statusCode != Interop.Crypto.X509VerifyStatusCode.X509_V_OK) 499using (SafeX509StackHandle chainStack = Interop.Crypto.X509StoreCtxGetChain(_storeCtx)) 538using (SafeSharedX509StackHandle untrusted = Interop.Crypto.X509StoreCtxGetSharedUntrusted(_storeCtx)) 539using (SafeX509Handle upref = Interop.Crypto.X509UpRef(_leafHandle)) 541Interop.Crypto.PushX509StackField(untrusted, upref); 547IntPtr rootPtr = Interop.Crypto.GetX509StackField(chainStack, start); 549using (SafeX509Handle rootHandle = Interop.Crypto.X509UpRef(rootPtr)) 554if (statusCode != Interop.Crypto.X509VerifyStatusCode.X509_V_OK) 610IntPtr certPtr = Interop.Crypto.GetX509StackField(chainStack, i); 612using (SafeX509Handle certHandle = Interop.Crypto.X509UpRef(certPtr)) 618if (statusCode != Interop.Crypto.X509VerifyStatusCode.X509_V_OK) 651return ((WorkingChain*)Interop.Crypto.X509StoreCtxGetAppData(storeCtx))->VerifyCallback(storeCtx); 670Interop.Crypto.X509StoreCtxReset(_storeCtx); 672Interop.Crypto.X509StoreCtxSetVerifyCallback(_storeCtx, &VerifyCallback, &workingChain); 674bool verify = Interop.Crypto.X509VerifyCert(_storeCtx); 685Interop.Crypto.X509StoreCtxSetVerifyCallback(_storeCtx, &VerifyCallback, &workingChain); 687verify = Interop.Crypto.X509VerifyCert(_storeCtx); 706if (Interop.Crypto.X509StoreCtxGetError(_storeCtx) != Interop.Crypto.X509VerifyStatusCode.X509_V_OK) 732Interop.Crypto.X509StoreCtxResetForSignatureError(_storeCtx, out newStore); 741private Interop.Crypto.X509VerifyStatusCode CheckOcsp( 752Interop.Crypto.X509VerifyStatusCode status = 753Interop.Crypto.X509ChainGetCachedOcspStatus(_storeCtx, ocspCache, chainDepth); 777using (SafeOcspRequestHandle req = Interop.Crypto.X509ChainBuildOcspRequest(_storeCtx, chainDepth)) 779ArraySegment<byte> encoded = Interop.Crypto.OpenSslRentEncode( 780Interop.Crypto.GetOcspRequestDerSize, 781Interop.Crypto.EncodeOcspRequest, 818status = Interop.Crypto.X509ChainVerifyOcsp(_storeCtx, req, resp, ocspCache, chainDepth); 852using (SafeX509StackHandle chainStack = Interop.Crypto.X509StoreCtxGetChain(_storeCtx)) 854int chainSize = Interop.Crypto.GetX509StackFieldCount(chainStack); 886IntPtr elementCertPtr = Interop.Crypto.GetX509StackField(chainStack, i); 890throw Interop.Crypto.CreateOpenSslCryptographicException(); 973foreach (Interop.Crypto.X509VerifyStatusCode errorCode in errorCodes) 998Interop.Crypto.X509VerifyStatusCode errorCode, 1075private static X509ChainStatusFlags MapVerifyErrorToChainStatus(Interop.Crypto.X509VerifyStatusCode code) 1164private static X509ChainStatusFlags MapOpenSsl30Code(Interop.Crypto.X509VerifyStatusCode code) 1168case Interop.Crypto.X509VerifyStatusCode30.X509_V_ERR_INVALID_CA: 1176private static X509ChainStatusFlags MapOpenSsl102Code(Interop.Crypto.X509VerifyStatusCode code) 1180case Interop.Crypto.X509VerifyStatusCode102.X509_V_ERR_INVALID_CA: 1188private static X509ChainStatusFlags MapOpenSsl111Code(Interop.Crypto.X509VerifyStatusCode code) 1192case Interop.Crypto.X509VerifyStatusCode111.X509_V_ERR_INVALID_CA: 1290using (SafeX509Handle tmp = Interop.Crypto.X509UpRef(cert)) 1292if (!Interop.Crypto.PushX509StackField(stack, tmp)) 1294throw Interop.Crypto.CreateOpenSslCryptographicException(); 1304using (SafeX509Handle tmp = Interop.Crypto.X509UpRef(cert)) 1306if (!Interop.Crypto.PushX509StackField(stack, tmp)) 1308throw Interop.Crypto.CreateOpenSslCryptographicException(); 1316private static string GetErrorString(Interop.Crypto.X509VerifyStatusCode code) 1320Interop.Crypto.GetX509VerifyCertErrorString); 1362Interop.Crypto.X509VerifyStatusCode errorCode = Interop.Crypto.X509StoreCtxGetError(storeCtx); 1363int errorDepth = Interop.Crypto.X509StoreCtxGetErrorDepth(storeCtx); 1437internal void Add(Interop.Crypto.X509VerifyStatusCode statusCode) 1443private void ClearError(Interop.Crypto.X509VerifyStatusCode statusCode) 1449private bool HasError(Interop.Crypto.X509VerifyStatusCode statusCode) 1542foreach (Interop.Crypto.X509VerifyStatusCode code in this) 1553private static int FindBucket(Interop.Crypto.X509VerifyStatusCode statusCode, out int bitValue) 1580foreach (Interop.Crypto.X509VerifyStatusCode code in coll) 1651public Interop.Crypto.X509VerifyStatusCode Current => 1653Interop.Crypto.X509VerifyStatusCode.X509_V_OK : 1654(Interop.Crypto.X509VerifyStatusCode)(_lastBit + 32 * _lastBucket);
System\Security\Cryptography\X509Certificates\OpenSslX509Encoder.cs (14)
101using (SafeBioHandle fileBio = Interop.Crypto.BioNewFile(fileName, "rb")) 103Interop.Crypto.CheckValidOpenSslHandle(fileBio); 105int bioPosition = Interop.Crypto.BioTell(fileBio); 168using (SafeAsn1BitStringHandle bitString = Interop.Crypto.DecodeAsn1BitString(encoded, encoded.Length)) 170Interop.Crypto.CheckValidOpenSslHandle(bitString); 172byte[] decoded = Interop.Crypto.GetAsn1StringBytes(bitString.DangerousGetHandle()); 225if (!Interop.Crypto.DecodeX509BasicConstraints2Extension( 232throw Interop.Crypto.CreateOpenSslCryptographicException(); 240using (SafeEkuExtensionHandle eku = Interop.Crypto.DecodeExtendedKeyUsage(encoded, encoded.Length)) 242Interop.Crypto.CheckValidOpenSslHandle(eku); 244int count = Interop.Crypto.GetX509EkuFieldCount(eku); 249IntPtr oidPtr = Interop.Crypto.GetX509EkuField(eku, i); 253throw Interop.Crypto.CreateOpenSslCryptographicException(); 256string oidValue = Interop.Crypto.GetOidValue(oidPtr);
System\Security\Cryptography\X509Certificates\StorePal.OpenSsl.cs (5)
57using (SafeBioHandle bio = Interop.Crypto.BioNewFile(fileName, "rb")) 59Interop.Crypto.CheckValidOpenSslHandle(bio); 71int bioPosition = Interop.Crypto.BioTell(bio); 123if (Interop.Crypto.BioSeek(bio, bioPosition) < 0) 125Interop.Crypto.ErrClearError();