Lines Matching defs:key

54      * Test that key1 (reference key) and key2 (key to be tested) are
78 private static void testPublic(KeyFactory kf, PublicKey key) throws Exception {
79 System.out.println("Testing public key...");
80 PublicKey key2 = (PublicKey)kf.translateKey(key);
81 KeySpec rsaSpec = kf.getKeySpec(key, RSAPublicKeySpec.class);
83 KeySpec x509Spec = kf.getKeySpec(key, X509EncodedKeySpec.class);
85 KeySpec x509Spec2 = new X509EncodedKeySpec(key.getEncoded());
87 testKey(key, key);
88 testKey(key, key2);
89 testKey(key, key3);
90 testKey(key, key4);
91 testKey(key, key5);
94 private static void testPrivate(KeyFactory kf, PrivateKey key) throws Exception {
95 System.out.println("Testing private key...");
96 PrivateKey key2 = (PrivateKey)kf.translateKey(key);
97 KeySpec rsaSpec = kf.getKeySpec(key, RSAPrivateCrtKeySpec.class);
99 KeySpec pkcs8Spec = kf.getKeySpec(key, PKCS8EncodedKeySpec.class);
101 KeySpec pkcs8Spec2 = new PKCS8EncodedKeySpec(key.getEncoded());
103 testKey(key, key);
104 testKey(key, key2);
105 testKey(key, key3);
106 testKey(key, key4);
107 testKey(key, key5);
110 // KeySpec rsaSpec2 = kf.getKeySpec(key, RSAPrivateKeySpec.class);
112 // RSAPrivateKey rsaKey = (RSAPrivateKey)key;
119 private static void test(KeyFactory kf, Key key) throws Exception {
120 if (key.getAlgorithm().equals("RSA") == false) {
121 System.out.println("Not an RSA key, ignoring");
123 if (key instanceof PublicKey) {
124 testPublic(kf, (PublicKey)key);
125 } else if (key instanceof PrivateKey) {
126 testPrivate(kf, (PrivateKey)key);
140 Key key = null;