package org.bouncycastle.crypto.engines;

import org.bouncycastle.crypto.digests.ISAPDigest;
import org.bouncycastle.util.Longs;

/* JADX INFO: loaded from: classes.dex */
public class AsconPermutationFriend {

    /* JADX INFO: loaded from: classes2.dex */
    public static class AsconPermutation {
        public long x0;
        public long x1;
        public long x2;
        public long x3;
        public long x4;

        AsconPermutation() {
        }

        public void p(int i) {
            if (i == 12) {
                round(240L);
                round(225L);
                round(210L);
                round(195L);
            }
            if (i >= 8) {
                round(180L);
                round(165L);
            }
            round(150L);
            round(135L);
            round(120L);
            round(105L);
            round(90L);
            round(75L);
        }

        public void round(long j) {
            this.x2 = j ^ this.x2;
            long j2 = this.x0 ^ this.x4;
            long j3 = this.x1 ^ this.x2;
            long j4 = this.x1 | this.x2;
            long j5 = ((this.x3 ^ j4) ^ this.x0) ^ (this.x1 & j2);
            long j6 = (j2 ^ (j4 | this.x3)) ^ ((this.x1 & this.x2) & this.x3);
            long j7 = (this.x4 & (~this.x3)) ^ j3;
            long j8 = j3 ^ (this.x0 | (this.x3 ^ this.x4));
            long j9 = (this.x3 ^ (this.x1 | this.x4)) ^ (this.x0 & this.x1);
            this.x0 = Longs.rotateRight(j5, 28) ^ (Longs.rotateRight(j5, 19) ^ j5);
            this.x1 = Longs.rotateRight(j6, 61) ^ (Longs.rotateRight(j6, 39) ^ j6);
            this.x2 = ~((Longs.rotateRight(j7, 1) ^ j7) ^ Longs.rotateRight(j7, 6));
            this.x3 = (Longs.rotateRight(j8, 10) ^ j8) ^ Longs.rotateRight(j8, 17);
            this.x4 = (Longs.rotateRight(j9, 7) ^ j9) ^ Longs.rotateRight(j9, 41);
        }

        public void set(long j, long j2, long j3, long j4, long j5) {
            this.x0 = j;
            this.x1 = j2;
            this.x2 = j3;
            this.x3 = j4;
            this.x4 = j5;
        }
    }

    public static AsconPermutation getAsconPermutation(ISAPDigest.Friend friend) {
        if (friend != null) {
            return new AsconPermutation();
        }
        throw new NullPointerException("This method is only for use by ISAPDigest or Ascon Digest");
    }
}
