102 lines
3.6 KiB
Java
102 lines
3.6 KiB
Java
package okhttp3.internal.ws;
|
|
|
|
import o.C14957gcv;
|
|
import o.C15111ghZ;
|
|
import o.C15155gij;
|
|
import o.gdP;
|
|
import org.bouncycastle.pqc.jcajce.spec.McElieceCCA2KeyGenParameterSpec;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public final class WebSocketProtocol {
|
|
public static final String ACCEPT_MAGIC = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
|
public static final int B0_FLAG_FIN = 128;
|
|
public static final int B0_FLAG_RSV1 = 64;
|
|
public static final int B0_FLAG_RSV2 = 32;
|
|
public static final int B0_FLAG_RSV3 = 16;
|
|
public static final int B0_MASK_OPCODE = 15;
|
|
public static final int B1_FLAG_MASK = 128;
|
|
public static final int B1_MASK_LENGTH = 127;
|
|
public static final int CLOSE_CLIENT_GOING_AWAY = 1001;
|
|
public static final long CLOSE_MESSAGE_MAX = 123;
|
|
public static final int CLOSE_NO_STATUS_CODE = 1005;
|
|
public static final WebSocketProtocol INSTANCE = new WebSocketProtocol();
|
|
public static final int OPCODE_BINARY = 2;
|
|
public static final int OPCODE_CONTINUATION = 0;
|
|
public static final int OPCODE_CONTROL_CLOSE = 8;
|
|
public static final int OPCODE_CONTROL_PING = 9;
|
|
public static final int OPCODE_CONTROL_PONG = 10;
|
|
public static final int OPCODE_FLAG_CONTROL = 8;
|
|
public static final int OPCODE_TEXT = 1;
|
|
public static final long PAYLOAD_BYTE_MAX = 125;
|
|
public static final int PAYLOAD_LONG = 127;
|
|
public static final int PAYLOAD_SHORT = 126;
|
|
public static final long PAYLOAD_SHORT_MAX = 65535;
|
|
|
|
private WebSocketProtocol() {
|
|
}
|
|
|
|
public final void toggleMask(C15111ghZ.RVV rvv, byte[] bArr) {
|
|
long j;
|
|
C14957gcv.e(rvv, "");
|
|
C14957gcv.e(bArr, "");
|
|
int length = bArr.length;
|
|
int i = 0;
|
|
do {
|
|
byte[] bArr2 = rvv.c;
|
|
int i2 = rvv.g;
|
|
int i3 = rvv.e;
|
|
if (bArr2 != null) {
|
|
while (i2 < i3) {
|
|
int i4 = i % length;
|
|
bArr2[i2] = (byte) (bArr2[i2] ^ bArr[i4]);
|
|
i2++;
|
|
i = i4 + 1;
|
|
}
|
|
}
|
|
long j2 = rvv.d;
|
|
C15111ghZ c15111ghZ = rvv.b;
|
|
C14957gcv.e(c15111ghZ);
|
|
if (j2 != c15111ghZ.c) {
|
|
j = rvv.d;
|
|
} else {
|
|
throw new IllegalStateException("no more bytes".toString());
|
|
}
|
|
} while (rvv.e(j == -1 ? 0L : j + (rvv.e - rvv.g)) != -1);
|
|
}
|
|
|
|
public final String closeCodeExceptionMessage(int i) {
|
|
if (i < 1000 || i >= 5000) {
|
|
return C14957gcv.c("Code must be in range [1000,5000): ", Integer.valueOf(i));
|
|
}
|
|
if ((1004 > i || i >= 1007) && (1015 > i || i >= 3000)) {
|
|
return null;
|
|
}
|
|
StringBuilder sb = new StringBuilder("Code ");
|
|
sb.append(i);
|
|
sb.append(" is reserved and may not be used.");
|
|
return sb.toString();
|
|
}
|
|
|
|
public final void validateCloseCode(int i) {
|
|
String closeCodeExceptionMessage = closeCodeExceptionMessage(i);
|
|
if (closeCodeExceptionMessage == null) {
|
|
return;
|
|
}
|
|
C14957gcv.e(closeCodeExceptionMessage);
|
|
throw new IllegalArgumentException(closeCodeExceptionMessage.toString());
|
|
}
|
|
|
|
public final String acceptHeader(String str) {
|
|
C14957gcv.e(str, "");
|
|
C15155gij.LWm lWm = C15155gij.c;
|
|
String c = C14957gcv.c(str, (Object) ACCEPT_MAGIC);
|
|
C14957gcv.e(c, "");
|
|
C14957gcv.e(c, "");
|
|
byte[] bytes = c.getBytes(gdP.a);
|
|
C14957gcv.c(bytes, "");
|
|
C15155gij c15155gij = new C15155gij(bytes);
|
|
c15155gij.d = c;
|
|
return c15155gij.b(McElieceCCA2KeyGenParameterSpec.SHA1).e();
|
|
}
|
|
}
|