本文整理汇总了Java中org.bouncycastle.crypto.engines.BlowfishEngine类的典型用法代码示例。如果您正苦于以下问题:Java BlowfishEngine类的具体用法?Java BlowfishEngine怎么用?Java BlowfishEngine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BlowfishEngine类属于org.bouncycastle.crypto.engines包,在下文中一共展示了BlowfishEngine类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initBlockCipherEngines
import org.bouncycastle.crypto.engines.BlowfishEngine; //导入依赖的package包/类
private static void initBlockCipherEngines() {
blockCipherEngines.put("MARS", MarsEngine.class);
blockCipherEngines.put("AES", AESEngine.class);
blockCipherEngines.put("Blowfish", BlowfishEngine.class);
blockCipherEngines.put("Camellia", CamelliaEngine.class);
blockCipherEngines.put("CAST5", CAST5Engine.class);
blockCipherEngines.put("CAST6", CAST6Engine.class);
blockCipherEngines.put("DESede", DESedeEngine.class);
blockCipherEngines.put("DES", DESEngine.class);
blockCipherEngines.put("GOST28147", GOST28147Engine.class);
blockCipherEngines.put("IDEA", IDEAEngine.class);
blockCipherEngines.put("Noekeon", NoekeonEngine.class);
blockCipherEngines.put("RC2", RC2Engine.class);
blockCipherEngines.put("RC5", RC532Engine.class);
blockCipherEngines.put("RC6", RC6Engine.class);
blockCipherEngines.put("SEED", SEEDEngine.class);
blockCipherEngines.put("Serpent", SerpentEngine.class);
blockCipherEngines.put("Shacal2", Shacal2Engine.class);
blockCipherEngines.put("Skipjack", SkipjackEngine.class);
blockCipherEngines.put("SM4", SM4Engine.class);
blockCipherEngines.put("TEA", TEAEngine.class);
blockCipherEngines.put("Twofish", TwofishEngine.class);
blockCipherEngines.put("XTEA", XTEAEngine.class);
blockCipherEngines.put("Threefish", ThreefishEngine.class);
}
示例2: performTests
import org.bouncycastle.crypto.engines.BlowfishEngine; //导入依赖的package包/类
private void performTests()
throws Exception
{
testModes(new BlowfishEngine(), new BlowfishEngine(), 16);
testModes(new DESEngine(), new DESEngine(), 8);
testModes(new DESedeEngine(), new DESedeEngine(), 24);
testModes(new TEAEngine(), new TEAEngine(), 16);
testModes(new CAST5Engine(), new CAST5Engine(), 16);
testModes(new RC2Engine(), new RC2Engine(), 16);
testModes(new XTEAEngine(), new XTEAEngine(), 16);
testModes(new AESEngine(), new AESEngine(), 16);
testModes(new NoekeonEngine(), new NoekeonEngine(), 16);
testModes(new TwofishEngine(), new TwofishEngine(), 16);
testModes(new CAST6Engine(), new CAST6Engine(), 16);
testModes(new SEEDEngine(), new SEEDEngine(), 16);
testModes(new SerpentEngine(), new SerpentEngine(), 16);
testModes(new RC6Engine(), new RC6Engine(), 16);
testModes(new CamelliaEngine(), new CamelliaEngine(), 16);
testModes(new ThreefishEngine(ThreefishEngine.BLOCKSIZE_512),
new ThreefishEngine(ThreefishEngine.BLOCKSIZE_512), 64);
testMode(new RC4Engine(), new KeyParameter(new byte[16]));
testMode(new Salsa20Engine(), new ParametersWithIV(new KeyParameter(new byte[16]), new byte[8]));
testMode(new XSalsa20Engine(), new ParametersWithIV(new KeyParameter(new byte[32]), new byte[24]));
testMode(new ChaChaEngine(), new ParametersWithIV(new KeyParameter(new byte[16]), new byte[8]));
testMode(new Grainv1Engine(), new ParametersWithIV(new KeyParameter(new byte[16]), new byte[8]));
testMode(new Grain128Engine(), new ParametersWithIV(new KeyParameter(new byte[16]), new byte[12]));
testMode(new HC128Engine(), new KeyParameter(new byte[16]));
testMode(new HC256Engine(), new ParametersWithIV(new KeyParameter(new byte[16]), new byte[16]));
testSkipping(new Salsa20Engine(), new ParametersWithIV(new KeyParameter(new byte[16]), new byte[8]));
testSkipping(new SICBlockCipher(new AESEngine()), new ParametersWithIV(new KeyParameter(new byte[16]), new byte[16]));
}
示例3: encrypt
import org.bouncycastle.crypto.engines.BlowfishEngine; //导入依赖的package包/类
@Override
public void encrypt(final byte[] passiveCheckBytes, final byte[] initVector, final String password) {
final BlowfishEngine engine = new BlowfishEngine();
PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CFBBlockCipher(engine, 8), new ZeroBytePadding());
try {
final byte[] passwordBytes = password.getBytes("US-ASCII");
assertValidPasswordBytesLength(passwordBytes);
final byte[] sessionKey = new byte[KEY_BYTES_LENGTH];
System.arraycopy(passwordBytes, 0, sessionKey, 0, Math.min(KEY_BYTES_LENGTH, passwordBytes.length));
final byte[] iv = new byte[KEY_BYTES_LENGTH];
System.arraycopy(initVector, 0, iv, 0, Math.min(KEY_BYTES_LENGTH, initVector.length));
cipher.init(true, new ParametersWithIV(new KeyParameter(sessionKey), iv));
final byte[] cipherText = new byte[cipher.getOutputSize(passiveCheckBytes.length)];
int cipherLength = cipher.processBytes(passiveCheckBytes, 0, passiveCheckBytes.length, cipherText, 0);
cipherLength = cipherLength + cipher.doFinal(cipherText, cipherLength);
final int bytesToCopy = Math.min(passiveCheckBytes.length, cipherLength);
System.arraycopy(cipherText, 0, passiveCheckBytes, 0, bytesToCopy);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例4: getBlowfishSignature
import org.bouncycastle.crypto.engines.BlowfishEngine; //导入依赖的package包/类
/**
* RTMPE type 9 uses Blowfish on the regular signature http://en.wikipedia.org/wiki/Blowfish_(cipher)
*
* @param array array to get signature
* @param offset offset to start from
* @param keyid ID of XTEA key
*/
public final static void getBlowfishSignature(byte[] array, int offset, int keyid) {
BlowfishEngine bf = new BlowfishEngine();
// need to use little endian
bf.init(true, new KeyParameter(BLOWFISH_KEYS[keyid]));
byte[] output = new byte[8];
bf.processBlock(array, offset, output, 0);
System.arraycopy(output, 0, array, offset, 8);
}
示例5: Blowfish_CFB8
import org.bouncycastle.crypto.engines.BlowfishEngine; //导入依赖的package包/类
public Blowfish_CFB8()
{
super(new CFBBlockCipher(new BlowfishEngine(), 8), 64);
}
示例6: Blowfish_OFB8
import org.bouncycastle.crypto.engines.BlowfishEngine; //导入依赖的package包/类
public Blowfish_OFB8()
{
super(new OFBBlockCipher(new BlowfishEngine(), 8), 64);
}
示例7: ECB
import org.bouncycastle.crypto.engines.BlowfishEngine; //导入依赖的package包/类
public ECB()
{
super(new BlowfishEngine());
}
示例8: CBC
import org.bouncycastle.crypto.engines.BlowfishEngine; //导入依赖的package包/类
public CBC()
{
super(new CBCBlockCipher(new BlowfishEngine()), 64);
}
示例9: performTest
import org.bouncycastle.crypto.engines.BlowfishEngine; //导入依赖的package包/类
public void performTest()
throws Exception
{
// 128 bit block ciphers
testReset("AESFastEngine", new AESFastEngine(), new AESFastEngine(), new KeyParameter(new byte[16]));
testReset("AESEngine", new AESEngine(), new AESEngine(), new KeyParameter(new byte[16]));
testReset("AESLightEngine", new AESLightEngine(), new AESLightEngine(), new KeyParameter(new byte[16]));
testReset("Twofish", new TwofishEngine(), new TwofishEngine(), new KeyParameter(new byte[16]));
testReset("NoekeonEngine", new NoekeonEngine(), new NoekeonEngine(), new KeyParameter(new byte[16]));
testReset("SerpentEngine", new SerpentEngine(), new SerpentEngine(), new KeyParameter(new byte[16]));
testReset("SEEDEngine", new SEEDEngine(), new SEEDEngine(), new KeyParameter(new byte[16]));
testReset("CAST6Engine", new CAST6Engine(), new CAST6Engine(), new KeyParameter(new byte[16]));
testReset("RC6Engine", new RC6Engine(), new RC6Engine(), new KeyParameter(new byte[16]));
// 64 bit block ciphers
testReset("DESEngine", new DESEngine(), new DESEngine(), new KeyParameter(new byte[8]));
testReset("BlowfishEngine", new BlowfishEngine(), new BlowfishEngine(), new KeyParameter(new byte[8]));
testReset("CAST5Engine", new CAST5Engine(), new CAST5Engine(), new KeyParameter(new byte[8]));
testReset("DESedeEngine", new DESedeEngine(), new DESedeEngine(), new KeyParameter(new byte[24]));
testReset("TEAEngine", new TEAEngine(), new TEAEngine(), new KeyParameter(new byte[16]));
testReset("XTEAEngine", new XTEAEngine(), new XTEAEngine(), new KeyParameter(new byte[16]));
// primitive block cipher modes (don't reset on processBlock)
testModeReset("AES/CBC", new CBCBlockCipher(new AESEngine()), new CBCBlockCipher(new AESEngine()),
new ParametersWithIV(new KeyParameter(new byte[16]), new byte[16]));
testModeReset("AES/SIC", new SICBlockCipher(new AESEngine()), new SICBlockCipher(new AESEngine()),
new ParametersWithIV(new KeyParameter(new byte[16]), new byte[16]));
testModeReset("AES/CFB", new CFBBlockCipher(new AESEngine(), 128), new CFBBlockCipher(new AESEngine(), 128),
new ParametersWithIV(new KeyParameter(new byte[16]), new byte[16]));
testModeReset("AES/OFB", new OFBBlockCipher(new AESEngine(), 128), new OFBBlockCipher(new AESEngine(), 128),
new ParametersWithIV(new KeyParameter(new byte[16]), new byte[16]));
testModeReset("AES/GCTR", new GOFBBlockCipher(new DESEngine()), new GOFBBlockCipher(new DESEngine()),
new ParametersWithIV(new KeyParameter(new byte[8]), new byte[8]));
testModeReset("AES/OpenPGPCFB", new OpenPGPCFBBlockCipher(new AESEngine()), new OpenPGPCFBBlockCipher(
new AESEngine()), new KeyParameter(new byte[16]));
testModeReset("AES/PGPCFB", new PGPCFBBlockCipher(new AESEngine(), false), new PGPCFBBlockCipher(
new AESEngine(), false), new KeyParameter(new byte[16]));
// PGPCFB with IV is broken (it's also not a PRP, so probably shouldn't be a BlockCipher)
// testModeReset("AES/PGPCFBwithIV", new PGPCFBBlockCipher(new AESEngine(), true), new
// PGPCFBBlockCipher(
// new AESEngine(), true), new ParametersWithIV(new KeyParameter(new byte[16]), new
// byte[16]));
// testModeReset("AES/PGPCFBwithIV_NoIV", new PGPCFBBlockCipher(new AESEngine(), true), new
// PGPCFBBlockCipher(
// new AESEngine(), true), new KeyParameter(new byte[16]));
}
示例10: BlowfishTest
import org.bouncycastle.crypto.engines.BlowfishEngine; //导入依赖的package包/类
BlowfishTest()
{
super(tests, new BlowfishEngine(), new KeyParameter(new byte[16]));
}
示例11: CMAC
import org.bouncycastle.crypto.engines.BlowfishEngine; //导入依赖的package包/类
public CMAC()
{
super(new CMac(new BlowfishEngine()));
}
示例12: performTest
import org.bouncycastle.crypto.engines.BlowfishEngine; //导入依赖的package包/类
@Override
public void performTest()
throws Exception
{
// 128 bit block ciphers
testReset("AESFastEngine", new AESFastEngine(), new AESFastEngine(), new KeyParameter(new byte[16]));
testReset("AESEngine", new AESEngine(), new AESEngine(), new KeyParameter(new byte[16]));
testReset("AESLightEngine", new AESLightEngine(), new AESLightEngine(), new KeyParameter(new byte[16]));
testReset("Twofish", new TwofishEngine(), new TwofishEngine(), new KeyParameter(new byte[16]));
testReset("NoekeonEngine", new NoekeonEngine(), new NoekeonEngine(), new KeyParameter(new byte[16]));
testReset("SerpentEngine", new SerpentEngine(), new SerpentEngine(), new KeyParameter(new byte[16]));
testReset("SEEDEngine", new SEEDEngine(), new SEEDEngine(), new KeyParameter(new byte[16]));
testReset("CAST6Engine", new CAST6Engine(), new CAST6Engine(), new KeyParameter(new byte[16]));
testReset("RC6Engine", new RC6Engine(), new RC6Engine(), new KeyParameter(new byte[16]));
// 64 bit block ciphers
testReset("DESEngine", new DESEngine(), new DESEngine(), new KeyParameter(new byte[8]));
testReset("BlowfishEngine", new BlowfishEngine(), new BlowfishEngine(), new KeyParameter(new byte[8]));
testReset("CAST5Engine", new CAST5Engine(), new CAST5Engine(), new KeyParameter(new byte[8]));
testReset("DESedeEngine", new DESedeEngine(), new DESedeEngine(), new KeyParameter(new byte[24]));
testReset("TEAEngine", new TEAEngine(), new TEAEngine(), new KeyParameter(new byte[16]));
testReset("XTEAEngine", new XTEAEngine(), new XTEAEngine(), new KeyParameter(new byte[16]));
// primitive block cipher modes (don't reset on processBlock)
testModeReset("AES/CBC", new CBCBlockCipher(new AESEngine()), new CBCBlockCipher(new AESEngine()),
new ParametersWithIV(new KeyParameter(new byte[16]), new byte[16]));
testModeReset("AES/SIC", new SICBlockCipher(new AESEngine()), new SICBlockCipher(new AESEngine()),
new ParametersWithIV(new KeyParameter(new byte[16]), new byte[16]));
testModeReset("AES/CFB", new CFBBlockCipher(new AESEngine(), 128), new CFBBlockCipher(new AESEngine(), 128),
new ParametersWithIV(new KeyParameter(new byte[16]), new byte[16]));
testModeReset("AES/OFB", new OFBBlockCipher(new AESEngine(), 128), new OFBBlockCipher(new AESEngine(), 128),
new ParametersWithIV(new KeyParameter(new byte[16]), new byte[16]));
testModeReset("AES/GCTR", new GOFBBlockCipher(new DESEngine()), new GOFBBlockCipher(new DESEngine()),
new ParametersWithIV(new KeyParameter(new byte[8]), new byte[8]));
testModeReset("AES/OpenPGPCFB", new OpenPGPCFBBlockCipher(new AESEngine()), new OpenPGPCFBBlockCipher(
new AESEngine()), new KeyParameter(new byte[16]));
testModeReset("AES/PGPCFB", new PGPCFBBlockCipher(new AESEngine(), false), new PGPCFBBlockCipher(
new AESEngine(), false), new KeyParameter(new byte[16]));
// PGPCFB with IV is broken (it's also not a PRP, so probably shouldn't be a BlockCipher)
// testModeReset("AES/PGPCFBwithIV", new PGPCFBBlockCipher(new AESEngine(), true), new
// PGPCFBBlockCipher(
// new AESEngine(), true), new ParametersWithIV(new KeyParameter(new byte[16]), new
// byte[16]));
// testModeReset("AES/PGPCFBwithIV_NoIV", new PGPCFBBlockCipher(new AESEngine(), true), new
// PGPCFBBlockCipher(
// new AESEngine(), true), new KeyParameter(new byte[16]));
}
示例13: BlowfishCipher
import org.bouncycastle.crypto.engines.BlowfishEngine; //导入依赖的package包/类
/**
* <b>Notice: </b><br>
* 1. in <code>new CFBBlockCipher(engine, <b>8</b> * 8);</code> the IV length (8) is
* reference to the shadowsocks's design.
*
* @see <a href="https://shadowsocks.org/en/spec/cipher.html">
* https://shadowsocks.org/en/spec/cipher.html</a>#Cipher
*/
public BlowfishCipher(String password, int mode) {
key = new SecretKeySpec(password.getBytes(), "BF");
keyLength = mode;
BlowfishEngine engine = new BlowfishEngine();
cipher = new CFBBlockCipher(engine, 8 * 8);
}