Java 类org.bouncycastle.crypto.macs.ISO9797Alg3Mac 实例源码

项目:animamea    文件:AmDESCrypto.java   
@Override
public byte[] getMAC(byte[] key, byte[] data) {
    BlockCipher cipher = new DESEngine();
    Mac mac = new ISO9797Alg3Mac(cipher, 64, new ISO7816d4Padding());

    KeyParameter keyP = new KeyParameter(key);
    mac.init(keyP);
    mac.update(data, 0, data.length);

    byte[] out = new byte[8];

    mac.doFinal(out, 0);

    return out;
}
项目:ipack    文件:DES.java   
public DES9797Alg3with7816d4()
{
    super(new ISO9797Alg3Mac(new DESEngine(), new ISO7816d4Padding()));
}
项目:ipack    文件:DES.java   
public DES9797Alg3()
{
    super(new ISO9797Alg3Mac(new DESEngine()));
}
项目:gwt-crypto    文件:ISO9797Alg3MacTest.java   
public void performTest()
{
    KeyParameter key = new KeyParameter(keyBytes);
    BlockCipher cipher = new DESEngine();
    Mac mac = new ISO9797Alg3Mac(cipher);

    //
    // standard DAC - zero IV
    //
    mac.init(key);

    mac.update(input1, 0, input1.length);

    byte[] out = new byte[8];

    mac.doFinal(out, 0);

    if (!areEqual(out, output1))
    {
        fail("Failed - expected " + new String(Hex.encode(output1)) + " got " + new String(Hex.encode(out)));
    }

    //
    //  reset
    //
    mac.reset();

    mac.init(key);

    for (int i = 0; i != input1.length / 2; i++)
    {
        mac.update(input1[i]);
    }

    mac.update(input1, input1.length / 2, input1.length - (input1.length / 2));

    mac.doFinal(out, 0);

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

    testMacWithIv();
}
项目:Aki-SSL    文件:DES.java   
public DES9797Alg3with7816d4()
{
    super(new ISO9797Alg3Mac(new DESEngine(), new ISO7816d4Padding()));
}
项目:Aki-SSL    文件:DES.java   
public DES9797Alg3()
{
    super(new ISO9797Alg3Mac(new DESEngine()));
}
项目:animamea    文件:AmDESCrypto.java   
@Override
public byte[] getMAC(byte[] data) {

    byte[] n = new byte[8 + data.length];
    System.arraycopy(sscBytes, 0, n, 0, 8);
    System.arraycopy(data, 0, n, 8, data.length);

    BlockCipher cipher = new DESEngine();
    Mac mac = new ISO9797Alg3Mac(cipher, 64, new ISO7816d4Padding());

    ParametersWithIV parameterIV = new ParametersWithIV(keyP, IV);

    mac.init(parameterIV);
    mac.update(n, 0, n.length);

    byte[] out = new byte[8];

    mac.doFinal(out, 0);

    return out;
}
项目:subshare    文件:MACCalculatorFactoryImpl.java   
@Override
public MACCalculator _createMACCalculator() {
    final BlockCipher cipher = new DESEngine();
    return new MACCalculatorImpl(new ISO9797Alg3Mac(cipher, new ISO7816d4Padding()), 24, cipher.getBlockSize());
}
项目:subshare    文件:MACCalculatorFactoryImpl.java   
@Override
public MACCalculator _createMACCalculator() {
    final BlockCipher cipher = new DESEngine();
    return new MACCalculatorImpl(new ISO9797Alg3Mac(cipher), 24, cipher.getBlockSize());
}
项目:CryptMeme    文件:DES.java   
public DES9797Alg3with7816d4()
{
    super(new ISO9797Alg3Mac(new DESEngine(), new ISO7816d4Padding()));
}
项目:CryptMeme    文件:DES.java   
public DES9797Alg3()
{
    super(new ISO9797Alg3Mac(new DESEngine()));
}
项目:irma_future_id    文件:ISO9797Alg3MacTest.java   
public void performTest()
{
    KeyParameter key = new KeyParameter(keyBytes);
    BlockCipher cipher = new DESEngine();
    Mac mac = new ISO9797Alg3Mac(cipher);

    //
    // standard DAC - zero IV
    //
    mac.init(key);

    mac.update(input1, 0, input1.length);

    byte[] out = new byte[8];

    mac.doFinal(out, 0);

    if (!areEqual(out, output1))
    {
        fail("Failed - expected " + new String(Hex.encode(output1)) + " got " + new String(Hex.encode(out)));
    }

    //
    //  reset
    //
    mac.reset();

    mac.init(key);

    for (int i = 0; i != input1.length / 2; i++)
    {
        mac.update(input1[i]);
    }

    mac.update(input1, input1.length / 2, input1.length - (input1.length / 2));

    mac.doFinal(out, 0);

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

    testMacWithIv();
}
项目:irma_future_id    文件:DES.java   
public DES9797Alg3with7816d4()
{
    super(new ISO9797Alg3Mac(new DESEngine(), new ISO7816d4Padding()));
}
项目:irma_future_id    文件:DES.java   
public DES9797Alg3()
{
    super(new ISO9797Alg3Mac(new DESEngine()));
}
项目:bc-java    文件:ISO9797Alg3MacTest.java   
public void performTest()
{
    KeyParameter key = new KeyParameter(keyBytes);
    BlockCipher cipher = new DESEngine();
    Mac mac = new ISO9797Alg3Mac(cipher);

    //
    // standard DAC - zero IV
    //
    mac.init(key);

    mac.update(input1, 0, input1.length);

    byte[] out = new byte[8];

    mac.doFinal(out, 0);

    if (!areEqual(out, output1))
    {
        fail("Failed - expected " + new String(Hex.encode(output1)) + " got " + new String(Hex.encode(out)));
    }

    //
    //  reset
    //
    mac.reset();

    mac.init(key);

    for (int i = 0; i != input1.length / 2; i++)
    {
        mac.update(input1[i]);
    }

    mac.update(input1, input1.length / 2, input1.length - (input1.length / 2));

    mac.doFinal(out, 0);

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

    testMacWithIv();
}
项目:bc-java    文件:DES.java   
public DES9797Alg3with7816d4()
{
    super(new ISO9797Alg3Mac(new DESEngine(), new ISO7816d4Padding()));
}
项目:bc-java    文件:DES.java   
public DES9797Alg3()
{
    super(new ISO9797Alg3Mac(new DESEngine()));
}