20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 import java.security.InvalidKeyException;
25 import java.security.NoSuchAlgorithmException;
26 import java.security.spec.InvalidKeySpecException;
27 import java.util.Arrays;
28 import java.util.Random;
29 import javax.crypto.SecretKey;
30 import javax.crypto.SecretKeyFactory;
31 import javax.crypto.interfaces.PBEKey;
32 import javax.crypto.spec.PBEKeySpec;
33
34 /**
35 * @test
36 * @bug 8041781
37 * @summary Verify if the SecretKeyFactory.translateKey() method works
38 * @author Alexander Fomin
39 * @run main PBKDF2Translate
40 */
41 public class PBKDF2Translate {
42
43 private static final String[] ALGO_TO_TEST = {
44 "PBKDF2WithHmacSHA1",
45 "PBKDF2WithHmacSHA224",
46 "PBKDF2WithHmacSHA256",
47 "PBKDF2WithHmacSHA384",
48 "PBKDF2WithHmacSHA512"
49 };
50
51 private static final String PASS_PHRASE = "some hidden string";
52 private static final int ITERATION_COUNT = 1000;
53 private static final int KEY_SIZE = 128;
54
55 private final String algoToTest;
56 private final byte[] salt = new byte[8];
57
58 public static void main(String[] args) throws Exception {
59
|
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 import java.security.InvalidKeyException;
25 import java.security.NoSuchAlgorithmException;
26 import java.security.spec.InvalidKeySpecException;
27 import java.util.Arrays;
28 import java.util.Random;
29 import javax.crypto.SecretKey;
30 import javax.crypto.SecretKeyFactory;
31 import javax.crypto.interfaces.PBEKey;
32 import javax.crypto.spec.PBEKeySpec;
33
34 /**
35 * @test
36 * @bug 8041781
37 * @summary Verify if the SecretKeyFactory.translateKey() method works
38 * @author Alexander Fomin
39 * @run main PBKDF2Translate
40 * @key randomness
41 */
42 public class PBKDF2Translate {
43
44 private static final String[] ALGO_TO_TEST = {
45 "PBKDF2WithHmacSHA1",
46 "PBKDF2WithHmacSHA224",
47 "PBKDF2WithHmacSHA256",
48 "PBKDF2WithHmacSHA384",
49 "PBKDF2WithHmacSHA512"
50 };
51
52 private static final String PASS_PHRASE = "some hidden string";
53 private static final int ITERATION_COUNT = 1000;
54 private static final int KEY_SIZE = 128;
55
56 private final String algoToTest;
57 private final byte[] salt = new byte[8];
58
59 public static void main(String[] args) throws Exception {
60
|