public Mac() { super(new GOST28147Mac()); }
@Override public MACCalculator _createMACCalculator() { return new MACCalculatorImpl(new GOST28147Mac(), 32, 0); // IV not supported - throws exception when passing ParameterWithIV }
public TestResult perform() { // test1 Mac mac = new GOST28147Mac(); KeyParameter key = new KeyParameter(gkeyBytes1); mac.init(key); mac.update(input3, 0, input3.length); byte[] out = new byte[4]; mac.doFinal(out, 0); if (!Arrays.areEqual(out, output7)) { return new SimpleTestResult(false, getName() + ": Failed test 1 - expected " + new String(Hex.encode(output7)) + " got " + new String(Hex.encode(out))); } // test2 key = new KeyParameter(gkeyBytes2); ParametersWithSBox gparam = new ParametersWithSBox(key, GOST28147Engine.getSBox("E-A")); mac.init(gparam); mac.update(input4, 0, input4.length); out = new byte[4]; mac.doFinal(out, 0); if (!Arrays.areEqual(out, output8)) { return new SimpleTestResult(false, getName() + ": Failed test 2 - expected " + new String(Hex.encode(output8)) + " got " + new String(Hex.encode(out))); } return new SimpleTestResult(true, getName() + ": Okay"); }