39 |
public static String PREFIX = "urn:x-storm:pointer-0.1:"; |
public static String PREFIX = "urn:x-storm:pointer-0.1:"; |
40 |
public static int PREFIX_LEN = PREFIX.length(); |
public static int PREFIX_LEN = PREFIX.length(); |
41 |
|
|
42 |
static final KeyFactory keyFactory; |
static KeyFactory keyFactory; |
43 |
static { |
static { |
44 |
try { |
try { |
45 |
keyFactory = KeyFactory.getInstance("DSA"); |
keyFactory = KeyFactory.getInstance("DSA"); |
46 |
} catch(NoSuchAlgorithmException e) { |
} catch(NoSuchAlgorithmException e) { |
47 |
e.printStackTrace(); |
e.printStackTrace(); |
48 |
throw new Error("PointerId needs DSA algorithm"); |
//throw new Error("PointerId needs DSA algorithm"); |
49 |
} |
} |
50 |
} |
} |
51 |
private static SecureRandom random = new SecureRandom(); |
private static SecureRandom random = new SecureRandom(); |
124 |
|
|
125 |
public static byte[] getKeyBytes(PublicKey key) |
public static byte[] getKeyBytes(PublicKey key) |
126 |
throws InvalidKeyException, InvalidKeySpecException { |
throws InvalidKeyException, InvalidKeySpecException { |
127 |
|
if(keyFactory == null) throw new Error("PointerId needs DSA algorithm"); |
128 |
key = (PublicKey)keyFactory.translateKey(key); |
key = (PublicKey)keyFactory.translateKey(key); |
129 |
EncodedKeySpec keySpec = |
EncodedKeySpec keySpec = |
130 |
(EncodedKeySpec)keyFactory.getKeySpec(key, X509EncodedKeySpec.class); |
(EncodedKeySpec)keyFactory.getKeySpec(key, X509EncodedKeySpec.class); |