From 1521defbd0011460cf31edbd44415df40c54de16 Mon Sep 17 00:00:00 2001 From: Adam Stone <8525409+adamjstone@users.noreply.github.com> Date: Thu, 30 Jul 2020 16:51:07 -0500 Subject: [PATCH] #289 Refactor bit field copy operations. (#331) * #291 Extend the architectural guide. (#305) (#307) (#316) (cherry picked from commit 5fc2b09fcc45750bb9217f90d3458f7051db2bc9) Co-authored-by: Adam Stone <8525409+adamjstone@users.noreply.github.com> * #289 Refactoring bit field operations. (#330) * #288 Refactor asynchronous operations. (#306) (#309) (#325) (cherry picked from commit b982236ea16d56486d454b496bc413128d961ef6) Co-authored-by: Adam Stone <8525409+adamjstone@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 419aeaad91e6806737db7fd6ec94b0371b4f5af7) --- .../CryptographicKey.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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)