Java 类org.bouncycastle.crypto.params.DSAParameterGenerationParameters 实例源码

项目:ipack    文件:DSAParametersGenerator.java   
/**
 * Initialise the key generator for DSA 2.
 * <p>
 *     Use this init method if you need to generate parameters for DSA 2 keys.
 * </p>
 *
 * @param params  DSA 2 key generation parameters.
 */
public void init(
    DSAParameterGenerationParameters params)
{
    // TODO Should we enforce the minimum 'certainty' values as per C.3 Table C.1?
    this.use186_3 = true;
    this.L = params.getL();
    this.N = params.getN();
    this.certainty = params.getCertainty();
    this.random = params.getRandom();
    this.usageIndex = params.getUsageIndex();

    if ((L < 1024 || L > 3072) || L % 1024 != 0)
    {
        throw new IllegalArgumentException("L values must be between 1024 and 3072 and a multiple of 1024");
    }
    else if (L == 1024 && N != 160)
    {
        throw new IllegalArgumentException("N must be 160 for L = 1024");
    }
    else if (L == 2048 && (N != 224 && N != 256))
    {
        throw new IllegalArgumentException("N must be 224 or 256 for L = 2048");
    }
    else if (L == 3072 && N != 256)
    {
        throw new IllegalArgumentException("N must be 256 for L = 3072");
    }

    if (digest.getDigestSize() * 8 < N)
    {
        throw new IllegalStateException("Digest output size too small for value of N");
    }
}
项目:xitk    文件:DSAParameterCache.java   
public static DSAParameterSpec getNewDSAParameterSpec(int plength, int qlength,
        SecureRandom random) {
    final int certainty = 80;
    SecureRandom tmpRandom = (random == null) ? new SecureRandom() : random;
    DSAParametersGenerator paramGen = new DSAParametersGenerator(new SHA512Digest());
    DSAParameterGenerationParameters genParams = new DSAParameterGenerationParameters(
            plength, qlength, certainty, tmpRandom);
    paramGen.init(genParams);
    DSAParameters dsaParams = paramGen.generateParameters();
    return new DSAParameterSpec(dsaParams.getP(), dsaParams.getQ(), dsaParams.getG());
}
项目:gwt-crypto    文件:DSAParametersGenerator.java   
/**
 * Initialise the key generator for DSA 2.
 * <p>
 *     Use this init method if you need to generate parameters for DSA 2 keys.
 * </p>
 *
 * @param params  DSA 2 key generation parameters.
 */
public void init(
    DSAParameterGenerationParameters params)
{
    int L = params.getL(), N = params.getN();

    if ((L < 1024 || L > 3072) || L % 1024 != 0)
    {
        throw new IllegalArgumentException("L values must be between 1024 and 3072 and a multiple of 1024");
    }
    else if (L == 1024 && N != 160)
    {
        throw new IllegalArgumentException("N must be 160 for L = 1024");
    }
    else if (L == 2048 && (N != 224 && N != 256))
    {
        throw new IllegalArgumentException("N must be 224 or 256 for L = 2048");
    }
    else if (L == 3072 && N != 256)
    {
        throw new IllegalArgumentException("N must be 256 for L = 3072");
    }

    if (digest.getDigestSize() * 8 < N)
    {
        throw new IllegalStateException("Digest output size too small for value of N");
    }

    this.L = L;
    this.N = N;
    this.certainty = params.getCertainty();
    this.iterations = Math.max(getMinimumIterations(L), (certainty + 1) / 2);
    this.random = params.getRandom();
    this.use186_3 = true;
    this.usageIndex = params.getUsageIndex();
}
项目:Aki-SSL    文件:DSAParametersGenerator.java   
/**
 * Initialise the key generator for DSA 2.
 * <p>
 *     Use this init method if you need to generate parameters for DSA 2 keys.
 * </p>
 *
 * @param params  DSA 2 key generation parameters.
 */
public void init(
    DSAParameterGenerationParameters params)
{
    int L = params.getL(), N = params.getN();

    if ((L < 1024 || L > 3072) || L % 1024 != 0)
    {
        throw new IllegalArgumentException("L values must be between 1024 and 3072 and a multiple of 1024");
    }
    else if (L == 1024 && N != 160)
    {
        throw new IllegalArgumentException("N must be 160 for L = 1024");
    }
    else if (L == 2048 && (N != 224 && N != 256))
    {
        throw new IllegalArgumentException("N must be 224 or 256 for L = 2048");
    }
    else if (L == 3072 && N != 256)
    {
        throw new IllegalArgumentException("N must be 256 for L = 3072");
    }

    if (digest.getDigestSize() * 8 < N)
    {
        throw new IllegalStateException("Digest output size too small for value of N");
    }

    this.L = L;
    this.N = N;
    this.certainty = params.getCertainty();
    this.iterations = Math.max(getMinimumIterations(L), (certainty + 1) / 2);
    this.random = params.getRandom();
    this.use186_3 = true;
    this.usageIndex = params.getUsageIndex();
}
项目:TinyTravelTracker    文件:DSAParametersGenerator.java   
/**
 * Initialise the key generator for DSA 2.
 * <p>
 *     Use this init method if you need to generate parameters for DSA 2 keys.
 * </p>
 *
 * @param params  DSA 2 key generation parameters.
 */
public void init(
    DSAParameterGenerationParameters params)
{
    // TODO Should we enforce the minimum 'certainty' values as per C.3 Table C.1?
    this.use186_3 = true;
    this.L = params.getL();
    this.N = params.getN();
    this.certainty = params.getCertainty();
    this.random = params.getRandom();
    this.usageIndex = params.getUsageIndex();

    if ((L < 1024 || L > 3072) || L % 1024 != 0)
    {
        throw new IllegalArgumentException("L values must be between 1024 and 3072 and a multiple of 1024");
    }
    else if (L == 1024 && N != 160)
    {
        throw new IllegalArgumentException("N must be 160 for L = 1024");
    }
    else if (L == 2048 && (N != 224 && N != 256))
    {
        throw new IllegalArgumentException("N must be 224 or 256 for L = 2048");
    }
    else if (L == 3072 && N != 256)
    {
        throw new IllegalArgumentException("N must be 256 for L = 3072");
    }

    if (digest.getDigestSize() * 8 < N)
    {
        throw new IllegalStateException("Digest output size too small for value of N");
    }
}
项目:CryptMeme    文件:DSAParametersGenerator.java   
/**
 * Initialise the key generator for DSA 2.
 * <p>
 *     Use this init method if you need to generate parameters for DSA 2 keys.
 * </p>
 *
 * @param params  DSA 2 key generation parameters.
 */
public void init(
    DSAParameterGenerationParameters params)
{
    // TODO Should we enforce the minimum 'certainty' values as per C.3 Table C.1?
    this.use186_3 = true;
    this.L = params.getL();
    this.N = params.getN();
    this.certainty = params.getCertainty();
    this.random = params.getRandom();
    this.usageIndex = params.getUsageIndex();

    if ((L < 1024 || L > 3072) || L % 1024 != 0)
    {
        throw new IllegalArgumentException("L values must be between 1024 and 3072 and a multiple of 1024");
    }
    else if (L == 1024 && N != 160)
    {
        throw new IllegalArgumentException("N must be 160 for L = 1024");
    }
    else if (L == 2048 && (N != 224 && N != 256))
    {
        throw new IllegalArgumentException("N must be 224 or 256 for L = 2048");
    }
    else if (L == 3072 && N != 256)
    {
        throw new IllegalArgumentException("N must be 256 for L = 3072");
    }

    if (digest.getDigestSize() * 8 < N)
    {
        throw new IllegalStateException("Digest output size too small for value of N");
    }
}
项目:irma_future_id    文件:DSAParametersGenerator.java   
/**
 * Initialise the key generator for DSA 2.
 * <p>
 *     Use this init method if you need to generate parameters for DSA 2 keys.
 * </p>
 *
 * @param params  DSA 2 key generation parameters.
 */
public void init(
    DSAParameterGenerationParameters params)
{
    // TODO Should we enforce the minimum 'certainty' values as per C.3 Table C.1?
    this.use186_3 = true;
    this.L = params.getL();
    this.N = params.getN();
    this.certainty = params.getCertainty();
    this.random = params.getRandom();
    this.usageIndex = params.getUsageIndex();

    if ((L < 1024 || L > 3072) || L % 1024 != 0)
    {
        throw new IllegalArgumentException("L values must be between 1024 and 3072 and a multiple of 1024");
    }
    else if (L == 1024 && N != 160)
    {
        throw new IllegalArgumentException("N must be 160 for L = 1024");
    }
    else if (L == 2048 && (N != 224 && N != 256))
    {
        throw new IllegalArgumentException("N must be 224 or 256 for L = 2048");
    }
    else if (L == 3072 && N != 256)
    {
        throw new IllegalArgumentException("N must be 256 for L = 3072");
    }

    if (digest.getDigestSize() * 8 < N)
    {
        throw new IllegalStateException("Digest output size too small for value of N");
    }
}
项目:bc-java    文件:DSAParametersGenerator.java   
/**
 * Initialise the key generator for DSA 2.
 * <p>
 *     Use this init method if you need to generate parameters for DSA 2 keys.
 * </p>
 *
 * @param params  DSA 2 key generation parameters.
 */
public void init(
    DSAParameterGenerationParameters params)
{
    // TODO Should we enforce the minimum 'certainty' values as per C.3 Table C.1?
    this.use186_3 = true;
    this.L = params.getL();
    this.N = params.getN();
    this.certainty = params.getCertainty();
    this.random = params.getRandom();
    this.usageIndex = params.getUsageIndex();

    if ((L < 1024 || L > 3072) || L % 1024 != 0)
    {
        throw new IllegalArgumentException("L values must be between 1024 and 3072 and a multiple of 1024");
    }
    else if (L == 1024 && N != 160)
    {
        throw new IllegalArgumentException("N must be 160 for L = 1024");
    }
    else if (L == 2048 && (N != 224 && N != 256))
    {
        throw new IllegalArgumentException("N must be 224 or 256 for L = 2048");
    }
    else if (L == 3072 && N != 256)
    {
        throw new IllegalArgumentException("N must be 256 for L = 3072");
    }

    if (digest.getDigestSize() * 8 < N)
    {
        throw new IllegalStateException("Digest output size too small for value of N");
    }
}