wbond / oscrypto

Compiler-free Python crypto library backed by the OS, supporting CPython and PyPy
MIT License
318 stars 71 forks source link

Fixes data corruption bug in _pkcs5.py/pbkdf2 #32

Closed atomontage closed 5 years ago

atomontage commented 5 years ago

There is a data corruption bug in _pkcs5.py/pbkdf2:

t = int_to_bytes(u)

int_to_bytes(u) will never return a leading zero byte, thus corrupting the output in some cases

codecov[bot] commented 5 years ago

Codecov Report

Merging #32 into master will decrease coverage by <.01%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #32      +/-   ##
==========================================
- Coverage    78.4%   78.39%   -0.01%     
==========================================
  Files          63       63              
  Lines        9196     9194       -2     
==========================================
- Hits         7210     7208       -2     
  Misses       1986     1986
Impacted Files Coverage Δ
oscrypto/_pkcs5.py 82.97% <100%> (-0.7%) :arrow_down:

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 0639ef2...5b75d8a. Read the comment docs.

wbond commented 5 years ago

Could you add a test that fails before this change is made and succeeds after?

wbond commented 5 years ago

Thanks for the test (and the fix)!

Did you come across this on Windows XP, or an old version of OpenSSL?

atomontage commented 5 years ago

I had to fork oscrypto/asn1crypto and heavily modify it (removed all parts I'm not going to use and changed others to be more inline with what I want) in order to use it in a project I'm working on. I wrote my own testsuite which discovered the problem.

On Tue, 23 Jul 2019 04:15:57 -0700, Will Bond notifications@github.com wrote:

Thanks for the test (and the fix)!

Did you come across this on Windows XP, or an old version of OpenSSL?