@@ -229,12 +229,12 @@ public byte[] Decrypt(ArraySegment<byte> protectedPayload, ArraySegment<byte> ad
229229 macOffset = eofOffset - _validationAlgorithmDigestLengthInBytes ;
230230 }
231231
232- correctHash = hashAlgorithm . ComputeHash ( protectedPayload . Array , ivOffset , macOffset - ivOffset ) ;
232+ correctHash = hashAlgorithm . ComputeHash ( protectedPayload . Array ! , ivOffset , macOffset - ivOffset ) ;
233233 }
234234
235235 // Step 4: Validate the MAC provided as part of the payload.
236236
237- if ( ! CryptoUtil . TimeConstantBuffersAreEqual ( correctHash , 0 , correctHash . Length , protectedPayload . Array , macOffset , eofOffset - macOffset ) )
237+ if ( ! CryptoUtil . TimeConstantBuffersAreEqual ( correctHash , 0 , correctHash . Length , protectedPayload . Array ! , macOffset , eofOffset - macOffset ) )
238238 {
239239 throw Error . CryptCommon_PayloadInvalid ( ) ; // integrity check failure
240240 }
@@ -247,7 +247,7 @@ public byte[] Decrypt(ArraySegment<byte> protectedPayload, ArraySegment<byte> ad
247247 var outputStream = new MemoryStream ( ) ;
248248 using ( var cryptoStream = new CryptoStream ( outputStream , cryptoTransform , CryptoStreamMode . Write ) )
249249 {
250- cryptoStream . Write ( protectedPayload . Array , ciphertextOffset , macOffset - ciphertextOffset ) ;
250+ cryptoStream . Write ( protectedPayload . Array ! , ciphertextOffset , macOffset - ciphertextOffset ) ;
251251 cryptoStream . FlushFinalBlock ( ) ;
252252
253253 // At this point, outputStream := { plaintext }, and we're done!
@@ -349,7 +349,7 @@ public byte[] Encrypt(ArraySegment<byte> plaintext, ArraySegment<byte> additiona
349349 var mac = validationAlgorithm . ComputeHash ( underlyingBuffer , KEY_MODIFIER_SIZE_IN_BYTES , checked ( ( int ) outputStream . Length - KEY_MODIFIER_SIZE_IN_BYTES ) ) ;
350350 outputStream . Write ( mac , 0 , mac . Length ) ;
351351
352- // At this point, outputStream := { keyModifier || IV || ciphertext || MAC(IV || ciphertext) }
352+ // At this point, outputStream := { keyModifier || IV || ciphertext || MAC(IV || ciphertext) }
353353 // And we're done!
354354 return outputStream . ToArray ( ) ;
355355 }
0 commit comments