Java 类org.bouncycastle.crypto.modes.OldCTSBlockCipher 实例源码

项目:gwt-crypto    文件:CTSTest.java   
private void testOldCTS(
        int                 id,
        BlockCipher         cipher,
        CipherParameters    params,
        byte[]              input,
        byte[]              output)
throws Exception
{
    byte[]                  out = new byte[input.length];
    BufferedBlockCipher     engine = new OldCTSBlockCipher(cipher);

    engine.init(true, params);

    int len = engine.processBytes(input, 0, input.length, out, 0);

    engine.doFinal(out, len);

    if (!areEqual(output, out))
    {
        fail("failed encryption expected " + new String(Hex.encode(output)) + " got " + new String(Hex.encode(out)));
    }

    engine.init(false, params);

    len = engine.processBytes(output, 0, output.length, out, 0);

    engine.doFinal(out, len);

    if (!areEqual(input, out))
    {
        fail("failed decryption expected " + new String(Hex.encode(input)) + " got " + new String(Hex.encode(out)));
    }
}
项目:irma_future_id    文件:CTSTest.java   
private void testOldCTS(
        int                 id,
        BlockCipher         cipher,
        CipherParameters    params,
        byte[]              input,
        byte[]              output)
throws Exception
{
    byte[]                  out = new byte[input.length];
    BufferedBlockCipher     engine = new OldCTSBlockCipher(cipher);

    engine.init(true, params);

    int len = engine.processBytes(input, 0, input.length, out, 0);

    engine.doFinal(out, len);

    if (!areEqual(output, out))
    {
        fail("failed encryption expected " + new String(Hex.encode(output)) + " got " + new String(Hex.encode(out)));
    }

    engine.init(false, params);

    len = engine.processBytes(output, 0, output.length, out, 0);

    engine.doFinal(out, len);

    if (!areEqual(input, out))
    {
        fail("failed decryption expected " + new String(Hex.encode(input)) + " got " + new String(Hex.encode(out)));
    }
}
项目:bc-java    文件:CTSTest.java   
private void testOldCTS(
        int                 id,
        BlockCipher         cipher,
        CipherParameters    params,
        byte[]              input,
        byte[]              output)
throws Exception
{
    byte[]                  out = new byte[input.length];
    BufferedBlockCipher     engine = new OldCTSBlockCipher(cipher);

    engine.init(true, params);

    int len = engine.processBytes(input, 0, input.length, out, 0);

    engine.doFinal(out, len);

    if (!areEqual(output, out))
    {
        fail("failed encryption expected " + new String(Hex.encode(output)) + " got " + new String(Hex.encode(out)));
    }

    engine.init(false, params);

    len = engine.processBytes(output, 0, output.length, out, 0);

    engine.doFinal(out, len);

    if (!areEqual(input, out))
    {
        fail("failed decryption expected " + new String(Hex.encode(input)) + " got " + new String(Hex.encode(out)));
    }
}