33 |
import java.security.*; |
import java.security.*; |
34 |
|
|
35 |
public class PointerIndex { |
public class PointerIndex { |
36 |
public static boolean dbg = true; |
public static boolean dbg = false; |
37 |
private static void p(String s) { System.out.println("PointerIndex:: "+s); } |
private static void p(String s) { System.out.println("PointerIndex:: "+s); } |
38 |
|
|
39 |
public static final String uri = |
public static final String uri = |
82 |
return result; |
return result; |
83 |
} |
} |
84 |
|
|
85 |
public void set(PointerId id, BlockId target, PrivateKey key) |
public void set(PointerId id, BlockId target, KeyPair keyPair) |
86 |
throws IOException, GeneralSecurityException { |
throws IOException, GeneralSecurityException { |
87 |
// XXX this assumes that the computer clock |
// XXX this assumes that the computer clock |
88 |
// is always set correctly: if there is an existing |
// is always set correctly: if there is an existing |
91 |
// actually change the pointer... |
// actually change the pointer... |
92 |
long timestamp = System.currentTimeMillis(); |
long timestamp = System.currentTimeMillis(); |
93 |
|
|
94 |
|
byte[] keyBytes = |
95 |
|
PointerId.getKeyBytes(keyPair.getPublic()); |
96 |
|
|
97 |
String data = |
String data = |
98 |
id.toString() + "\n" + |
id.toString() + "\n" + |
99 |
|
Base32.encode(keyBytes) + "\n" + |
100 |
timestamp + "\n" + |
timestamp + "\n" + |
101 |
target.toString(); |
target.toString(); |
102 |
|
|
103 |
Signature s = Signature.getInstance("SHA1withDSA"); |
Signature s = Signature.getInstance("SHA1withDSA"); |
104 |
s.initSign(key); |
s.initSign(keyPair.getPrivate()); |
105 |
s.update(data.getBytes("US-ASCII")); |
s.update(data.getBytes("US-ASCII")); |
106 |
byte[] signature = s.sign(); |
byte[] signature = s.sign(); |
107 |
|
|