Skip to content

Commit

Permalink
v3.1.5
Browse files Browse the repository at this point in the history
Update Bouncy Castle libraries
  • Loading branch information
SendSafely-GitHub committed May 12, 2020
1 parent 1c0613c commit e21f17a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
Binary file added SendSafelyAPI/lib/bcpg-jdk15on-1.65.jar
Binary file not shown.
Binary file removed SendSafelyAPI/lib/bcpg-jdk15on-151.jar
Binary file not shown.
Binary file added SendSafelyAPI/lib/bcprov-jdk15on-1.65.jar
Binary file not shown.
Binary file removed SendSafelyAPI/lib/bcprov-jdk15on-151.jar
Binary file not shown.
21 changes: 12 additions & 9 deletions SendSafelyAPI/src/com/sendsafely/utils/CryptoUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
import org.bouncycastle.openpgp.PGPSignature;
import org.bouncycastle.openpgp.PGPUtil;
import org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator;
import org.bouncycastle.openpgp.operator.PBEDataDecryptorFactory;
import org.bouncycastle.openpgp.operator.PGPDigestCalculator;
import org.bouncycastle.openpgp.operator.PGPKeyEncryptionMethodGenerator;
import org.bouncycastle.openpgp.operator.bc.BcKeyFingerprintCalculator;
import org.bouncycastle.openpgp.operator.bc.BcPBEDataDecryptorFactory;
import org.bouncycastle.openpgp.operator.bc.BcPBEKeyEncryptionMethodGenerator;
import org.bouncycastle.openpgp.operator.bc.BcPGPContentSignerBuilder;
Expand All @@ -75,6 +77,7 @@ public class CryptoUtil
{

private static final int RsaKeySize = 2048;
private static final KeyFingerPrintCalculator KEY_FINGERPRINT_CALCULATOR = new BcKeyFingerprintCalculator();

public static String createChecksum(String keyCode, String packageCode)
{
Expand Down Expand Up @@ -247,7 +250,7 @@ public static String decryptKeycode(String privateKey, String encryptedKeycode)

try
{
PGPObjectFactory pgpF = new PGPObjectFactory(in);
PGPObjectFactory pgpF = new PGPObjectFactory(in, KEY_FINGERPRINT_CALCULATOR);
PGPEncryptedDataList enc;

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

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

InputStream clear = pbe.getDataStream(new BcPublicKeyDataDecryptorFactory(sKey));
PGPObjectFactory plainFact = new PGPObjectFactory(clear);
PGPObjectFactory plainFact = new PGPObjectFactory(clear, KEY_FINGERPRINT_CALCULATOR);
Object message = plainFact.nextObject();

if (message instanceof PGPLiteralData)
Expand Down Expand Up @@ -325,7 +328,7 @@ public static String encryptKeycode(String publicKeyStr, String keycode) throws
try {
InputStream in=new ByteArrayInputStream(publicKeyStr.getBytes());
in = PGPUtil.getDecoderStream(in);
PGPPublicKeyRingCollection pgpPub = new PGPPublicKeyRingCollection(in);
PGPPublicKeyRingCollection pgpPub = new PGPPublicKeyRingCollection(in, KEY_FINGERPRINT_CALCULATOR);
PGPPublicKey key = null;
Iterator rIt = pgpPub.getKeyRings();
while (key == null && rIt.hasNext()) {
Expand Down Expand Up @@ -387,7 +390,7 @@ public static String encryptKeycode(String publicKeyStr, String keycode) throws
public static void decryptFile(InputStream input, OutputStream output, String decryptionKey, Progress progress) throws IOException, PGPException
{
input = PGPUtil.getDecoderStream(input);
PGPObjectFactory pgpF = new PGPObjectFactory(input);
PGPObjectFactory pgpF = new PGPObjectFactory(input, KEY_FINGERPRINT_CALCULATOR);
PGPEncryptedDataList enc;
Object o = pgpF.nextObject();

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

InputStream clear = pbe.getDataStream(pdf);
PGPObjectFactory pgpFact = new PGPObjectFactory(clear);
PGPObjectFactory pgpFact = new PGPObjectFactory(clear, KEY_FINGERPRINT_CALCULATOR);

o = pgpFact.nextObject();

if (o instanceof PGPCompressedData)
{
PGPCompressedData cData = (PGPCompressedData) o;
pgpFact = new PGPObjectFactory(cData.getDataStream());
pgpFact = new PGPObjectFactory(cData.getDataStream(), KEY_FINGERPRINT_CALCULATOR);
o = pgpFact.nextObject();
}

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

PGPObjectFactory pgpF = new PGPObjectFactory(in);
PGPObjectFactory pgpF = new PGPObjectFactory(in, KEY_FINGERPRINT_CALCULATOR);
PGPEncryptedDataList enc = null;
Object o = pgpF.nextObject();

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

PGPObjectFactory pgpFact = new PGPObjectFactory(clear);
PGPObjectFactory pgpFact = new PGPObjectFactory(clear, KEY_FINGERPRINT_CALCULATOR);

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

Expand Down

0 comments on commit e21f17a

Please sign in to comment.