namespace System.Security.Cryptography {
public abstract class Aes : SymmetricAlgorithm {
public static new Aes Create();
public static new Aes? Create(string algorithmName);
}
public sealed class AesCng : Aes {
public AesCng();
public AesCng(string keyName);
public AesCng(string keyName, CngProvider provider);
public AesCng(string keyName, CngProvider provider, CngKeyOpenOptions openOptions);
+ protected override bool TryDecryptCbcCore(ReadOnlySpan<byte> ciphertext, ReadOnlySpan<byte> iv, Span<byte> destination, PaddingMode paddingMode, out int bytesWritten);
+ protected override bool TryDecryptCfbCore(ReadOnlySpan<byte> ciphertext, ReadOnlySpan<byte> iv, Span<byte> destination, PaddingMode paddingMode, int feedbackSizeInBits, out int bytesWritten);
+ protected override bool TryDecryptEcbCore(ReadOnlySpan<byte> ciphertext, Span<byte> destination, PaddingMode paddingMode, out int bytesWritten);
+ protected override bool TryEncryptCbcCore(ReadOnlySpan<byte> plaintext, ReadOnlySpan<byte> iv, Span<byte> destination, PaddingMode paddingMode, out int bytesWritten);
+ protected override bool TryEncryptCfbCore(ReadOnlySpan<byte> plaintext, ReadOnlySpan<byte> iv, Span<byte> destination, PaddingMode paddingMode, int feedbackSizeInBits, out int bytesWritten);
+ protected override bool TryEncryptEcbCore(ReadOnlySpan<byte> plaintext, Span<byte> destination, PaddingMode paddingMode, out int bytesWritten);
}
public sealed class AesCryptoServiceProvider : Aes {
public AesCryptoServiceProvider();
}
public abstract class AsymmetricAlgorithm : IDisposable {
public static AsymmetricAlgorithm Create();
public static AsymmetricAlgorithm? Create(string algName);
+ public string ExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<char> password, PbeParameters pbeParameters);
+ public string ExportPkcs8PrivateKeyPem();
+ public string ExportSubjectPublicKeyInfoPem();
+ public bool TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<char> password, PbeParameters pbeParameters, Span<char> destination, out int charsWritten);
+ public bool TryExportPkcs8PrivateKeyPem(Span<char> destination, out int charsWritten);
+ public bool TryExportSubjectPublicKeyInfoPem(Span<char> destination, out int charsWritten);
}
public abstract class AsymmetricKeyExchangeDeformatter
public abstract class AsymmetricKeyExchangeFormatter
public abstract class AsymmetricSignatureDeformatter
public abstract class AsymmetricSignatureFormatter
public sealed class CngKey : IDisposable {
public static CngKey Create(CngAlgorithm algorithm);
public static CngKey Create(CngAlgorithm algorithm, string? keyName);
public static CngKey Create(CngAlgorithm algorithm, string? keyName, CngKeyCreationParameters? creationParameters);
public static bool Exists(string keyName);
public static bool Exists(string keyName, CngProvider provider);
public static bool Exists(string keyName, CngProvider provider, CngKeyOpenOptions options);
public static CngKey Import(byte[] keyBlob, CngKeyBlobFormat format);
public static CngKey Import(byte[] keyBlob, CngKeyBlobFormat format, CngProvider provider);
public static CngKey Open(SafeNCryptKeyHandle keyHandle, CngKeyHandleOpenOptions keyHandleOpenOptions);
public static CngKey Open(string keyName);
public static CngKey Open(string keyName, CngProvider provider);
public static CngKey Open(string keyName, CngProvider provider, CngKeyOpenOptions openOptions);
}
public class CryptographicException : SystemException {
public CryptographicException(string format, string? insert);
}
public abstract class DeriveBytes : IDisposable
public abstract class DES : SymmetricAlgorithm {
public static new DES Create();
public static new DES? Create(string algName);
}
public abstract class DSA : AsymmetricAlgorithm {
public static new DSA Create();
public static DSA Create(int keySizeInBits);
public static DSA Create(DSAParameters parameters);
public static new DSA? Create(string algName);
}
public sealed class DSACng : DSA {
public DSACng();
public DSACng(int keySize);
public DSACng(CngKey key);
+ public override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, PbeParameters pbeParameters);
+ public override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, PbeParameters pbeParameters);
- protected override byte[] HashData(byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm);
- protected override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm);
+ public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, ReadOnlySpan<byte> source, out int bytesRead);
+ public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, ReadOnlySpan<byte> source, out int bytesRead);
+ protected override bool TryCreateSignatureCore(ReadOnlySpan<byte> hash, Span<byte> destination, DSASignatureFormat signatureFormat, out int bytesWritten);
+ public override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);
+ public override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);
+ public override bool TryExportPkcs8PrivateKey(Span<byte> destination, out int bytesWritten);
+ protected override bool VerifySignatureCore(ReadOnlySpan<byte> hash, ReadOnlySpan<byte> signature, DSASignatureFormat signatureFormat);
}
public sealed class DSACryptoServiceProvider : DSA, ICspAsymmetricAlgorithm {
public DSACryptoServiceProvider();
public DSACryptoServiceProvider(int dwKeySize);
+ public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, ReadOnlySpan<byte> source, out int bytesRead);
+ public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, ReadOnlySpan<byte> source, out int bytesRead);
}
public sealed class DSAOpenSsl : DSA {
public DSAOpenSsl();
public DSAOpenSsl(int keySize);
public DSAOpenSsl(IntPtr handle);
public DSAOpenSsl(DSAParameters parameters);
public DSAOpenSsl(SafeEvpPKeyHandle pkeyHandle);
- public override int KeySize { set; }
- public override KeySizes[] LegalKeySizes { get; }
- protected override void Dispose(bool disposing);
- protected override byte[] HashData(byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm);
- protected override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm);
}
public class DSASignatureDeformatter : AsymmetricSignatureDeformatter
public class DSASignatureFormatter : AsymmetricSignatureFormatter
+ public abstract class ECAlgorithm : AsymmetricAlgorithm {
+ protected ECAlgorithm();
+ public virtual byte[] ExportECPrivateKey();
+ public string ExportECPrivateKeyPem();
+ public virtual ECParameters ExportExplicitParameters(bool includePrivateParameters);
+ public virtual ECParameters ExportParameters(bool includePrivateParameters);
+ public virtual void GenerateKey(ECCurve curve);
+ public virtual void ImportECPrivateKey(ReadOnlySpan<byte> source, out int bytesRead);
+ public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, ReadOnlySpan<byte> source, out int bytesRead);
+ public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, ReadOnlySpan<byte> source, out int bytesRead);
+ public override void ImportFromEncryptedPem(ReadOnlySpan<char> input, ReadOnlySpan<byte> passwordBytes);
+ public override void ImportFromEncryptedPem(ReadOnlySpan<char> input, ReadOnlySpan<char> password);
+ public override void ImportFromPem(ReadOnlySpan<char> input);
+ public virtual void ImportParameters(ECParameters parameters);
+ public override void ImportPkcs8PrivateKey(ReadOnlySpan<byte> source, out int bytesRead);
+ public override void ImportSubjectPublicKeyInfo(ReadOnlySpan<byte> source, out int bytesRead);
+ public virtual bool TryExportECPrivateKey(Span<byte> destination, out int bytesWritten);
+ public bool TryExportECPrivateKeyPem(Span<char> destination, out int charsWritten);
+ public override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);
+ public override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);
+ public override bool TryExportPkcs8PrivateKey(Span<byte> destination, out int bytesWritten);
+ public override bool TryExportSubjectPublicKeyInfo(Span<byte> destination, out int bytesWritten);
+ }
public struct ECCurve
- public abstract class ECDiffieHellman : AsymmetricAlgorithm {
+ public abstract class ECDiffieHellman : ECAlgorithm {
public static new ECDiffieHellman Create();
public static ECDiffieHellman Create(ECCurve curve);
public static ECDiffieHellman Create(ECParameters parameters);
public static new ECDiffieHellman? Create(string algorithm);
- public virtual byte[] ExportECPrivateKey();
- public virtual ECParameters ExportExplicitParameters(bool includePrivateParameters);
- public virtual ECParameters ExportParameters(bool includePrivateParameters);
- public virtual void GenerateKey(ECCurve curve);
- public virtual void ImportECPrivateKey(ReadOnlySpan<byte> source, out int bytesRead);
- public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, ReadOnlySpan<byte> source, out int bytesRead);
- public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, ReadOnlySpan<byte> source, out int bytesRead);
- public override void ImportFromEncryptedPem(ReadOnlySpan<char> input, ReadOnlySpan<byte> passwordBytes);
- public override void ImportFromEncryptedPem(ReadOnlySpan<char> input, ReadOnlySpan<char> password);
- public override void ImportFromPem(ReadOnlySpan<char> input);
- public virtual void ImportParameters(ECParameters parameters);
- public override void ImportPkcs8PrivateKey(ReadOnlySpan<byte> source, out int bytesRead);
- public override void ImportSubjectPublicKeyInfo(ReadOnlySpan<byte> source, out int bytesRead);
- public virtual bool TryExportECPrivateKey(Span<byte> destination, out int bytesWritten);
- public override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);
- public override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);
- public override bool TryExportPkcs8PrivateKey(Span<byte> destination, out int bytesWritten);
- public override bool TryExportSubjectPublicKeyInfo(Span<byte> destination, out int bytesWritten);
}
public sealed class ECDiffieHellmanCng : ECDiffieHellman {
public ECDiffieHellmanCng();
public ECDiffieHellmanCng(int keySize);
public ECDiffieHellmanCng(CngKey key);
public ECDiffieHellmanCng(ECCurve curve);
+ public override KeySizes[] LegalKeySizes { get; }
+ public override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, PbeParameters pbeParameters);
+ public override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, PbeParameters pbeParameters);
public void FromXmlString(string xml, ECKeyXmlFormat format);
+ public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, ReadOnlySpan<byte> source, out int bytesRead);
+ public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, ReadOnlySpan<byte> source, out int bytesRead);
+ public override void ImportPkcs8PrivateKey(ReadOnlySpan<byte> source, out int bytesRead);
public string ToXmlString(ECKeyXmlFormat format);
+ public override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);
+ public override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);
+ public override bool TryExportPkcs8PrivateKey(Span<byte> destination, out int bytesWritten);
}
public sealed class ECDiffieHellmanCngPublicKey : ECDiffieHellmanPublicKey {
public static ECDiffieHellmanPublicKey FromByteArray(byte[] publicKeyBlob, CngKeyBlobFormat format);
public static ECDiffieHellmanCngPublicKey FromXmlString(string xml);
public override string ToXmlString();
}
public sealed class ECDiffieHellmanOpenSsl : ECDiffieHellman {
public ECDiffieHellmanOpenSsl();
public ECDiffieHellmanOpenSsl(int keySize);
public ECDiffieHellmanOpenSsl(IntPtr handle);
public ECDiffieHellmanOpenSsl(ECCurve curve);
public ECDiffieHellmanOpenSsl(SafeEvpPKeyHandle pkeyHandle);
- public override byte[] DeriveKeyFromHash(ECDiffieHellmanPublicKey otherPartyPublicKey, HashAlgorithmName hashAlgorithm, byte[]? secretPrepend, byte[]? secretAppend);
- public override byte[] DeriveKeyFromHmac(ECDiffieHellmanPublicKey otherPartyPublicKey, HashAlgorithmName hashAlgorithm, byte[]? hmacKey, byte[]? secretPrepend, byte[]? secretAppend);
- public override byte[] DeriveKeyMaterial(ECDiffieHellmanPublicKey otherPartyPublicKey);
- public override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey, byte[] prfLabel, byte[] prfSeed);
- public override ECParameters ExportExplicitParameters(bool includePrivateParameters);
- public override void GenerateKey(ECCurve curve);
}
public abstract class ECDiffieHellmanPublicKey : IDisposable {
protected ECDiffieHellmanPublicKey(byte[] keyBlob);
public virtual byte[] ToByteArray();
public virtual string ToXmlString();
}
- public abstract class ECDsa : AsymmetricAlgorithm {
+ public abstract class ECDsa : ECAlgorithm {
public static new ECDsa Create();
public static ECDsa Create(ECCurve curve);
public static ECDsa Create(ECParameters parameters);
public static new ECDsa? Create(string algorithm);
- public virtual byte[] ExportECPrivateKey();
- public virtual ECParameters ExportExplicitParameters(bool includePrivateParameters);
- public virtual ECParameters ExportParameters(bool includePrivateParameters);
- public virtual void GenerateKey(ECCurve curve);
- public virtual void ImportECPrivateKey(ReadOnlySpan<byte> source, out int bytesRead);
- public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, ReadOnlySpan<byte> source, out int bytesRead);
- public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, ReadOnlySpan<byte> source, out int bytesRead);
- public override void ImportFromEncryptedPem(ReadOnlySpan<char> input, ReadOnlySpan<byte> passwordBytes);
- public override void ImportFromEncryptedPem(ReadOnlySpan<char> input, ReadOnlySpan<char> password);
- public override void ImportFromPem(ReadOnlySpan<char> input);
- public virtual void ImportParameters(ECParameters parameters);
- public override void ImportPkcs8PrivateKey(ReadOnlySpan<byte> source, out int bytesRead);
- public override void ImportSubjectPublicKeyInfo(ReadOnlySpan<byte> source, out int bytesRead);
+ public byte[] SignData(ReadOnlySpan<byte> data, HashAlgorithmName hashAlgorithm);
+ public byte[] SignData(ReadOnlySpan<byte> data, HashAlgorithmName hashAlgorithm, DSASignatureFormat signatureFormat);
+ public int SignData(ReadOnlySpan<byte> data, Span<byte> destination, HashAlgorithmName hashAlgorithm);
+ public int SignData(ReadOnlySpan<byte> data, Span<byte> destination, HashAlgorithmName hashAlgorithm, DSASignatureFormat signatureFormat);
+ public byte[] SignHash(ReadOnlySpan<byte> hash);
+ public byte[] SignHash(ReadOnlySpan<byte> hash, DSASignatureFormat signatureFormat);
+ public int SignHash(ReadOnlySpan<byte> hash, Span<byte> destination);
+ public int SignHash(ReadOnlySpan<byte> hash, Span<byte> destination, DSASignatureFormat signatureFormat);
- public virtual bool TryExportECPrivateKey(Span<byte> destination, out int bytesWritten);
- public override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);
- public override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);
- public override bool TryExportPkcs8PrivateKey(Span<byte> destination, out int bytesWritten);
- public override bool TryExportSubjectPublicKeyInfo(Span<byte> destination, out int bytesWritten);
}
public sealed class ECDsaCng : ECDsa {
public ECDsaCng();
public ECDsaCng(int keySize);
public ECDsaCng(CngKey key);
public ECDsaCng(ECCurve curve);
+ public override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, PbeParameters pbeParameters);
+ public override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, PbeParameters pbeParameters);
public void FromXmlString(string xml, ECKeyXmlFormat format);
- protected override byte[] HashData(byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm);
- protected override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm);
+ public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, ReadOnlySpan<byte> source, out int bytesRead);
+ public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, ReadOnlySpan<byte> source, out int bytesRead);
+ public override void ImportPkcs8PrivateKey(ReadOnlySpan<byte> source, out int bytesRead);
public string ToXmlString(ECKeyXmlFormat format);
+ public override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);
+ public override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);
+ public override bool TryExportPkcs8PrivateKey(Span<byte> destination, out int bytesWritten);
+ public override bool TrySignHash(ReadOnlySpan<byte> source, Span<byte> destination, out int bytesWritten);
+ protected override bool TrySignHashCore(ReadOnlySpan<byte> hash, Span<byte> destination, DSASignatureFormat signatureFormat, out int bytesWritten);
+ public override bool VerifyHash(ReadOnlySpan<byte> hash, ReadOnlySpan<byte> signature);
+ protected override bool VerifyHashCore(ReadOnlySpan<byte> hash, ReadOnlySpan<byte> signature, DSASignatureFormat signatureFormat);
}
public sealed class ECDsaOpenSsl : ECDsa {
public ECDsaOpenSsl();
public ECDsaOpenSsl(int keySize);
public ECDsaOpenSsl(IntPtr handle);
public ECDsaOpenSsl(ECCurve curve);
public ECDsaOpenSsl(SafeEvpPKeyHandle pkeyHandle);
- public override int KeySize { get; set; }
- public override KeySizes[] LegalKeySizes { get; }
- protected override void Dispose(bool disposing);
- public override ECParameters ExportExplicitParameters(bool includePrivateParameters);
- public override ECParameters ExportParameters(bool includePrivateParameters);
- public override void GenerateKey(ECCurve curve);
- protected override byte[] HashData(byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm);
- protected override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm);
- public override void ImportParameters(ECParameters parameters);
}
public struct ECParameters
public abstract class HashAlgorithm : ICryptoTransform, IDisposable {
public static HashAlgorithm Create();
public static HashAlgorithm? Create(string hashName);
}
public static class HKDF
public abstract class HMAC : KeyedHashAlgorithm {
public static new HMAC Create();
public static new HMAC? Create(string algorithmName);
}
public class HMACMD5 : HMAC {
+ public const int HashSizeInBits = 128;
+ public const int HashSizeInBytes = 16;
public HMACMD5();
public HMACMD5(byte[] key);
public static byte[] HashData(byte[] key, byte[] source);
+ public static byte[] HashData(byte[] key, Stream source);
+ public static byte[] HashData(ReadOnlySpan<byte> key, Stream source);
+ public static int HashData(ReadOnlySpan<byte> key, Stream source, Span<byte> destination);
public static byte[] HashData(ReadOnlySpan<byte> key, ReadOnlySpan<byte> source);
public static int HashData(ReadOnlySpan<byte> key, ReadOnlySpan<byte> source, Span<byte> destination);
+ public static ValueTask<byte[]> HashDataAsync(byte[] key, Stream source, CancellationToken cancellationToken = default(CancellationToken));
+ public static ValueTask<int> HashDataAsync(ReadOnlyMemory<byte> key, Stream source, Memory<byte> destination, CancellationToken cancellationToken = default(CancellationToken));
+ public static ValueTask<byte[]> HashDataAsync(ReadOnlyMemory<byte> key, Stream source, CancellationToken cancellationToken = default(CancellationToken));
public static bool TryHashData(ReadOnlySpan<byte> key, ReadOnlySpan<byte> source, Span<byte> destination, out int bytesWritten);
}
public class HMACSHA1 : HMAC {
+ public const int HashSizeInBits = 160;
+ public const int HashSizeInBytes = 20;
+ public static byte[] HashData(byte[] key, Stream source);
+ public static byte[] HashData(ReadOnlySpan<byte> key, Stream source);
+ public static int HashData(ReadOnlySpan<byte> key, Stream source, Span<byte> destination);
+ public static ValueTask<byte[]> HashDataAsync(byte[] key, Stream source, CancellationToken cancellationToken = default(CancellationToken));
+ public static ValueTask<int> HashDataAsync(ReadOnlyMemory<byte> key, Stream source, Memory<byte> destination, CancellationToken cancellationToken = default(CancellationToken));
+ public static ValueTask<byte[]> HashDataAsync(ReadOnlyMemory<byte> key, Stream source, CancellationToken cancellationToken = default(CancellationToken));
}
public class HMACSHA256 : HMAC {
+ public const int HashSizeInBits = 256;
+ public const int HashSizeInBytes = 32;
+ public static byte[] HashData(byte[] key, Stream source);
+ public static byte[] HashData(ReadOnlySpan<byte> key, Stream source);
+ public static int HashData(ReadOnlySpan<byte> key, Stream source, Span<byte> destination);
+ public static ValueTask<byte[]> HashDataAsync(byte[] key, Stream source, CancellationToken cancellationToken = default(CancellationToken));
+ public static ValueTask<int> HashDataAsync(ReadOnlyMemory<byte> key, Stream source, Memory<byte> destination, CancellationToken cancellationToken = default(CancellationToken));
+ public static ValueTask<byte[]> HashDataAsync(ReadOnlyMemory<byte> key, Stream source, CancellationToken cancellationToken = default(CancellationToken));
}
public class HMACSHA384 : HMAC {
+ public const int HashSizeInBits = 384;
+ public const int HashSizeInBytes = 48;
+ public static byte[] HashData(byte[] key, Stream source);
+ public static byte[] HashData(ReadOnlySpan<byte> key, Stream source);
+ public static int HashData(ReadOnlySpan<byte> key, Stream source, Span<byte> destination);
+ public static ValueTask<byte[]> HashDataAsync(byte[] key, Stream source, CancellationToken cancellationToken = default(CancellationToken));
+ public static ValueTask<int> HashDataAsync(ReadOnlyMemory<byte> key, Stream source, Memory<byte> destination, CancellationToken cancellationToken = default(CancellationToken));
+ public static ValueTask<byte[]> HashDataAsync(ReadOnlyMemory<byte> key, Stream source, CancellationToken cancellationToken = default(CancellationToken));
}
public class HMACSHA512 : HMAC {
+ public const int HashSizeInBits = 512;
+ public const int HashSizeInBytes = 64;
+ public static byte[] HashData(byte[] key, Stream source);
+ public static byte[] HashData(ReadOnlySpan<byte> key, Stream source);
+ public static int HashData(ReadOnlySpan<byte> key, Stream source, Span<byte> destination);
+ public static ValueTask<byte[]> HashDataAsync(byte[] key, Stream source, CancellationToken cancellationToken = default(CancellationToken));
+ public static ValueTask<int> HashDataAsync(ReadOnlyMemory<byte> key, Stream source, Memory<byte> destination, CancellationToken cancellationToken = default(CancellationToken));
+ public static ValueTask<byte[]> HashDataAsync(ReadOnlyMemory<byte> key, Stream source, CancellationToken cancellationToken = default(CancellationToken));
}
public sealed class IncrementalHash : IDisposable {
public static IncrementalHash CreateHMAC(HashAlgorithmName hashAlgorithm, byte[] key);
public static IncrementalHash CreateHMAC(HashAlgorithmName hashAlgorithm, ReadOnlySpan<byte> key);
}
public abstract class KeyedHashAlgorithm : HashAlgorithm {
public static new KeyedHashAlgorithm Create();
public static new KeyedHashAlgorithm? Create(string algName);
}
public abstract class MaskGenerationMethod
public abstract class MD5 : HashAlgorithm {
+ public const int HashSizeInBits = 128;
+ public const int HashSizeInBytes = 16;
public static new MD5 Create();
public static new MD5? Create(string algName);
public static byte[] HashData(byte[] source);
+ public static byte[] HashData(Stream source);
+ public static int HashData(Stream source, Span<byte> destination);
public static byte[] HashData(ReadOnlySpan<byte> source);
public static int HashData(ReadOnlySpan<byte> source, Span<byte> destination);
+ public static ValueTask<int> HashDataAsync(Stream source, Memory<byte> destination, CancellationToken cancellationToken = default(CancellationToken));
+ public static ValueTask<byte[]> HashDataAsync(Stream source, CancellationToken cancellationToken = default(CancellationToken));
public static bool TryHashData(ReadOnlySpan<byte> source, Span<byte> destination, out int bytesWritten);
}
public static class PemEncoding {
+ public static string WriteString(ReadOnlySpan<char> label, ReadOnlySpan<byte> data);
}
public class PKCS1MaskGenerationMethod : MaskGenerationMethod
public abstract class RandomNumberGenerator : IDisposable {
public static RandomNumberGenerator? Create(string rngName);
}
public abstract class RC2 : SymmetricAlgorithm {
public static new RC2 Create();
public static new RC2? Create(string AlgName);
}
public sealed class RC2CryptoServiceProvider : RC2 {
public RC2CryptoServiceProvider();
}
public class Rfc2898DeriveBytes : DeriveBytes {
public Rfc2898DeriveBytes(byte[] password, byte[] salt, int iterations);
public Rfc2898DeriveBytes(string password, byte[] salt);
public Rfc2898DeriveBytes(string password, byte[] salt, int iterations);
public Rfc2898DeriveBytes(string password, int saltSize);
public Rfc2898DeriveBytes(string password, int saltSize, int iterations);
}
public abstract class Rijndael : SymmetricAlgorithm {
public static new Rijndael Create();
public static new Rijndael? Create(string algName);
}
public abstract class RSA : AsymmetricAlgorithm {
public static new RSA Create();
public static RSA Create(int keySizeInBits);
public static RSA Create(RSAParameters parameters);
public static new RSA? Create(string algName);
+ public byte[] Decrypt(ReadOnlySpan<byte> data, RSAEncryptionPadding padding);
+ public int Decrypt(ReadOnlySpan<byte> data, Span<byte> destination, RSAEncryptionPadding padding);
+ public byte[] Encrypt(ReadOnlySpan<byte> data, RSAEncryptionPadding padding);
+ public int Encrypt(ReadOnlySpan<byte> data, Span<byte> destination, RSAEncryptionPadding padding);
+ public string ExportRSAPrivateKeyPem();
+ public string ExportRSAPublicKeyPem();
+ public byte[] SignData(ReadOnlySpan<byte> data, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding);
+ public int SignData(ReadOnlySpan<byte> data, Span<byte> destination, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding);
+ public byte[] SignHash(ReadOnlySpan<byte> hash, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding);
+ public int SignHash(ReadOnlySpan<byte> hash, Span<byte> destination, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding);
+ public bool TryExportRSAPrivateKeyPem(Span<char> destination, out int charsWritten);
+ public bool TryExportRSAPublicKeyPem(Span<char> destination, out int charsWritten);
}
public sealed class RSACng : RSA {
public RSACng();
public RSACng(int keySize);
public RSACng(CngKey key);
+ public override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, PbeParameters pbeParameters);
+ public override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, PbeParameters pbeParameters);
- protected override byte[] HashData(byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm);
- protected override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm);
+ public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, ReadOnlySpan<byte> source, out int bytesRead);
+ public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, ReadOnlySpan<byte> source, out int bytesRead);
+ public override void ImportPkcs8PrivateKey(ReadOnlySpan<byte> source, out int bytesRead);
+ public override bool TryDecrypt(ReadOnlySpan<byte> data, Span<byte> destination, RSAEncryptionPadding padding, out int bytesWritten);
+ public override bool TryEncrypt(ReadOnlySpan<byte> data, Span<byte> destination, RSAEncryptionPadding padding, out int bytesWritten);
+ public override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);
+ public override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);
+ public override bool TryExportPkcs8PrivateKey(Span<byte> destination, out int bytesWritten);
+ public override bool TrySignHash(ReadOnlySpan<byte> hash, Span<byte> destination, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding, out int bytesWritten);
+ public override bool VerifyHash(ReadOnlySpan<byte> hash, ReadOnlySpan<byte> signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding);
}
public sealed class RSACryptoServiceProvider : RSA, ICspAsymmetricAlgorithm {
public RSACryptoServiceProvider();
public RSACryptoServiceProvider(int dwKeySize);
- protected override byte[] HashData(byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm);
- protected override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm);
+ public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, ReadOnlySpan<byte> source, out int bytesRead);
+ public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, ReadOnlySpan<byte> source, out int bytesRead);
}
public sealed class RSAEncryptionPadding : IEquatable<RSAEncryptionPadding>
public class RSAOAEPKeyExchangeDeformatter : AsymmetricKeyExchangeDeformatter
public class RSAOAEPKeyExchangeFormatter : AsymmetricKeyExchangeFormatter
public sealed class RSAOpenSsl : RSA {
public RSAOpenSsl();
public RSAOpenSsl(int keySize);
public RSAOpenSsl(IntPtr handle);
public RSAOpenSsl(RSAParameters parameters);
public RSAOpenSsl(SafeEvpPKeyHandle pkeyHandle);
- public override int KeySize { set; }
- public override KeySizes[] LegalKeySizes { get; }
- public override byte[] Decrypt(byte[] data, RSAEncryptionPadding padding);
- protected override void Dispose(bool disposing);
- public override byte[] Encrypt(byte[] data, RSAEncryptionPadding padding);
- protected override byte[] HashData(byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm);
- protected override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm);
- public override byte[] SignHash(byte[] hash, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding);
- public override bool VerifyHash(byte[] hash, byte[] signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding);
}
public class RSAPKCS1KeyExchangeDeformatter : AsymmetricKeyExchangeDeformatter
public class RSAPKCS1KeyExchangeFormatter : AsymmetricKeyExchangeFormatter
public sealed class RSASignaturePadding : IEquatable<RSASignaturePadding>
public sealed class SafeEvpPKeyHandle : SafeHandle {
public SafeEvpPKeyHandle();
public SafeEvpPKeyHandle(IntPtr handle, bool ownsHandle);
public static long OpenSslVersion { get; }
}
public abstract class SHA1 : HashAlgorithm {
+ public const int HashSizeInBits = 160;
+ public const int HashSizeInBytes = 20;
public static new SHA1? Create(string hashName);
+ public static byte[] HashData(Stream source);
+ public static int HashData(Stream source, Span<byte> destination);
+ public static ValueTask<int> HashDataAsync(Stream source, Memory<byte> destination, CancellationToken cancellationToken = default(CancellationToken));
+ public static ValueTask<byte[]> HashDataAsync(Stream source, CancellationToken cancellationToken = default(CancellationToken));
}
public abstract class SHA256 : HashAlgorithm {
+ public const int HashSizeInBits = 256;
+ public const int HashSizeInBytes = 32;
public static new SHA256? Create(string hashName);
+ public static byte[] HashData(Stream source);
+ public static int HashData(Stream source, Span<byte> destination);
+ public static ValueTask<int> HashDataAsync(Stream source, Memory<byte> destination, CancellationToken cancellationToken = default(CancellationToken));
+ public static ValueTask<byte[]> HashDataAsync(Stream source, CancellationToken cancellationToken = default(CancellationToken));
}
public abstract class SHA384 : HashAlgorithm {
+ public const int HashSizeInBits = 384;
+ public const int HashSizeInBytes = 48;
public static new SHA384? Create(string hashName);
+ public static byte[] HashData(Stream source);
+ public static int HashData(Stream source, Span<byte> destination);
+ public static ValueTask<int> HashDataAsync(Stream source, Memory<byte> destination, CancellationToken cancellationToken = default(CancellationToken));
+ public static ValueTask<byte[]> HashDataAsync(Stream source, CancellationToken cancellationToken = default(CancellationToken));
}
public abstract class SHA512 : HashAlgorithm {
+ public const int HashSizeInBits = 512;
+ public const int HashSizeInBytes = 64;
public static new SHA512? Create(string hashName);
+ public static byte[] HashData(Stream source);
+ public static int HashData(Stream source, Span<byte> destination);
+ public static ValueTask<int> HashDataAsync(Stream source, Memory<byte> destination, CancellationToken cancellationToken = default(CancellationToken));
+ public static ValueTask<byte[]> HashDataAsync(Stream source, CancellationToken cancellationToken = default(CancellationToken));
}
public class SignatureDescription
public abstract class SymmetricAlgorithm : IDisposable {
public static SymmetricAlgorithm Create();
public static SymmetricAlgorithm? Create(string algName);
}
public abstract class TripleDES : SymmetricAlgorithm {
public static new TripleDES Create();
public static new TripleDES? Create(string str);
}
public sealed class TripleDESCng : TripleDES {
public TripleDESCng();
public TripleDESCng(string keyName);
public TripleDESCng(string keyName, CngProvider provider);
public TripleDESCng(string keyName, CngProvider provider, CngKeyOpenOptions openOptions);
+ protected override bool TryDecryptCbcCore(ReadOnlySpan<byte> ciphertext, ReadOnlySpan<byte> iv, Span<byte> destination, PaddingMode paddingMode, out int bytesWritten);
+ protected override bool TryDecryptCfbCore(ReadOnlySpan<byte> ciphertext, ReadOnlySpan<byte> iv, Span<byte> destination, PaddingMode paddingMode, int feedbackSizeInBits, out int bytesWritten);
+ protected override bool TryDecryptEcbCore(ReadOnlySpan<byte> ciphertext, Span<byte> destination, PaddingMode paddingMode, out int bytesWritten);
+ protected override bool TryEncryptCbcCore(ReadOnlySpan<byte> plaintext, ReadOnlySpan<byte> iv, Span<byte> destination, PaddingMode paddingMode, out int bytesWritten);
+ protected override bool TryEncryptCfbCore(ReadOnlySpan<byte> plaintext, ReadOnlySpan<byte> iv, Span<byte> destination, PaddingMode paddingMode, int feedbackSizeInBits, out int bytesWritten);
+ protected override bool TryEncryptEcbCore(ReadOnlySpan<byte> plaintext, Span<byte> destination, PaddingMode paddingMode, out int bytesWritten);
}
}