-
Notifications
You must be signed in to change notification settings - Fork 311
Proposed version 2.0 - file streaming, version tagging #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/Crypto.php
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace ;)
|
https://github.com/paragonie/php-encryption/blob/files/src/Crypto.php#L322 |
src/Crypto.php
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug code
|
The latest test verifies that our nonce incrementing strategy is functioning correctly. Aside from the danger of birthday collisions, nonce collisions are mitigated. Mitigating nonce reuse is nontrivial, since we're limited to 128 bits. I think we would first need to create a subkey for each file and store the random HKDF or PBKDF2 salt in the file data to make this impractical. |
|
Since HKDF accepts a salt parameter, I added a random per-file salt to the file encrypted file header in addition to the IV. Without the salt, the odds of a birthday collision after 2^64 files is approximately 50%. Depending on the file size, a nonce reuse becomes a real problem. Using a random salt and a nonrandom nonce (e.g. all 0's) is virtually identical to the existing situation. Using a random salt AND a random nonce raises our birthday resistance to require 2^128 files for a 50% chance of birthday collision. (This is effectively similar to a 256-bit nonce.) |
Default to hex encoding (since base64 is way too complicated) Files: Store a salt in the file data to create a per-file subkey (via HKDF) to prevent nonce reuse via birthday collisions. Use salts in HKDF everywhere. Affects Crypto.php and File.php. Also: MAC the salt. Authenticate the version tag
|
The lastest commit should satisfy #93 |
|
Forgot about the runtime tests. Need new test vectors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now CTR.
|
One thing that the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$if doesn't get closed here.
|
I haven't looked too closely at the issues, but I'm going to merge this into a v2.0 branch so that it's easier to work with, and then open tickets for the issues I found. |
|
Okay, sounds good to me. Need me to resubmit the PR? |
|
@paragonie-scott: I just created the v2.0 branch, so feel free to submit PRs to it if you feel like fixing any of those things. :) |
|
Hang on, I'm still trying to figure out how to push that branch to github. |
|
There we go. |
|
This has been merged in another branch. |
Satisfies the proposal outlined in #71
Supersedes #63
Closes #34
Closes #39