package androidx.credentials.webauthn; import androidx.annotation.RestrictTo; import com.google.android.gms.fido.u2f.api.common.ClientData; import com.tapjoy.TapjoyConstants; import java.security.MessageDigest; import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import kotlin.collections.ArraysKt___ArraysJvmKt; import kotlin.collections.CollectionsKt__CollectionsKt; import kotlin.collections.MapsKt__MapsKt; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.jvm.internal.Intrinsics; import kotlin.text.Charsets; import org.json.JSONArray; import org.json.JSONObject; @RestrictTo({RestrictTo.Scope.LIBRARY}) /* loaded from: classes.dex */ public final class AuthenticatorAttestationResponse implements AuthenticatorResponse { private byte[] attestationObject; private final boolean be; private final boolean bs; private final byte[] clientDataHash; private JSONObject clientJson; private final byte[] credentialId; private final byte[] credentialPublicKey; private final String origin; private final String packageName; private final PublicKeyCredentialCreationOptions requestOptions; private final boolean up; private final boolean uv; public final byte[] getAttestationObject() { return this.attestationObject; } @Override // androidx.credentials.webauthn.AuthenticatorResponse public JSONObject getClientJson() { return this.clientJson; } public final void setAttestationObject(byte[] bArr) { Intrinsics.checkNotNullParameter(bArr, ""); this.attestationObject = bArr; } @Override // androidx.credentials.webauthn.AuthenticatorResponse public void setClientJson(JSONObject jSONObject) { Intrinsics.checkNotNullParameter(jSONObject, ""); this.clientJson = jSONObject; } public AuthenticatorAttestationResponse(PublicKeyCredentialCreationOptions requestOptions, byte[] credentialId, byte[] credentialPublicKey, String origin, boolean z, boolean z2, boolean z3, boolean z4, String str, byte[] bArr) { Intrinsics.checkNotNullParameter(requestOptions, "requestOptions"); Intrinsics.checkNotNullParameter(credentialId, "credentialId"); Intrinsics.checkNotNullParameter(credentialPublicKey, "credentialPublicKey"); Intrinsics.checkNotNullParameter(origin, "origin"); this.requestOptions = requestOptions; this.credentialId = credentialId; this.credentialPublicKey = credentialPublicKey; this.origin = origin; this.up = z; this.uv = z2; this.be = z3; this.bs = z4; this.packageName = str; this.clientDataHash = bArr; this.clientJson = new JSONObject(); getClientJson().put("type", "webauthn.create"); getClientJson().put(ClientData.KEY_CHALLENGE, WebAuthnUtils.Companion.b64Encode(requestOptions.getChallenge())); getClientJson().put("origin", origin); if (str != null) { getClientJson().put("androidPackageName", str); } this.attestationObject = defaultAttestationObject$credentials_release(); } public /* synthetic */ AuthenticatorAttestationResponse(PublicKeyCredentialCreationOptions publicKeyCredentialCreationOptions, byte[] bArr, byte[] bArr2, String str, boolean z, boolean z2, boolean z3, boolean z4, String str2, byte[] bArr3, int i, DefaultConstructorMarker defaultConstructorMarker) { this(publicKeyCredentialCreationOptions, bArr, bArr2, str, z, z2, z3, z4, (i & 256) != 0 ? null : str2, (i & 512) != 0 ? null : bArr3); } /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Type inference failed for: r1v15 */ /* JADX WARN: Type inference failed for: r1v16 */ /* JADX WARN: Type inference failed for: r1v24 */ /* JADX WARN: Type inference failed for: r1v25 */ /* JADX WARN: Type inference failed for: r1v7 */ private final byte[] authData() { byte[] plus; byte[] plus2; byte[] plus3; byte[] plus4; byte[] plus5; byte[] plus6; MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); byte[] bytes = this.requestOptions.getRp().getId().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'; } ?? r1 = z3; if (this.bs) { r1 = (z3 ? 1 : 0) | 16; } int i = r1 | 64; byte[] bArr = new byte[16]; for (int i2 = 0; i2 < 16; i2++) { bArr[i2] = 0; } byte[] bArr2 = this.credentialId; byte[] bArr3 = {(byte) (bArr2.length >> 8), (byte) bArr2.length}; Intrinsics.checkNotNullExpressionValue(rpHash, "rpHash"); plus = ArraysKt___ArraysJvmKt.plus(rpHash, new byte[]{(byte) i}); plus2 = ArraysKt___ArraysJvmKt.plus(plus, new byte[]{0, 0, 0, 0}); plus3 = ArraysKt___ArraysJvmKt.plus(plus2, bArr); plus4 = ArraysKt___ArraysJvmKt.plus(plus3, bArr3); plus5 = ArraysKt___ArraysJvmKt.plus(plus4, this.credentialId); plus6 = ArraysKt___ArraysJvmKt.plus(plus5, this.credentialPublicKey); return plus6; } public final byte[] defaultAttestationObject$credentials_release() { Map emptyMap; LinkedHashMap linkedHashMap = new LinkedHashMap(); linkedHashMap.put("fmt", "none"); emptyMap = MapsKt__MapsKt.emptyMap(); linkedHashMap.put("attStmt", emptyMap); linkedHashMap.put("authData", authData()); return new Cbor().encode(linkedHashMap); } @Override // androidx.credentials.webauthn.AuthenticatorResponse public JSONObject json() { List listOf; 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)); } jSONObject2.put("attestationObject", WebAuthnUtils.Companion.b64Encode(this.attestationObject)); listOf = CollectionsKt__CollectionsKt.listOf((Object[]) new String[]{TapjoyConstants.LOG_LEVEL_INTERNAL, "hybrid"}); jSONObject2.put("transports", new JSONArray((Collection) listOf)); return jSONObject2; } }