-
-
Notifications
You must be signed in to change notification settings - Fork 69
Fixed Thunderbird/RNP issue in OpenPGP_SignaturePacket::sign_data()
#139
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
…ta was signed directly rather than signing the hash of the data (e.g. SHA256). Since the intermediate hash isn't returned from signer callbacks, phpseclib is called to generate a duplicate hash during signing. This supports the MD5 and SHA variations, but not RIPEMD160 (which could be handled separately). This change resolves the long-standing issue where Thunderbird (or other RNP-based projects) couldn't import keys or decrypt messages generated from OpenPGP-PHP. Fixes singpolyma#120
WalkthroughThe recent changes enhance the Changes
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
Outside diff range, codebase verification and nitpick comments (1)
lib/openpgp.php (1)
710-715: Ensure proper handling of unsupported algorithms.The try-catch block effectively handles unsupported algorithms by falling back to the original string. However, consider logging this exception to facilitate debugging and monitoring.
try { $hasher = new \phpseclib3\Crypt\Hash($this->hash_algorithm_name()); $hash = $hasher->hash($string_to_sign); } catch (\phpseclib3\Exception\UnsupportedAlgorithmException $e) { // Log the exception for debugging purposes error_log('Unsupported hash algorithm: ' . $this->hash_algorithm_name()); $hash = $string_to_sign; }
|
Thanks for looking into this! This code introduces a dependency on phpseclib in openpgp.php, which I'd rather avoid. The model right now is to pass the data to a hash-and-algorithm specific signer. So hashing the data is the signer's job. It looks like the actual bug is that |
|
Yeah, that's exactly the issue ( I see you fixed this with a better refactor where signers can return their own hash. That's much nicer. Thanks! |
Fixed an issue in
OpenPGP_SignaturePacket::sign_data()where the data was signed directly rather than signing the hash of the data (e.g. SHA256).Since the intermediate hash isn't returned from signer callbacks, phpseclib is called to generate a duplicate hash during signing. This supports the MD5 and SHA variations, but not RIPEMD160 (which could be handled separately).
This change resolves the long-standing issue where Thunderbird (or other RNP-based projects) couldn't import keys or decrypt messages generated from OpenPGP-PHP.
Fixes #120
Summary by CodeRabbit
New Features
Bug Fixes