php-encrypted-streams icon indicating copy to clipboard operation
php-encrypted-streams copied to clipboard

Fix warning and empty hash

Open fredeom opened this issue 3 years ago • 1 comments

Sometimes stream is read even after reaching eof. In this case hash_final is called on obsolete hashResource producing warning and destroys hash result. Checking that hash is null prevents this behavior. User still can seek(0) and set hash to null in initializeHash function.

Use case: AesDecryptingStream:113 calls read on empty stream (in our case its HashingStream) in order to prefetch data. Results:

  • Warning is produced.
  • Hash is spoiled.

fredeom avatar May 15 '21 04:05 fredeom

Codecov Report

Merging #18 (5acd6d8) into master (0cd5b6a) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##              master       #18   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity       113       114    +1     
===========================================
  Files             12        12           
  Lines            300       301    +1     
===========================================
+ Hits             300       301    +1     
Impacted Files Coverage Δ Complexity Δ
src/AesDecryptingStream.php 100.00% <100.00%> (ø) 21.00 <0.00> (ø)
src/AesEncryptingStream.php 100.00% <100.00%> (ø) 18.00 <0.00> (ø)
src/AesGcmDecryptingStream.php 100.00% <100.00%> (ø) 4.00 <0.00> (ø)
src/AesGcmEncryptingStream.php 100.00% <100.00%> (ø) 5.00 <0.00> (ø)
src/HashingStream.php 100.00% <100.00%> (ø) 15.00 <0.00> (+1.00)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 432b7b9...5acd6d8. Read the comment docs.

codecov[bot] avatar May 15 '21 04:05 codecov[bot]