-
Notifications
You must be signed in to change notification settings - Fork 122
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
Undisclosed v3 breaking change: KeyRing.Decrypt was removed #313
Comments
Hi 👋 All OpenPGP operations can now only be executed via the new API.
So for keyRing := ...
pgp := PGP()
decHandle, err := pgp.
Decryption().
DecryptionKeys(keyRing).
VerificationKeys(...). // optional if signatures should be verified
VerifyTime(...). // optional if the verification time should be something else than the local time
New()
if err != nil {
panic(err)
}
decrypted, err := decHandle.Decrypt([]byte(armoredMessage), crypto.Armor)
if err != nil {
panic(err)
}
fmt.Println(decrypted.String()) |
Thank you @lubux, that worked. I see that your quote is from the releases page. My bad, I only looked at the Changelog file. |
Hey @lubux! The code change worked in CI (unit tests are decrypting a local file with a local key/passphrase) but it crashed on production with
I'm wondering where the difference in behavior might be. Have you seen any regression between v2 and v3 related to that? With v2 we're using the library like this: pgpMessage, err := crypto.NewPGPMessageFromArmored(string(bytes))
if err != nil {
return nil, err
}
message, err := keyring.Decrypt(pgpMessage, nil, 0)
if err != nil {
return nil, err
}
keyring.ClearPrivateParams()
return message.Data, nil and in v3 we're doing pgp := crypto.PGP()
decHandle, err := pgp.Decryption().DecryptionKeys(keyring).New()
if err != nil {
return nil, err
}
message, err := decHandle.Decrypt(bytes, crypto.Armor)
if err != nil {
return nil, err
}
keyring.ClearPrivateParams()
return message.Bytes(), nil |
@hpurmann I am also seeing the same when testing this, some files work ok and some others using the same key return the |
Hi 👋 This error indicates that there is no matching In version 3, decryption now involves checking the decryption keys for validity, if they are not valid they are not considered. Consequently, some subkeys might have invalid or outdated signatures or use a blocked hash functions. |
@lubux So they key is able to decrypt some of the files but not others using v3 but gpg on the cmd line can decrypt them all so they key seems fine to me. |
I figured out what the difference was. For the files which worked in V2 but failed in V3 the file was encrypted using the primary key instead of the sub key so i guess that was allowed to be decrypted in v2 but changed for v3? |
Thanks for checking this. GopenPGP v3 does allow to decrypt with the primary key if it is marked as encryption capable. However, if it fails it means the primary key is most likely marked as signing key only. We are considering adding a flag to allow decryption with signing keys (ProtonMail/go-crypto#251), if the client accepts the security risk. Using the same key for encryption and signing reduces security. |
That makes sense, thank you |
Added the option with: #316 |
That's awesome, I've confirmed it works for me. Thank you.
…On Mon, 25 Nov 2024, 15:58 Lukas Burkhalter, ***@***.***> wrote:
Added the option with: #316
<#316>
—
Reply to this email directly, view it on GitHub
<#313 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANUUSJ5DOMU5SFOCQIVCQT2CNCKHAVCNFSM6AAAAABRRTGAAWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJYGQYTCNBWGE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Thank you @lubux for the quick reaction, it works for me too 👍 |
Hi @JasonQuinn and @hpurmann can you show the point if code to resolved this issue ? not for all only issue point. still not work for me 🙏🏻 |
@jamesapc I needed to add .InsecureAllowDecryptionWithSigningKeys() to the DecryptionHandleBuilder so it would allow decrypting with the signing key like v2 allowed
|
@jamesapc exactly as @JasonQuinn wrote, you disable the validation by invoking the |
Thank you 🙇🏻♂️ @JasonQuinn @hpurmann |
Hey all!
We are currently using v2 and make use of the KeyRing.Decrypt function. This function has disappeared in v3, but it's not mentioned in the changelog.
I'm wondering if this was a mistake or deliberate. And if deliberate, how can we adapt our implementation to fit v3?
The text was updated successfully, but these errors were encountered: