javax.crypto.spec.DHGenParameterSpec Java Examples
The following examples show how to use
javax.crypto.spec.DHGenParameterSpec.
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: JDKAlgorithmParameterGenerator.java From BiglyBT with GNU General Public License v2.0 | 6 votes |
@Override protected void engineInit( AlgorithmParameterSpec genParamSpec, SecureRandom random) throws InvalidAlgorithmParameterException { if (!(genParamSpec instanceof DHGenParameterSpec)) { throw new InvalidAlgorithmParameterException("DH parameter generator requires a DHGenParameterSpec for initialisation"); } DHGenParameterSpec spec = (DHGenParameterSpec)genParamSpec; this.strength = spec.getPrimeSize(); this.l = spec.getExponentSize(); this.random = random; }
Example #2
Source File: DHParameterGenerator.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Initializes this parameter generator with a set of parameter * generation values, which specify the size of the prime modulus and * the size of the random exponent, both in bits. * * @param params the set of 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 DHGenParameterSpec)) { throw new InvalidAlgorithmParameterException ("Inappropriate parameter type"); } DHGenParameterSpec dhParamSpec = (DHGenParameterSpec)genParamSpec; primeSize = dhParamSpec.getPrimeSize(); // Re-uses DSA parameters and thus have the same range checkKeySize(primeSize); exponentSize = dhParamSpec.getExponentSize(); if (exponentSize <= 0) { throw new InvalidAlgorithmParameterException ("Exponent size must be greater than zero"); } // Require exponentSize < primeSize if (exponentSize >= primeSize) { throw new InvalidAlgorithmParameterException ("Exponent size must be less than modulus size"); } }
Example #3
Source File: AlgorithmParameterGeneratorSpi.java From ripple-lib-java with ISC License | 5 votes |
protected void engineInit( AlgorithmParameterSpec genParamSpec, SecureRandom random) throws InvalidAlgorithmParameterException { if (!(genParamSpec instanceof DHGenParameterSpec)) { throw new InvalidAlgorithmParameterException("DH parameter generator requires a DHGenParameterSpec for initialisation"); } DHGenParameterSpec spec = (DHGenParameterSpec)genParamSpec; this.strength = spec.getPrimeSize(); this.l = spec.getExponentSize(); this.random = random; }
Example #4
Source File: AlgorithmParameterGeneratorSpi.java From ripple-lib-java with ISC License | 5 votes |
protected void engineInit( AlgorithmParameterSpec genParamSpec, SecureRandom random) throws InvalidAlgorithmParameterException { if (!(genParamSpec instanceof DHGenParameterSpec)) { throw new InvalidAlgorithmParameterException("DH parameter generator requires a DHGenParameterSpec for initialisation"); } DHGenParameterSpec spec = (DHGenParameterSpec)genParamSpec; this.strength = spec.getPrimeSize(); this.l = spec.getExponentSize(); this.random = random; }
Example #5
Source File: AlgorithmParameterGeneratorSpi.java From RipplePower with Apache License 2.0 | 5 votes |
protected void engineInit( AlgorithmParameterSpec genParamSpec, SecureRandom random) throws InvalidAlgorithmParameterException { if (!(genParamSpec instanceof DHGenParameterSpec)) { throw new InvalidAlgorithmParameterException("DH parameter generator requires a DHGenParameterSpec for initialisation"); } DHGenParameterSpec spec = (DHGenParameterSpec)genParamSpec; this.strength = spec.getPrimeSize(); this.l = spec.getExponentSize(); this.random = random; }
Example #6
Source File: AlgorithmParameterGeneratorSpi.java From RipplePower with Apache License 2.0 | 5 votes |
protected void engineInit( AlgorithmParameterSpec genParamSpec, SecureRandom random) throws InvalidAlgorithmParameterException { if (!(genParamSpec instanceof DHGenParameterSpec)) { throw new InvalidAlgorithmParameterException("DH parameter generator requires a DHGenParameterSpec for initialisation"); } DHGenParameterSpec spec = (DHGenParameterSpec)genParamSpec; this.strength = spec.getPrimeSize(); this.l = spec.getExponentSize(); this.random = random; }
Example #7
Source File: DHGenParameterSpecTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * DHGenParameterSpec class testing. Tests the equivalence of * parameters specified in the constructor with the values returned * by getters. */ public void testDHGenParameterSpec() { int[] primes = {Integer.MIN_VALUE, -1, 0, 1, Integer.MAX_VALUE}; int[] exponents = {Integer.MIN_VALUE, -1, 0, 1, Integer.MAX_VALUE}; for (int i=0; i<primes.length; i++) { DHGenParameterSpec ps = new DHGenParameterSpec(primes[i], exponents[i]); assertEquals("The value returned by getPrimeSize() must be " + "equal to the value specified in the constructor", ps.getPrimeSize(), primes[i]); assertEquals("The value returned by getExponentSize() must be " + "equal to the value specified in the constructor", ps.getPrimeSize(), exponents[i]); } }
Example #8
Source File: DHParameterGenerator.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Initializes this parameter generator with a set of parameter * generation values, which specify the size of the prime modulus and * the size of the random exponent, both in bits. * * @param params the set of 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 DHGenParameterSpec)) { throw new InvalidAlgorithmParameterException ("Inappropriate parameter type"); } DHGenParameterSpec dhParamSpec = (DHGenParameterSpec)genParamSpec; primeSize = dhParamSpec.getPrimeSize(); // Re-uses DSA parameters and thus have the same range checkKeySize(primeSize); exponentSize = dhParamSpec.getExponentSize(); if (exponentSize <= 0) { throw new InvalidAlgorithmParameterException ("Exponent size must be greater than zero"); } // Require exponentSize < primeSize if (exponentSize >= primeSize) { throw new InvalidAlgorithmParameterException ("Exponent size must be less than modulus size"); } }
Example #9
Source File: DHParameterGenerator.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Initializes this parameter generator with a set of parameter * generation values, which specify the size of the prime modulus and * the size of the random exponent, both in bits. * * @param params the set of 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 DHGenParameterSpec)) { throw new InvalidAlgorithmParameterException ("Inappropriate parameter type"); } DHGenParameterSpec dhParamSpec = (DHGenParameterSpec)genParamSpec; primeSize = dhParamSpec.getPrimeSize(); // Re-uses DSA parameters and thus have the same range checkKeySize(primeSize); exponentSize = dhParamSpec.getExponentSize(); if (exponentSize <= 0) { throw new InvalidAlgorithmParameterException ("Exponent size must be greater than zero"); } // Require exponentSize < primeSize if (exponentSize >= primeSize) { throw new InvalidAlgorithmParameterException ("Exponent size must be less than modulus size"); } }
Example #10
Source File: DiffieHellmanSession.java From openid4java with Apache License 2.0 | 5 votes |
public static DHParameterSpec generateRandomParameter(int primeSize, int keySize) { try { AlgorithmParameterGenerator paramGen = AlgorithmParameterGenerator.getInstance(ALGORITHM); DHGenParameterSpec genParameterSpec = new DHGenParameterSpec(primeSize, keySize); paramGen.init(genParameterSpec); AlgorithmParameters params = paramGen.generateParameters(); DHParameterSpec result = (DHParameterSpec) params.getParameterSpec(DHParameterSpec.class); if (DEBUG) _log.debug("Generated random DHParameterSpec, base: " + result.getG() + ", modulus: " + result.getP()); return result; } catch (GeneralSecurityException e) { _log.error("Cannot generate DH params for primeSize: " + primeSize + " keySize: " + keySize, e); return null; } }
Example #11
Source File: DHParameterGenerator.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Initializes this parameter generator with a set of parameter * generation values, which specify the size of the prime modulus and * the size of the random exponent, both in bits. * * @param genParamSpec the set of 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 DHGenParameterSpec)) { throw new InvalidAlgorithmParameterException ("Inappropriate parameter type"); } DHGenParameterSpec dhParamSpec = (DHGenParameterSpec)genParamSpec; primeSize = dhParamSpec.getPrimeSize(); exponentSize = dhParamSpec.getExponentSize(); if ((exponentSize <= 0) || (exponentSize >= primeSize)) { throw new InvalidAlgorithmParameterException( "Exponent size (" + exponentSize + ") must be positive and less than modulus size (" + primeSize + ")"); } try { checkKeySize(primeSize); } catch (InvalidParameterException ipe) { throw new InvalidAlgorithmParameterException(ipe.getMessage()); } this.random = random; }
Example #12
Source File: DHParameterGenerator.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Initializes this parameter generator with a set of parameter * generation values, which specify the size of the prime modulus and * the size of the random exponent, both in bits. * * @param params the set of 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 DHGenParameterSpec)) { throw new InvalidAlgorithmParameterException ("Inappropriate parameter type"); } DHGenParameterSpec dhParamSpec = (DHGenParameterSpec)genParamSpec; primeSize = dhParamSpec.getPrimeSize(); // Re-uses DSA parameters and thus have the same range checkKeySize(primeSize); exponentSize = dhParamSpec.getExponentSize(); if (exponentSize <= 0) { throw new InvalidAlgorithmParameterException ("Exponent size must be greater than zero"); } // Require exponentSize < primeSize if (exponentSize >= primeSize) { throw new InvalidAlgorithmParameterException ("Exponent size must be less than modulus size"); } }
Example #13
Source File: JDKAlgorithmParameterGenerator.java From TorrentEngine with GNU General Public License v3.0 | 5 votes |
protected void engineInit( AlgorithmParameterSpec genParamSpec, SecureRandom random) throws InvalidAlgorithmParameterException { if (!(genParamSpec instanceof DHGenParameterSpec)) { throw new InvalidAlgorithmParameterException("DH parameter generator requires a DHGenParameterSpec for initialisation"); } DHGenParameterSpec spec = (DHGenParameterSpec)genParamSpec; this.strength = spec.getPrimeSize(); this.l = spec.getExponentSize(); this.random = random; }
Example #14
Source File: DHParameterGenerator.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Initializes this parameter generator with a set of parameter * generation values, which specify the size of the prime modulus and * the size of the random exponent, both in bits. * * @param params the set of 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 DHGenParameterSpec)) { throw new InvalidAlgorithmParameterException ("Inappropriate parameter type"); } DHGenParameterSpec dhParamSpec = (DHGenParameterSpec)genParamSpec; primeSize = dhParamSpec.getPrimeSize(); // Re-uses DSA parameters and thus have the same range checkKeySize(primeSize); exponentSize = dhParamSpec.getExponentSize(); if (exponentSize <= 0) { throw new InvalidAlgorithmParameterException ("Exponent size must be greater than zero"); } // Require exponentSize < primeSize if (exponentSize >= primeSize) { throw new InvalidAlgorithmParameterException ("Exponent size must be less than modulus size"); } }
Example #15
Source File: DHParameterGenerator.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Initializes this parameter generator with a set of parameter * generation values, which specify the size of the prime modulus and * the size of the random exponent, both in bits. * * @param params the set of 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 DHGenParameterSpec)) { throw new InvalidAlgorithmParameterException ("Inappropriate parameter type"); } DHGenParameterSpec dhParamSpec = (DHGenParameterSpec)genParamSpec; primeSize = dhParamSpec.getPrimeSize(); exponentSize = dhParamSpec.getExponentSize(); if ((exponentSize <= 0) || (exponentSize >= primeSize)) { throw new InvalidAlgorithmParameterException( "Exponent size (" + exponentSize + ") must be positive and less than modulus size (" + primeSize + ")"); } try { checkKeySize(primeSize); } catch (InvalidParameterException ipe) { throw new InvalidAlgorithmParameterException(ipe.getMessage()); } this.random = random; }
Example #16
Source File: DHParameterGenerator.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Initializes this parameter generator with a set of parameter * generation values, which specify the size of the prime modulus and * the size of the random exponent, both in bits. * * @param params the set of 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 DHGenParameterSpec)) { throw new InvalidAlgorithmParameterException ("Inappropriate parameter type"); } DHGenParameterSpec dhParamSpec = (DHGenParameterSpec)genParamSpec; primeSize = dhParamSpec.getPrimeSize(); // Re-uses DSA parameters and thus have the same range try { checkKeySize(primeSize); } catch (InvalidParameterException ipe) { throw new InvalidAlgorithmParameterException(ipe.getMessage()); } exponentSize = dhParamSpec.getExponentSize(); if (exponentSize <= 0) { throw new InvalidAlgorithmParameterException ("Exponent size must be greater than zero"); } // Require exponentSize < primeSize if (exponentSize >= primeSize) { throw new InvalidAlgorithmParameterException ("Exponent size must be less than modulus size"); } }
Example #17
Source File: DHParameterGenerator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Initializes this parameter generator with a set of parameter * generation values, which specify the size of the prime modulus and * the size of the random exponent, both in bits. * * @param genParamSpec the set of 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 DHGenParameterSpec)) { throw new InvalidAlgorithmParameterException ("Inappropriate parameter type"); } DHGenParameterSpec dhParamSpec = (DHGenParameterSpec)genParamSpec; primeSize = dhParamSpec.getPrimeSize(); exponentSize = dhParamSpec.getExponentSize(); if ((exponentSize <= 0) || (exponentSize >= primeSize)) { throw new InvalidAlgorithmParameterException( "Exponent size (" + exponentSize + ") must be positive and less than modulus size (" + primeSize + ")"); } try { checkKeySize(primeSize); } catch (InvalidParameterException ipe) { throw new InvalidAlgorithmParameterException(ipe.getMessage()); } this.random = random; }
Example #18
Source File: DHParameterGenerator.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Initializes this parameter generator with a set of parameter * generation values, which specify the size of the prime modulus and * the size of the random exponent, both in bits. * * @param genParamSpec the set of 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 DHGenParameterSpec)) { throw new InvalidAlgorithmParameterException ("Inappropriate parameter type"); } DHGenParameterSpec dhParamSpec = (DHGenParameterSpec)genParamSpec; primeSize = dhParamSpec.getPrimeSize(); exponentSize = dhParamSpec.getExponentSize(); if ((exponentSize <= 0) || (exponentSize >= primeSize)) { throw new InvalidAlgorithmParameterException( "Exponent size (" + exponentSize + ") must be positive and less than modulus size (" + primeSize + ")"); } try { checkKeySize(primeSize); } catch (InvalidParameterException ipe) { throw new InvalidAlgorithmParameterException(ipe.getMessage()); } this.random = random; }
Example #19
Source File: DHParameterGenerator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Initializes this parameter generator with a set of parameter * generation values, which specify the size of the prime modulus and * the size of the random exponent, both in bits. * * @param params the set of 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 DHGenParameterSpec)) { throw new InvalidAlgorithmParameterException ("Inappropriate parameter type"); } DHGenParameterSpec dhParamSpec = (DHGenParameterSpec)genParamSpec; primeSize = dhParamSpec.getPrimeSize(); exponentSize = dhParamSpec.getExponentSize(); if ((exponentSize <= 0) || (exponentSize >= primeSize)) { throw new InvalidAlgorithmParameterException( "Exponent size (" + exponentSize + ") must be positive and less than modulus size (" + primeSize + ")"); } try { checkKeySize(primeSize); } catch (InvalidParameterException ipe) { throw new InvalidAlgorithmParameterException(ipe.getMessage()); } this.random = random; }
Example #20
Source File: DHParameterGenerator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Initializes this parameter generator with a set of parameter * generation values, which specify the size of the prime modulus and * the size of the random exponent, both in bits. * * @param genParamSpec the set of 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 DHGenParameterSpec)) { throw new InvalidAlgorithmParameterException ("Inappropriate parameter type"); } DHGenParameterSpec dhParamSpec = (DHGenParameterSpec)genParamSpec; primeSize = dhParamSpec.getPrimeSize(); exponentSize = dhParamSpec.getExponentSize(); if ((exponentSize <= 0) || (exponentSize >= primeSize)) { throw new InvalidAlgorithmParameterException( "Exponent size (" + exponentSize + ") must be positive and less than modulus size (" + primeSize + ")"); } try { checkKeySize(primeSize); } catch (InvalidParameterException ipe) { throw new InvalidAlgorithmParameterException(ipe.getMessage()); } this.random = random; }
Example #21
Source File: DHParameterGenerator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Initializes this parameter generator with a set of parameter * generation values, which specify the size of the prime modulus and * the size of the random exponent, both in bits. * * @param params the set of 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 DHGenParameterSpec)) { throw new InvalidAlgorithmParameterException ("Inappropriate parameter type"); } DHGenParameterSpec dhParamSpec = (DHGenParameterSpec)genParamSpec; primeSize = dhParamSpec.getPrimeSize(); // Re-uses DSA parameters and thus have the same range checkKeySize(primeSize); exponentSize = dhParamSpec.getExponentSize(); if (exponentSize <= 0) { throw new InvalidAlgorithmParameterException ("Exponent size must be greater than zero"); } // Require exponentSize < primeSize if (exponentSize >= primeSize) { throw new InvalidAlgorithmParameterException ("Exponent size must be less than modulus size"); } }
Example #22
Source File: DHParameterGenerator.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Initializes this parameter generator with a set of parameter * generation values, which specify the size of the prime modulus and * the size of the random exponent, both in bits. * * @param params the set of 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 DHGenParameterSpec)) { throw new InvalidAlgorithmParameterException ("Inappropriate parameter type"); } DHGenParameterSpec dhParamSpec = (DHGenParameterSpec)genParamSpec; primeSize = dhParamSpec.getPrimeSize(); exponentSize = dhParamSpec.getExponentSize(); if ((exponentSize <= 0) || (exponentSize >= primeSize)) { throw new InvalidAlgorithmParameterException( "Exponent size (" + exponentSize + ") must be positive and less than modulus size (" + primeSize + ")"); } try { checkKeySize(primeSize); } catch (InvalidParameterException ipe) { throw new InvalidAlgorithmParameterException(ipe.getMessage()); } this.random = random; }
Example #23
Source File: SameDHKeyStressTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static boolean runTest(String algo, int numParties, String secretAlgo) { KAParticipant[] parties = new KAParticipant[numParties]; Key[] keyArchives = new Key[numParties]; try { // generate AlogirhtmParameterSpec AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance("DH","SunJCE"); AlgorithmParameterSpec aps = new DHGenParameterSpec(512, 64); apg.init(aps); DHParameterSpec spec = apg.generateParameters(). getParameterSpec(DHParameterSpec.class); //initilize all KeyAgreement participants for (int i = 0; i < numParties; i++) { parties[i] = new KAParticipant(PA_NAMES[i], algo); parties[i].initialize(spec); keyArchives[i] = parties[i].getPublicKey(); } // Do all phases in the KeyAgreement for all participants Key[] keyBuffer = new Key[numParties]; boolean lastPhase = false; for (int j = 0; j < numParties - 1; j++) { if (j == numParties - 2) { lastPhase = true; } for (int k = 0; k < numParties; k++) { if (k == numParties - 1) { keyBuffer[k] = parties[k].doPhase(keyArchives[0], lastPhase); } else { keyBuffer[k] = parties[k].doPhase(keyArchives[k + 1], lastPhase); } } System.arraycopy(keyBuffer, 0, keyArchives, 0, numParties); } //Comparison: The secret keys generated by all involved parties should be the same SecretKey[] sKeys = new SecretKey[numParties]; for (int n = 0; n < numParties; n++) { sKeys[n] = parties[n].generateSecret(secretAlgo); } for (int q = 0; q < numParties - 1; q++) { if (!Arrays.equals(sKeys[q].getEncoded(), sKeys[q + 1].getEncoded())) { return false; } } return true; } catch (Exception ex) { ex.printStackTrace(); return false; } }
Example #24
Source File: SameDHKeyStressTest.java From hottub with GNU General Public License v2.0 | 4 votes |
public static boolean runTest(String algo, int numParties, String secretAlgo) { KAParticipant[] parties = new KAParticipant[numParties]; Key[] keyArchives = new Key[numParties]; try { // generate AlogirhtmParameterSpec AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance("DH","SunJCE"); AlgorithmParameterSpec aps = new DHGenParameterSpec(512, 64); apg.init(aps); DHParameterSpec spec = apg.generateParameters(). getParameterSpec(DHParameterSpec.class); //initilize all KeyAgreement participants for (int i = 0; i < numParties; i++) { parties[i] = new KAParticipant(PA_NAMES[i], algo); parties[i].initialize(spec); keyArchives[i] = parties[i].getPublicKey(); } // Do all phases in the KeyAgreement for all participants Key[] keyBuffer = new Key[numParties]; boolean lastPhase = false; for (int j = 0; j < numParties - 1; j++) { if (j == numParties - 2) { lastPhase = true; } for (int k = 0; k < numParties; k++) { if (k == numParties - 1) { keyBuffer[k] = parties[k].doPhase(keyArchives[0], lastPhase); } else { keyBuffer[k] = parties[k].doPhase(keyArchives[k + 1], lastPhase); } } System.arraycopy(keyBuffer, 0, keyArchives, 0, numParties); } //Comparison: The secret keys generated by all involved parties should be the same SecretKey[] sKeys = new SecretKey[numParties]; for (int n = 0; n < numParties; n++) { sKeys[n] = parties[n].generateSecret(secretAlgo); } for (int q = 0; q < numParties - 1; q++) { if (!Arrays.equals(sKeys[q].getEncoded(), sKeys[q + 1].getEncoded())) { return false; } } return true; } catch (Exception ex) { ex.printStackTrace(); return false; } }
Example #25
Source File: SameDHKeyStressTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static boolean runTest(String algo, int numParties, String secretAlgo) { KAParticipant[] parties = new KAParticipant[numParties]; Key[] keyArchives = new Key[numParties]; try { // generate AlogirhtmParameterSpec AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance("DH","SunJCE"); AlgorithmParameterSpec aps = new DHGenParameterSpec(512, 64); apg.init(aps); DHParameterSpec spec = apg.generateParameters(). getParameterSpec(DHParameterSpec.class); //initilize all KeyAgreement participants for (int i = 0; i < numParties; i++) { parties[i] = new KAParticipant(PA_NAMES[i], algo); parties[i].initialize(spec); keyArchives[i] = parties[i].getPublicKey(); } // Do all phases in the KeyAgreement for all participants Key[] keyBuffer = new Key[numParties]; boolean lastPhase = false; for (int j = 0; j < numParties - 1; j++) { if (j == numParties - 2) { lastPhase = true; } for (int k = 0; k < numParties; k++) { if (k == numParties - 1) { keyBuffer[k] = parties[k].doPhase(keyArchives[0], lastPhase); } else { keyBuffer[k] = parties[k].doPhase(keyArchives[k + 1], lastPhase); } } System.arraycopy(keyBuffer, 0, keyArchives, 0, numParties); } //Comparison: The secret keys generated by all involved parties should be the same SecretKey[] sKeys = new SecretKey[numParties]; for (int n = 0; n < numParties; n++) { sKeys[n] = parties[n].generateSecret(secretAlgo); } for (int q = 0; q < numParties - 1; q++) { if (!Arrays.equals(sKeys[q].getEncoded(), sKeys[q + 1].getEncoded())) { return false; } } return true; } catch (Exception ex) { ex.printStackTrace(); return false; } }
Example #26
Source File: SameDHKeyStressTest.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static boolean runTest(String algo, int numParties, String secretAlgo) { KAParticipant[] parties = new KAParticipant[numParties]; Key[] keyArchives = new Key[numParties]; try { // generate AlogirhtmParameterSpec AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance("DH","SunJCE"); AlgorithmParameterSpec aps = new DHGenParameterSpec(512, 64); apg.init(aps); DHParameterSpec spec = apg.generateParameters(). getParameterSpec(DHParameterSpec.class); //initilize all KeyAgreement participants for (int i = 0; i < numParties; i++) { parties[i] = new KAParticipant(PA_NAMES[i], algo); parties[i].initialize(spec); keyArchives[i] = parties[i].getPublicKey(); } // Do all phases in the KeyAgreement for all participants Key[] keyBuffer = new Key[numParties]; boolean lastPhase = false; for (int j = 0; j < numParties - 1; j++) { if (j == numParties - 2) { lastPhase = true; } for (int k = 0; k < numParties; k++) { if (k == numParties - 1) { keyBuffer[k] = parties[k].doPhase(keyArchives[0], lastPhase); } else { keyBuffer[k] = parties[k].doPhase(keyArchives[k + 1], lastPhase); } } System.arraycopy(keyBuffer, 0, keyArchives, 0, numParties); } //Comparison: The secret keys generated by all involved parties should be the same SecretKey[] sKeys = new SecretKey[numParties]; for (int n = 0; n < numParties; n++) { sKeys[n] = parties[n].generateSecret(secretAlgo); } for (int q = 0; q < numParties - 1; q++) { if (!Arrays.equals(sKeys[q].getEncoded(), sKeys[q + 1].getEncoded())) { return false; } } return true; } catch (Exception ex) { ex.printStackTrace(); return false; } }
Example #27
Source File: SameDHKeyStressTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public static boolean runTest(String algo, int numParties, String secretAlgo) { KAParticipant[] parties = new KAParticipant[numParties]; Key[] keyArchives = new Key[numParties]; try { // generate AlogirhtmParameterSpec AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance("DH","SunJCE"); AlgorithmParameterSpec aps = new DHGenParameterSpec(512, 64); apg.init(aps); DHParameterSpec spec = apg.generateParameters(). getParameterSpec(DHParameterSpec.class); //initilize all KeyAgreement participants for (int i = 0; i < numParties; i++) { parties[i] = new KAParticipant(PA_NAMES[i], algo); parties[i].initialize(spec); keyArchives[i] = parties[i].getPublicKey(); } // Do all phases in the KeyAgreement for all participants Key[] keyBuffer = new Key[numParties]; boolean lastPhase = false; for (int j = 0; j < numParties - 1; j++) { if (j == numParties - 2) { lastPhase = true; } for (int k = 0; k < numParties; k++) { if (k == numParties - 1) { keyBuffer[k] = parties[k].doPhase(keyArchives[0], lastPhase); } else { keyBuffer[k] = parties[k].doPhase(keyArchives[k + 1], lastPhase); } } System.arraycopy(keyBuffer, 0, keyArchives, 0, numParties); } //Comparison: The secret keys generated by all involved parties should be the same SecretKey[] sKeys = new SecretKey[numParties]; for (int n = 0; n < numParties; n++) { sKeys[n] = parties[n].generateSecret(secretAlgo); } for (int q = 0; q < numParties - 1; q++) { if (!Arrays.equals(sKeys[q].getEncoded(), sKeys[q + 1].getEncoded())) { return false; } } return true; } catch (Exception ex) { ex.printStackTrace(); return false; } }
Example #28
Source File: SameDHKeyStressTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static boolean runTest(String algo, int numParties, String secretAlgo) { KAParticipant[] parties = new KAParticipant[numParties]; Key[] keyArchives = new Key[numParties]; try { // generate AlogirhtmParameterSpec AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance("DH","SunJCE"); AlgorithmParameterSpec aps = new DHGenParameterSpec(512, 64); apg.init(aps); DHParameterSpec spec = apg.generateParameters(). getParameterSpec(DHParameterSpec.class); //initilize all KeyAgreement participants for (int i = 0; i < numParties; i++) { parties[i] = new KAParticipant(PA_NAMES[i], algo); parties[i].initialize(spec); keyArchives[i] = parties[i].getPublicKey(); } // Do all phases in the KeyAgreement for all participants Key[] keyBuffer = new Key[numParties]; boolean lastPhase = false; for (int j = 0; j < numParties - 1; j++) { if (j == numParties - 2) { lastPhase = true; } for (int k = 0; k < numParties; k++) { if (k == numParties - 1) { keyBuffer[k] = parties[k].doPhase(keyArchives[0], lastPhase); } else { keyBuffer[k] = parties[k].doPhase(keyArchives[k + 1], lastPhase); } } System.arraycopy(keyBuffer, 0, keyArchives, 0, numParties); } //Comparison: The secret keys generated by all involved parties should be the same SecretKey[] sKeys = new SecretKey[numParties]; for (int n = 0; n < numParties; n++) { sKeys[n] = parties[n].generateSecret(secretAlgo); } for (int q = 0; q < numParties - 1; q++) { if (!Arrays.equals(sKeys[q].getEncoded(), sKeys[q + 1].getEncoded())) { return false; } } return true; } catch (Exception ex) { ex.printStackTrace(); return false; } }
Example #29
Source File: SameDHKeyStressTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static boolean runTest(String algo, int numParties, String secretAlgo) { KAParticipant[] parties = new KAParticipant[numParties]; Key[] keyArchives = new Key[numParties]; try { // generate AlogirhtmParameterSpec AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance("DH","SunJCE"); AlgorithmParameterSpec aps = new DHGenParameterSpec(512, 64); apg.init(aps); DHParameterSpec spec = apg.generateParameters(). getParameterSpec(DHParameterSpec.class); //initilize all KeyAgreement participants for (int i = 0; i < numParties; i++) { parties[i] = new KAParticipant(PA_NAMES[i], algo); parties[i].initialize(spec); keyArchives[i] = parties[i].getPublicKey(); } // Do all phases in the KeyAgreement for all participants Key[] keyBuffer = new Key[numParties]; boolean lastPhase = false; for (int j = 0; j < numParties - 1; j++) { if (j == numParties - 2) { lastPhase = true; } for (int k = 0; k < numParties; k++) { if (k == numParties - 1) { keyBuffer[k] = parties[k].doPhase(keyArchives[0], lastPhase); } else { keyBuffer[k] = parties[k].doPhase(keyArchives[k + 1], lastPhase); } } System.arraycopy(keyBuffer, 0, keyArchives, 0, numParties); } //Comparison: The secret keys generated by all involved parties should be the same SecretKey[] sKeys = new SecretKey[numParties]; for (int n = 0; n < numParties; n++) { sKeys[n] = parties[n].generateSecret(secretAlgo); } for (int q = 0; q < numParties - 1; q++) { if (!Arrays.equals(sKeys[q].getEncoded(), sKeys[q + 1].getEncoded())) { return false; } } return true; } catch (Exception ex) { ex.printStackTrace(); return false; } }
Example #30
Source File: SameDHKeyStressTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static boolean runTest(String algo, int numParties, String secretAlgo) { KAParticipant[] parties = new KAParticipant[numParties]; Key[] keyArchives = new Key[numParties]; try { // generate AlogirhtmParameterSpec AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance("DH","SunJCE"); AlgorithmParameterSpec aps = new DHGenParameterSpec(512, 64); apg.init(aps); DHParameterSpec spec = apg.generateParameters(). getParameterSpec(DHParameterSpec.class); //initilize all KeyAgreement participants for (int i = 0; i < numParties; i++) { parties[i] = new KAParticipant(PA_NAMES[i], algo); parties[i].initialize(spec); keyArchives[i] = parties[i].getPublicKey(); } // Do all phases in the KeyAgreement for all participants Key[] keyBuffer = new Key[numParties]; boolean lastPhase = false; for (int j = 0; j < numParties - 1; j++) { if (j == numParties - 2) { lastPhase = true; } for (int k = 0; k < numParties; k++) { if (k == numParties - 1) { keyBuffer[k] = parties[k].doPhase(keyArchives[0], lastPhase); } else { keyBuffer[k] = parties[k].doPhase(keyArchives[k + 1], lastPhase); } } System.arraycopy(keyBuffer, 0, keyArchives, 0, numParties); } //Comparison: The secret keys generated by all involved parties should be the same SecretKey[] sKeys = new SecretKey[numParties]; for (int n = 0; n < numParties; n++) { sKeys[n] = parties[n].generateSecret(secretAlgo); } for (int q = 0; q < numParties - 1; q++) { if (!Arrays.equals(sKeys[q].getEncoded(), sKeys[q + 1].getEncoded())) { return false; } } return true; } catch (Exception ex) { ex.printStackTrace(); return false; } }