Skip to content

Commit f68a305

Browse files
author
gefeili
committed
Fixed the bugs in BcPBEKeyEncryptionMethodGenerator.getEskAndTag
1 parent 46588f7 commit f68a305

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public BcAEADSecretKeyEncryptorBuilder setSecureRandom(SecureRandom random)
3131
return this;
3232
}
3333

34-
public PBESecretKeyEncryptor build(char[] passphrase, PublicKeyPacket pubKey)
34+
public PBESecretKeyEncryptor build(char[] passphrase, final PublicKeyPacket pubKey)
3535
{
3636
return new PBESecretKeyEncryptor(symmetricAlgorithm, aeadAlgorithm, argon2Params, random, passphrase)
3737
{
@@ -62,7 +62,7 @@ public byte[] encryptKeyData(byte[] key, byte[] keyData, int keyOff, int keyLen)
6262
}
6363
catch (IOException e)
6464
{
65-
throw new PGPException("Exception AEAD protecting private key material", e);
65+
throw new PGPException("Exception AEAD protecting private key material", e);
6666
}
6767
}
6868

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
import org.bouncycastle.bcpg.SymmetricKeyUtils;
88
import org.bouncycastle.bcpg.UnsupportedPacketVersionException;
99
import org.bouncycastle.crypto.BlockCipher;
10-
import org.bouncycastle.crypto.BufferedBlockCipher;
1110
import org.bouncycastle.openpgp.PGPException;
1211
import org.bouncycastle.openpgp.PGPSessionKey;
1312
import org.bouncycastle.openpgp.operator.PBEDataDecryptorFactory;
1413
import org.bouncycastle.openpgp.operator.PGPDataDecryptor;
14+
import org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider;
1515
import org.bouncycastle.util.Arrays;
1616

1717
/**

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,9 @@ protected byte[] generateV6KEK(int kekAlgorithm, byte[] ikm, byte[] info)
101101
return BcAEADUtil.generateHKDFBytes(ikm, null, info, SymmetricKeyUtils.getKeyLengthInOctets(kekAlgorithm));
102102
}
103103

104-
protected byte[] getEskAndTag(int kekAlgorithm, int aeadAlgorithm, byte[] sessionInfo, byte[] key, byte[] iv, byte[] info)
104+
protected byte[] getEskAndTag(int kekAlgorithm, int aeadAlgorithm, byte[] sessionKey, byte[] key, byte[] iv, byte[] info)
105105
throws PGPException
106106
{
107-
byte[] sessionKey = new byte[sessionInfo.length - 3];
108-
System.arraycopy(sessionInfo, 1, sessionKey, 0, sessionKey.length);
109107
return BcAEADUtil.processAEADData(true, kekAlgorithm, aeadAlgorithm, key, iv, info, sessionKey, 0, sessionKey.length, BcAEADUtil.GetEskAndTagErrorMessage);
110108
}
111109
}

0 commit comments

Comments
 (0)