equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
25 * @test |
25 * @test |
26 * @bug 6687725 |
26 * @bug 6687725 |
27 * @summary Test internal PKCS5Padding impl with various error conditions. |
27 * @summary Test internal PKCS5Padding impl with various error conditions. |
28 * @author Valerie Peng |
28 * @author Valerie Peng |
29 * @library .. |
29 * @library .. |
|
30 * @run main/othervm TestPKCS5PaddingError |
|
31 * @run main/othervm TestPKCS5PaddingError sm |
30 */ |
32 */ |
31 import java.io.*; |
|
32 import java.nio.*; |
|
33 import java.util.*; |
|
34 |
33 |
35 import java.security.*; |
34 import java.security.AlgorithmParameters; |
36 import java.security.spec.AlgorithmParameterSpec; |
35 import java.security.NoSuchAlgorithmException; |
37 |
36 import java.security.Provider; |
38 import javax.crypto.*; |
37 import javax.crypto.BadPaddingException; |
39 import javax.crypto.spec.IvParameterSpec; |
38 import javax.crypto.Cipher; |
|
39 import javax.crypto.IllegalBlockSizeException; |
|
40 import javax.crypto.KeyGenerator; |
|
41 import javax.crypto.SecretKey; |
40 |
42 |
41 public class TestPKCS5PaddingError extends PKCS11Test { |
43 public class TestPKCS5PaddingError extends PKCS11Test { |
42 private static class CI { // class for holding Cipher Information |
44 private static class CI { // class for holding Cipher Information |
43 String transformation; |
45 String transformation; |
44 String keyAlgo; |
46 String keyAlgo; |
60 new CI("AES/ECB/PKCS5Padding", "AES"), |
62 new CI("AES/ECB/PKCS5Padding", "AES"), |
61 }; |
63 }; |
62 |
64 |
63 private static StringBuffer debugBuf = new StringBuffer(); |
65 private static StringBuffer debugBuf = new StringBuffer(); |
64 |
66 |
|
67 @Override |
65 public void main(Provider p) throws Exception { |
68 public void main(Provider p) throws Exception { |
66 boolean status = true; |
|
67 Random random = new Random(); |
|
68 |
|
69 try { |
69 try { |
70 byte[] plainText = new byte[200]; |
70 byte[] plainText = new byte[200]; |
71 |
71 |
72 for (int i = 0; i < TEST_LIST.length; i++) { |
72 for (int i = 0; i < TEST_LIST.length; i++) { |
73 CI currTest = TEST_LIST[i]; |
73 CI currTest = TEST_LIST[i]; |
125 throw ex; |
125 throw ex; |
126 } |
126 } |
127 } |
127 } |
128 |
128 |
129 public static void main(String[] args) throws Exception { |
129 public static void main(String[] args) throws Exception { |
130 main(new TestPKCS5PaddingError()); |
130 main(new TestPKCS5PaddingError(), args); |
131 } |
131 } |
132 } |
132 } |