- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
150 lines
6.3 KiB
Java
150 lines
6.3 KiB
Java
package androidx.credentials.webauthn;
|
|
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.credentials.webauthn.WebAuthnUtils;
|
|
import com.google.android.gms.fido.u2f.api.common.ClientData;
|
|
import com.unity3d.ads.metadata.InAppPurchaseMetaData;
|
|
import java.security.MessageDigest;
|
|
import kotlin.collections.ArraysKt___ArraysJvmKt;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.text.Charsets;
|
|
import org.json.JSONObject;
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY})
|
|
/* loaded from: classes.dex */
|
|
public final class AuthenticatorAssertionResponse implements AuthenticatorResponse {
|
|
private byte[] authenticatorData;
|
|
private final boolean be;
|
|
private final boolean bs;
|
|
private final byte[] clientDataHash;
|
|
private JSONObject clientJson;
|
|
private final byte[] credentialId;
|
|
private final String origin;
|
|
private final String packageName;
|
|
private final PublicKeyCredentialRequestOptions requestOptions;
|
|
private byte[] signature;
|
|
private final boolean up;
|
|
private byte[] userHandle;
|
|
private final boolean uv;
|
|
|
|
public final byte[] getAuthenticatorData() {
|
|
return this.authenticatorData;
|
|
}
|
|
|
|
@Override // androidx.credentials.webauthn.AuthenticatorResponse
|
|
public JSONObject getClientJson() {
|
|
return this.clientJson;
|
|
}
|
|
|
|
public final byte[] getSignature() {
|
|
return this.signature;
|
|
}
|
|
|
|
public final void setAuthenticatorData(byte[] bArr) {
|
|
Intrinsics.checkNotNullParameter(bArr, "<set-?>");
|
|
this.authenticatorData = bArr;
|
|
}
|
|
|
|
@Override // androidx.credentials.webauthn.AuthenticatorResponse
|
|
public void setClientJson(JSONObject jSONObject) {
|
|
Intrinsics.checkNotNullParameter(jSONObject, "<set-?>");
|
|
this.clientJson = jSONObject;
|
|
}
|
|
|
|
public final void setSignature(byte[] bArr) {
|
|
Intrinsics.checkNotNullParameter(bArr, "<set-?>");
|
|
this.signature = bArr;
|
|
}
|
|
|
|
public AuthenticatorAssertionResponse(PublicKeyCredentialRequestOptions requestOptions, byte[] credentialId, String origin, boolean z, boolean z2, boolean z3, boolean z4, byte[] userHandle, String str, byte[] bArr) {
|
|
Intrinsics.checkNotNullParameter(requestOptions, "requestOptions");
|
|
Intrinsics.checkNotNullParameter(credentialId, "credentialId");
|
|
Intrinsics.checkNotNullParameter(origin, "origin");
|
|
Intrinsics.checkNotNullParameter(userHandle, "userHandle");
|
|
this.requestOptions = requestOptions;
|
|
this.credentialId = credentialId;
|
|
this.origin = origin;
|
|
this.up = z;
|
|
this.uv = z2;
|
|
this.be = z3;
|
|
this.bs = z4;
|
|
this.userHandle = userHandle;
|
|
this.packageName = str;
|
|
this.clientDataHash = bArr;
|
|
this.clientJson = new JSONObject();
|
|
this.signature = new byte[0];
|
|
getClientJson().put("type", "webauthn.get");
|
|
getClientJson().put(ClientData.KEY_CHALLENGE, WebAuthnUtils.Companion.b64Encode(requestOptions.getChallenge()));
|
|
getClientJson().put("origin", origin);
|
|
if (str != null) {
|
|
getClientJson().put("androidPackageName", str);
|
|
}
|
|
this.authenticatorData = defaultAuthenticatorData();
|
|
}
|
|
|
|
public /* synthetic */ AuthenticatorAssertionResponse(PublicKeyCredentialRequestOptions publicKeyCredentialRequestOptions, byte[] bArr, String str, boolean z, boolean z2, boolean z3, boolean z4, byte[] bArr2, String str2, byte[] bArr3, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(publicKeyCredentialRequestOptions, bArr, str, z, z2, z3, z4, bArr2, (i & 256) != 0 ? null : str2, (i & 512) != 0 ? null : bArr3);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public final byte[] defaultAuthenticatorData() {
|
|
byte[] plus;
|
|
byte[] plus2;
|
|
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
|
|
byte[] bytes = this.requestOptions.getRpId().getBytes(Charsets.UTF_8);
|
|
Intrinsics.checkNotNullExpressionValue(bytes, "this as java.lang.String).getBytes(charset)");
|
|
byte[] rpHash = messageDigest.digest(bytes);
|
|
boolean z = this.up;
|
|
boolean z2 = z;
|
|
if (this.uv) {
|
|
z2 = (z ? 1 : 0) | 4;
|
|
}
|
|
boolean z3 = z2;
|
|
if (this.be) {
|
|
z3 = (z2 ? 1 : 0) | '\b';
|
|
}
|
|
int i = z3;
|
|
if (this.bs) {
|
|
i = (z3 ? 1 : 0) | 16;
|
|
}
|
|
Intrinsics.checkNotNullExpressionValue(rpHash, "rpHash");
|
|
plus = ArraysKt___ArraysJvmKt.plus(rpHash, new byte[]{(byte) i});
|
|
plus2 = ArraysKt___ArraysJvmKt.plus(plus, new byte[]{0, 0, 0, 0});
|
|
return plus2;
|
|
}
|
|
|
|
public final byte[] dataToSign() {
|
|
byte[] plus;
|
|
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
|
|
byte[] bArr = this.clientDataHash;
|
|
if (bArr == null) {
|
|
String jSONObject = getClientJson().toString();
|
|
Intrinsics.checkNotNullExpressionValue(jSONObject, "clientJson.toString()");
|
|
byte[] bytes = jSONObject.getBytes(Charsets.UTF_8);
|
|
Intrinsics.checkNotNullExpressionValue(bytes, "this as java.lang.String).getBytes(charset)");
|
|
bArr = messageDigest.digest(bytes);
|
|
Intrinsics.checkNotNullExpressionValue(bArr, "md.digest(clientJson.toString().toByteArray())");
|
|
}
|
|
plus = ArraysKt___ArraysJvmKt.plus(this.authenticatorData, bArr);
|
|
return plus;
|
|
}
|
|
|
|
@Override // androidx.credentials.webauthn.AuthenticatorResponse
|
|
public JSONObject json() {
|
|
String jSONObject = getClientJson().toString();
|
|
Intrinsics.checkNotNullExpressionValue(jSONObject, "clientJson.toString()");
|
|
byte[] bytes = jSONObject.getBytes(Charsets.UTF_8);
|
|
Intrinsics.checkNotNullExpressionValue(bytes, "this as java.lang.String).getBytes(charset)");
|
|
JSONObject jSONObject2 = new JSONObject();
|
|
if (this.clientDataHash == null) {
|
|
jSONObject2.put("clientDataJSON", WebAuthnUtils.Companion.b64Encode(bytes));
|
|
}
|
|
WebAuthnUtils.Companion companion = WebAuthnUtils.Companion;
|
|
jSONObject2.put("authenticatorData", companion.b64Encode(this.authenticatorData));
|
|
jSONObject2.put(InAppPurchaseMetaData.KEY_SIGNATURE, companion.b64Encode(this.signature));
|
|
jSONObject2.put("userHandle", companion.b64Encode(this.userHandle));
|
|
return jSONObject2;
|
|
}
|
|
}
|