Lines Matching defs:key

53      * Test that key1 (reference key) and key2 (key to be tested) are
77 private static void testPublic(KeyFactory kf, PublicKey key) throws Exception {
78 System.out.println("Testing public key...");
79 PublicKey key2 = (PublicKey)kf.translateKey(key);
80 KeySpec rsaSpec = kf.getKeySpec(key, RSAPublicKeySpec.class);
82 KeySpec x509Spec = kf.getKeySpec(key, X509EncodedKeySpec.class);
84 KeySpec x509Spec2 = new X509EncodedKeySpec(key.getEncoded());
86 testKey(key, key);
87 testKey(key, key2);
88 testKey(key, key3);
89 testKey(key, key4);
90 testKey(key, key5);
93 private static void testPrivate(KeyFactory kf, PrivateKey key) throws Exception {
94 System.out.println("Testing private key...");
95 PrivateKey key2 = (PrivateKey)kf.translateKey(key);
96 KeySpec rsaSpec = kf.getKeySpec(key, RSAPrivateCrtKeySpec.class);
98 KeySpec pkcs8Spec = kf.getKeySpec(key, PKCS8EncodedKeySpec.class);
100 KeySpec pkcs8Spec2 = new PKCS8EncodedKeySpec(key.getEncoded());
102 testKey(key, key);
103 testKey(key, key2);
104 testKey(key, key3);
105 testKey(key, key4);
106 testKey(key, key5);
108 KeySpec rsaSpec2 = kf.getKeySpec(key, RSAPrivateKeySpec.class);
110 RSAPrivateKey rsaKey = (RSAPrivateKey)key;
117 private static void test(KeyFactory kf, Key key) throws Exception {
118 if (key.getAlgorithm().equals("RSA") == false) {
119 System.out.println("Not an RSA key, ignoring");
121 if (key instanceof PublicKey) {
122 testPublic(kf, (PublicKey)key);
123 } else if (key instanceof PrivateKey) {
124 testPrivate(kf, (PrivateKey)key);
134 Key key = null;