package org.bouncycastle.jcajce.provider.asymmetric.gost;

import java.math.BigInteger;
import org.bouncycastle.crypto.params.GOST3410Parameters;
import org.bouncycastle.util.Arrays;
import org.bouncycastle.util.Fingerprint;
import org.bouncycastle.util.Strings;

/* JADX INFO: loaded from: classes2.dex */
class GOSTUtil {
    GOSTUtil() {
    }

    private static String generateKeyFingerprint(BigInteger bigInteger, GOST3410Parameters gOST3410Parameters) {
        return new Fingerprint(Arrays.concatenate(bigInteger.toByteArray(), gOST3410Parameters.getP().toByteArray(), gOST3410Parameters.getA().toByteArray())).toString();
    }

    static String privateKeyToString(String str, BigInteger bigInteger, GOST3410Parameters gOST3410Parameters) {
        StringBuilder sb = new StringBuilder();
        String strLineSeparator = Strings.lineSeparator();
        BigInteger bigIntegerModPow = gOST3410Parameters.getA().modPow(bigInteger, gOST3410Parameters.getP());
        sb.append(str);
        sb.append(" Private Key [").append(generateKeyFingerprint(bigIntegerModPow, gOST3410Parameters)).append("]").append(strLineSeparator);
        sb.append("                  Y: ").append(bigIntegerModPow.toString(16)).append(strLineSeparator);
        return sb.toString();
    }

    static String publicKeyToString(String str, BigInteger bigInteger, GOST3410Parameters gOST3410Parameters) {
        StringBuilder sb = new StringBuilder();
        String strLineSeparator = Strings.lineSeparator();
        sb.append(str);
        sb.append(" Public Key [").append(generateKeyFingerprint(bigInteger, gOST3410Parameters)).append("]").append(strLineSeparator);
        sb.append("                 Y: ").append(bigInteger.toString(16)).append(strLineSeparator);
        return sb.toString();
    }
}
