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); }
/** * Standard constructor */ public GOST3411Digest() { sBox = GOST28147Engine.getSBox("D-A"); cipher.init(true, new ParametersWithSBox(null, sBox)); reset(); }
public static void main( String[] args) { HMac gMac = new HMac(new GOST3411Digest(GOST28147Engine.getSBox("D-Test"))); gMac.init(new KeyParameter(PKCS5S1ParametersGenerator.PKCS5PasswordToUTF8Bytes("Boss".toCharArray()))); byte[] iBuf = new byte[4]; byte[] data = Hex.decode("b5d78fa546ba645c"); gMac.update(data, 0, data.length); byte[] mac = new byte[gMac.getMacSize()]; int pos = 3; while (++iBuf[pos] == 0) { --pos; } gMac.update(iBuf, 0, iBuf.length); gMac.doFinal(mac, 0); System.err.println(mac.length + " " + new String(Hex.encode(mac))); PKCS5S2ParametersGenerator pGen = new PKCS5S2ParametersGenerator(new GOST3411Digest()); pGen.init(PKCS5S1ParametersGenerator.PKCS5PasswordToUTF8Bytes("1".toCharArray()), data, 2048); KeyParameter kp = (KeyParameter)pGen.generateDerivedMacParameters(256); System.err.println(kp.getKey().length + " " + new String(Hex.encode(kp.getKey()))); runTest(new GOST3411DigestTest()); }
public GOST28147ParameterSpec( String sBoxName) { this.sBox = GOST28147Engine.getSBox(sBoxName); }
public ECB() { super(new GOST28147Engine()); }
public CBC() { super(new CBCBlockCipher(new GOST28147Engine()), 64); }
GOST28147Test() { super(tests, new GOST28147Engine(), new KeyParameter(new byte[32])); }
public GCFB() { super(new BufferedBlockCipher(new GCFBBlockCipher(new GOST28147Engine())), 64); }
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"); }