package M3;

import C0.B;
import java.nio.ByteBuffer;
import java.security.GeneralSecurityException;

/* JADX INFO: loaded from: classes3.dex */
public final class w extends b {
    public static w b(j jVar, B b5, Integer num) throws GeneralSecurityException {
        j jVar2 = j.f5075q;
        if (jVar != jVar2 && num == null) {
            throw new GeneralSecurityException("For given Variant " + jVar + " the value of idRequirement must be non-null");
        }
        if (jVar == jVar2 && num != null) {
            throw new GeneralSecurityException("For given Variant NO_PREFIX the value of idRequirement must be null");
        }
        Z3.a aVar = (Z3.a) b5.f506b;
        if (aVar.f9150a.length != 32) {
            throw new GeneralSecurityException("XChaCha20Poly1305 key must be constructed with key of length 32 bytes, not " + aVar.f9150a.length);
        }
        if (jVar == jVar2) {
            Z3.a.a(new byte[0]);
        } else if (jVar == j.f5074p) {
            Z3.a.a(ByteBuffer.allocate(5).put((byte) 0).putInt(num.intValue()).array());
        } else {
            if (jVar != j.f5073o) {
                throw new IllegalStateException("Unknown Variant: " + jVar);
            }
            Z3.a.a(ByteBuffer.allocate(5).put((byte) 1).putInt(num.intValue()).array());
        }
        return new w();
    }
}
