Lines Matching defs:key
42 * Test that key1 (reference key) and key2 (key to be tested) are
70 private static void testPublic(KeyFactory kf, PublicKey key) throws Exception {
71 System.out.println("Testing public key...");
72 PublicKey key2 = (PublicKey)kf.translateKey(key);
73 KeySpec keySpec = kf.getKeySpec(key, ECPublicKeySpec.class);
75 KeySpec x509Spec = kf.getKeySpec(key, X509EncodedKeySpec.class);
77 KeySpec x509Spec2 = new X509EncodedKeySpec(key.getEncoded());
79 testKey(key, key);
80 testKey(key, key2);
81 testKey(key, key3);
82 testKey(key, key4);
83 testKey(key, key5);
86 private static void testPrivate(KeyFactory kf, PrivateKey key) throws Exception {
87 System.out.println("Testing private key...");
88 PrivateKey key2 = (PrivateKey)kf.translateKey(key);
89 KeySpec keySpec = kf.getKeySpec(key, ECPrivateKeySpec.class);
91 KeySpec pkcs8Spec = kf.getKeySpec(key, PKCS8EncodedKeySpec.class);
93 KeySpec pkcs8Spec2 = new PKCS8EncodedKeySpec(key.getEncoded());
95 testKey(key, key);
96 testKey(key, key2);
97 testKey(key, key3);
98 testKey(key, key4);
99 testKey(key, key5);
102 private static void test(KeyFactory kf, Key key) throws Exception {
103 if (key.getAlgorithm().equals("EC") == false) {
104 throw new Exception("Not an EC key");
106 if (key instanceof PublicKey) {
107 testPublic(kf, (PublicKey)key);
108 } else if (key instanceof PrivateKey) {
109 testPrivate(kf, (PrivateKey)key);