669 references to Crypto
System.Security.Cryptography (669)
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.Crypto.cs (3)
143throw Interop.Crypto.CreateOpenSslCryptographicException(); 153throw Interop.Crypto.CreateOpenSslCryptographicException(); 162throw Interop.Crypto.CreateOpenSslCryptographicException();
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.Dsa.cs (5)
127P = Crypto.ExtractBignum(p_bn, pgy_cb)!, 128Q = Crypto.ExtractBignum(q_bn, qx_cb)!, 129G = Crypto.ExtractBignum(g_bn, pgy_cb)!, 130Y = Crypto.ExtractBignum(y_bn, pgy_cb)!, 135dsaParameters.X = Crypto.ExtractBignum(x_bn, qx_cb);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.EcDsa.ImportExport.cs (21)
33Interop.Crypto.ErrClearError(); 71SafeEcKeyHandle key = Interop.Crypto.EcKeyCreateByExplicitParameters( 87Exception e = Interop.Crypto.CreateOpenSslCryptographicException(); 94Interop.Crypto.ErrClearError(); 137throw Interop.Crypto.CreateOpenSslCryptographicException(); 155X = Crypto.ExtractBignum(qx_bn, cbKey), 156Y = Crypto.ExtractBignum(qy_bn, cbKey) 158parameters.D = d_cb == 0 ? null : Crypto.ExtractBignum(d_bn, cbKey); 234throw Interop.Crypto.CreateOpenSslCryptographicException(); 262X = Crypto.ExtractBignum(qx_bn, cbFieldLength), 263Y = Crypto.ExtractBignum(qy_bn, cbFieldLength) 265parameters.D = d_cb == 0 ? null : Crypto.ExtractBignum(d_h, cbSubgroupOrder); 269curve.A = Crypto.ExtractBignum(a_bn, cbFieldLength)!; 270curve.B = Crypto.ExtractBignum(b_bn, cbFieldLength)!; 273X = Crypto.ExtractBignum(gx_bn, cbFieldLength), 274Y = Crypto.ExtractBignum(gy_bn, cbFieldLength) 276curve.Order = Crypto.ExtractBignum(order_bn, cbSubgroupOrder)!; 280curve.Polynomial = Crypto.ExtractBignum(p_bn, pFieldLength)!; 284curve.Prime = Crypto.ExtractBignum(p_bn, pFieldLength)!; 288curve.Cofactor = cofactor_cb == 0 ? null : Crypto.ExtractBignum(cofactor_bn, cofactor_cb); 289curve.Seed = seed_cb == 0 ? null : Crypto.ExtractBignum(seed_bn, seed_cb);
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.EvpPkey.cs (1)
28int keySizeBits = Interop.Crypto.EvpPKeyBits(pkey);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.EcKey.cs (2)
22SafeEvpPKeyHandle pkey = Interop.Crypto.EvpPkeyCreate(); 26throw Interop.Crypto.CreateOpenSslCryptographicException();
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.Rsa.cs (2)
142IntPtr digestAlgorithmPtr = Interop.Crypto.HashAlgorithmToEvp(digestAlgorithm.Name); 183IntPtr digestAlgorithmPtr = Interop.Crypto.HashAlgorithmToEvp(digestAlgorithm.Name);
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 (2)
18Interop.Crypto.Asn1ObjectFree(handle); 38Interop.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\SafeEvpKdfHandle.Unix.cs (1)
18Interop.Crypto.EvpKdfFree(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\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 (1)
19Interop.Crypto.X509ExtensionDestroy(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.cs (2)
115using (SafeEcKeyHandle ecKey = Interop.Crypto.EvpPkeyGetEcKey(_key.Value)) 125using (SafeEcKeyHandle ecKey = Interop.Crypto.EvpPkeyGetEcKey(_key.Value))
src\libraries\Common\src\System\Security\Cryptography\ECDiffieHellmanOpenSsl.Derive.cs (3)
93using (SafeEcKeyHandle ecKey = Interop.Crypto.EvpPkeyGetEcKey(_key.Value)) 95thisIsNamed = Interop.Crypto.EcKeyHasCurveName(ecKey); 165int written = Interop.Crypto.EvpPKeyDeriveSecretAgreement(ourKey, theirKey, secret);
src\libraries\Common\src\System\Security\Cryptography\ECDiffieHellmanOpenSslPublicKey.cs (4)
21SafeEcKeyHandle key = Interop.Crypto.EvpPkeyGetEcKey(pkeyHandle); 25Exception e = Interop.Crypto.CreateOpenSslCryptographicException(); 58internal bool HasCurveName => Interop.Crypto.EcKeyHasCurveName(GetKey()); 83return Interop.Crypto.CreateEvpPkeyFromEcKey(currentKey);
src\libraries\Common\src\System\Security\Cryptography\ECDsaOpenSsl.cs (6)
90int written = Interop.Crypto.EcDsaSignHash(key, hash, derSignature); 128int written = Interop.Crypto.EcDsaSignHash(key, hash, derSignature); 144bytesWritten = Interop.Crypto.EcDsaSignHash(key, hash, tmpDerSignature); 211return Interop.Crypto.EcDsaVerifyHash( 296using (SafeEcKeyHandle ecKey = Interop.Crypto.EvpPkeyGetEcKey(_key.Value)) 306using (SafeEcKeyHandle ecKey = Interop.Crypto.EvpPkeyGetEcKey(_key.Value))
src\libraries\Common\src\System\Security\Cryptography\ECOpenSsl.cs (9)
41internal int KeySize => Interop.Crypto.EcKeyGetSize(_key.Value); 48return Interop.Crypto.CreateEvpPkeyFromEcKey(currentKey); 72SafeEcKeyHandle? key = Interop.Crypto.EcKeyCreateByOid(oid); 80if (!Interop.Crypto.EcKeyGenerateKey(key)) 82throw Interop.Crypto.CreateOpenSslCryptographicException(); 89SafeEcKeyHandle key = Interop.Crypto.EcKeyCreateByExplicitCurve(curve); 91if (!Interop.Crypto.EcKeyGenerateKey(key)) 92throw Interop.Crypto.CreateOpenSslCryptographicException(); 140SafeEvpPKeyHandle handle = Interop.Crypto.CreateEvpPkeyFromEcKey(ec.Value);
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)
89int rsaSize = Interop.Crypto.GetEvpPKeySizeBytes(key); 121int keySizeBytes = Interop.Crypto.GetEvpPKeySizeBytes(key); 176int rsaSize = Interop.Crypto.GetEvpPKeySizeBytes(key); 194hashAlgorithm = Interop.Crypto.HashAlgorithmToEvp(padding.OaepHashAlgorithm.Name); 197return Interop.Crypto.RsaDecrypt( 213byte[] buf = new byte[Interop.Crypto.GetEvpPKeySizeBytes(key)]; 248int rsaSize = Interop.Crypto.GetEvpPKeySizeBytes(key); 261hashAlgorithm = Interop.Crypto.HashAlgorithmToEvp(padding.OaepHashAlgorithm.Name); 264int written = Interop.Crypto.RsaEncrypt( 287ArraySegment<byte> p8 = Interop.Crypto.RentEncodePkcs8PrivateKey(key); 305ArraySegment<byte> p8 = Interop.Crypto.RentEncodePkcs8PrivateKey(key); 324ArraySegment<byte> spki = Interop.Crypto.RentEncodeSubjectPublicKeyInfo(key); 344ArraySegment<byte> spki = Interop.Crypto.RentEncodeSubjectPublicKeyInfo(key); 543SafeEvpPKeyHandle newKey = Interop.Crypto.DecodeSubjectPublicKeyInfo( 545Interop.Crypto.EvpAlgorithmId.RSA); 590SafeEvpPKeyHandle newKey = Interop.Crypto.DecodePkcs8PrivateKey( 592Interop.Crypto.EvpAlgorithmId.RSA); 662ForceSetKeySize(Interop.Crypto.EvpPKeyBits(newKey)); 724return Interop.Crypto.RsaGenerateKey(KeySize); 735int bytesRequired = Interop.Crypto.GetEvpPKeySizeBytes(key); 738int written = Interop.Crypto.RsaSignHash(key, padding.Mode, hashAlgorithm, hash, signature); 761int bytesRequired = Interop.Crypto.GetEvpPKeySizeBytes(key); 769bytesWritten = Interop.Crypto.RsaSignHash(key, padding.Mode, hashAlgorithm, hash, destination); 794return Interop.Crypto.RsaVerifyHash(
System\Security\Cryptography\AesCcm.OpenSsl.cs (29)
40using (SafeEvpCipherCtxHandle ctx = Interop.Crypto.EvpCipherCreatePartial(GetCipher(key.Length * 8))) 42Interop.Crypto.CheckValidOpenSslHandle(ctx); 46Interop.Crypto.EvpCipherSetKeyAndIV(ctx, ReadOnlySpan<byte>.Empty, ReadOnlySpan<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 (25)
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 (23)
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 (5)
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();
System\Security\Cryptography\ECDiffieHellmanOpenSsl.cs (5)
34if (Interop.Crypto.EvpPKeyType(pkeyHandle) != Interop.Crypto.EvpAlgorithmId.ECC) 40KeySizeValue = Interop.Crypto.EvpPKeyBits(_key.Value); 68_key = new Lazy<SafeEvpPKeyHandle>(Interop.Crypto.CreateEvpPkeyFromEcKey(ecKeyHandle)); 71KeySizeValue = Interop.Crypto.EvpPKeyBits(_key.Value);
System\Security\Cryptography\ECDsaOpenSsl.cs (5)
34if (Interop.Crypto.EvpPKeyType(pkeyHandle) != Interop.Crypto.EvpAlgorithmId.ECC) 40ForceSetKeySize(Interop.Crypto.EvpPKeyBits(pkeyHandle)); 68_key = new Lazy<SafeEvpPKeyHandle>(Interop.Crypto.CreateEvpPkeyFromEcKey(ecKeyHandle)); 71ForceSetKeySize(Interop.Crypto.EvpPKeyBits(_key.Value));
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\HKDF.OpenSsl.cs (10)
10private static readonly bool s_hasOpenSslImplementation = Interop.Crypto.EvpKdfAlgs.Hkdf is not null; 21Debug.Assert(Interop.Crypto.EvpKdfAlgs.Hkdf is not null); 24Interop.Crypto.HkdfExtract(Interop.Crypto.EvpKdfAlgs.Hkdf, ikm, hashAlgorithmName.Name, salt, prk); 41Debug.Assert(Interop.Crypto.EvpKdfAlgs.Hkdf is not null); 44Interop.Crypto.HkdfExpand(Interop.Crypto.EvpKdfAlgs.Hkdf, prk, hashAlgorithmName.Name, info, output); 62Debug.Assert(Interop.Crypto.EvpKdfAlgs.Hkdf is not null); 65Interop.Crypto.HkdfDeriveKey( 66Interop.Crypto.EvpKdfAlgs.Hkdf,
System\Security\Cryptography\LiteHash.OpenSsl.cs (9)
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); 57Interop.Crypto.EvpMacUpdate(_ctx, data); 62SafeEvpMacCtxHandle clone = Interop.Crypto.EvpMacCtxDup(_ctx); 68Interop.Crypto.EvpMacCurrent(_ctx, destination); 74Interop.Crypto.EvpMacFinal(_ctx, destination); 78public void Reset() => Interop.Crypto.EvpMacReset(_ctx);
System\Security\Cryptography\LiteHash.Unix.cs (37)
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)); 83Check(Interop.Crypto.EvpDigestCurrentXOF(_ctx, destination)); 88SafeEvpMdCtxHandle clone = Interop.Crypto.EvpMdCtxCopyEx(_ctx); 89Interop.Crypto.CheckValidOpenSslHandle(clone); 95Check(Interop.Crypto.EvpDigestSqueeze(_ctx, destination)); 110throw Interop.Crypto.CreateOpenSslCryptographicException(); 128_hashSizeInBytes = Interop.Crypto.EvpMdSize(algorithm); 130if (_hashSizeInBytes <= 0 || _hashSizeInBytes > Interop.Crypto.EVP_MAX_MD_SIZE) 132Debug.Fail($"Unexpected hash '{_hashSizeInBytes}' size from {nameof(Interop.Crypto.EvpMdSize)}."); 136_ctx = Interop.Crypto.EvpMdCtxCreate(algorithm); 137Interop.Crypto.CheckValidOpenSslHandle(_ctx); 154Check(Interop.Crypto.EvpDigestUpdate(_ctx, data, data.Length)); 162Check(Interop.Crypto.EvpDigestFinalEx(_ctx, ref MemoryMarshal.GetReference(destination), ref length)); 170Check(Interop.Crypto.EvpDigestReset(_ctx, _algorithm)); 176Check(Interop.Crypto.EvpDigestCurrent(_ctx, ref MemoryMarshal.GetReference(destination), ref length)); 183SafeEvpMdCtxHandle clone = Interop.Crypto.EvpMdCtxCopyEx(_ctx); 184Interop.Crypto.CheckValidOpenSslHandle(clone); 200throw Interop.Crypto.CreateOpenSslCryptographicException(); 215_hashSizeInBytes = Interop.Crypto.EvpMdSize(algorithm); 217if (_hashSizeInBytes <= 0 || _hashSizeInBytes > Interop.Crypto.EVP_MAX_MD_SIZE) 219Debug.Fail($"Unexpected hash '{_hashSizeInBytes}' size from {nameof(Interop.Crypto.EvpMdSize)}."); 223_ctx = Interop.Crypto.HmacCreate(ref MemoryMarshal.GetReference(key), key.Length, algorithm); 224Interop.Crypto.CheckValidOpenSslHandle(_ctx); 240Check(Interop.Crypto.HmacUpdate(_ctx, data, data.Length)); 248Check(Interop.Crypto.HmacCurrent(_ctx, ref MemoryMarshal.GetReference(destination), ref length)); 258Check(Interop.Crypto.HmacFinal(_ctx, ref MemoryMarshal.GetReference(destination), ref length)); 265Check(Interop.Crypto.HmacReset(_ctx)); 270SafeHmacCtxHandle clone = Interop.Crypto.HmacCopy(_ctx); 271Interop.Crypto.CheckValidOpenSslHandle(clone); 287throw 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); 142CheckBoolReturn(Interop.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(); 48CipherMode.CBC => Interop.Crypto.EvpRC2Cbc(), 49CipherMode.ECB => Interop.Crypto.EvpRC2Ecb(),
System\Security\Cryptography\RSAOpenSsl.cs (3)
47SafeEvpPKeyHandle pkey = Interop.Crypto.EvpPKeyCreateRsa(handle); 77if (Interop.Crypto.EvpPKeyType(pkeyHandle) != Interop.Crypto.EvpAlgorithmId.RSA)
System\Security\Cryptography\SafeEvpPKeyHandle.OpenSsl.cs (6)
48Interop.Crypto.EvpPkeyDestroy(handle, ExtraHandle); 74int success = Interop.Crypto.UpRefEvpPkey(this); 79Exception e = Interop.Crypto.CreateOpenSslCryptographicException(); 141return Interop.Crypto.LoadPrivateKeyFromEngine(engineName, keyId); 194return Interop.Crypto.LoadPublicKeyFromEngine(engineName, keyId); 246return Interop.Crypto.LoadKeyFromProvider(providerName, keyUri);
System\Security\Cryptography\SP800108HmacCounterKdf.OpenSsl.cs (1)
8private static readonly bool s_hasOpenSslImplementation = Interop.Crypto.EvpKdfAlgs.Kbkdf is not null;
System\Security\Cryptography\SP800108HmacCounterKdfImplementationOpenSsl.cs (6)
29Debug.Assert(Interop.Crypto.EvpKdfAlgs.Kbkdf is { IsInvalid: false }); 41Interop.Crypto.KbkdfHmacOneShot( 42Interop.Crypto.EvpKdfAlgs.Kbkdf, 79Debug.Assert(Interop.Crypto.EvpKdfAlgs.Kbkdf is { IsInvalid: false }); 86Interop.Crypto.KbkdfHmacOneShot( 87Interop.Crypto.EvpKdfAlgs.Kbkdf,
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 (16)
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) ?? "";
System\Security\Cryptography\X509Certificates\OpenSslCertificateAssetDownloader.cs (8)
68SafeX509CrlHandle handle = Interop.Crypto.DecodeX509Crl(data, data.Length); 77using (SafeBioHandle bio = Interop.Crypto.CreateMemoryBio()) 79Interop.Crypto.CheckValidOpenSslHandle(bio); 81Interop.Crypto.BioWrite(bio, data, data.Length); 83handle = Interop.Crypto.PemReadBioX509Crl(bio); 87Interop.Crypto.ErrClearError(); 116SafeOcspResponseHandle resp = Interop.Crypto.DecodeOcspResponse(data); 122Interop.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\OpenSslExportProvider.cs (14)
32Interop.Crypto.EvpAlgorithmId evpAlgId = Interop.Crypto.EvpPKeyType(privateKey); 36Interop.Crypto.EvpAlgorithmId.RSA => new RSAOpenSsl(privateKey), 37Interop.Crypto.EvpAlgorithmId.ECC => new ECDsaOpenSsl(privateKey), 38Interop.Crypto.EvpAlgorithmId.DSA => new DSAOpenSsl(privateKey), 47using (SafeX509Handle certHandle = Interop.Crypto.X509UpRef(certPtr)) 49if (!Interop.Crypto.PushX509StackField(publicCerts, certHandle)) 51throw Interop.Crypto.CreateOpenSslCryptographicException(); 63using (SafeX509StackHandle certs = Interop.Crypto.NewX509Stack()) 71using (SafePkcs7Handle pkcs7 = Interop.Crypto.Pkcs7CreateCertificateCollection(certs)) 73Interop.Crypto.CheckValidOpenSslHandle(pkcs7); 74return Interop.Crypto.OpenSslEncode( 75Interop.Crypto.GetPkcs7DerSize, 76Interop.Crypto.EncodePkcs7,
System\Security\Cryptography\X509Certificates\OpenSslPkcsFormatReader.cs (25)
15using (SafePkcs7Handle pkcs7 = Interop.Crypto.DecodePkcs7(rawData)) 19Interop.Crypto.ErrClearError(); 28using (SafeBioHandle bio = Interop.Crypto.CreateMemoryBio()) 30Interop.Crypto.CheckValidOpenSslHandle(bio); 32if (Interop.Crypto.BioWrite(bio, rawData) != rawData.Length) 34Interop.Crypto.ErrClearError(); 37using (SafePkcs7Handle pkcs7 = Interop.Crypto.PemReadBioPkcs7(bio)) 41Interop.Crypto.ErrClearError(); 52using (SafePkcs7Handle pkcs7 = Interop.Crypto.D2IPkcs7Bio(fileBio)) 56Interop.Crypto.ErrClearError(); 66using (SafePkcs7Handle pkcs7 = Interop.Crypto.PemReadBioPkcs7(fileBio)) 70Interop.Crypto.ErrClearError(); 104using (SafePkcs7Handle pkcs7 = Interop.Crypto.DecodePkcs7(rawData)) 110Interop.Crypto.ErrClearError(); 124using (SafePkcs7Handle pkcs7 = Interop.Crypto.D2IPkcs7Bio(bio)) 130Interop.Crypto.ErrClearError(); 164using (SafeBioHandle bio = Interop.Crypto.CreateMemoryBio()) 166Interop.Crypto.CheckValidOpenSslHandle(bio); 168if (Interop.Crypto.BioWrite(bio, rawData) != rawData.Length) 170Interop.Crypto.ErrClearError(); 183using (SafePkcs7Handle pkcs7 = Interop.Crypto.PemReadBioPkcs7(bio)) 189Interop.Crypto.ErrClearError(); 205using (SafeSharedX509StackHandle certs = Interop.Crypto.GetPkcs7Certificates(pkcs7)) 207int count = Interop.Crypto.GetX509StackFieldCount(certs); 227IntPtr certHandle = Interop.Crypto.GetX509StackField(certs, i);
System\Security\Cryptography\X509Certificates\OpenSslX509CertificateReader.cs (82)
30return new OpenSslX509CertificateReader(Interop.Crypto.X509UpRef(handle)); 78using (SafeBioHandle fileBio = Interop.Crypto.BioNewFile(fileName, "rb")) 80Interop.Crypto.CheckValidOpenSslHandle(fileBio); 108int bioPosition = Interop.Crypto.BioTell(bio); 147int ret = Interop.Crypto.BioSeek(bio, bioPosition); 151throw Interop.Crypto.CreateOpenSslCryptographicException(); 157SafeX509Handle certHandle = Interop.Crypto.DecodeX509( 165Interop.Crypto.ErrClearError(); 175SafeX509Handle cert = Interop.Crypto.PemReadX509FromBioAux(bio); 181Interop.Crypto.ErrClearError(); 191SafeX509Handle cert = Interop.Crypto.PemReadX509FromBio(bio); 197Interop.Crypto.ErrClearError(); 207using (SafeBioHandle bio = Interop.Crypto.CreateMemoryBio()) 209Interop.Crypto.CheckValidOpenSslHandle(bio); 211if (Interop.Crypto.BioWrite(bio, rawData) != rawData.Length) 213Interop.Crypto.ErrClearError(); 222SafeX509Handle cert = Interop.Crypto.ReadX509AsDerFromBio(bio); 228Interop.Crypto.ErrClearError(); 240bool init = Interop.Crypto.X509CheckPurpose(handle, -1, 0); 244throw Interop.Crypto.CreateOpenSslCryptographicException(); 273return Interop.Crypto.LoadX500Name(Interop.Crypto.X509GetIssuerName(cert)).Name; 286return Interop.Crypto.LoadX500Name(Interop.Crypto.X509GetSubjectName(cert)).Name; 299return Interop.Crypto.GetX509Thumbprint(_cert); 308IntPtr oidPtr = Interop.Crypto.GetX509PublicKeyAlgorithm(cert); 309return Interop.Crypto.GetOidValue(oidPtr); 318return Interop.Crypto.GetX509PublicKeyParameterBytes(_cert); 327IntPtr keyBytesPtr = Interop.Crypto.GetX509PublicKeyBytes(cert); 328return Interop.Crypto.GetAsn1StringBytes(keyBytesPtr); 337using (SafeSharedAsn1IntegerHandle serialNumber = Interop.Crypto.X509GetSerialNumber(_cert)) 339return Interop.Crypto.GetAsn1IntegerBytes(serialNumber); 349IntPtr oidPtr = Interop.Crypto.GetX509SignatureAlgorithm(cert); 350return Interop.Crypto.GetOidValue(oidPtr); 361return ExtractValidityDateTime(Interop.Crypto.GetX509NotAfter(cert)); 371return ExtractValidityDateTime(Interop.Crypto.GetX509NotBefore(cert)); 380return Interop.Crypto.OpenSslEncode( 381Interop.Crypto.GetX509DerSize, 382Interop.Crypto.EncodeX509, 391int version = Interop.Crypto.GetX509Version(_cert); 429return Interop.Crypto.LoadX500Name(Interop.Crypto.X509GetSubjectName(cert)); 439return Interop.Crypto.LoadX500Name(Interop.Crypto.X509GetIssuerName(cert)); 449int extensionCount = Interop.Crypto.X509GetExtCount(cert); 453IntPtr ext = Interop.Crypto.X509GetExt(cert, i); 454Interop.Crypto.CheckValidOpenSslHandle(ext); 456IntPtr oidPtr = Interop.Crypto.X509ExtensionGetOid(ext); 457Interop.Crypto.CheckValidOpenSslHandle(oidPtr); 458string oidValue = Interop.Crypto.GetOidValue(oidPtr); 460IntPtr dataPtr = Interop.Crypto.X509ExtensionGetData(ext); 461Interop.Crypto.CheckValidOpenSslHandle(dataPtr); 466policyData.ApplicationCertPolicies = Interop.Crypto.GetAsn1StringBytes(dataPtr); 469policyData.CertPolicies = Interop.Crypto.GetAsn1StringBytes(dataPtr); 472policyData.CertPolicyMappings = Interop.Crypto.GetAsn1StringBytes(dataPtr); 475policyData.CertPolicyConstraints = Interop.Crypto.GetAsn1StringBytes(dataPtr); 478policyData.EnhancedKeyUsage = Interop.Crypto.GetAsn1StringBytes(dataPtr); 481policyData.InhibitAnyPolicyExtension = Interop.Crypto.GetAsn1StringBytes(dataPtr); 495int extensionCount = Interop.Crypto.X509GetExtCount(cert); 500IntPtr ext = Interop.Crypto.X509GetExt(cert, i); 502Interop.Crypto.CheckValidOpenSslHandle(ext); 504IntPtr oidPtr = Interop.Crypto.X509ExtensionGetOid(ext); 506Interop.Crypto.CheckValidOpenSslHandle(oidPtr); 508string oidValue = Interop.Crypto.GetOidValue(oidPtr); 511IntPtr dataPtr = Interop.Crypto.X509ExtensionGetData(ext); 513Interop.Crypto.CheckValidOpenSslHandle(dataPtr); 515byte[] extData = Interop.Crypto.GetAsn1StringBytes(dataPtr); 516bool critical = Interop.Crypto.X509ExtensionGetCritical(ext); 528int nid = Interop.Crypto.ResolveRequiredNid(oidValue); 530using (SafeSharedAsn1OctetStringHandle data = Interop.Crypto.X509FindExtensionData(cert, nid)) 537return Interop.Crypto.RentAsn1StringBytes(data.DangerousGetHandle()); 573using (SafeEvpPKeyHandle publicKeyHandle = Interop.Crypto.GetX509EvpPublicKey(_cert)) 575Interop.Crypto.CheckValidOpenSslHandle(publicKeyHandle); 583using (SafeEvpPKeyHandle publicKeyHandle = Interop.Crypto.GetX509EvpPublicKey(_cert)) 585Interop.Crypto.CheckValidOpenSslHandle(publicKeyHandle); 615SafeX509Handle certHandle = Interop.Crypto.X509UpRef(_cert); 705using (SafeBioHandle bioHandle = Interop.Crypto.GetX509NameInfo(_cert, (int)nameType, forIssuer)) 712int bioSize = Interop.Crypto.GetMemoryBioSize(bioHandle); 721read = Interop.Crypto.BioGets(bioHandle, current); 725throw Interop.Crypto.CreateOpenSslCryptographicException(); 767SafeX509Handle certHandle = Interop.Crypto.X509UpRef(_cert); 781byte[] 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; 22private delegate X509ChainStatusFlags MapVersionSpecificCode(Interop.Crypto.X509VerifyStatusCode code); 111untrusted = Interop.Crypto.NewX509Stack(); 112Interop.Crypto.X509StackAddMultiple(untrusted, s_userIntermediateStore.GetNativeCollection()); 113Interop.Crypto.X509StackAddMultiple(untrusted, s_userPersonalStore.GetNativeCollection()); 117Interop.Crypto.X509StackAddMultiple(untrusted, systemIntermediate); 118Interop.Crypto.X509StoreSetVerifyTime(store, verificationTime); 120storeCtx = Interop.Crypto.X509StoreCtxCreate(); 122if (!Interop.Crypto.X509StoreCtxInit(storeCtx, store, leafHandle, untrusted)) 124throw Interop.Crypto.CreateOpenSslCryptographicException(); 152using (SafeX509StackHandle customTrust = Interop.Crypto.NewX509Stack()) 167return Interop.Crypto.X509ChainNew(customTrust, SafeX509StackHandle.InvalidHandle); 171return Interop.Crypto.X509ChainNew(systemTrust, s_userRootStore.GetNativeCollection()); 174internal Interop.Crypto.X509VerifyStatusCode FindFirstChain(X509Certificate2Collection? extraCerts) 179Interop.Crypto.X509VerifyCert(storeCtx); 180Interop.Crypto.X509VerifyStatusCode statusCode = Interop.Crypto.X509StoreCtxGetError(storeCtx); 196Interop.Crypto.X509StoreCtxRebuildChain(storeCtx); 197statusCode = Interop.Crypto.X509StoreCtxGetError(storeCtx); 203internal static bool IsCompleteChain(Interop.Crypto.X509VerifyStatusCode statusCode) 215internal Interop.Crypto.X509VerifyStatusCode FindChainViaAia( 221Interop.Crypto.X509VerifyStatusCode statusCode = 226using (SafeX509Handle currentCert = Interop.Crypto.X509StoreCtxGetCurrentCert(storeCtx)) 270Interop.Crypto.X509StoreCtxRebuildChain(storeCtx); 271statusCode = Interop.Crypto.X509StoreCtxGetError(storeCtx); 275if (statusCode == Interop.Crypto.X509VerifyStatusCode.X509_V_OK && downloadedCerts != null) 277using (SafeX509StackHandle chainStack = Interop.Crypto.X509StoreCtxGetChain(_storeCtx)) 279int chainSize = Interop.Crypto.GetX509StackFieldCount(chainStack); 296tempChain[i] = Interop.Crypto.GetX509StackField(chainStack, i); 339Interop.Crypto.X509StoreCtxCommitToChain(_storeCtx); 361using (SafeX509StackHandle chainStack = Interop.Crypto.X509StoreCtxGetChain(_storeCtx)) 363chainSize = Interop.Crypto.GetX509StackFieldCount(chainStack); 388if (i == 0 && Interop.Crypto.X509ChainHasStapledOcsp(_storeCtx)) 398Interop.Crypto.X509UpRef(Interop.Crypto.GetX509StackField(chainStack, i))) 411Interop.Crypto.X509StoreSetRevocationFlag(_store, revocationFlag); 412Interop.Crypto.X509StoreCtxRebuildChain(_storeCtx); 415Interop.Crypto.X509VerifyStatusCode errorCode = Interop.Crypto.X509StoreCtxGetError(_storeCtx); 424if (errorCode != Interop.Crypto.X509VerifyStatusCode.X509_V_OK) 465Interop.Crypto.X509VerifyStatusCode statusCode; 487if (statusCode != Interop.Crypto.X509VerifyStatusCode.X509_V_OK) 497using (SafeX509StackHandle chainStack = Interop.Crypto.X509StoreCtxGetChain(_storeCtx)) 536using (SafeSharedX509StackHandle untrusted = Interop.Crypto.X509StoreCtxGetSharedUntrusted(_storeCtx)) 537using (SafeX509Handle upref = Interop.Crypto.X509UpRef(_leafHandle)) 539Interop.Crypto.PushX509StackField(untrusted, upref); 545IntPtr rootPtr = Interop.Crypto.GetX509StackField(chainStack, start); 547using (SafeX509Handle rootHandle = Interop.Crypto.X509UpRef(rootPtr)) 552if (statusCode != Interop.Crypto.X509VerifyStatusCode.X509_V_OK) 608IntPtr certPtr = Interop.Crypto.GetX509StackField(chainStack, i); 610using (SafeX509Handle certHandle = Interop.Crypto.X509UpRef(certPtr)) 616if (statusCode != Interop.Crypto.X509VerifyStatusCode.X509_V_OK) 649return ((WorkingChain*)Interop.Crypto.X509StoreCtxGetAppData(storeCtx))->VerifyCallback(storeCtx); 668Interop.Crypto.X509StoreCtxReset(_storeCtx); 670Interop.Crypto.X509StoreCtxSetVerifyCallback(_storeCtx, &VerifyCallback, &workingChain); 672bool verify = Interop.Crypto.X509VerifyCert(_storeCtx); 683Interop.Crypto.X509StoreCtxSetVerifyCallback(_storeCtx, &VerifyCallback, &workingChain); 685verify = Interop.Crypto.X509VerifyCert(_storeCtx); 704if (Interop.Crypto.X509StoreCtxGetError(_storeCtx) != Interop.Crypto.X509VerifyStatusCode.X509_V_OK) 730Interop.Crypto.X509StoreCtxResetForSignatureError(_storeCtx, out newStore); 739private Interop.Crypto.X509VerifyStatusCode CheckOcsp( 750Interop.Crypto.X509VerifyStatusCode status = 751Interop.Crypto.X509ChainGetCachedOcspStatus(_storeCtx, ocspCache, chainDepth); 775using (SafeOcspRequestHandle req = Interop.Crypto.X509ChainBuildOcspRequest(_storeCtx, chainDepth)) 777ArraySegment<byte> encoded = Interop.Crypto.OpenSslRentEncode( 778Interop.Crypto.GetOcspRequestDerSize, 779Interop.Crypto.EncodeOcspRequest, 816status = Interop.Crypto.X509ChainVerifyOcsp(_storeCtx, req, resp, ocspCache, chainDepth); 850using (SafeX509StackHandle chainStack = Interop.Crypto.X509StoreCtxGetChain(_storeCtx)) 852int chainSize = Interop.Crypto.GetX509StackFieldCount(chainStack); 884IntPtr elementCertPtr = Interop.Crypto.GetX509StackField(chainStack, i); 888throw Interop.Crypto.CreateOpenSslCryptographicException(); 971foreach (Interop.Crypto.X509VerifyStatusCode errorCode in errorCodes) 996Interop.Crypto.X509VerifyStatusCode errorCode, 1073private static X509ChainStatusFlags MapVerifyErrorToChainStatus(Interop.Crypto.X509VerifyStatusCode code) 1162private static X509ChainStatusFlags MapOpenSsl30Code(Interop.Crypto.X509VerifyStatusCode code) 1166case Interop.Crypto.X509VerifyStatusCode30.X509_V_ERR_INVALID_CA: 1174private static X509ChainStatusFlags MapOpenSsl102Code(Interop.Crypto.X509VerifyStatusCode code) 1178case Interop.Crypto.X509VerifyStatusCode102.X509_V_ERR_INVALID_CA: 1186private static X509ChainStatusFlags MapOpenSsl111Code(Interop.Crypto.X509VerifyStatusCode code) 1190case Interop.Crypto.X509VerifyStatusCode111.X509_V_ERR_INVALID_CA: 1288using (SafeX509Handle tmp = Interop.Crypto.X509UpRef(cert)) 1290if (!Interop.Crypto.PushX509StackField(stack, tmp)) 1292throw Interop.Crypto.CreateOpenSslCryptographicException(); 1302using (SafeX509Handle tmp = Interop.Crypto.X509UpRef(cert)) 1304if (!Interop.Crypto.PushX509StackField(stack, tmp)) 1306throw Interop.Crypto.CreateOpenSslCryptographicException(); 1314private static string GetErrorString(Interop.Crypto.X509VerifyStatusCode code) 1318Interop.Crypto.GetX509VerifyCertErrorString); 1360Interop.Crypto.X509VerifyStatusCode errorCode = Interop.Crypto.X509StoreCtxGetError(storeCtx); 1361int errorDepth = Interop.Crypto.X509StoreCtxGetErrorDepth(storeCtx); 1435internal void Add(Interop.Crypto.X509VerifyStatusCode statusCode) 1441private void ClearError(Interop.Crypto.X509VerifyStatusCode statusCode) 1447private bool HasError(Interop.Crypto.X509VerifyStatusCode statusCode) 1540foreach (Interop.Crypto.X509VerifyStatusCode code in this) 1551private static int FindBucket(Interop.Crypto.X509VerifyStatusCode statusCode, out int bitValue) 1578foreach (Interop.Crypto.X509VerifyStatusCode code in coll) 1649public Interop.Crypto.X509VerifyStatusCode Current => 1651Interop.Crypto.X509VerifyStatusCode.X509_V_OK : 1652(Interop.Crypto.X509VerifyStatusCode)(_lastBit + 32 * _lastBucket);
System\Security\Cryptography\X509Certificates\OpenSslX509Encoder.cs (3)
96using (SafeBioHandle fileBio = Interop.Crypto.BioNewFile(fileName, "rb")) 98Interop.Crypto.CheckValidOpenSslHandle(fileBio); 100int bioPosition = Interop.Crypto.BioTell(fileBio);
System\Security\Cryptography\X509Certificates\StorePal.OpenSsl.cs (3)
64using (SafeBioHandle bio = Interop.Crypto.BioNewFile(fileName, "rb")) 66Interop.Crypto.CheckValidOpenSslHandle(bio); 78int bioPosition = Interop.Crypto.BioTell(bio);
System\Security\Cryptography\X509Certificates\X509CertificateLoader.OpenSsl.cs (3)
28using (SafeBioHandle fileBio = Interop.Crypto.BioNewFile(path, "rb")) 30Interop.Crypto.CheckValidOpenSslHandle(fileBio); 32int bioPosition = Interop.Crypto.BioTell(fileBio);