Skip to content

Commit

Permalink
Java 1.4 updates
Browse files Browse the repository at this point in the history
Added support for MD5/SHA1 DES PBE
  • Loading branch information
dghgit committed Aug 11, 2017
1 parent bf408ef commit a017b5f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ant/jdk14.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@
<exclude name="**/PKCS12StoreParameter.java" />
<exclude name="**/JDKPKCS12StoreParameter.java" />
<exclude name="**/NTRU*.java" />
<exclude name="**/XMS*.java" />
<exclude name="**/IndexGenerator.java" />
<exclude name="**/ntru/**/*.java" />
<exclude name="**/xmss/**/*.java" />
<exclude name="**/asymmetric/DSTU*.java" />
<exclude name="**/asymmetric/dstu/*.java" />
<exclude name="**/asymmetric/ecgost12/*.java" />
<exclude name="**/provider/config/PKCS12StoreParameter.java" />
</fileset>
<fileset dir="prov/src/main/resources" includes="**/*.properties" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.cryptopro.GOST28147Parameters;
import org.bouncycastle.asn1.pkcs.PBEParameter;
import org.bouncycastle.asn1.pkcs.PBES2Parameters;
import org.bouncycastle.asn1.pkcs.PBKDF2Params;
import org.bouncycastle.asn1.pkcs.PKCS12PBEParams;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.crypto.CharToByteConverter;
import org.bouncycastle.crypto.PasswordConverter;
import org.bouncycastle.jcajce.PBKDF1Key;
import org.bouncycastle.jcajce.PKCS12KeyWithParameters;
import org.bouncycastle.jcajce.spec.GOST28147ParameterSpec;
import org.bouncycastle.jcajce.spec.PBKDF2KeySpec;
Expand Down Expand Up @@ -138,6 +142,20 @@ else if (algorithm.equals(PKCSObjectIdentifiers.id_PBES2))
cipher.init(Cipher.DECRYPT_MODE, key, new GOST28147ParameterSpec(gParams.getEncryptionParamSet(), gParams.getIV()));
}
}
else if (algorithm.equals(PKCSObjectIdentifiers.pbeWithMD5AndDES_CBC)
|| algorithm.equals(PKCSObjectIdentifiers.pbeWithSHA1AndDES_CBC))
{
PBEParameter pbeParams = PBEParameter.getInstance(algorithmIdentifier.getParameters());

cipher = helper.createCipher(algorithm.getId());

cipher.init(Cipher.DECRYPT_MODE, new PBKDF1Key(password, PasswordConverter.ASCII),
new PBEParameterSpec(pbeParams.getSalt(), pbeParams.getIterationCount().intValue()));
}
else
{
throw new OperatorCreationException("unable to create InputDecryptor: algorithm " + algorithm + " unknown.");
}
}
catch (Exception e)
{
Expand Down

0 comments on commit a017b5f

Please sign in to comment.