Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Pbes1Decrypt() [2/2]

static int System.Security.Cryptography.PasswordBasedEncryption.Pbes1Decrypt ( ReadOnlyMemory< byte >? algorithmParameters,
ReadOnlySpan< byte > password,
IncrementalHash hasher,
SymmetricAlgorithm cipher,
ReadOnlySpan< byte > encryptedData,
Span< byte > destination )
inlinestaticprivate

Definition at line 501 of file PasswordBasedEncryption.cs.

502 {
503 if (!algorithmParameters.HasValue)
504 {
505 throw new CryptographicException(System.SR.Cryptography_Der_Invalid_Encoding);
506 }
508 if (pBEParameter.Salt.Length != 8)
509 {
510 throw new CryptographicException(System.SR.Cryptography_Der_Invalid_Encoding);
511 }
512 if (pBEParameter.IterationCount < 1)
513 {
514 throw new CryptographicException(System.SR.Cryptography_Der_Invalid_Encoding);
515 }
516 int iterationCount = NormalizeIterationCount(pBEParameter.IterationCount);
517 Span<byte> span = stackalloc byte[16];
518 try
519 {
520 Pbkdf1(hasher, password, pBEParameter.Salt.Span, iterationCount, span);
521 Span<byte> span2 = span.Slice(0, 8);
522 Span<byte> span3 = span.Slice(8, 8);
523 return Decrypt(cipher, span2, span3, encryptedData, destination);
524 }
525 finally
526 {
527 CryptographicOperations.ZeroMemory(span);
528 }
529 }
static string Cryptography_Der_Invalid_Encoding
Definition SR.cs:50
Definition SR.cs:7
static int NormalizeIterationCount(int iterationCount, int? iterationLimit=null)
static unsafe int Decrypt(in AlgorithmIdentifierAsn algorithmIdentifier, ReadOnlySpan< char > password, ReadOnlySpan< byte > passwordBytes, ReadOnlySpan< byte > encryptedData, Span< byte > destination)
static void Pbkdf1(IncrementalHash hasher, ReadOnlySpan< byte > password, ReadOnlySpan< byte > salt, int iterationCount, Span< byte > dk)
unsafe ReadOnlySpan< T > Span
static PBEParameter Decode(ReadOnlyMemory< byte > encoded, AsnEncodingRules ruleSet)

References System.SR.Cryptography_Der_Invalid_Encoding, System.Security.Cryptography.Asn1.PBEParameter.Decode(), System.Security.Cryptography.PasswordBasedEncryption.Decrypt(), System.destination, System.Security.Cryptography.Asn1.PBEParameter.IterationCount, System.ReadOnlyMemory< T >.Length, System.Security.Cryptography.PasswordBasedEncryption.NormalizeIterationCount(), System.Security.Cryptography.PasswordBasedEncryption.Pbkdf1(), System.Security.Cryptography.Asn1.PBEParameter.Salt, System.Span< T >.Slice(), System.ReadOnlyMemory< T >.Span, and System.Security.Cryptography.CryptographicOperations.ZeroMemory().