what-the-bank/sources/org/bouncycastle/crypto/tls/DTLSReplayWindow.java

51 lines
1.4 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.crypto.tls;
/* loaded from: classes6.dex */
class DTLSReplayWindow {
private static final long VALID_SEQ_MASK = 281474976710655L;
private static final long WINDOW_SIZE = 64;
private long latestConfirmedSeq = -1;
private long bitmap = 0;
/* JADX INFO: Access modifiers changed from: package-private */
public boolean shouldDiscard(long j) {
if ((VALID_SEQ_MASK & j) != j) {
return true;
}
long j2 = this.latestConfirmedSeq;
if (j > j2) {
return false;
}
long j3 = j2 - j;
return j3 >= WINDOW_SIZE || (this.bitmap & (1 << ((int) j3))) != 0;
}
void reset() {
this.latestConfirmedSeq = -1L;
this.bitmap = 0L;
}
/* JADX INFO: Access modifiers changed from: package-private */
public void reportAuthenticated(long j) {
if ((VALID_SEQ_MASK & j) != j) {
throw new IllegalArgumentException("'seq' out of range");
}
long j2 = this.latestConfirmedSeq;
if (j <= j2) {
long j3 = j2 - j;
if (j3 < WINDOW_SIZE) {
this.bitmap |= 1 << ((int) j3);
return;
}
return;
}
long j4 = j - j2;
if (j4 >= WINDOW_SIZE) {
this.bitmap = 1L;
} else {
this.bitmap = (this.bitmap << ((int) j4)) | 1;
}
this.latestConfirmedSeq = j;
}
}