Examples of MyKeyPairGenerator2


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

     * is used
     */
    public void testKeyPairGenerator13() {
        int[] keys = { -1, -250, 1, 63, -512, -1024 };
        SecureRandom random = new SecureRandom();
        KeyPairGenerator mKPG = new MyKeyPairGenerator2(null);
        assertEquals("Algorithm must be null", mKPG.getAlgorithm(),
                MyKeyPairGenerator2.getResAlgorithm());
        assertNull("genKeyPair() must return null", mKPG.genKeyPair());
        assertNull("generateKeyPair() mut return null", mKPG.generateKeyPair());
        for (int i = 0; i < keys.length; i++) {
            try {
                mKPG.initialize(keys[i]);
                fail("InvalidParameterException must be thrown (key: "
                        + Integer.toString(keys[i]) + ")");
            } catch (InvalidParameterException e) {
            }
            try {
                mKPG.initialize(keys[i], random);
                fail("InvalidParameterException must be thrown (key: "
                        + Integer.toString(keys[i]) + ")");
            } catch (InvalidParameterException e) {
            }
        }
        try {
            mKPG.initialize(64);
        } catch (InvalidParameterException e) {
            fail("Unexpected InvalidParameterException was thrown");
        }
        try {
            mKPG.initialize(64, null);
        } catch (InvalidParameterException e) {
            fail("Unexpected InvalidParameterException was thrown");
        }
        try {
            mKPG.initialize(null, random);
        } catch (UnsupportedOperationException e) {
            // on j2se1.4 this exception is not thrown
        } catch (InvalidAlgorithmParameterException e) {
            fail("Unexpected InvalidAlgorithmParameterException was thrown");
        }
View Full Code Here

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

     * is used
     */
    public void testKeyPairGenerator13() {
        int[] keys = { -1, -250, 1, 63, -512, -1024 };
        SecureRandom random = new SecureRandom();
        KeyPairGenerator mKPG = new MyKeyPairGenerator2(null);
        assertEquals("Algorithm must be null", mKPG.getAlgorithm(),
                MyKeyPairGenerator2.getResAlgorithm());
        assertNull("genKeyPair() must return null", mKPG.genKeyPair());
        assertNull("generateKeyPair() mut return null", mKPG.generateKeyPair());
        for (int i = 0; i < keys.length; i++) {
            try {
                mKPG.initialize(keys[i]);
                fail("InvalidParameterException must be thrown (key: "
                        + Integer.toString(keys[i]) + ")");
            } catch (InvalidParameterException e) {
            }
            try {
                mKPG.initialize(keys[i], random);
                fail("InvalidParameterException must be thrown (key: "
                        + Integer.toString(keys[i]) + ")");
            } catch (InvalidParameterException e) {
            }
        }
        try {
            mKPG.initialize(64);
        } catch (InvalidParameterException e) {
            fail("Unexpected InvalidParameterException was thrown");
        }
        try {
            mKPG.initialize(64, null);
        } catch (InvalidParameterException e) {
            fail("Unexpected InvalidParameterException was thrown");
        }
        try {
            mKPG.initialize(null, random);
        } catch (UnsupportedOperationException e) {
            // on j2se1.4 this exception is not thrown
        } catch (InvalidAlgorithmParameterException e) {
            fail("Unexpected InvalidAlgorithmParameterException was thrown");
        }
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.