java.security.spec.DSAGenParameterSpec Java Examples
The following examples show how to use
java.security.spec.DSAGenParameterSpec.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DSAParameterGenerator.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Initializes this parameter generator with a set of * algorithm-specific parameter generation values. * * @param genParamSpec the set of algorithm-specific parameter * generation values * @param random the source of randomness * * @exception InvalidAlgorithmParameterException if the given parameter * generation values are inappropriate for this parameter generator */ @Override protected void engineInit(AlgorithmParameterSpec genParamSpec, SecureRandom random) throws InvalidAlgorithmParameterException { if (!(genParamSpec instanceof DSAGenParameterSpec)) { throw new InvalidAlgorithmParameterException("Invalid parameter"); } DSAGenParameterSpec dsaGenParams = (DSAGenParameterSpec)genParamSpec; // directly initialize using the already validated values this.valueL = dsaGenParams.getPrimePLength(); this.valueN = dsaGenParams.getSubprimeQLength(); this.seedLen = dsaGenParams.getSeedLength(); this.random = random; }
Example #2
Source File: DSAParameterGenerator.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Initializes this parameter generator with a set of * algorithm-specific parameter generation values. * * @param genParamSpec the set of algorithm-specific parameter generation values * @param random the source of randomness * * @exception InvalidAlgorithmParameterException if the given parameter * generation values are inappropriate for this parameter generator */ protected void engineInit(AlgorithmParameterSpec genParamSpec, SecureRandom random) throws InvalidAlgorithmParameterException { if (!(genParamSpec instanceof DSAGenParameterSpec)) { throw new InvalidAlgorithmParameterException("Invalid parameter"); } DSAGenParameterSpec dsaGenParams = (DSAGenParameterSpec) genParamSpec; int primePLen = dsaGenParams.getPrimePLength(); if (primePLen > 2048) { throw new InvalidParameterException ("No support for prime size " + primePLen); } // directly initialize using the already validated values this.valueL = primePLen; this.valueN = dsaGenParams.getSubprimeQLength(); this.seedLen = dsaGenParams.getSeedLength(); this.random = random; }
Example #3
Source File: DSAParameterGenerator.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Initializes this parameter generator with a set of * algorithm-specific parameter generation values. * * @param genParamSpec the set of algorithm-specific parameter generation values * @param random the source of randomness * * @exception InvalidAlgorithmParameterException if the given parameter * generation values are inappropriate for this parameter generator */ protected void engineInit(AlgorithmParameterSpec genParamSpec, SecureRandom random) throws InvalidAlgorithmParameterException { if (!(genParamSpec instanceof DSAGenParameterSpec)) { throw new InvalidAlgorithmParameterException("Invalid parameter"); } DSAGenParameterSpec dsaGenParams = (DSAGenParameterSpec) genParamSpec; int primePLen = dsaGenParams.getPrimePLength(); if (primePLen > 2048) { throw new InvalidParameterException ("No support for prime size " + primePLen); } // directly initialize using the already validated values this.valueL = primePLen; this.valueN = dsaGenParams.getSubprimeQLength(); this.seedLen = dsaGenParams.getSeedLength(); this.random = random; }
Example #4
Source File: TestAlgParameterGenerator.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
private static void checkParamStrength(AlgorithmParameters param, DSAGenParameterSpec genParam) throws Exception { String algo = param.getAlgorithm(); if (!algo.equalsIgnoreCase("DSA")) { throw new RuntimeException("Unexpected type of parameters: " + algo); } DSAParameterSpec spec = param.getParameterSpec(DSAParameterSpec.class); int valueL = spec.getP().bitLength(); int strength = genParam.getPrimePLength(); if (strength != valueL) { System.out.println("P: Expected " + strength + " but actual " + valueL); throw new RuntimeException("Wrong P strength"); } int valueN = spec.getQ().bitLength(); strength = genParam.getSubprimeQLength(); if (strength != valueN) { System.out.println("Q: Expected " + strength + " but actual " + valueN); throw new RuntimeException("Wrong Q strength"); } }
Example #5
Source File: TestDSAGenParameterSpec.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
private static void testDSAGenParameterSpec(DataTuple dataTuple) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidParameterSpecException, InvalidAlgorithmParameterException { System.out.printf("Test case: primePLen=%d, " + "subprimeQLen=%d%n", dataTuple.primePLen, dataTuple.subprimeQLen); AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance(ALGORITHM_NAME, PROVIDER_NAME); DSAGenParameterSpec genParamSpec = createGenParameterSpec(dataTuple); // genParamSpec will be null if IllegalAE is thrown when expected. if (genParamSpec == null) { return; } try { apg.init(genParamSpec, null); AlgorithmParameters param = apg.generateParameters(); checkParam(param, genParamSpec); System.out.println("Test case passed"); } catch (InvalidParameterException ipe) { throw new RuntimeException("Test case failed.", ipe); } }
Example #6
Source File: DSAParameterGenerator.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Initializes this parameter generator with a set of * algorithm-specific parameter generation values. * * @param genParamSpec the set of algorithm-specific parameter generation values * @param random the source of randomness * * @exception InvalidAlgorithmParameterException if the given parameter * generation values are inappropriate for this parameter generator */ protected void engineInit(AlgorithmParameterSpec genParamSpec, SecureRandom random) throws InvalidAlgorithmParameterException { if (!(genParamSpec instanceof DSAGenParameterSpec)) { throw new InvalidAlgorithmParameterException("Invalid parameter"); } DSAGenParameterSpec dsaGenParams = (DSAGenParameterSpec) genParamSpec; int primePLen = dsaGenParams.getPrimePLength(); if (primePLen > 2048) { throw new InvalidParameterException ("No support for prime size " + primePLen); } // directly initialize using the already validated values this.valueL = primePLen; this.valueN = dsaGenParams.getSubprimeQLength(); this.seedLen = dsaGenParams.getSeedLength(); this.random = random; }
Example #7
Source File: DSAParameterGenerator.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Initializes this parameter generator with a set of * algorithm-specific parameter generation values. * * @param genParamSpec the set of algorithm-specific parameter generation values * @param random the source of randomness * * @exception InvalidAlgorithmParameterException if the given parameter * generation values are inappropriate for this parameter generator */ protected void engineInit(AlgorithmParameterSpec genParamSpec, SecureRandom random) throws InvalidAlgorithmParameterException { if (!(genParamSpec instanceof DSAGenParameterSpec)) { throw new InvalidAlgorithmParameterException("Invalid parameter"); } DSAGenParameterSpec dsaGenParams = (DSAGenParameterSpec) genParamSpec; int primePLen = dsaGenParams.getPrimePLength(); if (primePLen > 2048) { throw new InvalidParameterException ("No support for prime size " + primePLen); } // directly initialize using the already validated values this.valueL = primePLen; this.valueN = dsaGenParams.getSubprimeQLength(); this.seedLen = dsaGenParams.getSeedLength(); this.random = random; }
Example #8
Source File: DSAParameterGenerator.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Initializes this parameter generator with a set of * algorithm-specific parameter generation values. * * @param genParamSpec the set of algorithm-specific parameter generation values * @param random the source of randomness * * @exception InvalidAlgorithmParameterException if the given parameter * generation values are inappropriate for this parameter generator */ protected void engineInit(AlgorithmParameterSpec genParamSpec, SecureRandom random) throws InvalidAlgorithmParameterException { if (!(genParamSpec instanceof DSAGenParameterSpec)) { throw new InvalidAlgorithmParameterException("Invalid parameter"); } DSAGenParameterSpec dsaGenParams = (DSAGenParameterSpec) genParamSpec; int primePLen = dsaGenParams.getPrimePLength(); if (primePLen > 2048) { throw new InvalidParameterException ("No support for prime size " + primePLen); } // directly initialize using the already validated values this.valueL = primePLen; this.valueN = dsaGenParams.getSubprimeQLength(); this.seedLen = dsaGenParams.getSeedLength(); this.random = random; }
Example #9
Source File: DSAParameterGenerator.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Initializes this parameter generator with a set of * algorithm-specific parameter generation values. * * @param genParamSpec the set of algorithm-specific parameter generation values * @param random the source of randomness * * @exception InvalidAlgorithmParameterException if the given parameter * generation values are inappropriate for this parameter generator */ protected void engineInit(AlgorithmParameterSpec genParamSpec, SecureRandom random) throws InvalidAlgorithmParameterException { if (!(genParamSpec instanceof DSAGenParameterSpec)) { throw new InvalidAlgorithmParameterException("Invalid parameter"); } DSAGenParameterSpec dsaGenParams = (DSAGenParameterSpec) genParamSpec; int primePLen = dsaGenParams.getPrimePLength(); if (primePLen > 2048) { throw new InvalidParameterException ("No support for prime size " + primePLen); } // directly initialize using the already validated values this.valueL = primePLen; this.valueN = dsaGenParams.getSubprimeQLength(); this.seedLen = dsaGenParams.getSeedLength(); this.random = random; }
Example #10
Source File: TestAlgParameterGenerator.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static void checkParamStrength(AlgorithmParameters param, DSAGenParameterSpec genParam) throws Exception { String algo = param.getAlgorithm(); if (!algo.equalsIgnoreCase("DSA")) { throw new RuntimeException("Unexpected type of parameters: " + algo); } DSAParameterSpec spec = param.getParameterSpec(DSAParameterSpec.class); int valueL = spec.getP().bitLength(); int strength = genParam.getPrimePLength(); if (strength != valueL) { System.out.println("P: Expected " + strength + " but actual " + valueL); throw new RuntimeException("Wrong P strength"); } int valueN = spec.getQ().bitLength(); strength = genParam.getSubprimeQLength(); if (strength != valueN) { System.out.println("Q: Expected " + strength + " but actual " + valueN); throw new RuntimeException("Wrong Q strength"); } }
Example #11
Source File: TestDSAGenParameterSpec.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static void testDSAGenParameterSpec(DataTuple dataTuple) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidParameterSpecException, InvalidAlgorithmParameterException { System.out.printf("Test case: primePLen=%d, " + "subprimeQLen=%d%n", dataTuple.primePLen, dataTuple.subprimeQLen); AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance(ALGORITHM_NAME, PROVIDER_NAME); DSAGenParameterSpec genParamSpec = createGenParameterSpec(dataTuple); // genParamSpec will be null if IllegalAE is thrown when expected. if (genParamSpec == null) { return; } try { apg.init(genParamSpec, null); AlgorithmParameters param = apg.generateParameters(); checkParam(param, genParamSpec); System.out.println("Test case passed"); } catch (InvalidParameterException ipe) { throw new RuntimeException("Test case failed.", ipe); } }
Example #12
Source File: TestDSAGenParameterSpec.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private static void testDSAGenParameterSpec(DataTuple dataTuple) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidParameterSpecException, InvalidAlgorithmParameterException { System.out.printf("Test case: primePLen=%d, " + "subprimeQLen=%d%n", dataTuple.primePLen, dataTuple.subprimeQLen); AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance(ALGORITHM_NAME, PROVIDER_NAME); DSAGenParameterSpec genParamSpec = createGenParameterSpec(dataTuple); // genParamSpec will be null if IllegalAE is thrown when expected. if (genParamSpec == null) { return; } try { apg.init(genParamSpec, null); AlgorithmParameters param = apg.generateParameters(); checkParam(param, genParamSpec); System.out.println("Test case passed"); } catch (InvalidParameterException ipe) { throw new RuntimeException("Test case failed.", ipe); } }
Example #13
Source File: TestAlgParameterGenerator.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private static void checkParamStrength(AlgorithmParameters param, DSAGenParameterSpec genParam) throws Exception { String algo = param.getAlgorithm(); if (!algo.equalsIgnoreCase("DSA")) { throw new RuntimeException("Unexpected type of parameters: " + algo); } DSAParameterSpec spec = param.getParameterSpec(DSAParameterSpec.class); int valueL = spec.getP().bitLength(); int strength = genParam.getPrimePLength(); if (strength != valueL) { System.out.println("P: Expected " + strength + " but actual " + valueL); throw new RuntimeException("Wrong P strength"); } int valueN = spec.getQ().bitLength(); strength = genParam.getSubprimeQLength(); if (strength != valueN) { System.out.println("Q: Expected " + strength + " but actual " + valueN); throw new RuntimeException("Wrong Q strength"); } }
Example #14
Source File: TestDSAGenParameterSpec.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private static void testDSAGenParameterSpec(DataTuple dataTuple) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidParameterSpecException, InvalidAlgorithmParameterException { System.out.printf("Test case: primePLen=%d, " + "subprimeQLen=%d%n", dataTuple.primePLen, dataTuple.subprimeQLen); AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance(ALGORITHM_NAME, PROVIDER_NAME); DSAGenParameterSpec genParamSpec = createGenParameterSpec(dataTuple); // genParamSpec will be null if IllegalAE is thrown when expected. if (genParamSpec == null) { return; } try { apg.init(genParamSpec, null); AlgorithmParameters param = apg.generateParameters(); checkParam(param, genParamSpec); System.out.println("Test case passed"); } catch (InvalidParameterException ipe) { throw new RuntimeException("Test case failed.", ipe); } }
Example #15
Source File: TestDSAGenParameterSpec.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private static void testDSAGenParameterSpec(DataTuple dataTuple) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidParameterSpecException, InvalidAlgorithmParameterException { System.out.printf("Test case: primePLen=%d, " + "subprimeQLen=%d%n", dataTuple.primePLen, dataTuple.subprimeQLen); AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance(ALGORITHM_NAME, PROVIDER_NAME); DSAGenParameterSpec genParamSpec = createGenParameterSpec(dataTuple); // genParamSpec will be null if IllegalAE is thrown when expected. if (genParamSpec == null) { return; } try { apg.init(genParamSpec, null); AlgorithmParameters param = apg.generateParameters(); checkParam(param, genParamSpec); System.out.println("Test case passed"); } catch (InvalidParameterException ipe) { throw new RuntimeException("Test case failed.", ipe); } }
Example #16
Source File: TestAlgParameterGenerator.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private static void checkParamStrength(AlgorithmParameters param, DSAGenParameterSpec genParam) throws Exception { String algo = param.getAlgorithm(); if (!algo.equalsIgnoreCase("DSA")) { throw new RuntimeException("Unexpected type of parameters: " + algo); } DSAParameterSpec spec = param.getParameterSpec(DSAParameterSpec.class); int valueL = spec.getP().bitLength(); int strength = genParam.getPrimePLength(); if (strength != valueL) { System.out.println("P: Expected " + strength + " but actual " + valueL); throw new RuntimeException("Wrong P strength"); } int valueN = spec.getQ().bitLength(); strength = genParam.getSubprimeQLength(); if (strength != valueN) { System.out.println("Q: Expected " + strength + " but actual " + valueN); throw new RuntimeException("Wrong Q strength"); } }
Example #17
Source File: TestDSAGenParameterSpec.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static void testDSAGenParameterSpec(DataTuple dataTuple) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidParameterSpecException, InvalidAlgorithmParameterException { System.out.printf("Test case: primePLen=%d, " + "subprimeQLen=%d%n", dataTuple.primePLen, dataTuple.subprimeQLen); AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance(ALGORITHM_NAME, PROVIDER_NAME); DSAGenParameterSpec genParamSpec = createGenParameterSpec(dataTuple); // genParamSpec will be null if IllegalAE is thrown when expected. if (genParamSpec == null) { return; } try { apg.init(genParamSpec, null); AlgorithmParameters param = apg.generateParameters(); checkParam(param, genParamSpec); System.out.println("Test case passed"); } catch (InvalidParameterException ipe) { throw new RuntimeException("Test case failed.", ipe); } }
Example #18
Source File: TestAlgParameterGenerator.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static void checkParamStrength(AlgorithmParameters param, DSAGenParameterSpec genParam) throws Exception { String algo = param.getAlgorithm(); if (!algo.equalsIgnoreCase("DSA")) { throw new RuntimeException("Unexpected type of parameters: " + algo); } DSAParameterSpec spec = param.getParameterSpec(DSAParameterSpec.class); int valueL = spec.getP().bitLength(); int strength = genParam.getPrimePLength(); if (strength != valueL) { System.out.println("P: Expected " + strength + " but actual " + valueL); throw new RuntimeException("Wrong P strength"); } int valueN = spec.getQ().bitLength(); strength = genParam.getSubprimeQLength(); if (strength != valueN) { System.out.println("Q: Expected " + strength + " but actual " + valueN); throw new RuntimeException("Wrong Q strength"); } }
Example #19
Source File: DSAParameterGenerator.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Initializes this parameter generator with a set of * algorithm-specific parameter generation values. * * @param genParamSpec the set of algorithm-specific parameter generation values * @param random the source of randomness * * @exception InvalidAlgorithmParameterException if the given parameter * generation values are inappropriate for this parameter generator */ protected void engineInit(AlgorithmParameterSpec genParamSpec, SecureRandom random) throws InvalidAlgorithmParameterException { if (!(genParamSpec instanceof DSAGenParameterSpec)) { throw new InvalidAlgorithmParameterException("Invalid parameter"); } DSAGenParameterSpec dsaGenParams = (DSAGenParameterSpec) genParamSpec; int primePLen = dsaGenParams.getPrimePLength(); if (primePLen > 2048) { throw new InvalidParameterException ("No support for prime size " + primePLen); } // directly initialize using the already validated values this.valueL = primePLen; this.valueN = dsaGenParams.getSubprimeQLength(); this.seedLen = dsaGenParams.getSeedLength(); this.random = random; }
Example #20
Source File: TestDSAGenParameterSpec.java From hottub with GNU General Public License v2.0 | 5 votes |
private static void testDSAGenParameterSpec(DataTuple dataTuple) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidParameterSpecException, InvalidAlgorithmParameterException { System.out.printf("Test case: primePLen=%d, " + "subprimeQLen=%d%n", dataTuple.primePLen, dataTuple.subprimeQLen); AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance(ALGORITHM_NAME, PROVIDER_NAME); DSAGenParameterSpec genParamSpec = createGenParameterSpec(dataTuple); // genParamSpec will be null if IllegalAE is thrown when expected. if (genParamSpec == null) { return; } try { apg.init(genParamSpec, null); AlgorithmParameters param = apg.generateParameters(); checkParam(param, genParamSpec); System.out.println("Test case passed"); } catch (InvalidParameterException ipe) { // The DSAGenParameterSpec API support this, but the real // implementation in SUN doesn't if (!dataTuple.isSunProviderSupported) { System.out.println("Test case passed: expected " + "InvalidParameterException is caught"); } else { throw new RuntimeException("Test case failed.", ipe); } } }
Example #21
Source File: TestDSAGenParameterSpec.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void checkParam(AlgorithmParameters param, DSAGenParameterSpec genParam) throws InvalidParameterSpecException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { String algorithm = param.getAlgorithm(); if (!algorithm.equalsIgnoreCase(ALGORITHM_NAME)) { throw new RuntimeException( "Unexpected type of parameters: " + algorithm); } DSAParameterSpec spec = param.getParameterSpec(DSAParameterSpec.class); int valueL = spec.getP().bitLength(); int strengthP = genParam.getPrimePLength(); if (strengthP != valueL) { System.out.printf("P: Expected %d but actual %d%n", strengthP, valueL); throw new RuntimeException("Wrong P strength"); } int valueN = spec.getQ().bitLength(); int strengthQ = genParam.getSubprimeQLength(); if (strengthQ != valueN) { System.out.printf("Q: Expected %d but actual %d%n", strengthQ, valueN); throw new RuntimeException("Wrong Q strength"); } if (genParam.getSubprimeQLength() != genParam.getSeedLength()) { System.out.println("Defaut seed length should be the same as Q."); throw new RuntimeException("Wrong seed length"); } KeyPairGenerator keyGen = KeyPairGenerator.getInstance(ALGORITHM_NAME, PROVIDER_NAME); keyGen.initialize(spec); }
Example #22
Source File: TestDSAGenParameterSpec.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static void checkParam(AlgorithmParameters param, DSAGenParameterSpec genParam) throws InvalidParameterSpecException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { String algorithm = param.getAlgorithm(); if (!algorithm.equalsIgnoreCase(ALGORITHM_NAME)) { throw new RuntimeException( "Unexpected type of parameters: " + algorithm); } DSAParameterSpec spec = param.getParameterSpec(DSAParameterSpec.class); int valueL = spec.getP().bitLength(); int strengthP = genParam.getPrimePLength(); if (strengthP != valueL) { System.out.printf("P: Expected %d but actual %d%n", strengthP, valueL); throw new RuntimeException("Wrong P strength"); } int valueN = spec.getQ().bitLength(); int strengthQ = genParam.getSubprimeQLength(); if (strengthQ != valueN) { System.out.printf("Q: Expected %d but actual %d%n", strengthQ, valueN); throw new RuntimeException("Wrong Q strength"); } if (genParam.getSubprimeQLength() != genParam.getSeedLength()) { System.out.println("Defaut seed length should be the same as Q."); throw new RuntimeException("Wrong seed length"); } KeyPairGenerator keyGen = KeyPairGenerator.getInstance(ALGORITHM_NAME, PROVIDER_NAME); keyGen.initialize(spec); }
Example #23
Source File: TestDSAGenParameterSpec.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static void checkParam(AlgorithmParameters param, DSAGenParameterSpec genParam) throws InvalidParameterSpecException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { String algorithm = param.getAlgorithm(); if (!algorithm.equalsIgnoreCase(ALGORITHM_NAME)) { throw new RuntimeException( "Unexpected type of parameters: " + algorithm); } DSAParameterSpec spec = param.getParameterSpec(DSAParameterSpec.class); int valueL = spec.getP().bitLength(); int strengthP = genParam.getPrimePLength(); if (strengthP != valueL) { System.out.printf("P: Expected %d but actual %d%n", strengthP, valueL); throw new RuntimeException("Wrong P strength"); } int valueN = spec.getQ().bitLength(); int strengthQ = genParam.getSubprimeQLength(); if (strengthQ != valueN) { System.out.printf("Q: Expected %d but actual %d%n", strengthQ, valueN); throw new RuntimeException("Wrong Q strength"); } if (genParam.getSubprimeQLength() != genParam.getSeedLength()) { System.out.println("Defaut seed length should be the same as Q."); throw new RuntimeException("Wrong seed length"); } KeyPairGenerator keyGen = KeyPairGenerator.getInstance(ALGORITHM_NAME, PROVIDER_NAME); keyGen.initialize(spec); }
Example #24
Source File: DSAParameterGenerator.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Initializes this parameter generator with a set of * algorithm-specific parameter generation values. * * @param genParamSpec the set of algorithm-specific parameter * generation values * @param random the source of randomness * * @exception InvalidAlgorithmParameterException if the given parameter * generation values are inappropriate for this parameter generator */ @Override protected void engineInit(AlgorithmParameterSpec genParamSpec, SecureRandom random) throws InvalidAlgorithmParameterException { if (!(genParamSpec instanceof DSAGenParameterSpec)) { throw new InvalidAlgorithmParameterException("Invalid parameter"); } DSAGenParameterSpec dsaGenParams = (DSAGenParameterSpec)genParamSpec; // directly initialize using the already validated values this.valueL = dsaGenParams.getPrimePLength(); this.valueN = dsaGenParams.getSubprimeQLength(); this.seedLen = dsaGenParams.getSeedLength(); this.random = random; }
Example #25
Source File: DSAParameterGenerator.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Initializes this parameter generator with a set of * algorithm-specific parameter generation values. * * @param genParamSpec the set of algorithm-specific parameter * generation values * @param random the source of randomness * * @exception InvalidAlgorithmParameterException if the given parameter * generation values are inappropriate for this parameter generator */ @Override protected void engineInit(AlgorithmParameterSpec genParamSpec, SecureRandom random) throws InvalidAlgorithmParameterException { if (!(genParamSpec instanceof DSAGenParameterSpec)) { throw new InvalidAlgorithmParameterException("Invalid parameter"); } DSAGenParameterSpec dsaGenParams = (DSAGenParameterSpec)genParamSpec; // directly initialize using the already validated values this.valueL = dsaGenParams.getPrimePLength(); this.valueN = dsaGenParams.getSubprimeQLength(); this.seedLen = dsaGenParams.getSeedLength(); this.random = random; }
Example #26
Source File: DSAParameterGenerator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Initializes this parameter generator with a set of * algorithm-specific parameter generation values. * * @param genParamSpec the set of algorithm-specific parameter * generation values * @param random the source of randomness * * @exception InvalidAlgorithmParameterException if the given parameter * generation values are inappropriate for this parameter generator */ @Override protected void engineInit(AlgorithmParameterSpec genParamSpec, SecureRandom random) throws InvalidAlgorithmParameterException { if (!(genParamSpec instanceof DSAGenParameterSpec)) { throw new InvalidAlgorithmParameterException("Invalid parameter"); } DSAGenParameterSpec dsaGenParams = (DSAGenParameterSpec)genParamSpec; // directly initialize using the already validated values this.valueL = dsaGenParams.getPrimePLength(); this.valueN = dsaGenParams.getSubprimeQLength(); this.seedLen = dsaGenParams.getSeedLength(); this.random = random; }
Example #27
Source File: TestDSAGenParameterSpec.java From hottub with GNU General Public License v2.0 | 5 votes |
private static void checkParam(AlgorithmParameters param, DSAGenParameterSpec genParam) throws InvalidParameterSpecException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { String algorithm = param.getAlgorithm(); if (!algorithm.equalsIgnoreCase(ALGORITHM_NAME)) { throw new RuntimeException( "Unexpected type of parameters: " + algorithm); } DSAParameterSpec spec = param.getParameterSpec(DSAParameterSpec.class); int valueL = spec.getP().bitLength(); int strengthP = genParam.getPrimePLength(); if (strengthP != valueL) { System.out.printf("P: Expected %d but actual %d%n", strengthP, valueL); throw new RuntimeException("Wrong P strength"); } int valueN = spec.getQ().bitLength(); int strengthQ = genParam.getSubprimeQLength(); if (strengthQ != valueN) { System.out.printf("Q: Expected %d but actual %d%n", strengthQ, valueN); throw new RuntimeException("Wrong Q strength"); } if (genParam.getSubprimeQLength() != genParam.getSeedLength()) { System.out.println("Defaut seed length should be the same as Q."); throw new RuntimeException("Wrong seed length"); } // use the parameters to generate real DSA keys KeyPairGenerator keyGen = KeyPairGenerator.getInstance(ALGORITHM_NAME, PROVIDER_NAME); keyGen.initialize(spec); keyGen.generateKeyPair(); }
Example #28
Source File: DSAParameterGenerator.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Initializes this parameter generator with a set of * algorithm-specific parameter generation values. * * @param genParamSpec the set of algorithm-specific parameter * generation values * @param random the source of randomness * * @exception InvalidAlgorithmParameterException if the given parameter * generation values are inappropriate for this parameter generator */ @Override protected void engineInit(AlgorithmParameterSpec genParamSpec, SecureRandom random) throws InvalidAlgorithmParameterException { if (!(genParamSpec instanceof DSAGenParameterSpec)) { throw new InvalidAlgorithmParameterException("Invalid parameter"); } DSAGenParameterSpec dsaGenParams = (DSAGenParameterSpec)genParamSpec; // directly initialize using the already validated values this.valueL = dsaGenParams.getPrimePLength(); this.valueN = dsaGenParams.getSubprimeQLength(); this.seedLen = dsaGenParams.getSeedLength(); this.random = random; }
Example #29
Source File: TestDSAGenParameterSpec.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void checkParam(AlgorithmParameters param, DSAGenParameterSpec genParam) throws InvalidParameterSpecException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { String algorithm = param.getAlgorithm(); if (!algorithm.equalsIgnoreCase(ALGORITHM_NAME)) { throw new RuntimeException( "Unexpected type of parameters: " + algorithm); } DSAParameterSpec spec = param.getParameterSpec(DSAParameterSpec.class); int valueL = spec.getP().bitLength(); int strengthP = genParam.getPrimePLength(); if (strengthP != valueL) { System.out.printf("P: Expected %d but actual %d%n", strengthP, valueL); throw new RuntimeException("Wrong P strength"); } int valueN = spec.getQ().bitLength(); int strengthQ = genParam.getSubprimeQLength(); if (strengthQ != valueN) { System.out.printf("Q: Expected %d but actual %d%n", strengthQ, valueN); throw new RuntimeException("Wrong Q strength"); } if (genParam.getSubprimeQLength() != genParam.getSeedLength()) { System.out.println("Defaut seed length should be the same as Q."); throw new RuntimeException("Wrong seed length"); } KeyPairGenerator keyGen = KeyPairGenerator.getInstance(ALGORITHM_NAME, PROVIDER_NAME); keyGen.initialize(spec); }
Example #30
Source File: TestDSAGenParameterSpec.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void checkParam(AlgorithmParameters param, DSAGenParameterSpec genParam) throws InvalidParameterSpecException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { String algorithm = param.getAlgorithm(); if (!algorithm.equalsIgnoreCase(ALGORITHM_NAME)) { throw new RuntimeException( "Unexpected type of parameters: " + algorithm); } DSAParameterSpec spec = param.getParameterSpec(DSAParameterSpec.class); int valueL = spec.getP().bitLength(); int strengthP = genParam.getPrimePLength(); if (strengthP != valueL) { System.out.printf("P: Expected %d but actual %d%n", strengthP, valueL); throw new RuntimeException("Wrong P strength"); } int valueN = spec.getQ().bitLength(); int strengthQ = genParam.getSubprimeQLength(); if (strengthQ != valueN) { System.out.printf("Q: Expected %d but actual %d%n", strengthQ, valueN); throw new RuntimeException("Wrong Q strength"); } if (genParam.getSubprimeQLength() != genParam.getSeedLength()) { System.out.println("Defaut seed length should be the same as Q."); throw new RuntimeException("Wrong seed length"); } // use the parameters to generate real DSA keys KeyPairGenerator keyGen = KeyPairGenerator.getInstance(ALGORITHM_NAME, PROVIDER_NAME); keyGen.initialize(spec); keyGen.generateKeyPair(); }