Skip to content

Commit d839606

Browse files
author
gefeili
committed
Minor changes in PBEKeyEncryptionMethodGenerator, remove unused functions in PublicKeyKeyEncryptionMethodGenerator.
1 parent 6790031 commit d839606

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

pg/src/main/java/org/bouncycastle/openpgp/operator/PBEKeyEncryptionMethodGenerator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,8 @@ public ContainedPacket generateV6(int kekAlgorithm, int aeadAlgorithm, byte[] se
231231
byte[] iv = new byte[AEADUtils.getIVLength(aeadAlgorithm)];
232232
random.nextBytes(iv);
233233

234-
byte[] sk = new byte[sessionInfo.length - 3];
235-
System.arraycopy(sessionInfo, 1, sk, 0, sk.length);
236234
int tagLen = AEADUtils.getAuthTagLength(aeadAlgorithm);
235+
byte[] sk = getSessionKey(sessionInfo);
237236
byte[] eskAndTag = getEskAndTag(kekAlgorithm, aeadAlgorithm, sk, kek, iv, info);
238237
byte[] esk = Arrays.copyOfRange(eskAndTag, 0, eskAndTag.length - tagLen);
239238
byte[] tag = Arrays.copyOfRange(eskAndTag, esk.length, eskAndTag.length);

pg/src/main/java/org/bouncycastle/openpgp/operator/PublicKeyKeyEncryptionMethodGenerator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ protected static byte[] concatECDHEphKeyWithWrappedSessionKey(byte[] ephPubEncod
216216
return out;
217217
}
218218

219-
private static byte[] getSessionInfo(byte[] ephPubEncoding, int symmetricKeyAlgorithm, byte[] c)
220-
{
221-
return getSessionInfo(ephPubEncoding, new byte[]{(byte) symmetricKeyAlgorithm}, c);
222-
}
219+
// private static byte[] getSessionInfo(byte[] ephPubEncoding, int symmetricKeyAlgorithm, byte[] c)
220+
// {
221+
// return getSessionInfo(ephPubEncoding, new byte[]{(byte) symmetricKeyAlgorithm}, c);
222+
// }
223223

224224
protected static byte[] getSessionInfo(byte[] ephPubEncoding, byte[] optSymKeyAlgorithm, byte[] wrappedSessionKey)
225225
{

pg/src/main/java/org/bouncycastle/openpgp/operator/bc/BcPublicKeyKeyEncryptionMethodGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ private byte[] encryptSessionInfoWithECDHKey(byte[] sessionInfo,
328328
private byte[] encryptV3SessionInfoWithX25519X448Key(PublicKeyPacket pubKeyPacket, byte[] sessionInfo, int hashAlgorithm, int symmetricKeyAlgorithm, String algorithmName,
329329
AsymmetricCipherKeyPairGenerator gen, KeyGenerationParameters parameters, RawAgreement agreement, AsymmetricKeyParameter cryptoPublicKey,
330330
int keySize, EphPubEncodingOperation ephPubEncodingOperation)
331-
throws PGPException, IOException
331+
throws PGPException
332332
{
333333
AsymmetricCipherKeyPair ephKp = getAsymmetricCipherKeyPair(gen, parameters);
334334
byte[] secret = BcUtil.getSecret(agreement, ephKp.getPrivate(), cryptoPublicKey);

0 commit comments

Comments
 (0)