Package javax.crypto

Examples of javax.crypto.EncryptedPrivateKeyInfo


     */
    public final void testGetEncryptedData04() {
        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
                // new array each time
                byte[] ecd1 = epki.getEncryptedData();
                byte[] ecd2 = epki.getEncryptedData();
                assertNotSame(EncryptedPrivateKeyInfoData.encryptedData, ecd1);
                assertNotSame(EncryptedPrivateKeyInfoData.encryptedData, ecd2);
                assertNotSame(ecd1, ecd2);

                performed = true;
View Full Code Here


        for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) {
            try {
                byte[] enc = EncryptedPrivateKeyInfoData
                        .getValidEncryptedPrivateKeyInfoEncoding(
                                EncryptedPrivateKeyInfoData.algName0[i][0]);
                EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(enc);

                // check that method under test returns
                // valid encoded form
                assertTrue(Arrays.equals(enc, epki.getEncoded()));

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

     */
    public final void testGetEncoded02() 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
                // valid encoded form
                byte[] refEnc = EncryptedPrivateKeyInfoData
                        .getValidEncryptedPrivateKeyInfoEncoding(
                                EncryptedPrivateKeyInfoData.algName0[i][0],
                                false);
                //                System.out.println(Array.toString(refEnc, " "));
                byte[] actEnc = epki.getEncoded();
                //                System.out.println(Array.toString(actEnc, " "));
                assertTrue(Arrays.equals(refEnc, actEnc));

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

                        .getInstance(EncryptedPrivateKeyInfoData.algName0[i][0]);
                // use pregenerated AlgorithmParameters encodings
                ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding(
                        EncryptedPrivateKeyInfoData.algName0[i][0]));

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

                // check that method under test returns
                // valid encoded form
                assertTrue(Arrays.equals(
                        EncryptedPrivateKeyInfoData
                            .getValidEncryptedPrivateKeyInfoEncoding(
                                EncryptedPrivateKeyInfoData.algName0[i][0]),
                                epki.getEncoded()));

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

     */
    public final void testGetEncoded04() 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
                // new array each time
                byte[] ec1 = epki.getEncoded();
                byte[] ec2 = epki.getEncoded();
                byte[] ec3 = epki.getEncoded();
                assertNotSame(ec1, ec2);
                assertNotSame(ec2, ec3);
                assertNotSame(ec1, ec3);

                performed = true;
View Full Code Here

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

                try {

                    // check that method under test throws NPE
                    epki.getKeySpec((Cipher) null);
                    fail(getName() + "NullPointerException has not been thrown");

                } catch (NullPointerException ok) {
                } catch (InvalidKeySpecException e) {
                    fail(getName() + "Unexpected exception: " + e);
View Full Code Here

                // generate test data
                TestDataGenerator g = new TestDataGenerator(algName[i][0],
                        algName[i][1], privateKeyInfo, null);

                // create test object
                EncryptedPrivateKeyInfo epki;
                if (g.ap() == null) {
                    epki = new EncryptedPrivateKeyInfo(algName[i][0], g.ct());
                } else {
                    epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct());
                }

                // call methods under test
                try {

                    PKCS8EncodedKeySpec eks = epki.getKeySpec(g.c());

                    if (!Arrays.equals(privateKeyInfo, eks.getEncoded())) {
                        fail(algName[i][0] + " != " + algName[i][1]);
                    }
                } catch (InvalidKeySpecException e) {
View Full Code Here

                // generate test data
                TestDataGenerator g = new TestDataGenerator(algName[i][0],
                        algName[i][1], privateKeyInfoDamaged, null);

                // create test object
                EncryptedPrivateKeyInfo epki;
                if (g.ap() == null) {
                    epki = new EncryptedPrivateKeyInfo(algName[i][0], g.ct());
                } else {
                    epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct());
                }

                // call methods under test
                try {
                    epki.getKeySpec(g.c());

                    // must not get here because decrypted data does
                    // not represent valid PKCS8 encoding
                    fail(algName[i][0] + ", " + algName[i][1]);
                } catch (InvalidKeySpecException ok) {
View Full Code Here

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

                try {

                    // check that method under test throws NPE
                    epki.getKeySpec((Key) null);
                    fail(getName() + "NullPointerException has not been thrown");

                } catch (NullPointerException ok) {
                } catch (InvalidKeyException e) {
                    fail(getName() + "Unexpected exception: " + e);
View Full Code Here

                // generate test data
                TestDataGenerator g = new TestDataGenerator(algName[i][0],
                        algName[i][1], privateKeyInfo, null);

                // create test object
                EncryptedPrivateKeyInfo epki;
                if (g.ap() == null) {
                    epki = new EncryptedPrivateKeyInfo(algName[i][0], g.ct());
                } else {
                    epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct());
                }

                try {
                    PKCS8EncodedKeySpec eks = epki
                            .getKeySpec(g.pubK() == null ? g.k() : g.pubK());

                    if (!Arrays.equals(privateKeyInfo, eks.getEncoded())) {
                        fail(algName[i][0] + " != " + algName[i][1]);
                    }
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.