Skip to content
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

Issues with byte loss during PGP encryption/decryption process #272

Closed
KEdore opened this issue Mar 11, 2024 · 2 comments
Closed

Issues with byte loss during PGP encryption/decryption process #272

KEdore opened this issue Mar 11, 2024 · 2 comments

Comments

@KEdore
Copy link

KEdore commented Mar 11, 2024

We've been using the github.com/ProtonMail/gopenpgp/v2/helper library for PGP encryption in our project. Recently, we've encountered an issue where bytes are being dropped during the encryption/decryption process.

Steps to reproduce:

ciphertext, err := helper.EncryptMessageArmored(publicKey, plaintext)

Expected behaviour:

The encrypted files should be able to be decrypted without any loss of data.

Actual behaviour:

Bytes are being dropped during the encryption/decryption process, resulting in incomplete data when the files are decrypted.

Environment:
Go version: 1.21.1
Library version: v2.7.5

We would appreciate any guidance on why this might be happening and how we can resolve it. Thank you in advance for your help.

@lubux
Copy link
Contributor

lubux commented Mar 11, 2024

Hi. This helper internally calls NewPlainMessageFromString(text string) *PlainMessage, which does the following:

// NewPlainMessageFromString generates a new text PlainMessage,
// ready for encryption, signature, or verification from an unencrypted string.
// This will encrypt the message with the text flag, canonicalize the line endings
// (i.e. set all of them to \r\n) and strip the trailing spaces for each line.
// This allows seamless conversion to clear text signed messages (see RFC 4880 5.2.1 and 7.1).

Hence, it treats the data as text data, strips trailing spaces on each line, and canonicalizes the line endings.

@KEdore
Copy link
Author

KEdore commented Jun 16, 2024

Thank you !

@KEdore KEdore closed this as completed Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants