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

项目:vsDiaryWriter    文件:BlockCiphers.java   
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);
}
项目:ipack    文件:GOST3411Digest.java   
/**
 * Standard constructor
 */
public GOST3411Digest()
{
    sBox = GOST28147Engine.getSBox("D-A");
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();
}
项目:gwt-crypto    文件:GOST3411Digest.java   
/**
 * Standard constructor
 */
public GOST3411Digest()
{
    sBox = GOST28147Engine.getSBox("D-A");
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();
}
项目:Aki-SSL    文件:GOST3411Digest.java   
/**
 * Standard constructor
 */
public GOST3411Digest()
{
    sBox = GOST28147Engine.getSBox("D-A");
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();
}
项目:TinyTravelTracker    文件:GOST3411Digest.java   
/**
 * Standard constructor
 */
public GOST3411Digest()
{
    sBox = GOST28147Engine.getSBox("D-A");
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();
}
项目:CryptMeme    文件:GOST3411Digest.java   
/**
 * Standard constructor
 */
public GOST3411Digest()
{
    sBox = GOST28147Engine.getSBox("D-A");
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();
}
项目:irma_future_id    文件:GOST3411Digest.java   
/**
 * Standard constructor
 */
public GOST3411Digest()
{
    sBox = GOST28147Engine.getSBox("D-A");
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();
}
项目:irma_future_id    文件:GOST3411DigestTest.java   
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());
}
项目:bc-java    文件:GOST3411Digest.java   
/**
 * Standard constructor
 */
public GOST3411Digest()
{
    sBox = GOST28147Engine.getSBox("D-A");
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();
}
项目:bc-java    文件:GOST3411DigestTest.java   
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());
}
项目:ipack    文件:GOST28147ParameterSpec.java   
public GOST28147ParameterSpec(
    String  sBoxName)
{
    this.sBox = GOST28147Engine.getSBox(sBoxName);
}
项目:ipack    文件:GOST28147.java   
public ECB()
{
    super(new GOST28147Engine());
}
项目:ipack    文件:GOST28147.java   
public CBC()
{
    super(new CBCBlockCipher(new GOST28147Engine()), 64);
}
项目:gwt-crypto    文件:GOST28147Test.java   
GOST28147Test()
{
    super(tests, new GOST28147Engine(), new KeyParameter(new byte[32]));
}
项目:Aki-SSL    文件:GOST28147ParameterSpec.java   
public GOST28147ParameterSpec(
    String sBoxName)
{
    this.sBox = GOST28147Engine.getSBox(sBoxName);
}
项目:Aki-SSL    文件:GOST28147.java   
public ECB()
{
    super(new GOST28147Engine());
}
项目:Aki-SSL    文件:GOST28147.java   
public CBC()
{
    super(new CBCBlockCipher(new GOST28147Engine()), 64);
}
项目:Aki-SSL    文件:GOST28147.java   
public GCFB()
{
    super(new BufferedBlockCipher(new GCFBBlockCipher(new GOST28147Engine())), 64);
}
项目:CryptMeme    文件:GOST28147ParameterSpec.java   
public GOST28147ParameterSpec(
    String sBoxName)
{
    this.sBox = GOST28147Engine.getSBox(sBoxName);
}
项目:CryptMeme    文件:GOST28147.java   
public ECB()
{
    super(new GOST28147Engine());
}
项目:CryptMeme    文件:GOST28147.java   
public CBC()
{
    super(new CBCBlockCipher(new GOST28147Engine()), 64);
}
项目:CryptMeme    文件:GOST28147.java   
public GCFB()
{
    super(new BufferedBlockCipher(new GCFBBlockCipher(new GOST28147Engine())), 64);
}
项目:irma_future_id    文件:GOST28147Test.java   
GOST28147Test()
{
    super(tests, new GOST28147Engine(), new KeyParameter(new byte[32]));
}
项目:irma_future_id    文件:GOST28147ParameterSpec.java   
public GOST28147ParameterSpec(
    String sBoxName)
{
    this.sBox = GOST28147Engine.getSBox(sBoxName);
}
项目:irma_future_id    文件:GOST28147.java   
public ECB()
{
    super(new GOST28147Engine());
}
项目:irma_future_id    文件:GOST28147.java   
public CBC()
{
    super(new CBCBlockCipher(new GOST28147Engine()), 64);
}
项目:irma_future_id    文件:GOST28147.java   
public GCFB()
{
    super(new BufferedBlockCipher(new GCFBBlockCipher(new GOST28147Engine())), 64);
}
项目:bc-java    文件:GOST28147Test.java   
GOST28147Test()
{
    super(tests, new GOST28147Engine(), new KeyParameter(new byte[32]));
}
项目:bc-java    文件:GOST28147ParameterSpec.java   
public GOST28147ParameterSpec(
    String sBoxName)
{
    this.sBox = GOST28147Engine.getSBox(sBoxName);
}
项目:bc-java    文件:GOST28147.java   
public ECB()
{
    super(new GOST28147Engine());
}
项目:bc-java    文件:GOST28147.java   
public CBC()
{
    super(new CBCBlockCipher(new GOST28147Engine()), 64);
}
项目:bc-java    文件:GOST28147.java   
public GCFB()
{
    super(new BufferedBlockCipher(new GCFBBlockCipher(new GOST28147Engine())), 64);
}
项目:gwt-crypto    文件:GOST28147MacTest.java   
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");
}
项目:irma_future_id    文件:GOST28147MacTest.java   
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");
}
项目:bc-java    文件:GOST28147MacTest.java   
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");
}