当前位置: 首页>>代码示例>>Java>>正文


Java PKCS5S1ParametersGenerator类代码示例

本文整理汇总了Java中org.bouncycastle.crypto.generators.PKCS5S1ParametersGenerator的典型用法代码示例。如果您正苦于以下问题:Java PKCS5S1ParametersGenerator类的具体用法?Java PKCS5S1ParametersGenerator怎么用?Java PKCS5S1ParametersGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PKCS5S1ParametersGenerator类属于org.bouncycastle.crypto.generators包,在下文中一共展示了PKCS5S1ParametersGenerator类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.bouncycastle.crypto.generators.PKCS5S1ParametersGenerator; //导入依赖的package包/类
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());
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:34,代码来源:GOST3411DigestTest.java

示例2: performTest

import org.bouncycastle.crypto.generators.PKCS5S1ParametersGenerator; //导入依赖的package包/类
public void performTest()
{
    super.performTest();

    millionATest(million_a_digest);

    HMac gMac = new HMac(new GOST3411Digest());

    gMac.init(new KeyParameter(PKCS5S1ParametersGenerator.PKCS5PasswordToUTF8Bytes("1".toCharArray())));

    byte[] data = "fred".getBytes();

    gMac.update(data, 0, data.length);
    byte[] mac = new byte[gMac.getMacSize()];

    gMac.doFinal(mac, 0);

    if (!Arrays.areEqual(Hex.decode("e9f98610cfc80084462b175a15d2b4ec10b2ab892eae5a6179d572d9b1db6b72"), mac))
    {
        fail("mac calculation failed.");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:23,代码来源:GOST3411DigestTest.java

示例3: createDecryptionParameters

import org.bouncycastle.crypto.generators.PKCS5S1ParametersGenerator; //导入依赖的package包/类
protected ParametersWithIV createDecryptionParameters(String password,
        String salt, byte[] iv) {

    byte[] passwordBytes = password.getBytes(Charsets.UTF_8);
    byte[] saltBytes = salt.getBytes(Charsets.UTF_8);

    PKCS5S1ParametersGenerator keyGenerator = new PKCS5S1ParametersGenerator(
            new SHA512Digest());
    keyGenerator.init(passwordBytes, saltBytes, PBE_ITERATION_COUNT);

    KeyParameter params =
            (KeyParameter) keyGenerator.generateDerivedParameters(KEY_SIZE);

    return new ParametersWithIV(params, iv);

}
 
开发者ID:giacomodrago,项目名称:immediatecrypt,代码行数:17,代码来源:AESFacadeImpl.java

示例4: newParamGenerator

import org.bouncycastle.crypto.generators.PKCS5S1ParametersGenerator; //导入依赖的package包/类
/** {@inheritDoc} */
protected PBEParametersGenerator newParamGenerator() {
	return new PKCS5S1ParametersGenerator(digest.getDigest());
}
 
开发者ID:shivam091,项目名称:Java-Security,代码行数:5,代码来源:PBKDF1KeyGenerator.java

示例5: performTest

import org.bouncycastle.crypto.generators.PKCS5S1ParametersGenerator; //导入依赖的package包/类
public void performTest()
{
    super.performTest();
    
    millionATest(million_a_digest);

    HMac gMac = new HMac(new GOST3411Digest());

    gMac.init(new KeyParameter(PKCS5S1ParametersGenerator.PKCS5PasswordToUTF8Bytes("1".toCharArray())));

    byte[] data = "fred".getBytes();

    gMac.update(data, 0, data.length);
    byte[] mac = new byte[gMac.getMacSize()];

    gMac.doFinal(mac, 0);
    System.err.println("e080de3bde792327a6cccfa5dfd51e72b6829baa88d8130ed1a48822873fc7f6");
    System.err.println(new String(Hex.encode(mac)));
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:20,代码来源:GOST3411DigestTest.java

示例6: createEncryptionParameters

import org.bouncycastle.crypto.generators.PKCS5S1ParametersGenerator; //导入依赖的package包/类
protected ParametersWithIV createEncryptionParameters(String password, String salt) {

        byte[] passwordBytes = password.getBytes(Charsets.UTF_8);
        byte[] saltBytes = salt.getBytes(Charsets.UTF_8);

        PKCS5S1ParametersGenerator keyGenerator = new PKCS5S1ParametersGenerator(
                new SHA512Digest());
        keyGenerator.init(passwordBytes, saltBytes, PBE_ITERATION_COUNT);

        ParametersWithIV params =
                (ParametersWithIV) keyGenerator.generateDerivedParameters(KEY_SIZE, IV_SIZE);

        return params;

    }
 
开发者ID:giacomodrago,项目名称:immediatecrypt,代码行数:16,代码来源:AESFacadeImpl.java


注:本文中的org.bouncycastle.crypto.generators.PKCS5S1ParametersGenerator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。