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


Java PBEParametersGenerator.PKCS5PasswordToBytes方法代码示例

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


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

示例1: convertPassword

import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
private static byte[] convertPassword(int type, PBEKeySpec keySpec)
{
    byte[] key;

    if (type == PKCS12)
    {
        key = PBEParametersGenerator.PKCS12PasswordToBytes(keySpec.getPassword());
    }
    else if (type == PKCS5S2_UTF8 || type == PKCS5S1_UTF8)
    {
        key = PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(keySpec.getPassword());
    }
    else
    {
        key = PBEParametersGenerator.PKCS5PasswordToBytes(keySpec.getPassword());
    }
    return key;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:19,代码来源:PBE.java

示例2: makePBEParameters

import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
/**
 * construct a key and iv (if necessary) suitable for use with a 
 * Cipher.
 */
static CipherParameters makePBEParameters(
    PBEKeySpec              keySpec,
    int                     type,
    int                     hash,
    int                     keySize,
    int                     ivSize)
{    
    PBEParametersGenerator  generator = makePBEGenerator(type, hash);
    byte[]                  key;
    CipherParameters        param;
    
    if (type == PKCS12)
    {
        key = PBEParametersGenerator.PKCS12PasswordToBytes(keySpec.getPassword());
    }
    else
    {   
        key = PBEParametersGenerator.PKCS5PasswordToBytes(keySpec.getPassword());
    }
    
    generator.init(key, keySpec.getSalt(), keySpec.getIterationCount());
    
    if (ivSize != 0)
    {
        param = generator.generateDerivedParameters(keySize, ivSize);
    }
    else
    {
        param = generator.generateDerivedParameters(keySize);
    }
    
    for (int i = 0; i != key.length; i++)
    {
        key[i] = 0;
    }
    
    return param;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:43,代码来源: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.
 */
static CipherParameters makePBEMacParameters(
    PBEKeySpec              keySpec,
    int                     type,
    int                     hash,
    int                     keySize)
{
    PBEParametersGenerator  generator = makePBEGenerator(type, hash);
    byte[]                  key;
    CipherParameters        param;
    
    if (type == PKCS12)
    {
        key = PBEParametersGenerator.PKCS12PasswordToBytes(keySpec.getPassword());
    }
    else
    {   
        key = PBEParametersGenerator.PKCS5PasswordToBytes(keySpec.getPassword());
    }
    
    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:PhilippC,项目名称:keepass2android,代码行数:36,代码来源:PBE.java

示例4: getPasswordBytes

import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
protected byte[] getPasswordBytes(int scheme, char[] password)
{
    if (scheme == PasswordRecipient.PKCS5_SCHEME2)
    {
        return PBEParametersGenerator.PKCS5PasswordToBytes(password);
    }

    return PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(password);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:10,代码来源:PasswordRecipientInformation.java

示例5: getEncoded

import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
public byte[] getEncoded()
{
    if (param != null)
    {
        KeyParameter    kParam;
        
        if (param instanceof ParametersWithIV)
        {
            kParam = (KeyParameter)((ParametersWithIV)param).getParameters();
        }
        else
        {
            kParam = (KeyParameter)param;
        }
        
        return kParam.getKey();
    }
    else
    {
        if (type == PBE.PKCS12)
        {
            return PBEParametersGenerator.PKCS12PasswordToBytes(pbeKeySpec.getPassword());
        }
        else
        {   
            return PBEParametersGenerator.PKCS5PasswordToBytes(pbeKeySpec.getPassword());
        }
    }
}
 
开发者ID:FSteitz,项目名称:KeePass2Android,代码行数:30,代码来源:JCEPBEKey.java

示例6: calculateDerivedKey

import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
protected byte[] calculateDerivedKey(int schemeID, AlgorithmIdentifier derivationAlgorithm, int keySize)
    throws CMSException
{
    PBKDF2Params params = PBKDF2Params.getInstance(derivationAlgorithm.getParameters());
    byte[] encodedPassword = (schemeID == PasswordRecipient.PKCS5_SCHEME2) ? PBEParametersGenerator.PKCS5PasswordToBytes(password) : PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(password);

    PKCS5S2ParametersGenerator gen = new PKCS5S2ParametersGenerator();

    gen.init(encodedPassword, params.getSalt(), params.getIterationCount().intValue());

    return ((KeyParameter)gen.generateDerivedParameters(keySize)).getKey();
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:13,代码来源:BcPasswordRecipientInfoGenerator.java

示例7: calculateDerivedKey

import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
public byte[] calculateDerivedKey(int schemeID, AlgorithmIdentifier derivationAlgorithm, int keySize)
    throws CMSException
{
    PBKDF2Params params = PBKDF2Params.getInstance(derivationAlgorithm.getParameters());
    byte[] encodedPassword = (schemeID == PasswordRecipient.PKCS5_SCHEME2) ? PBEParametersGenerator.PKCS5PasswordToBytes(password) : PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(password);

    PKCS5S2ParametersGenerator gen = new PKCS5S2ParametersGenerator();

    gen.init(encodedPassword, params.getSalt(), params.getIterationCount().intValue());

    return ((KeyParameter)gen.generateDerivedParameters(keySize)).getKey();
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:13,代码来源:BcPasswordRecipient.java

示例8: getEncoded

import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
public byte[] getEncoded()
{
    if (param != null)
    {
        KeyParameter    kParam;
        
        if (param instanceof ParametersWithIV)
        {
            kParam = (KeyParameter)((ParametersWithIV)param).getParameters();
        }
        else
        {
            kParam = (KeyParameter)param;
        }
        
        return kParam.getKey();
    }
    else
    {
        if (type == PBE.PKCS12)
        {
            return PBEParametersGenerator.PKCS12PasswordToBytes(pbeKeySpec.getPassword());
        }
        else if (type == PBE.PKCS5S2_UTF8)
        {
            return PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(pbeKeySpec.getPassword());
        }
        else
        {   
            return PBEParametersGenerator.PKCS5PasswordToBytes(pbeKeySpec.getPassword());
        }
    }
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:34,代码来源:BCPBEKey.java

示例9: toBytes

import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected byte[] toBytes(final char[] password) {
	return PBEParametersGenerator.PKCS5PasswordToBytes(password);
}
 
开发者ID:shivam091,项目名称:Java-Security,代码行数:5,代码来源:PBKDF2KeyGenerator.java


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