9[UnsupportedOSPlatform(
"browser")]
53 return _salt.AsSpan(0,
_salt.Length - 4).ToArray();
61 _salt =
new byte[value.Length + 4];
73 : this(password, salt, iterations, hashAlgorithm, clearPassword: false)
78 : this(password, salt, 1000)
88 : this(
Encoding.UTF8.
GetBytes(password), salt, iterations, hashAlgorithm, clearPassword: true)
93 : this(password, saltSize, 1000)
112 _salt =
new byte[saltSize + 4];
133 if (password ==
null)
137 _salt =
new byte[salt.Length + 4];
138 salt.AsSpan().CopyTo(
_salt);
150 protected override void Dispose(
bool disposing)
168 base.Dispose(disposing);
177 byte[]
array =
new byte[cb];
209 [Obsolete(
"Rfc2898DeriveBytes.CryptDeriveKey is obsolete and is not supported. Use PasswordDeriveBytes.CryptDeriveKey instead.", DiagnosticId =
"SYSLIB0033", UrlFormat =
"https://aka.ms/dotnet-warnings/{0}")]
210 public byte[]
CryptDeriveKey(
string algname,
string alghashname,
int keySize,
byte[] rgbIV)
223 if (
string.IsNullOrEmpty(hashAlgorithm.
Name))
246 [MemberNotNull(
"_buffer")]
260 if (
_block == uint.MaxValue)
278 for (
int num =
_buffer.Length - 1; num >= 0; num--)
288 if (password ==
null)
305 if (outputLength < 0)
310 byte[]
array =
new byte[outputLength];
327 if (password ==
null)
340 if (outputLength < 0)
349 byte[]
array =
new byte[outputLength];
398 if (
string.IsNullOrEmpty(hashAlgorithm.
Name))
402 string name = hashAlgorithm.
Name;
static void Fill(ReadOnlySpan< byte > password, ReadOnlySpan< byte > salt, int iterations, HashAlgorithmName hashAlgorithmName, Span< byte > destination)
static unsafe void Clear(Array array)
static void BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count)
static void WriteUInt32BigEndian(Span< byte > destination, uint value)
static string ArgumentOutOfRange_NeedPosNum
static string Cryptography_UnknownHashAlgorithm
static string Format(string resourceFormat, object p1)
static string Cryptography_ExceedKdfExtractLimit
static string ArgumentOutOfRange_NeedNonNegNum
static string Cryptography_HashAlgorithmNameNullOrEmpty
static void Return(byte[] array, int clearSize=-1)
static byte[] Rent(int minimumLength)
static void ZeroMemory(Span< byte > buffer)
override void Dispose(bool disposing)
bool TryComputeHash(ReadOnlySpan< byte > source, Span< byte > destination, out int bytesWritten)
static void Fill(Span< byte > data)
static byte[] Pbkdf2(byte[] password, byte[] salt, int iterations, HashAlgorithmName hashAlgorithm, int outputLength)
Rfc2898DeriveBytes(string password, byte[] salt, int iterations, HashAlgorithmName hashAlgorithm)
Rfc2898DeriveBytes(string password, int saltSize, int iterations)
Rfc2898DeriveBytes(byte[] password, byte[] salt, int iterations)
HashAlgorithmName HashAlgorithm
HMAC OpenHmac(byte[] password)
static void Pbkdf2Core(ReadOnlySpan< byte > password, ReadOnlySpan< byte > salt, Span< byte > destination, int iterations, HashAlgorithmName hashAlgorithm)
override void Dispose(bool disposing)
Rfc2898DeriveBytes(byte[] password, byte[] salt, int iterations, HashAlgorithmName hashAlgorithm)
static void Pbkdf2Core(ReadOnlySpan< char > password, ReadOnlySpan< byte > salt, Span< byte > destination, int iterations, HashAlgorithmName hashAlgorithm)
Rfc2898DeriveBytes(string password, int saltSize, int iterations, HashAlgorithmName hashAlgorithm)
static byte[] Pbkdf2(string password, byte[] salt, int iterations, HashAlgorithmName hashAlgorithm, int outputLength)
Rfc2898DeriveBytes(byte[] password, byte[] salt, int iterations, HashAlgorithmName hashAlgorithm, bool clearPassword)
static byte[] Pbkdf2(ReadOnlySpan< byte > password, ReadOnlySpan< byte > salt, int iterations, HashAlgorithmName hashAlgorithm, int outputLength)
static void Pbkdf2(ReadOnlySpan< char > password, ReadOnlySpan< byte > salt, Span< byte > destination, int iterations, HashAlgorithmName hashAlgorithm)
byte[] CryptDeriveKey(string algname, string alghashname, int keySize, byte[] rgbIV)
override byte[] GetBytes(int cb)
Rfc2898DeriveBytes(string password, byte[] salt)
Rfc2898DeriveBytes(string password, byte[] salt, int iterations)
static void Pbkdf2(ReadOnlySpan< byte > password, ReadOnlySpan< byte > salt, Span< byte > destination, int iterations, HashAlgorithmName hashAlgorithm)
static byte[] Pbkdf2(ReadOnlySpan< char > password, ReadOnlySpan< byte > salt, int iterations, HashAlgorithmName hashAlgorithm, int outputLength)
static void ValidateHashAlgorithm(HashAlgorithmName hashAlgorithm)
static readonly Encoding s_throwingUtf8Encoding
Rfc2898DeriveBytes(string password, int saltSize)
static HashAlgorithmName SHA1
static HashAlgorithmName SHA512
static HashAlgorithmName SHA256
static HashAlgorithmName SHA384
void CopyTo(Span< T > destination)
Span< T > Slice(int start)