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


Java KeyGenerationParameters类代码示例

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


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

示例1: generateDESKey

import org.bouncycastle.crypto.KeyGenerationParameters; //导入依赖的package包/类
/**
 * Generate des key.
 *
 * @param file the file
 * @throws java.io.IOException Signals that an I/O exception has occurred.
 */
public static void generateDESKey(String file) throws IOException {
    DESedeKeyGenerator kg = new DESedeKeyGenerator();
    KeyGenerationParameters kgp = new KeyGenerationParameters(
            new SecureRandom(),
            DESedeParameters.DES_EDE_KEY_LENGTH * 8);
    kg.init(kgp);
    byte[] key = kg.generateKey();
    BufferedOutputStream keystream =
            new BufferedOutputStream(new FileOutputStream(file));
    byte[] keyhex = Hex.encode(key);
    keystream.write(keyhex, 0, keyhex.length);
    keystream.flush();
    keystream.close();
}
 
开发者ID:oneops,项目名称:oneops,代码行数:21,代码来源:CmsCryptoDES.java

示例2: init

import org.bouncycastle.crypto.KeyGenerationParameters; //导入依赖的package包/类
/**
 * initialise the key generator - if strength is set to zero
 * the key generated will be 192 bits in size, otherwise
 * strength can be 128 or 192 (or 112 or 168 if you don't count
 * parity bits), depending on whether you wish to do 2-key or 3-key
 * triple DES.
 *
 * @param param the parameters to be used for key generation
 */
public void init(
    KeyGenerationParameters param)
{
    this.random = param.getRandom();
    this.strength = (param.getStrength() + 7) / 8;

    if (strength == 0 || strength == (168 / 8))
    {
        strength = DESedeParameters.DES_EDE_KEY_LENGTH;
    }
    else if (strength == (112 / 8))
    {
        strength = 2 * DESedeParameters.DES_KEY_LENGTH;
    }
    else if (strength != DESedeParameters.DES_EDE_KEY_LENGTH
            && strength != (2 * DESedeParameters.DES_KEY_LENGTH))
    {
        throw new IllegalArgumentException("DESede key must be "
            + (DESedeParameters.DES_EDE_KEY_LENGTH * 8) + " or "
            + (2 * 8 * DESedeParameters.DES_KEY_LENGTH)
            + " bits long.");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:33,代码来源:DESedeKeyGenerator.java

示例3: init

import org.bouncycastle.crypto.KeyGenerationParameters; //导入依赖的package包/类
/**
 * initialise the key generator - if strength is set to zero
 * the key generated will be 64 bits in size, otherwise
 * strength can be 64 or 56 bits (if you don't count the parity bits).
 *
 * @param param the parameters to be used for key generation
 */
public void init(
    KeyGenerationParameters param)
{
    super.init(param);

    if (strength == 0 || strength == (56 / 8))
    {
        strength = DESParameters.DES_KEY_LENGTH;
    }
    else if (strength != DESParameters.DES_KEY_LENGTH)
    {
        throw new IllegalArgumentException("DES key must be "
                + (DESParameters.DES_KEY_LENGTH * 8)
                + " bits long.");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:24,代码来源:DESKeyGenerator.java

示例4: engineGenerateKey

import org.bouncycastle.crypto.KeyGenerationParameters; //导入依赖的package包/类
protected SecretKey engineGenerateKey()
{
    if (uninitialised)
    {
        engine.init(new KeyGenerationParameters(new SecureRandom(), defaultKeySize));
        uninitialised = false;
    }

    //
    // if no key size has been defined generate a 24 byte key in
    // the a-b-a format
    //
    if (!keySizeSet)
    {
        byte[]     k = engine.generateKey();

        System.arraycopy(k, 0, k, 16, 8);

        return new SecretKeySpec(k, algName);
    }
    else
    {
        return new SecretKeySpec(engine.generateKey(), algName);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:26,代码来源:DESede.java

示例5: init

import org.bouncycastle.crypto.KeyGenerationParameters; //导入依赖的package包/类
/**
 * initialise the key generator - if strength is set to zero
 * the key generated will be 192 bits in size, otherwise
 * strength can be 128 or 192 (or 112 or 168 if you don't count
 * parity bits), depending on whether you wish to do 2-key or 3-key
 * triple DES.
 *
 * @param param the parameters to be used for key generation
 */
public void init(
    KeyGenerationParameters param)
{
    super.init(param);

    if (strength == 0 || strength == (168 / 8))
    {
        strength = DESedeParameters.DES_EDE_KEY_LENGTH;
    }
    else if (strength == (112 / 8))
    {
        strength = 2 * DESedeParameters.DES_KEY_LENGTH;
    }
    else if (strength != DESedeParameters.DES_EDE_KEY_LENGTH
            && strength != (2 * DESedeParameters.DES_KEY_LENGTH))
    {
        throw new IllegalArgumentException("DESede key must be "
            + (DESedeParameters.DES_EDE_KEY_LENGTH * 8) + " or "
            + (2 * 8 * DESedeParameters.DES_KEY_LENGTH)
            + " bits long.");
    }
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:32,代码来源:DESedeKeyGenerator.java

示例6: create

import org.bouncycastle.crypto.KeyGenerationParameters; //导入依赖的package包/类
public static KeyGenerator create() {
  final SecureRandom random = new SecureRandom();
  final KeyGenerationParameters parameters = new KeyGenerationParameters(
      random,
      DESedeParameters.DES_EDE_KEY_LENGTH * 8);
  final DESedeKeyGenerator keyGenerator = new DESedeKeyGenerator();
  keyGenerator.init(parameters);
  return new KeyGenerator(keyGenerator);
}
 
开发者ID:AndreasWBartels,项目名称:libraries,代码行数:10,代码来源:KeyGenerator.java

示例7: engineInit

import org.bouncycastle.crypto.KeyGenerationParameters; //导入依赖的package包/类
protected void engineInit(
    int             keySize,
    SecureRandom    random)
{
    try
    {
        if (random == null)
        {
            random = new SecureRandom();
        }
        engine.init(new KeyGenerationParameters(random, keySize));
        uninitialised = false;
    }
    catch (IllegalArgumentException e)
    {
        throw new InvalidParameterException(e.getMessage());
    }
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:19,代码来源:BaseKeyGenerator.java

示例8: init

import org.bouncycastle.crypto.KeyGenerationParameters; //导入依赖的package包/类
@Override
public void init(final KeyGenerationParameters params)
{
	strength = 0;
	random = null;

	if (params != null) {
		strength = params.getStrength();
		random = params.getRandom();
	}

	if (strength < 1)
		strength = 256;

	if (random == null)
		random = new SecureRandom();

	strengthInBytes = (strength + 7) / 8;
}
 
开发者ID:subshare,项目名称:subshare,代码行数:20,代码来源:SecretKeyGeneratorImpl.java

示例9: initialize

import org.bouncycastle.crypto.KeyGenerationParameters; //导入依赖的package包/类
/**
 * Initalizes the key pair generator using a parameter set as input
 */
public void initialize(KeyGenerationParameters param)
{

    this.gmssParams = (GMSSKeyGenerationParameters)param;

    // generate GMSSParameterset
    this.gmssPS = new GMSSParameters(gmssParams.getParameters().getNumOfLayers(), gmssParams.getParameters().getHeightOfTrees(),
        gmssParams.getParameters().getWinternitzParameter(), gmssParams.getParameters().getK());

    this.numLayer = gmssPS.getNumOfLayers();
    this.heightOfTrees = gmssPS.getHeightOfTrees();
    this.otsIndex = gmssPS.getWinternitzParameter();
    this.K = gmssPS.getK();

    // seeds
    this.currentSeeds = new byte[numLayer][mdLength];
    this.nextNextSeeds = new byte[numLayer - 1][mdLength];

    // construct SecureRandom for initial seed generation
    SecureRandom secRan = new SecureRandom();

    // generation of initial seeds
    for (int i = 0; i < numLayer; i++)
    {
        secRan.nextBytes(currentSeeds[i]);
        gmssRandom.nextSeed(currentSeeds[i]);
    }

    this.initialized = true;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:34,代码来源:GMSSKeyPairGenerator.java

示例10: initializeDefault

import org.bouncycastle.crypto.KeyGenerationParameters; //导入依赖的package包/类
/**
 * This method is called by generateKeyPair() in case that no other
 * initialization method has been called by the user
 */
private void initializeDefault()
{
    int[] defh = {10, 10, 10, 10};
    int[] defw = {3, 3, 3, 3};
    int[] defk = {2, 2, 2, 2};

    KeyGenerationParameters kgp = new GMSSKeyGenerationParameters(new SecureRandom(), new GMSSParameters(defh.length, defh, defw, defk));
    this.initialize(kgp);

}
 
开发者ID:Appdome,项目名称:ipack,代码行数:15,代码来源:GMSSKeyPairGenerator.java

示例11: initialize

import org.bouncycastle.crypto.KeyGenerationParameters; //导入依赖的package包/类
public void initialize(
    KeyGenerationParameters param)
{
    this.rainbowParams = (RainbowKeyGenerationParameters)param;

    // set source of randomness
    this.sr = new SecureRandom();

    // unmarshalling:
    this.vi = this.rainbowParams.getParameters().getVi();
    this.numOfLayers = this.rainbowParams.getParameters().getNumOfLayers();

    this.initialized = true;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:15,代码来源:RainbowKeyPairGenerator.java

示例12: initialize

import org.bouncycastle.crypto.KeyGenerationParameters; //导入依赖的package包/类
private void initialize(
    KeyGenerationParameters param)
{
    this.mcElieceParams = (McElieceKeyGenerationParameters)param;

    // set source of randomness
    this.random = new SecureRandom();

    this.m = this.mcElieceParams.getParameters().getM();
    this.n = this.mcElieceParams.getParameters().getN();
    this.t = this.mcElieceParams.getParameters().getT();
    this.fieldPoly = this.mcElieceParams.getParameters().getFieldPoly();
    this.initialized = true;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:15,代码来源:McElieceKeyPairGenerator.java

示例13: init

import org.bouncycastle.crypto.KeyGenerationParameters; //导入依赖的package包/类
public void init(
    KeyGenerationParameters param)
{
    this.mcElieceCCA2Params = (McElieceCCA2KeyGenerationParameters)param;

    // set source of randomness
    this.random = new SecureRandom();

    this.m = this.mcElieceCCA2Params.getParameters().getM();
    this.n = this.mcElieceCCA2Params.getParameters().getN();
    this.t = this.mcElieceCCA2Params.getParameters().getT();
    this.fieldPoly = this.mcElieceCCA2Params.getParameters().getFieldPoly();
    this.initialized = true;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:15,代码来源:McElieceCCA2KeyPairGenerator.java

示例14: init

import org.bouncycastle.crypto.KeyGenerationParameters; //导入依赖的package包/类
public void init(
    KeyGenerationParameters param)
{
    ECKeyGenerationParameters  ecP = (ECKeyGenerationParameters)param;

    this.random = ecP.getRandom();
    this.params = ecP.getDomainParameters();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:9,代码来源:ECKeyPairGenerator.java

示例15: engineGenerateKey

import org.bouncycastle.crypto.KeyGenerationParameters; //导入依赖的package包/类
protected SecretKey engineGenerateKey()
{
    if (uninitialised)
    {
        engine.init(new KeyGenerationParameters(new SecureRandom(), defaultKeySize));
        uninitialised = false;
    }

    return new SecretKeySpec(engine.generateKey(), algName);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:11,代码来源:DES.java


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