8000 Fix PGPSecretKey.copyWithNewPassword() for AEAD by vanitasvitae · Pull Request #1882 · bcgit/bc-java · GitHub
[go: up one dir, main page]

Skip to content

Fix PGPSecretKey.copyWithNewPassword() for AEAD #1882

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

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PGPSecretKey.copyWithNewPassword: Fix S2KUsage if newKeyEncryptor is …
…using AEAD
  • Loading branch information
vanitasvitae committed Oct 25, 2024
commit fe12757b9f96f9ae814e535cf04cd15097b6e1d3
10 changes: 9 additions & 1 deletion pg/src/main/java/org/bouncycastle/openpgp/PGPSecretKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,15 @@ public static PGPSecretKey copyWithNewPassword(

SecretKeyPacket secret;

secret = generateSecretKeyPacket(!(key.secret instanceof SecretSubkeyPacket), key.secret.getPublicKeyPacket(), newEncAlgorithm, s2kUsage, s2k, iv, keyData);
if (newKeyEncryptor.getAeadAlgorithm() > 0)
{
s2kUsage = SecretKeyPacket.USAGE_AEAD;
secret = generateSecretKeyPacket(!(key.secret instanceof SecretSubkeyPacket), key.secret.getPublicKeyPacket(), newEncAlgorithm, newKeyEncryptor.getAeadAlgorithm(), s2kUsage, s2k, iv, keyData);
}
else
{
secret = generateSecretKeyPacket(!(key.secret instanceof SecretSubkeyPacket), key.secret.getPublicKeyPacket(), newEncAlgorithm, s2kUsage, s2k, iv, keyData);
}

return new PGPSecretKey(secret, key.pub);
}
Expand Down
0