Ratchet: log tweaks

This commit is contained in:
zzz
2021-01-17 09:47:04 -05:00
parent a6398d88a9
commit b17d321503
2 changed files with 20 additions and 7 deletions

View File

@@ -864,7 +864,7 @@ public class RatchetSKM extends SessionKeyManager implements SessionTagListener
if (ts.getAcked())
buf.append(" acked");
buf.append(" created:</b> ").append(DataHelper.formatTime(ts.getCreated()))
.append(" <b>last use:</b> ").append(DataHelper.formatTime(ts.getDate()));
.append(" <b>last used:</b> ").append(DataHelper.formatTime(ts.getDate()));
buf.append(" <b>expires in:</b> ").append(DataHelper.formatDuration2(expires)).append(" with ");
buf.append(size).append(" tags remaining");
if (ts.getNextKey() != null)
@@ -1178,8 +1178,11 @@ public class RatchetSKM extends SessionKeyManager implements SessionTagListener
_context.clock().now(), newtsID, _myOBKeyID);
_tagSet = ts;
_currentOBTagSetID = newtsID;
if (_log.shouldDebug())
_log.debug("Got nextkey " + key + "\nratchet to new OB ES TS:\n" + ts);
if (_log.shouldWarn())
_log.warn("Got nextkey " + key +
"from " + (_destination != null ? _destination.toBase32() : "???") +
"\nold OB TS:\n" + oldts +
"\nratchet to new OB ES TS:\n" + ts);
} else {
// this is about my inbound tag set
if (key.equals(_hisOBKey)) {
@@ -1273,8 +1276,11 @@ public class RatchetSKM extends SessionKeyManager implements SessionTagListener
_context.clock().now(), newtsID, _myIBKeyID,
MAX_RCV_WINDOW_ES, MAX_RCV_WINDOW_ES);
_nextIBRootKey = ts.getNextRootKey();
if (_log.shouldDebug())
_log.debug("Got nextkey " + key + "\nratchet to new IB ES TS:\n" + ts);
if (_log.shouldWarn())
_log.warn("Got nextkey " + key +
"from " + (_destination != null ? _destination.toBase32() : "???") +
"\nold IB TS ID #" + oldtsID +
"\nratchet to new IB ES TS:\n" + ts);
}
}
}

View File

@@ -81,6 +81,7 @@ class RatchetTagSet implements TagSetHandle {
private static final byte[] ZEROLEN = new byte[0];
private static final int TAGLEN = RatchetSessionTag.LENGTH;
private static final int MAX = 65535;
private static final boolean DEBUG = false;
private static final boolean TEST_RATCHET = false;
// 4 * max streaming window
private static final int LOW = TEST_RATCHET ? (MAX - 512) : (MAX - 4096);
@@ -572,10 +573,16 @@ class RatchetTagSet implements TagSetHandle {
buf.append("\n ").append(n).append('\t').append(tag.toBase64());
if (_sessionKeys != null) {
byte[] key = _sessionKeys.get(n);
if (key != null)
if (key != null) {
buf.append('\t').append(Base64.encode(key));
else
} else {
buf.append("\tTBD");
// set DEBUG if you want to see them all
if (!DEBUG) {
buf.append(" (" + (sz - (i +1)) + " more)");
break;
}
}
}
}
}