jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CICOPBEFuncTest.java
author tyan
Wed, 23 Sep 2015 21:28:14 +0000
changeset 32766 2322e6c2a032
permissions -rw-r--r--
8048604: Tests for strong crypto ciphers Summary: SQE test co-location effort Reviewed-by: valeriep
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32766
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
     1
/*
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
     2
 * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
     4
 *
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
     7
 * published by the Free Software Foundation.
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
     8
 *
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    13
 * accompanied this code).
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    14
 *
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    18
 *
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    21
 * questions.
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    22
 */
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    23
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    24
/*
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    25
 * @test
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    26
 * @bug 8048604
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    27
 * @summary This test verifies the assertion "The encrypt/decrypt
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    28
 *  mechanism of cipher should perform correctly." for feature
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    29
 *  "CipherInputStream & CipherOutputStream".
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    30
 * @library ../
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    31
 * @run main CICOPBEFuncTest
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    32
 */
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    33
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    34
import java.util.Arrays;
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    35
import javax.crypto.Cipher;
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    36
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    37
public class CICOPBEFuncTest {
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    38
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    39
    public static void main(String[] args) throws Exception {
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    40
        for (PBEAlgorithm algorithm : PBEAlgorithm.values()) {
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    41
            // int buffertin test
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    42
            String algo = algorithm.baseAlgo.toUpperCase();
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    43
            if (!algo.contains("TRIPLEDES") && !algo.contains("AES_256")
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    44
                    || Cipher.getMaxAllowedKeyLength(algo) > 128) {
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    45
                // skip this if this key length is larger than what's
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    46
                // configured in the jce jurisdiction policy files
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    47
                System.out.println("Testing " + algorithm.getTransformation());
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    48
                for (String type : Arrays.asList(CICO_PBE_Test.INT_BYTE_BUFFER,
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    49
                        CICO_PBE_Test.BYTE_ARR_BUFFER)) {
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    50
                    new CICO_PBE_RW_Test(algorithm)
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    51
                        .proceedTest(type);
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    52
                    new CICO_PBE_SKIP_Test(algorithm)
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    53
                        .proceedTest(type);
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    54
                }
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    55
            }
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    56
        }
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    57
    }
2322e6c2a032 8048604: Tests for strong crypto ciphers
tyan
parents:
diff changeset
    58
}