package org.bouncycastle.crypto.util; import org.bouncycastle.asn1.ASN1OctetString; import org.bouncycastle.asn1.DERTaggedObject; import org.bouncycastle.util.Arrays; import org.bouncycastle.util.Strings; /* loaded from: classes6.dex */ public final class DERMacData { private final byte[] macData; /* loaded from: classes6.dex */ public enum Type { UNILATERALU("KC_1_U"), UNILATERALV("KC_1_V"), BILATERALU("KC_2_U"), BILATERALV("KC_2_V"); private final String enc; public final byte[] getHeader() { return Strings.toByteArray(this.enc); } Type(String str) { this.enc = str; } } /* loaded from: classes6.dex */ public static final class Builder { private ASN1OctetString ephemDataU; private ASN1OctetString ephemDataV; private ASN1OctetString idU; private ASN1OctetString idV; private byte[] text; private final Type type; public final Builder withText(byte[] bArr) { this.text = DerUtil.toByteArray(new DERTaggedObject(false, 0, DerUtil.getOctetString(bArr))); return this; } public final DERMacData build() { int i = AnonymousClass1.$SwitchMap$org$bouncycastle$crypto$util$DERMacData$Type[this.type.ordinal()]; AnonymousClass1 anonymousClass1 = null; if (i == 1 || i == 2) { return new DERMacData(concatenate(this.type.getHeader(), DerUtil.toByteArray(this.idU), DerUtil.toByteArray(this.idV), DerUtil.toByteArray(this.ephemDataU), DerUtil.toByteArray(this.ephemDataV), this.text), anonymousClass1); } if (i == 3 || i == 4) { return new DERMacData(concatenate(this.type.getHeader(), DerUtil.toByteArray(this.idV), DerUtil.toByteArray(this.idU), DerUtil.toByteArray(this.ephemDataV), DerUtil.toByteArray(this.ephemDataU), this.text), anonymousClass1); } throw new IllegalStateException("Unknown type encountered in build"); } private byte[] concatenate(byte[] bArr, byte[] bArr2, byte[] bArr3, byte[] bArr4, byte[] bArr5, byte[] bArr6) { return Arrays.concatenate(Arrays.concatenate(bArr, bArr2, bArr3), Arrays.concatenate(bArr4, bArr5, bArr6)); } public Builder(Type type, byte[] bArr, byte[] bArr2, byte[] bArr3, byte[] bArr4) { this.type = type; this.idU = DerUtil.getOctetString(bArr); this.idV = DerUtil.getOctetString(bArr2); this.ephemDataU = DerUtil.getOctetString(bArr3); this.ephemDataV = DerUtil.getOctetString(bArr4); } } public final byte[] getMacData() { return Arrays.clone(this.macData); } /* renamed from: org.bouncycastle.crypto.util.DERMacData$1, reason: invalid class name */ /* loaded from: classes6.dex */ static /* synthetic */ class AnonymousClass1 { static final int[] $SwitchMap$org$bouncycastle$crypto$util$DERMacData$Type; static { int[] iArr = new int[Type.values().length]; $SwitchMap$org$bouncycastle$crypto$util$DERMacData$Type = iArr; try { iArr[Type.UNILATERALU.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { $SwitchMap$org$bouncycastle$crypto$util$DERMacData$Type[Type.BILATERALU.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } try { $SwitchMap$org$bouncycastle$crypto$util$DERMacData$Type[Type.UNILATERALV.ordinal()] = 3; } catch (NoSuchFieldError unused3) { } try { $SwitchMap$org$bouncycastle$crypto$util$DERMacData$Type[Type.BILATERALV.ordinal()] = 4; } catch (NoSuchFieldError unused4) { } } } /* synthetic */ DERMacData(byte[] bArr, AnonymousClass1 anonymousClass1) { this(bArr); } private DERMacData(byte[] bArr) { this.macData = bArr; } }