Package javax.crypto

Examples of javax.crypto.EncryptedPrivateKeyInfo


     * Test preconditions: wrong encoding passed as a parameter <br>
     * Expected: <code>IOException</code>
     */
    public final void testEncryptedPrivateKeyInfobyteArray3() {
        try {
            new EncryptedPrivateKeyInfo(new byte[0]);
            fail(getName() + ": IOException has not been thrown");
        } catch (IOException ok) {
        }
    }
View Full Code Here


     * Test preconditions: wrong encoding passed as a parameter <br>
     * Expected: <code>IOException</code>
     */
    public final void testEncryptedPrivateKeyInfobyteArray4() {
        try {
            new EncryptedPrivateKeyInfo(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9,
                    10 });
            fail(getName() + ": IOException has not been thrown");
        } catch (IOException ok) {
        }
    }
View Full Code Here

                    .getValidEncryptedPrivateKeyInfoEncoding("DSA");

            // ... and corrupt it (set wrong alg OID length)
            enc[9] = (byte) 6;

            new EncryptedPrivateKeyInfo(enc);
            fail(getName() + "(1): IOException has not been thrown");
        } catch (IOException ok) {
        }

        try {
            // 2: get valid encoding
            enc = EncryptedPrivateKeyInfoData
                    .getValidEncryptedPrivateKeyInfoEncoding("DSA");
            // ... and corrupt it (set wrong encrypted data tag)
            enc[307] = (byte) 6;
            new EncryptedPrivateKeyInfo(enc);
            fail(getName() + "(2): IOException has not been thrown");
        } catch (IOException ok) {
        }

        try {
            // 3: get valid encoding
            enc = EncryptedPrivateKeyInfoData
                    .getValidEncryptedPrivateKeyInfoEncoding("DSA");
            // ... and corrupt it (set wrong encrypted data length)
            enc[310] = (byte) 1;
            new EncryptedPrivateKeyInfo(enc);
            fail(getName() + "(3): IOException has not been thrown");
        } catch (IOException ok) {
        }

        try {
            // 4: get valid encoding
            enc = EncryptedPrivateKeyInfoData
                    .getValidEncryptedPrivateKeyInfoEncoding("DSA");
            // ... and corrupt it (set wrong tag for alg params sequence)
            enc[17] = (byte) 0x29;
            EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(enc);

            if (epki.getAlgParameters() == null) {
                // This kind of encoding corruption can
                // be only determined while AlgorithmParameters
                // initialization BUT No AlgorithmParameters instance
                // available for algName0[i][0].
                // So just skip this sub test
            } else {
                fail(getName() + "(4): IOException has not been thrown");
            }

        } catch (IOException ok) {
        }

        try {
            // 5: get valid encoding
            enc = EncryptedPrivateKeyInfoData
                    .getValidEncryptedPrivateKeyInfoEncoding("DSA");
            // ... and corrupt it (set wrong length for alg params sequence)
            enc[20] = (byte) 0x1d;
            new EncryptedPrivateKeyInfo(enc);
            fail(getName() + "(5): IOException has not been thrown");
        } catch (IOException ok) {
        }

        try {
            // 6: get valid encoding
            enc = EncryptedPrivateKeyInfoData
                    .getValidEncryptedPrivateKeyInfoEncoding("DSA");
            // ... and corrupt it (set wrong length for alg params sequence)
            enc[20] = (byte) 0x1f;
            new EncryptedPrivateKeyInfo(enc);
            fail(getName() + "(6): IOException has not been thrown");
        } catch (IOException ok) {
        }
    }
View Full Code Here

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

    public final void testEncryptedPrivateKeyInfoStringbyteArray1() {
        boolean performed = false;

        for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
            try {
                new EncryptedPrivateKeyInfo(
                        EncryptedPrivateKeyInfoData.algName0[i][0],
                        EncryptedPrivateKeyInfoData.encryptedData);
                performed = true;
            } catch (NoSuchAlgorithmException allowed) {
            }
View Full Code Here

     * Test preconditions: pass nonexistent algorithm name <br>
     * Expected: <code>NoSuchAlgorithmException</code>
     */
    public final void testEncryptedPrivateKeyInfoStringbyteArray2() {
        try {
            new EncryptedPrivateKeyInfo("bla-bla",
                    EncryptedPrivateKeyInfoData.encryptedData);
            fail(getName() + ": NoSuchAlgorithmException has not been thrown");
        } catch (NoSuchAlgorithmException ok) {
        }

        try {
            new EncryptedPrivateKeyInfo("",
                    EncryptedPrivateKeyInfoData.encryptedData);
            fail(getName() + ": NoSuchAlgorithmException has not been thrown");
        } catch (NoSuchAlgorithmException ok) {
        }
    }
View Full Code Here

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

        // pass null as encrypted data
        try {
            new EncryptedPrivateKeyInfo("DSA", null);
            fail(getName() + ": NullPointerException has not been thrown");
        } catch (NullPointerException ok) {
        }
    }
View Full Code Here

     * 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

    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

     * 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

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.