Java 类org.bouncycastle.crypto.engines.SM4Engine 实例源码

项目:vsDiaryWriter    文件:BlockCiphers.java   
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);
}
项目:gwt-crypto    文件:SM4Test.java   
private void test1000000()
{
    byte[] plain = Hex.decode("0123456789abcdeffedcba9876543210");
    byte[] key = Hex.decode("0123456789abcdeffedcba9876543210");
    byte[] cipher = Hex.decode("595298c7c6fd271f0402f804c33d3f66");
    byte[] buf = new byte[16];

    BlockCipher engine = new SM4Engine();

    engine.init(true, new KeyParameter(key));

    System.arraycopy(plain, 0, buf, 0, buf.length);

    for (int i = 0; i != 1000000; i++)
    {
        engine.processBlock(buf, 0, buf, 0);
    }

    if (!areEqual(cipher, buf))
    {
        fail("1000000 encryption test failed");
    }

    engine.init(false, new KeyParameter(key));

    for (int i = 0; i != 1000000; i++)
    {
        engine.processBlock(buf, 0, buf, 0);
    }

    if (!areEqual(plain, buf))
    {
        fail("1000000 decryption test failed");
    }
}
项目:Aki-SSL    文件:SM4.java   
public ECB()
{
    super(new BlockCipherProvider()
    {
        public BlockCipher get()
        {
            return new SM4Engine();
        }
    });
}
项目:gwt-crypto    文件:SM4Test.java   
SM4Test()
{
    super(tests, new SM4Engine(), new KeyParameter(new byte[16]));
}
项目:Aki-SSL    文件:SM4.java   
public CMAC()
{
    super(new CMac(new SM4Engine()));
}
项目:Aki-SSL    文件:SM4.java   
public GMAC()
{
    super(new GMac(new GCMBlockCipher(new SM4Engine())));
}
项目:Aki-SSL    文件:SM4.java   
public Poly1305()
{
    super(new org.bouncycastle.crypto.macs.Poly1305(new SM4Engine()));
}