Examples of MyKeyPairGeneratorSpi


Examples of org.apache.harmony.security.tests.support.MyKeyPairGeneratorSpi

     * Assertion: constructs KeyPairGeneratorSpi
     */
    public void testKeyPairGeneratorSpi01()
            throws InvalidAlgorithmParameterException,
            InvalidParameterException {
        KeyPairGeneratorSpi keyPairGen = new MyKeyPairGeneratorSpi();

        AlgorithmParameterSpec pp = null;
        try {
            keyPairGen.initialize(pp, null);
            fail("UnsupportedOperationException must be thrown");
        } catch (UnsupportedOperationException e) {
        }
        keyPairGen.initialize(pp, new SecureRandom());
        keyPairGen.initialize(1024, new SecureRandom());
        try {
            keyPairGen.initialize(-1024, new SecureRandom());
            fail("IllegalArgumentException must be thrown for incorrect keysize");
        } catch (IllegalArgumentException e) {
        }
        try {
            keyPairGen.initialize(1024, null);
            fail("IllegalArgumentException must be thrown");
        } catch (IllegalArgumentException e) {
            assertEquals("Incorrect exception", e.getMessage(),
                    "Invalid random");
        }
        KeyPair kp = keyPairGen.generateKeyPair();
        assertNull("Not null KeyPair", kp);
    }
View Full Code Here

Examples of org.apache.harmony.security.tests.support.MyKeyPairGeneratorSpi

     * Assertion: constructs KeyPairGeneratorSpi
     */
    public void testKeyPairGeneratorSpi01()
            throws InvalidAlgorithmParameterException,
            InvalidParameterException {
        KeyPairGeneratorSpi keyPairGen = new MyKeyPairGeneratorSpi();

        AlgorithmParameterSpec pp = null;
        try {
            keyPairGen.initialize(pp, null);
            fail("UnsupportedOperationException must be thrown");
        } catch (UnsupportedOperationException e) {
        }
        keyPairGen.initialize(pp, new SecureRandom());
        keyPairGen.initialize(1024, new SecureRandom());
        try {
            keyPairGen.initialize(-1024, new SecureRandom());
            fail("IllegalArgumentException must be thrown for incorrect keysize");
        } catch (IllegalArgumentException e) {
        }
        try {
            keyPairGen.initialize(1024, null);
            fail("IllegalArgumentException must be thrown");
        } catch (IllegalArgumentException e) {
            assertEquals("Incorrect exception", e.getMessage(),
                    "Invalid random");
        }
        KeyPair kp = keyPairGen.generateKeyPair();
        assertNull("Not null KeyPair", kp);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.