Examples of EncryptedPrivateKeyInfo


Examples of javax.crypto.EncryptedPrivateKeyInfo

     * Expected: <code>IllegalArgumentException</code>
     */
    public final void testEncryptedPrivateKeyInfoStringbyteArray4()
            throws Exception {
        try {
            new EncryptedPrivateKeyInfo("DSA", new byte[] {});
            fail(getName() + ": IllegalArgumentException has not been thrown");
        } catch (IllegalArgumentException ok) {
        }
    }
View Full Code Here

Examples of javax.crypto.EncryptedPrivateKeyInfo

    public final void testEncryptedPrivateKeyInfoStringbyteArray5()
            throws Exception {
        byte[] encryptedDataCopy = EncryptedPrivateKeyInfoData.encryptedData
                .clone();
        // pass valid array
        EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo("DSA",
                encryptedDataCopy);
        // modify array passed
        encryptedDataCopy[0] = (byte) 6;
        // check that internal state has not been affected
        assertTrue(Arrays.equals(EncryptedPrivateKeyInfoData.encryptedData,
                epki.getEncryptedData()));
    }
View Full Code Here

Examples of javax.crypto.EncryptedPrivateKeyInfo

     * Checks exception order
     */
    public final void testEncryptedPrivateKeyInfoStringbyteArray6() {
        //Regression for HARMONY-768
        try {
            new EncryptedPrivateKeyInfo("0", new byte[] {});
            fail("NoSuchAlgorithmException expected");
        } catch (NoSuchAlgorithmException e) {
            //expected
        }   
    }
View Full Code Here

Examples of javax.crypto.EncryptedPrivateKeyInfo

     */
    public final void testEncryptedPrivateKeyInfoAlgorithmParametersbyteArray2()
            throws NoSuchAlgorithmException, IOException {
        // 1: pass null as AlgorithmParameters
        try {
            new EncryptedPrivateKeyInfo((AlgorithmParameters) null,
                    EncryptedPrivateKeyInfoData.encryptedData);
            fail(getName() + ": NullPointerException has not been thrown");
        } catch (NullPointerException ok) {
        }

        // 2: pass null as encrypted data
        try {
            AlgorithmParameters ap = AlgorithmParameters.getInstance("DSA");
            // use pregenerated AlgorithmParameters encodings
            ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding("DSA"));
            new EncryptedPrivateKeyInfo(ap, null);
            fail(getName() + ": NullPointerException has not been thrown");
        } catch (NullPointerException ok) {
        }
    }
View Full Code Here

Examples of javax.crypto.EncryptedPrivateKeyInfo

        try {
            AlgorithmParameters ap = AlgorithmParameters.getInstance("DSA");
            // use pregenerated AlgorithmParameters encodings
            ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding("DSA"));

            new EncryptedPrivateKeyInfo(ap, new byte[] {});
            fail(getName() + ": IllegalArgumentException has not been thrown");

        } catch (IllegalArgumentException ok) {
        }
    }
View Full Code Here

Examples of javax.crypto.EncryptedPrivateKeyInfo

        // use pregenerated AlgorithmParameters encodings
        ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding("DSA"));

        byte[] encryptedDataCopy = EncryptedPrivateKeyInfoData.encryptedData.clone();
        // pass valid array
        EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap,
                encryptedDataCopy);

        // modify array passed
        encryptedDataCopy[0] = (byte) 6;

        // check that internal state has not been affected
        assertTrue(Arrays.equals(EncryptedPrivateKeyInfoData.encryptedData,
                epki.getEncryptedData()));
    }
View Full Code Here

Examples of javax.crypto.EncryptedPrivateKeyInfo

    public final void testGetAlgParameters01_01() throws Exception {
        byte[] validEncodingWithUnknownAlgOID = EncryptedPrivateKeyInfoData
                .getValidEncryptedPrivateKeyInfoEncoding("DH");
        // correct oid value
        validEncodingWithUnknownAlgOID[18] = 0;
        EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
                validEncodingWithUnknownAlgOID);

        assertNull(epki.getAlgParameters());
    }
View Full Code Here

Examples of javax.crypto.EncryptedPrivateKeyInfo

     */
    public final void testGetAlgParameters02() throws IOException {
        boolean performed = false;
        for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
            try {
                EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
                        EncryptedPrivateKeyInfoData
                                .getValidEncryptedPrivateKeyInfoEncoding(
                                        EncryptedPrivateKeyInfoData.algName0[i][0],
                                        false));

                // check that method under test returns null
                assertNull(epki.getAlgParameters());

                performed = true;
            } catch (NoSuchAlgorithmException allowedFailure) {
            }
        }
View Full Code Here

Examples of javax.crypto.EncryptedPrivateKeyInfo

     */
    public final void testGetAlgParameters03() throws IOException {
        boolean performed = false;
        for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
            try {
                EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(
                        EncryptedPrivateKeyInfoData.algName0[i][0],
                        EncryptedPrivateKeyInfoData.encryptedData);

                // check that method under test returns null
                // for object constructed in such a way
                assertNull(epki.getAlgParameters());

                performed = true;
            } catch (NoSuchAlgorithmException allowedFailure) {
            }
        }
View Full Code Here

Examples of javax.crypto.EncryptedPrivateKeyInfo

                ap
                        .init(EncryptedPrivateKeyInfoData
                                .getParametersEncoding(
                                        EncryptedPrivateKeyInfoData.algName0[i][0]));

                EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap,
                        EncryptedPrivateKeyInfoData.encryptedData);

                // check that method under test returns
                // the same parameters instance
                assertSame(ap, epki.getAlgParameters());

                performed = true;
            } catch (NoSuchAlgorithmException allowedFailure) {
            }
        }
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.