Package javax.crypto

Examples of javax.crypto.EncryptedPrivateKeyInfo


                // 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());
                }

                try {
                    epki.getKeySpec(g.pubK() == null ? g.k() : g.pubK());
                    fail(algName[i][0] + ", " + algName[i][1]);
                } catch (InvalidKeyException e) {
                }

                performed = true;
View Full Code Here


    public final void testGetKeySpecKeyString01() throws Exception {
        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, "SomeProviderName");
                    fail(getName() + "NullPointerException has not been thrown");

                } catch (NullPointerException ok) {
                }

                try {

                    // check that method under test throws NPE
                    epki.getKeySpec(new Key() {
                        public String getAlgorithm() {
                            return "alg";
                        }

                        public String getFormat() {
View Full Code Here

                    continue;
                }

                try {
                    // 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(),
                                provider[l].getName());

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

                    continue;
                }

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

                        epki.getKeySpec(g.pubK() == null ? g.k() : g.pubK(),
                                provider[l].getName());

                        fail(algName[i][0] + ", " + algName[i][1]);

                    } catch (InvalidKeyException e) {
View Full Code Here

    public final void testGetKeySpecKeyProvider01() throws Exception {
        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, (Provider) null);
                    fail(getName() + "NullPointerException has not been thrown");
                } catch (NullPointerException ok) {
                }

                try {

                    // check that method under test throws NPE
                    epki.getKeySpec(new Key() {
                        public String getAlgorithm() {
                            return "alg";
                        }

                        public String getFormat() {
View Full Code Here

                } catch (TestDataGenerator.AllowedFailure allowedFailure) {
                    continue;
                }
                try {
                    // 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(),
                                provider[l]);

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

                    continue;
                }

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

                        epki.getKeySpec(g.pubK() == null ? g.k() : g.pubK(),
                                provider[l]);

                        fail(algName[i][0] + ", " + algName[i][1]);

                    } catch (InvalidKeyException e) {
View Full Code Here

     *
     * @throws IOException
     * @throws NoSuchAlgorithmException
     */
    public final void testEncryptedPrivateKeyInfobyteArray1() throws Exception {
        new EncryptedPrivateKeyInfo(EncryptedPrivateKeyInfoData
                .getValidEncryptedPrivateKeyInfoEncoding("DH"));
    }
View Full Code Here

     * @throws IOException
     */
    public final void testEncryptedPrivateKeyInfobyteArray2()
            throws IOException {
        try {
            new EncryptedPrivateKeyInfo(null);
            fail(getName() + ": NullPointerException has not been thrown");
        } catch (NullPointerException ok) {
        }
    }
View Full Code Here

     * 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

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.