31 |
import java.util.*; |
import java.util.*; |
32 |
import java.io.*; |
import java.io.*; |
33 |
import java.security.*; |
import java.security.*; |
34 |
|
import java.security.spec.*; |
35 |
|
|
36 |
public final class PointerBlock { |
public final class PointerBlock { |
37 |
public static final String COOKIE = |
public static final String COOKIE = |
62 |
byte[] signature = Base32.decode(r.readLine()); |
byte[] signature = Base32.decode(r.readLine()); |
63 |
|
|
64 |
pointer = new PointerId(r.readLine()); |
pointer = new PointerId(r.readLine()); |
65 |
|
|
66 |
|
byte[] keyBytes = Base32.decode(r.readLine()); |
67 |
|
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes); |
68 |
|
PublicKey key = PointerId.keyFactory.generatePublic(keySpec); |
69 |
|
|
70 |
timestamp = Long.parseLong(r.readLine()); |
timestamp = Long.parseLong(r.readLine()); |
71 |
target = new BlockId(r.readLine()); |
target = new BlockId(r.readLine()); |
72 |
|
|
75 |
|
|
76 |
r.close(); |
r.close(); |
77 |
|
|
78 |
|
// Next, verify that the pubkey matches the pointer id. |
79 |
|
|
80 |
|
pointer.verify(keyBytes); |
81 |
|
|
82 |
// Now, verify signature. |
// Now, verify signature. |
83 |
// Everything *after* the signature itself is signed. |
// Everything *after* the signature itself is signed. |
84 |
is = block.getInputStream(); |
is = block.getInputStream(); |
92 |
} |
} |
93 |
|
|
94 |
Signature s = Signature.getInstance("SHA1withDSA"); |
Signature s = Signature.getInstance("SHA1withDSA"); |
95 |
s.initVerify(pointer.getKey()); |
s.initVerify(key); |
96 |
|
|
97 |
int b; |
int b; |
98 |
while((b = is.read()) >= 0) |
while((b = is.read()) >= 0) |