Data: Consolidate offline key check

i2ptunnel: Prevent registration auth if key offline
This commit is contained in:
zzz
2019-03-09 11:47:03 +00:00
parent 409207e02d
commit d6a53cc3a6
5 changed files with 20 additions and 42 deletions

View File

@ -117,7 +117,7 @@ class SAMUtils {
SigType dtype = d.getSigningPublicKey().getType();
SigningPrivateKey spk = new SigningPrivateKey(dtype);
spk.readBytes(destKeyStream);
if (isOffline(spk)) {
if (spk.isOffline()) {
// offlineExpiration
DataHelper.readLong(destKeyStream, 4);
int itype = (int) DataHelper.readLong(destKeyStream, 2);
@ -140,19 +140,6 @@ class SAMUtils {
return destKeyStream.available() == 0;
}
/**
* @since 0.9.39
*/
private static boolean isOffline(SigningPrivateKey spk) {
byte[] data = spk.getData();
for (int i = 0; i < data.length; i++) {
if (data[i] != 0)
return false;
}
return true;
}
/**
* Resolved the specified hostname.
*