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


Java PBEParametersGenerator.generateDerivedMacParameters方法代码示例

本文整理汇总了Java中org.bouncycastle.crypto.PBEParametersGenerator.generateDerivedMacParameters方法的典型用法代码示例。如果您正苦于以下问题:Java PBEParametersGenerator.generateDerivedMacParameters方法的具体用法?Java PBEParametersGenerator.generateDerivedMacParameters怎么用?Java PBEParametersGenerator.generateDerivedMacParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.crypto.PBEParametersGenerator的用法示例。


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

示例1: makePBEMacParameters

import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
/**
 * generate a PBE based key suitable for a MAC algorithm, the
 * key size is chosen according the MAC size, or the hashing algorithm,
 * whichever is greater.
 */
public static CipherParameters makePBEMacParameters(
    PBEKeySpec keySpec,
    int type,
    int hash,
    int keySize)
{
    PBEParametersGenerator  generator = makePBEGenerator(type, hash);
    byte[]                  key;
    CipherParameters        param;
    
    key = convertPassword(type, keySpec);
    
    generator.init(key, keySpec.getSalt(), keySpec.getIterationCount());
    
    param = generator.generateDerivedMacParameters(keySize);
    
    for (int i = 0; i != key.length; i++)
    {
        key[i] = 0;
    }
    
    return param;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:29,代码来源:PBE.java

示例2: makePBEMacParameters

import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
/**
 * generate a PBE based key suitable for a MAC algorithm, the
 * key size is chosen according the MAC size, or the hashing algorithm,
 * whichever is greater.
 */
public static CipherParameters makePBEMacParameters(
    BCPBEKey pbeKey,
    AlgorithmParameterSpec spec)
{
    if ((spec == null) || !(spec instanceof PBEParameterSpec))
    {
        throw new IllegalArgumentException("Need a PBEParameter spec with a PBE key.");
    }
    
    PBEParameterSpec        pbeParam = (PBEParameterSpec)spec;
    PBEParametersGenerator  generator = makePBEGenerator(pbeKey.getType(), pbeKey.getDigest());
    byte[]                  key = pbeKey.getEncoded();
    CipherParameters        param;
    
    generator.init(key, pbeParam.getSalt(), pbeParam.getIterationCount());

    param = generator.generateDerivedMacParameters(pbeKey.getKeySize());
    
    for (int i = 0; i != key.length; i++)
    {
        key[i] = 0;
    }

    return param;
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:31,代码来源:PBE.java

示例3: makePBEMacParameters

import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
/**
 * generate a PBE based key suitable for a MAC algorithm, the
 * key size is chosen according the MAC size, or the hashing algorithm,
 * whichever is greater.
 */
public static CipherParameters makePBEMacParameters(
    PBEKeySpec keySpec,
    int type,
    int hash,
    int keySize)
{
    PBEParametersGenerator  generator = makePBEGenerator(type, hash);
    byte[]                  key;
    CipherParameters        param;
    
    key = convertPassword(type, keySpec);
    
    generator.init(key, keySpec.getSalt(), keySpec.getIterationCount());

    param = generator.generateDerivedMacParameters(keySize);

    for (int i = 0; i != key.length; i++)
    {
        key[i] = 0;
    }
    
    return param;
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:29,代码来源:PBE.java

示例4: makePBEMacParameters

import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
/**
 * generate a PBE based key suitable for a MAC algorithm, the
 * key size is chosen according the MAC size, or the hashing algorithm,
 * whichever is greater.
 */
static CipherParameters makePBEMacParameters(
    JCEPBEKey               pbeKey,
    AlgorithmParameterSpec  spec)
{
    if ((spec == null) || !(spec instanceof PBEParameterSpec))
    {
        throw new IllegalArgumentException("Need a PBEParameter spec with a PBE key.");
    }
    
    PBEParameterSpec        pbeParam = (PBEParameterSpec)spec;
    PBEParametersGenerator  generator = makePBEGenerator(pbeKey.getType(), pbeKey.getDigest());
    byte[]                  key = pbeKey.getEncoded();
    CipherParameters        param;
    
    if (pbeKey.shouldTryWrongPKCS12())
    {
        key = new byte[2];
    }
    
    generator.init(key, pbeParam.getSalt(), pbeParam.getIterationCount());

    param = generator.generateDerivedMacParameters(pbeKey.getKeySize());
    
    for (int i = 0; i != key.length; i++)
    {
        key[i] = 0;
    }

    return param;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:36,代码来源:PBE.java

示例5: makePBEMacParameters

import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
/**
 * generate a PBE based key suitable for a MAC algorithm, the
 * key size is chosen according the MAC size, or the hashing algorithm,
 * whichever is greater.
 */
static CipherParameters makePBEMacParameters(
    BCPBEKey pbeKey,
    AlgorithmParameterSpec  spec,
    int                     type,
    int                     hash,
    int                     keySize)
{
    if ((spec == null) || !(spec instanceof PBEParameterSpec))
    {
        throw new IllegalArgumentException("Need a PBEParameter spec with a PBE key.");
    }
    
    PBEParameterSpec        pbeParam = (PBEParameterSpec)spec;
    PBEParametersGenerator  generator = makePBEGenerator(type, hash);
    byte[]                  key = pbeKey.getEncoded();
    CipherParameters        param;
    
    generator.init(key, pbeParam.getSalt(), pbeParam.getIterationCount());

    param = generator.generateDerivedMacParameters(keySize);
    
    for (int i = 0; i != key.length; i++)
    {
        key[i] = 0;
    }

    return param;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:34,代码来源:BrokenPBE.java

示例6: SingleIterationPBKDF2

import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
private static byte[] SingleIterationPBKDF2(byte[] P, byte[] S, int dkLen)
{
    PBEParametersGenerator pGen = new PKCS5S2ParametersGenerator(new SHA256Digest());
    pGen.init(P, S, 1);
    KeyParameter key = (KeyParameter) pGen.generateDerivedMacParameters(dkLen * 8);
    return key.getKey();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:8,代码来源:SCrypt.java

示例7: run3

import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
private TestResult run3(
    int     id,
    char[]  password,
    byte[]  salt,
    int     iCount,
    byte[]  result)
{
    PBEParametersGenerator  generator = new PKCS12ParametersGenerator(
                                                new SHA1Digest());

    generator.init(
            PBEParametersGenerator.PKCS12PasswordToBytes(password),
            salt,
            iCount);

    CipherParameters  key = generator.generateDerivedMacParameters(160);

    if (isEqual(result, ((KeyParameter)key).getKey()))
    {
        return new SimpleTestResult(true, "PKCS12Test: Okay");
    }
    else
    {
        return new SimpleTestResult(false, "PKCS12Test: id "
                                                + id + " Failed");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:28,代码来源:PKCS12Test.java


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