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

项目:gwt-crypto    文件:Grainv1Test.java   
private void Grainv1Test1(CipherParameters params)
{
    StreamCipher grain = new Grainv1Engine();
    byte[] in = new byte[10];
    byte[] out = new byte[10];

    grain.init(true, params);

    grain.processBytes(in, 0, in.length, out, 0);

    if (!areEqual(out, Hex.decode(keyStream1)))
    {
        mismatch("Keystream 1", keyStream1, out);
    }

    grain.reset();

    grain.processBytes(in, 0, in.length, out, 0);

    if (!areEqual(out, Hex.decode(keyStream1)))
    {
        mismatch("Keystream 1", keyStream1, out);
    }
}
项目:gwt-crypto    文件:Grainv1Test.java   
private void Grainv1Test2(CipherParameters params)
{
    StreamCipher grain = new Grainv1Engine();
    byte[] in = new byte[10];
    byte[] out = new byte[10];

    grain.init(true, params);

    grain.processBytes(in, 0, in.length, out, 0);

    if (!areEqual(out, Hex.decode(keyStream2)))
    {
        mismatch("Keystream 2", keyStream2, out);
    }

    grain.reset();

    grain.processBytes(in, 0, in.length, out, 0);

    if (!areEqual(out, Hex.decode(keyStream2)))
    {
        mismatch("Keystream 2", keyStream2, out);
    }
}
项目:gwt-crypto    文件:Grainv1Test.java   
private void Grainv1Test3(CipherParameters params)
{
    StreamCipher grain = new Grainv1Engine();
    byte[] in = "Encrypt me!".getBytes();
    byte[] cipher = new byte[in.length];
    byte[] clear = new byte[in.length];

    grain.init(true, params);

    grain.processBytes(in, 0, in.length, cipher, 0);
    grain.reset();
    grain.processBytes(cipher, 0, cipher.length, clear, 0);

    if (!areEqual(in, clear))
    {
        mismatch("Test 3", new String(Hex.encode(in)), clear);
    }
}
项目:gwt-crypto    文件:StreamCipherResetTest.java   
public void performTest()
    throws Exception
{
    testReset(new Salsa20Engine(), new Salsa20Engine(), new ParametersWithIV(new KeyParameter(random(32)),
        random(8)));
    testReset(new Salsa20Engine(), new Salsa20Engine(), new ParametersWithIV(new KeyParameter(random(16)),
        random(8)));
    testReset(new XSalsa20Engine(), new XSalsa20Engine(), new ParametersWithIV(new KeyParameter(random(32)),
        random(24)));
    testReset(new ChaChaEngine(), new ChaChaEngine(), new ParametersWithIV(new KeyParameter(random(32)), random(8)));
    testReset(new ChaChaEngine(), new ChaChaEngine(), new ParametersWithIV(new KeyParameter(random(16)), random(8)));
    testReset(new RC4Engine(), new RC4Engine(), new KeyParameter(random(16)));
    testReset(new ISAACEngine(), new ISAACEngine(), new KeyParameter(random(16)));
    testReset(new HC128Engine(), new HC128Engine(), new ParametersWithIV(new KeyParameter(random(16)), random(16)));
    testReset(new HC256Engine(), new HC256Engine(), new ParametersWithIV(new KeyParameter(random(16)), random(16)));
    testReset(new Grainv1Engine(), new Grainv1Engine(), new ParametersWithIV(new KeyParameter(random(16)),
        random(8)));
    testReset(new Grain128Engine(), new Grain128Engine(), new ParametersWithIV(new KeyParameter(random(16)),
        random(12)));
}
项目:subshare    文件:StreamCipherImpl.java   
@Override
public int getIVSize()
{
    if (ivSize < 0) {
        if (delegate instanceof Grainv1Engine)
            ivSize = 8;
        else if (delegate instanceof Grain128Engine)
            ivSize = 12;
        else if (delegate instanceof HC128Engine)
            ivSize = 16;
        else if (delegate instanceof HC256Engine)
            ivSize = 32;
        else if (delegate instanceof ISAACEngine)
            ivSize = 0;
        else if (delegate instanceof RC4Engine)
            ivSize = 0;
        else if (delegate instanceof Salsa20Engine)
            ivSize = 8;
        else
            throw new UnsupportedOperationException("For this delegate cipher type, this operation is not yet supported!");
    }
    return ivSize;
}
项目:irma_future_id    文件:Grainv1Test.java   
private void Grainv1Test1(CipherParameters params)
{
    StreamCipher grain = new Grainv1Engine();
    byte[] in = new byte[10];
    byte[] out = new byte[10];

    grain.init(true, params);

    grain.processBytes(in, 0, in.length, out, 0);

    if (!areEqual(out, Hex.decode(keyStream1)))
    {
        mismatch("Keystream 1", keyStream1, out);
    }

    grain.reset();

    grain.processBytes(in, 0, in.length, out, 0);

    if (!areEqual(out, Hex.decode(keyStream1)))
    {
        mismatch("Keystream 1", keyStream1, out);
    }
}
项目:irma_future_id    文件:Grainv1Test.java   
private void Grainv1Test2(CipherParameters params)
{
    StreamCipher grain = new Grainv1Engine();
    byte[] in = new byte[10];
    byte[] out = new byte[10];

    grain.init(true, params);

    grain.processBytes(in, 0, in.length, out, 0);

    if (!areEqual(out, Hex.decode(keyStream2)))
    {
        mismatch("Keystream 2", keyStream2, out);
    }

    grain.reset();

    grain.processBytes(in, 0, in.length, out, 0);

    if (!areEqual(out, Hex.decode(keyStream2)))
    {
        mismatch("Keystream 2", keyStream2, out);
    }
}
项目:irma_future_id    文件:Grainv1Test.java   
private void Grainv1Test3(CipherParameters params)
{
    StreamCipher grain = new Grainv1Engine();
    byte[] in = "Encrypt me!".getBytes();
    byte[] cipher = new byte[in.length];
    byte[] clear = new byte[in.length];

    grain.init(true, params);

    grain.processBytes(in, 0, in.length, cipher, 0);
    grain.reset();
    grain.processBytes(cipher, 0, cipher.length, clear, 0);

    if (!areEqual(in, clear))
    {
        mismatch("Test 3", new String(Hex.encode(in)), clear);
    }
}
项目:bc-java    文件:Grainv1Test.java   
private void Grainv1Test1(CipherParameters params)
{
    StreamCipher grain = new Grainv1Engine();
    byte[] in = new byte[10];
    byte[] out = new byte[10];

    grain.init(true, params);

    grain.processBytes(in, 0, in.length, out, 0);

    if (!areEqual(out, Hex.decode(keyStream1)))
    {
        mismatch("Keystream 1", keyStream1, out);
    }

    grain.reset();

    grain.processBytes(in, 0, in.length, out, 0);

    if (!areEqual(out, Hex.decode(keyStream1)))
    {
        mismatch("Keystream 1", keyStream1, out);
    }
}
项目:bc-java    文件:Grainv1Test.java   
private void Grainv1Test2(CipherParameters params)
{
    StreamCipher grain = new Grainv1Engine();
    byte[] in = new byte[10];
    byte[] out = new byte[10];

    grain.init(true, params);

    grain.processBytes(in, 0, in.length, out, 0);

    if (!areEqual(out, Hex.decode(keyStream2)))
    {
        mismatch("Keystream 2", keyStream2, out);
    }

    grain.reset();

    grain.processBytes(in, 0, in.length, out, 0);

    if (!areEqual(out, Hex.decode(keyStream2)))
    {
        mismatch("Keystream 2", keyStream2, out);
    }
}
项目:bc-java    文件:Grainv1Test.java   
private void Grainv1Test3(CipherParameters params)
{
    StreamCipher grain = new Grainv1Engine();
    byte[] in = "Encrypt me!".getBytes();
    byte[] cipher = new byte[in.length];
    byte[] clear = new byte[in.length];

    grain.init(true, params);

    grain.processBytes(in, 0, in.length, cipher, 0);
    grain.reset();
    grain.processBytes(cipher, 0, cipher.length, clear, 0);

    if (!areEqual(in, clear))
    {
        mismatch("Test 3", new String(Hex.encode(in)), clear);
    }
}
项目:gwt-crypto    文件:CipherStreamTest.java   
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]));
}
项目:gwt-crypto    文件:Grainv1Test.java   
private void Grainv1Test4(CipherParameters params)
{
    StreamCipher grain = new Grainv1Engine();
    byte[] in = new byte[keyStream4.length() / 2];
    byte[] out = new byte[in.length];

    grain.init(true, params);

    grain.processBytes(in, 0, in.length, out, 0);

    if (!areEqual(out, Hex.decode(keyStream4)))
    {
        mismatch("Keystream 4", keyStream4, out);
    }
}
项目:irma_future_id    文件:Grainv1Test.java   
private void Grainv1Test4(CipherParameters params)
{
    StreamCipher grain = new Grainv1Engine();
    byte[] in = new byte[keyStream4.length() / 2];
    byte[] out = new byte[in.length];

    grain.init(true, params);

    grain.processBytes(in, 0, in.length, out, 0);

    if (!areEqual(out, Hex.decode(keyStream4)))
    {
        mismatch("Keystream 4", keyStream4, out);
    }
}
项目:bc-java    文件:Grainv1Test.java   
private void Grainv1Test4(CipherParameters params)
{
    StreamCipher grain = new Grainv1Engine();
    byte[] in = new byte[keyStream4.length() / 2];
    byte[] out = new byte[in.length];

    grain.init(true, params);

    grain.processBytes(in, 0, in.length, out, 0);

    if (!areEqual(out, Hex.decode(keyStream4)))
    {
        mismatch("Keystream 4", keyStream4, out);
    }
}
项目:ipack    文件:Grainv1.java   
public Base()
{
    super(new Grainv1Engine(), 8);
}
项目:Aki-SSL    文件:Grainv1.java   
public Base()
{
    super(new Grainv1Engine(), 8);
}
项目:CryptMeme    文件:Grainv1.java   
public Base()
{
    super(new Grainv1Engine(), 8);
}
项目:irma_future_id    文件:Grainv1.java   
public Base()
{
    super(new Grainv1Engine(), 8);
}
项目:bc-java    文件:Grainv1.java   
public Base()
{
    super(new Grainv1Engine(), 8);
}