forked from I2P_Developers/i2p.i2p
PrivateKeyFile: Add validateKeyPairs()
Router: Validate router key pairs read in from file
This commit is contained in:
@ -53,7 +53,7 @@ public class PrivateKeyFile {
|
||||
|
||||
protected final File file;
|
||||
private final I2PClient client;
|
||||
private Destination dest;
|
||||
protected Destination dest;
|
||||
protected PrivateKey privKey;
|
||||
protected SigningPrivateKey signingPrivKey;
|
||||
|
||||
@ -455,6 +455,23 @@ public class PrivateKeyFile {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that the PublicKey matches the PrivateKey, and
|
||||
* the SigningPublicKey matches the SigningPrivateKey.
|
||||
*
|
||||
* @return success
|
||||
* @since 0.9.16
|
||||
*/
|
||||
public boolean validateKeyPairs() {
|
||||
try {
|
||||
if (!dest.getPublicKey().equals(KeyGenerator.getPublicKey(privKey)))
|
||||
return false;
|
||||
return dest.getSigningPublicKey().equals(KeyGenerator.getSigningPublicKey(signingPrivKey));
|
||||
} catch (IllegalArgumentException iae) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder s = new StringBuilder(128);
|
||||
|
Reference in New Issue
Block a user