diff --git a/src/RapidField.SolidInstruments.Cryptography/CryptographicKey.cs b/src/RapidField.SolidInstruments.Cryptography/CryptographicKey.cs index 806e74de..397f8641 100644 --- a/src/RapidField.SolidInstruments.Cryptography/CryptographicKey.cs +++ b/src/RapidField.SolidInstruments.Cryptography/CryptographicKey.cs @@ -14,7 +14,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using System.Security; using System.Security.Cryptography; using System.Text; @@ -312,9 +311,10 @@ private Rfc2898DeriveBytes InitializePbkdf2Algorithm() KeySource.Access(memory => { - var iterationSumBytes = memory.Take(Pbkdf2IterationSumLengthInBytes); - var saltBytes = memory.Skip(Pbkdf2IterationSumLengthInBytes).Take(Pbkdf2SaltLengthInBytes); - var passwordBytes = memory.Skip(Pbkdf2IterationSumLengthInBytes + Pbkdf2SaltLengthInBytes).Take(Pbkdf2PasswordLengthInBytes); + var memorySpan = memory.ReadOnlySpan; + var iterationSumBytes = memorySpan.Slice(0, Pbkdf2IterationSumLengthInBytes); + var saltBytes = memorySpan.Slice(Pbkdf2IterationSumLengthInBytes, Pbkdf2SaltLengthInBytes); + var passwordBytes = memorySpan.Slice(Pbkdf2IterationSumLengthInBytes + Pbkdf2SaltLengthInBytes, Pbkdf2PasswordLengthInBytes); var iterationCount = Pbkdf2MinimumIterationCount; foreach (var iterationSumValue in iterationSumBytes)