//
Cipher cEnc = Cipher.getInstance("DES/CBC/PKCS7Padding", "BC");
cEnc.init(Cipher.ENCRYPT_MODE,
new SecretKeySpec(Hex.decode("30e69252758e5346"), "DES"),
new IvParameterSpec(Hex.decode("7c1c1ab9c454a688")));
byte[] out = cEnc.doFinal(input);
char[] password = { 'p', 'a', 's', 's', 'w', 'o', 'r', 'd' };
Cipher cDec = makePBECipherUsingParam(
"PBEWithSHA1AndDES",
Cipher.DECRYPT_MODE,
password,
Hex.decode("7d60435f02e9e0ae"),
2048);
byte[] in = cDec.doFinal(out);
if (!Arrays.areEqual(input, in))
{
fail("DES failed");
}
cDec = makePBECipherWithoutParam(
"PBEWithSHA1AndDES",
Cipher.DECRYPT_MODE,
password,
Hex.decode("7d60435f02e9e0ae"),
2048);
in = cDec.doFinal(out);
if (!Arrays.areEqual(input, in))
{
fail("DES failed without param");
}
//
// DESede
//
cEnc = Cipher.getInstance("DESede/CBC/PKCS7Padding", "BC");
cEnc.init(Cipher.ENCRYPT_MODE,
new SecretKeySpec(Hex.decode("732f2d33c801732b7206756cbd44f9c1c103ddd97c7cbe8e"), "DES"),
new IvParameterSpec(Hex.decode("b07bf522c8d608b8")));
out = cEnc.doFinal(input);
cDec = makePBECipherUsingParam(
"PBEWithSHAAnd3-KeyTripleDES-CBC",
Cipher.DECRYPT_MODE,
password,
Hex.decode("7d60435f02e9e0ae"),
2048);
in = cDec.doFinal(out);
if (!Arrays.areEqual(input, in))
{
fail("DESede failed");
}
//
// 40Bit RC2
//
cEnc = Cipher.getInstance("RC2/CBC/PKCS7Padding", "BC");
cEnc.init(Cipher.ENCRYPT_MODE,
new SecretKeySpec(Hex.decode("732f2d33c8"), "RC2"),
new IvParameterSpec(Hex.decode("b07bf522c8d608b8")));
out = cEnc.doFinal(input);
cDec = makePBECipherUsingParam(
"PBEWithSHAAnd40BitRC2-CBC",