Package javax.crypto

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


        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

        // 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

     */
    public final void testGetAlgParameters01() 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]));

                AlgorithmParameters apar = epki.getAlgParameters();
                if (apar == null) {
                    continue;
                }

                // check that method under test returns
View Full Code Here

    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

     */
    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

     */
    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

                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

     */
    public final void testGetEncryptedData01() 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]));

                // check that method under test returns
                // valid encrypted data
                assertTrue(Arrays.equals(
                        EncryptedPrivateKeyInfoData.encryptedData, epki
                                .getEncryptedData()));

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

     */
    public final void testGetEncryptedData02() {
        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
                // valid encrypted data
                assertTrue(Arrays.equals(
                        EncryptedPrivateKeyInfoData.encryptedData, epki
                                .getEncryptedData()));

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

TOP

Related Classes of javax.crypto.EncryptedPrivateKeyInfo

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.