Skip to content

Commit a308814

Browse files
author
gefeili
committed
Fix the bug in encryptSessionInfoWithX25519X448Key when optSymAlgId is 0.
1 parent 4926064 commit a308814

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pg/src/main/java/org/bouncycastle/openpgp/operator/jcajce/JcePublicKeyKeyEncryptionMethodGenerator.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ private byte[] encryptSessionInfoWithECDHKey(PublicKeyPacket pubKeyPacket, Strin
264264

265265
// wrap the padded session info using the shared-secret public key
266266
// https://www.rfc-editor.org/rfc/rfc9580.html#section-11.5-16
267-
return getSessionInfo(new MPInteger(new BigInteger(1, ephPubEncoding))
267+
return getSessionInfo(new MPInteger(new BigInteger(1, ephPubEncoding))
268268
.getEncoded(), getWrapper(symmetricKeyAlgorithm, sessionInfo, secret, paddedSessionData));
269269
}
270270

@@ -292,7 +292,10 @@ private byte[] encryptSessionInfoWithX25519X448Key(PGPPublicKey pgpPublicKey, St
292292
//No checksum or padding
293293
byte[] sessionData = new byte[sessionInfo.length - 3];
294294
System.arraycopy(sessionInfo, 1, sessionData, 0, sessionData.length);
295-
295+
if (optSymAlgId == 0)
296+
{
297+
return getSessionInfo(ephPubEncoding, getWrapper(symmetricKeyAlgorithm, sessionInfo, secret, sessionData));
298+
}
296299
return getSessionInfo(ephPubEncoding, optSymAlgId, getWrapper(symmetricKeyAlgorithm, sessionInfo, secret, sessionData));
297300
}
298301

0 commit comments

Comments
 (0)