mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-25 16:42:30 -06:00
190 lines
9 KiB
Java
190 lines
9 KiB
Java
|
package okio;
|
||
|
|
||
|
import io.sentry.protocol.TransactionInfo;
|
||
|
import java.io.IOException;
|
||
|
import java.security.InvalidKeyException;
|
||
|
import java.security.MessageDigest;
|
||
|
import javax.crypto.Mac;
|
||
|
import javax.crypto.spec.SecretKeySpec;
|
||
|
import kotlin.Deprecated;
|
||
|
import kotlin.DeprecationLevel;
|
||
|
import kotlin.Metadata;
|
||
|
import kotlin.ReplaceWith;
|
||
|
import kotlin.Unit;
|
||
|
import kotlin.jvm.JvmStatic;
|
||
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
||
|
import kotlin.jvm.internal.Intrinsics;
|
||
|
|
||
|
/* compiled from: HashingSink.kt */
|
||
|
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000B\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0002\b\u0002\u0018\u0000 \u00172\u00020\u0001:\u0001\u0017B\u0017\b\u0010\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005¢\u0006\u0002\u0010\u0006B\u001f\b\u0010\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0007\u001a\u00020\b\u0012\u0006\u0010\u0004\u001a\u00020\u0005¢\u0006\u0002\u0010\tJ\r\u0010\n\u001a\u00020\bH\u0007¢\u0006\u0002\b\u0010J\u0018\u0010\u0011\u001a\u00020\u00122\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u0016H\u0016R\u0011\u0010\n\u001a\u00020\b8G¢\u0006\u0006\u001a\u0004\b\n\u0010\u000bR\u0010\u0010\f\u001a\u0004\u0018\u00010\rX\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\u000e\u001a\u0004\u0018\u00010\u000fX\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u0018"}, d2 = {"Lokio/HashingSink;", "Lokio/ForwardingSink;", "sink", "Lokio/Sink;", "algorithm", "", "(Lokio/Sink;Ljava/lang/String;)V", "key", "Lokio/ByteString;", "(Lokio/Sink;Lokio/ByteString;Ljava/lang/String;)V", "hash", "()Lokio/ByteString;", "mac", "Ljavax/crypto/Mac;", "messageDigest", "Ljava/security/MessageDigest;", "-deprecated_hash", "write", "", TransactionInfo.JsonKeys.SOURCE, "Lokio/Buffer;", "byteCount", "", "Companion", "okio"}, k = 1, mv = {1, 4, 0})
|
||
|
/* loaded from: classes3.dex */
|
||
|
public final class HashingSink extends ForwardingSink {
|
||
|
|
||
|
/* renamed from: Companion, reason: from kotlin metadata */
|
||
|
public static final Companion INSTANCE = new Companion(null);
|
||
|
private final Mac mac;
|
||
|
private final MessageDigest messageDigest;
|
||
|
|
||
|
@JvmStatic
|
||
|
public static final HashingSink hmacSha1(Sink sink, ByteString byteString) {
|
||
|
return INSTANCE.hmacSha1(sink, byteString);
|
||
|
}
|
||
|
|
||
|
@JvmStatic
|
||
|
public static final HashingSink hmacSha256(Sink sink, ByteString byteString) {
|
||
|
return INSTANCE.hmacSha256(sink, byteString);
|
||
|
}
|
||
|
|
||
|
@JvmStatic
|
||
|
public static final HashingSink hmacSha512(Sink sink, ByteString byteString) {
|
||
|
return INSTANCE.hmacSha512(sink, byteString);
|
||
|
}
|
||
|
|
||
|
@JvmStatic
|
||
|
public static final HashingSink md5(Sink sink) {
|
||
|
return INSTANCE.md5(sink);
|
||
|
}
|
||
|
|
||
|
@JvmStatic
|
||
|
public static final HashingSink sha1(Sink sink) {
|
||
|
return INSTANCE.sha1(sink);
|
||
|
}
|
||
|
|
||
|
@JvmStatic
|
||
|
public static final HashingSink sha256(Sink sink) {
|
||
|
return INSTANCE.sha256(sink);
|
||
|
}
|
||
|
|
||
|
@JvmStatic
|
||
|
public static final HashingSink sha512(Sink sink) {
|
||
|
return INSTANCE.sha512(sink);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
||
|
public HashingSink(Sink sink, String algorithm) {
|
||
|
super(sink);
|
||
|
Intrinsics.checkNotNullParameter(sink, "sink");
|
||
|
Intrinsics.checkNotNullParameter(algorithm, "algorithm");
|
||
|
this.messageDigest = MessageDigest.getInstance(algorithm);
|
||
|
this.mac = null;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
||
|
public HashingSink(Sink sink, ByteString key, String algorithm) {
|
||
|
super(sink);
|
||
|
Intrinsics.checkNotNullParameter(sink, "sink");
|
||
|
Intrinsics.checkNotNullParameter(key, "key");
|
||
|
Intrinsics.checkNotNullParameter(algorithm, "algorithm");
|
||
|
try {
|
||
|
Mac mac = Mac.getInstance(algorithm);
|
||
|
mac.init(new SecretKeySpec(key.toByteArray(), algorithm));
|
||
|
Unit unit = Unit.INSTANCE;
|
||
|
this.mac = mac;
|
||
|
this.messageDigest = null;
|
||
|
} catch (InvalidKeyException e) {
|
||
|
throw new IllegalArgumentException(e);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // okio.ForwardingSink, okio.Sink
|
||
|
public void write(Buffer source, long byteCount) throws IOException {
|
||
|
Intrinsics.checkNotNullParameter(source, "source");
|
||
|
Util.checkOffsetAndCount(source.size(), 0L, byteCount);
|
||
|
Segment segment = source.head;
|
||
|
Intrinsics.checkNotNull(segment);
|
||
|
long j = 0;
|
||
|
while (j < byteCount) {
|
||
|
int min = (int) Math.min(byteCount - j, segment.limit - segment.pos);
|
||
|
MessageDigest messageDigest = this.messageDigest;
|
||
|
if (messageDigest != null) {
|
||
|
messageDigest.update(segment.data, segment.pos, min);
|
||
|
} else {
|
||
|
Mac mac = this.mac;
|
||
|
Intrinsics.checkNotNull(mac);
|
||
|
mac.update(segment.data, segment.pos, min);
|
||
|
}
|
||
|
j += min;
|
||
|
segment = segment.next;
|
||
|
Intrinsics.checkNotNull(segment);
|
||
|
}
|
||
|
super.write(source, byteCount);
|
||
|
}
|
||
|
|
||
|
public final ByteString hash() {
|
||
|
byte[] result;
|
||
|
MessageDigest messageDigest = this.messageDigest;
|
||
|
if (messageDigest != null) {
|
||
|
result = messageDigest.digest();
|
||
|
} else {
|
||
|
Mac mac = this.mac;
|
||
|
Intrinsics.checkNotNull(mac);
|
||
|
result = mac.doFinal();
|
||
|
}
|
||
|
Intrinsics.checkNotNullExpressionValue(result, "result");
|
||
|
return new ByteString(result);
|
||
|
}
|
||
|
|
||
|
@Deprecated(level = DeprecationLevel.ERROR, message = "moved to val", replaceWith = @ReplaceWith(expression = "hash", imports = {}))
|
||
|
/* renamed from: -deprecated_hash, reason: not valid java name */
|
||
|
public final ByteString m7421deprecated_hash() {
|
||
|
return hash();
|
||
|
}
|
||
|
|
||
|
/* compiled from: HashingSink.kt */
|
||
|
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000 \n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0007\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0018\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\bH\u0007J\u0018\u0010\t\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\bH\u0007J\u0018\u0010\n\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\bH\u0007J\u0010\u0010\u000b\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0006H\u0007J\u0010\u0010\f\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0006H\u0007J\u0010\u0010\r\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0006H\u0007J\u0010\u0010\u000e\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0006H\u0007¨\u0006\u000f"}, d2 = {"Lokio/HashingSink$Companion;", "", "()V", "hmacSha1", "Lokio/HashingSink;", "sink", "Lokio/Sink;", "key", "Lokio/ByteString;", "hmacSha256", "hmacSha512", "md5", "sha1", "sha256", "sha512", "okio"}, k = 1, mv = {1, 4, 0})
|
||
|
/* loaded from: classes3.dex */
|
||
|
public static final class Companion {
|
||
|
private Companion() {
|
||
|
}
|
||
|
|
||
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
||
|
this();
|
||
|
}
|
||
|
|
||
|
@JvmStatic
|
||
|
public final HashingSink md5(Sink sink) {
|
||
|
Intrinsics.checkNotNullParameter(sink, "sink");
|
||
|
return new HashingSink(sink, "MD5");
|
||
|
}
|
||
|
|
||
|
@JvmStatic
|
||
|
public final HashingSink sha1(Sink sink) {
|
||
|
Intrinsics.checkNotNullParameter(sink, "sink");
|
||
|
return new HashingSink(sink, "SHA-1");
|
||
|
}
|
||
|
|
||
|
@JvmStatic
|
||
|
public final HashingSink sha256(Sink sink) {
|
||
|
Intrinsics.checkNotNullParameter(sink, "sink");
|
||
|
return new HashingSink(sink, "SHA-256");
|
||
|
}
|
||
|
|
||
|
@JvmStatic
|
||
|
public final HashingSink sha512(Sink sink) {
|
||
|
Intrinsics.checkNotNullParameter(sink, "sink");
|
||
|
return new HashingSink(sink, "SHA-512");
|
||
|
}
|
||
|
|
||
|
@JvmStatic
|
||
|
public final HashingSink hmacSha1(Sink sink, ByteString key) {
|
||
|
Intrinsics.checkNotNullParameter(sink, "sink");
|
||
|
Intrinsics.checkNotNullParameter(key, "key");
|
||
|
return new HashingSink(sink, key, "HmacSHA1");
|
||
|
}
|
||
|
|
||
|
@JvmStatic
|
||
|
public final HashingSink hmacSha256(Sink sink, ByteString key) {
|
||
|
Intrinsics.checkNotNullParameter(sink, "sink");
|
||
|
Intrinsics.checkNotNullParameter(key, "key");
|
||
|
return new HashingSink(sink, key, "HmacSHA256");
|
||
|
}
|
||
|
|
||
|
@JvmStatic
|
||
|
public final HashingSink hmacSha512(Sink sink, ByteString key) {
|
||
|
Intrinsics.checkNotNullParameter(sink, "sink");
|
||
|
Intrinsics.checkNotNullParameter(key, "key");
|
||
|
return new HashingSink(sink, key, "HmacSHA512");
|
||
|
}
|
||
|
}
|
||
|
}
|