Skip to content

Commit e21f17a

Browse files
v3.1.5
Update Bouncy Castle libraries
1 parent 1c0613c commit e21f17a

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed
328 KB
Binary file not shown.
-250 KB
Binary file not shown.
4.25 MB
Binary file not shown.
-2.71 MB
Binary file not shown.

SendSafelyAPI/src/com/sendsafely/utils/CryptoUtil.java

+12-9
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@
4848
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
4949
import org.bouncycastle.openpgp.PGPSignature;
5050
import org.bouncycastle.openpgp.PGPUtil;
51+
import org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator;
5152
import org.bouncycastle.openpgp.operator.PBEDataDecryptorFactory;
5253
import org.bouncycastle.openpgp.operator.PGPDigestCalculator;
5354
import org.bouncycastle.openpgp.operator.PGPKeyEncryptionMethodGenerator;
55+
import org.bouncycastle.openpgp.operator.bc.BcKeyFingerprintCalculator;
5456
import org.bouncycastle.openpgp.operator.bc.BcPBEDataDecryptorFactory;
5557
import org.bouncycastle.openpgp.operator.bc.BcPBEKeyEncryptionMethodGenerator;
5658
import org.bouncycastle.openpgp.operator.bc.BcPGPContentSignerBuilder;
@@ -75,6 +77,7 @@ public class CryptoUtil
7577
{
7678

7779
private static final int RsaKeySize = 2048;
80+
private static final KeyFingerPrintCalculator KEY_FINGERPRINT_CALCULATOR = new BcKeyFingerprintCalculator();
7881

7982
public static String createChecksum(String keyCode, String packageCode)
8083
{
@@ -247,7 +250,7 @@ public static String decryptKeycode(String privateKey, String encryptedKeycode)
247250

248251
try
249252
{
250-
PGPObjectFactory pgpF = new PGPObjectFactory(in);
253+
PGPObjectFactory pgpF = new PGPObjectFactory(in, KEY_FINGERPRINT_CALCULATOR);
251254
PGPEncryptedDataList enc;
252255

253256
Object o = pgpF.nextObject();
@@ -266,7 +269,7 @@ public static String decryptKeycode(String privateKey, String encryptedKeycode)
266269
Iterator it = enc.getEncryptedDataObjects();
267270
PGPPrivateKey sKey = null;
268271
PGPPublicKeyEncryptedData pbe = null;
269-
PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(PGPUtil.getDecoderStream(keyIn));
272+
PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(PGPUtil.getDecoderStream(keyIn), KEY_FINGERPRINT_CALCULATOR);
270273

271274
while (sKey == null && it.hasNext())
272275
{
@@ -280,7 +283,7 @@ public static String decryptKeycode(String privateKey, String encryptedKeycode)
280283
}
281284

282285
InputStream clear = pbe.getDataStream(new BcPublicKeyDataDecryptorFactory(sKey));
283-
PGPObjectFactory plainFact = new PGPObjectFactory(clear);
286+
PGPObjectFactory plainFact = new PGPObjectFactory(clear, KEY_FINGERPRINT_CALCULATOR);
284287
Object message = plainFact.nextObject();
285288

286289
if (message instanceof PGPLiteralData)
@@ -325,7 +328,7 @@ public static String encryptKeycode(String publicKeyStr, String keycode) throws
325328
try {
326329
InputStream in=new ByteArrayInputStream(publicKeyStr.getBytes());
327330
in = PGPUtil.getDecoderStream(in);
328-
PGPPublicKeyRingCollection pgpPub = new PGPPublicKeyRingCollection(in);
331+
PGPPublicKeyRingCollection pgpPub = new PGPPublicKeyRingCollection(in, KEY_FINGERPRINT_CALCULATOR);
329332
PGPPublicKey key = null;
330333
Iterator rIt = pgpPub.getKeyRings();
331334
while (key == null && rIt.hasNext()) {
@@ -387,7 +390,7 @@ public static String encryptKeycode(String publicKeyStr, String keycode) throws
387390
public static void decryptFile(InputStream input, OutputStream output, String decryptionKey, Progress progress) throws IOException, PGPException
388391
{
389392
input = PGPUtil.getDecoderStream(input);
390-
PGPObjectFactory pgpF = new PGPObjectFactory(input);
393+
PGPObjectFactory pgpF = new PGPObjectFactory(input, KEY_FINGERPRINT_CALCULATOR);
391394
PGPEncryptedDataList enc;
392395
Object o = pgpF.nextObject();
393396

@@ -405,14 +408,14 @@ public static void decryptFile(InputStream input, OutputStream output, String de
405408
PBEDataDecryptorFactory pdf = new BcPBEDataDecryptorFactory(decryptionKey.toCharArray(), bcPgp);
406409

407410
InputStream clear = pbe.getDataStream(pdf);
408-
PGPObjectFactory pgpFact = new PGPObjectFactory(clear);
411+
PGPObjectFactory pgpFact = new PGPObjectFactory(clear, KEY_FINGERPRINT_CALCULATOR);
409412

410413
o = pgpFact.nextObject();
411414

412415
if (o instanceof PGPCompressedData)
413416
{
414417
PGPCompressedData cData = (PGPCompressedData) o;
415-
pgpFact = new PGPObjectFactory(cData.getDataStream());
418+
pgpFact = new PGPObjectFactory(cData.getDataStream(), KEY_FINGERPRINT_CALCULATOR);
416419
o = pgpFact.nextObject();
417420
}
418421

@@ -455,7 +458,7 @@ public static String decryptMessage(String message, String decryptionKey) throws
455458
InputStream in = new ByteArrayInputStream(encrypted);
456459
in = PGPUtil.getDecoderStream(in);
457460

458-
PGPObjectFactory pgpF = new PGPObjectFactory(in);
461+
PGPObjectFactory pgpF = new PGPObjectFactory(in, KEY_FINGERPRINT_CALCULATOR);
459462
PGPEncryptedDataList enc = null;
460463
Object o = pgpF.nextObject();
461464

@@ -474,7 +477,7 @@ public static String decryptMessage(String message, String decryptionKey) throws
474477
PBEDataDecryptorFactory pdf = new BcPBEDataDecryptorFactory(decryptionKey.toCharArray(), bcPgp);
475478
InputStream clear = pbe.getDataStream(pdf);
476479

477-
PGPObjectFactory pgpFact = new PGPObjectFactory(clear);
480+
PGPObjectFactory pgpFact = new PGPObjectFactory(clear, KEY_FINGERPRINT_CALCULATOR);
478481

479482
PGPLiteralData ld = (PGPLiteralData)pgpFact.nextObject();
480483

0 commit comments

Comments
 (0)