forked from I2P_Developers/i2p.i2p
SAM: Fix checkPrivateDestination() for key certs (ticket #1318)
This commit is contained in:
@ -79,15 +79,26 @@ class SAMUtils {
|
||||
}
|
||||
|
||||
public static class InvalidDestinationException extends Exception {
|
||||
static final long serialVersionUID = 0x1 ;
|
||||
private static final long serialVersionUID = 0x1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check whether a base64-encoded {dest,privkey,signingprivkey} is valid
|
||||
*
|
||||
* @param dest The base64-encoded destination and keys to be checked (same format as PrivateKeyFile)
|
||||
*
|
||||
* @throws InvalidDestination if invalid
|
||||
*/
|
||||
public static void checkPrivateDestination(String dest) throws InvalidDestinationException {
|
||||
ByteArrayInputStream destKeyStream = new ByteArrayInputStream(Base64.decode(dest));
|
||||
|
||||
try {
|
||||
new Destination().readBytes(destKeyStream);
|
||||
Destination d = new Destination();
|
||||
d.readBytes(destKeyStream);
|
||||
new PrivateKey().readBytes(destKeyStream);
|
||||
new SigningPrivateKey().readBytes(destKeyStream);
|
||||
SigningPrivateKey spk = new SigningPrivateKey(d.getSigningPublicKey().getType());
|
||||
spk.readBytes(destKeyStream);
|
||||
} catch (Exception e) {
|
||||
throw new InvalidDestinationException();
|
||||
}
|
||||
|
Reference in New Issue
Block a user