93 testSignature("MD2withRSA", privateKey, publicKey);
94 testSignature("MD5withRSA", privateKey, publicKey);
95 testSignature("SHA1withRSA", privateKey, publicKey);
96 testSignature("SHA224withRSA", privateKey, publicKey);
97 testSignature("SHA256withRSA", privateKey, publicKey);
98 RSAPublicKey rsaKey = (RSAPublicKey)publicKey;
99 if (rsaKey.getModulus().bitLength() > 512) {
100 // for SHA384 and SHA512 the data is too long for 512 bit keys
101 testSignature("SHA384withRSA", privateKey, publicKey);
102 testSignature("SHA512withRSA", privateKey, publicKey);
103 }
104 }
105
106 public static void main(String[] args) throws Exception {
107 main(new TestSignatures(), args);
108 }
109
110 @Override
111 public void main(Provider p) throws Exception {
112
113 /*
114 * Use Solaris SPARC 11.2 or later to avoid an intermittent failure
115 * when running SunPKCS11-Solaris (8044554)
116 */
117 if (p.getName().equals("SunPKCS11-Solaris") &&
118 props.getProperty("os.name").equals("SunOS") &&
119 props.getProperty("os.arch").equals("sparcv9") &&
120 props.getProperty("os.version").compareTo("5.11") <= 0 &&
121 getDistro().compareTo("11.2") < 0) {
122
123 System.out.println("SunPKCS11-Solaris provider requires " +
124 "Solaris SPARC 11.2 or later, skipping");
125 return;
126 }
127
128 long start = System.currentTimeMillis();
129 provider = p;
130 data = new byte[2048];
131 new Random().nextBytes(data);
132 KeyStore ks = getKeyStore();
133 KeyFactory kf = KeyFactory.getInstance("RSA", provider);
134 for (Enumeration e = ks.aliases(); e.hasMoreElements(); ) {
135 String alias = (String)e.nextElement();
136 if (ks.isKeyEntry(alias)) {
137 System.out.println("* Key " + alias + "...");
138 PrivateKey privateKey = (PrivateKey)ks.getKey(alias, password);
139 PublicKey publicKey = ks.getCertificate(alias).getPublicKey();
140 privateKey = (PrivateKey)kf.translateKey(privateKey);
141 publicKey = (PublicKey)kf.translateKey(publicKey);
142 test(privateKey, publicKey);
143 }
144 }
145 long stop = System.currentTimeMillis();
146 System.out.println("All tests passed (" + (stop - start) + " ms).");
147 }
|
93 testSignature("MD2withRSA", privateKey, publicKey);
94 testSignature("MD5withRSA", privateKey, publicKey);
95 testSignature("SHA1withRSA", privateKey, publicKey);
96 testSignature("SHA224withRSA", privateKey, publicKey);
97 testSignature("SHA256withRSA", privateKey, publicKey);
98 RSAPublicKey rsaKey = (RSAPublicKey)publicKey;
99 if (rsaKey.getModulus().bitLength() > 512) {
100 // for SHA384 and SHA512 the data is too long for 512 bit keys
101 testSignature("SHA384withRSA", privateKey, publicKey);
102 testSignature("SHA512withRSA", privateKey, publicKey);
103 }
104 }
105
106 public static void main(String[] args) throws Exception {
107 main(new TestSignatures(), args);
108 }
109
110 @Override
111 public void main(Provider p) throws Exception {
112
113 long start = System.currentTimeMillis();
114 provider = p;
115 data = new byte[2048];
116 new Random().nextBytes(data);
117 KeyStore ks = getKeyStore();
118 KeyFactory kf = KeyFactory.getInstance("RSA", provider);
119 for (Enumeration e = ks.aliases(); e.hasMoreElements(); ) {
120 String alias = (String)e.nextElement();
121 if (ks.isKeyEntry(alias)) {
122 System.out.println("* Key " + alias + "...");
123 PrivateKey privateKey = (PrivateKey)ks.getKey(alias, password);
124 PublicKey publicKey = ks.getCertificate(alias).getPublicKey();
125 privateKey = (PrivateKey)kf.translateKey(privateKey);
126 publicKey = (PublicKey)kf.translateKey(publicKey);
127 test(privateKey, publicKey);
128 }
129 }
130 long stop = System.currentTimeMillis();
131 System.out.println("All tests passed (" + (stop - start) + " ms).");
132 }
|