Package javax.crypto.spec

Examples of javax.crypto.spec.DHGenParameterSpec


     */
    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]);
        }
    }
View Full Code Here


     */
    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]);
        }
    }
View Full Code Here

        }
        Mac [] macs = createMacs();
        assertNotNull("Mac objects were not created", macs);
        byte [] b = {(byte)1, (byte)2, (byte)3, (byte)4, (byte)5};
        SecretKeySpec sks = new SecretKeySpec(b, "SHA1");
        DHGenParameterSpec algPS = new DHGenParameterSpec(1, 2);

        for (int i = 0; i < macs.length; i++) {
            try {
                macs[i].init(sks, algPS);
                fail("init(..) accepts incorrect AlgorithmParameterSpec parameter");
View Full Code Here

    // use our own?
    Object params = attributes.get(DH_PARAMETERS);
    // find out the desired sizes
    if (params instanceof DHGenParameterSpec)
      {
        DHGenParameterSpec jceSpec = (DHGenParameterSpec) params;
        l = jceSpec.getPrimeSize();
        m = jceSpec.getExponentSize();
      }
    else if (params instanceof DHParameterSpec)
      {
        // FIXME: I'm not sure this is correct. It seems to behave the
        // same way as Sun's RI, but I don't know if this behavior is
        // documented anywhere.
        DHParameterSpec jceSpec = (DHParameterSpec) params;
        p = jceSpec.getP();
        g = jceSpec.getG();
        l = p.bitLength();
        m = jceSpec.getL();
        // If no exponent size was given, generate an exponent as
        // large as the prime.
        if (m == 0)
          m = l;
      }
View Full Code Here

        {
            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;
        }
View Full Code Here

        {
            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;
        }
View Full Code Here

        {
            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;
        }
View Full Code Here

        {
            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;
        }
View Full Code Here

TOP

Related Classes of javax.crypto.spec.DHGenParameterSpec

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.