package org.bouncycastle.openpgp.api;

import org.bouncycastle.bcpg.sig.PreferredAEADCiphersuites;

/* JADX INFO: loaded from: classes3.dex */
public class MessageEncryptionMechanism {
    private final int aeadAlgorithm;
    private final EncryptedDataPacketType mode;
    private final int symmetricKeyAlgorithm;

    private MessageEncryptionMechanism(EncryptedDataPacketType encryptedDataPacketType, int i, int i2) {
        this.mode = encryptedDataPacketType;
        this.symmetricKeyAlgorithm = i;
        this.aeadAlgorithm = i2;
    }

    public static MessageEncryptionMechanism aead(int i, int i2) {
        return new MessageEncryptionMechanism(EncryptedDataPacketType.SEIPDv2, i, i2);
    }

    public static MessageEncryptionMechanism aead(PreferredAEADCiphersuites.Combination combination) {
        return aead(combination.getSymmetricAlgorithm(), combination.getAeadAlgorithm());
    }

    public static MessageEncryptionMechanism integrityProtected(int i) {
        return new MessageEncryptionMechanism(EncryptedDataPacketType.SEIPDv1, i, 0);
    }

    @Deprecated
    public static MessageEncryptionMechanism legacyEncryptedNonIntegrityProtected(int i) {
        return new MessageEncryptionMechanism(EncryptedDataPacketType.SED, i, 0);
    }

    public static MessageEncryptionMechanism librePgp(int i) {
        return new MessageEncryptionMechanism(EncryptedDataPacketType.LIBREPGP_OED, i, 2);
    }

    public static MessageEncryptionMechanism unencrypted() {
        return new MessageEncryptionMechanism(EncryptedDataPacketType.SEIPDv1, 0, 0);
    }

    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof MessageEncryptionMechanism)) {
            return false;
        }
        MessageEncryptionMechanism messageEncryptionMechanism = (MessageEncryptionMechanism) obj;
        return getMode() == messageEncryptionMechanism.getMode() && getSymmetricKeyAlgorithm() == messageEncryptionMechanism.getSymmetricKeyAlgorithm() && getAeadAlgorithm() == messageEncryptionMechanism.getAeadAlgorithm();
    }

    public int getAeadAlgorithm() {
        return this.aeadAlgorithm;
    }

    public EncryptedDataPacketType getMode() {
        return this.mode;
    }

    public int getSymmetricKeyAlgorithm() {
        return this.symmetricKeyAlgorithm;
    }

    public int hashCode() {
        return this.mode.hashCode() + (this.symmetricKeyAlgorithm * 13) + (this.aeadAlgorithm * 17);
    }

    public boolean isEncrypted() {
        return this.symmetricKeyAlgorithm != 0;
    }

    public String toString() {
        String str = this.mode.name() + "[cipher: " + this.symmetricKeyAlgorithm;
        if (this.mode == EncryptedDataPacketType.SEIPDv2 || this.mode == EncryptedDataPacketType.LIBREPGP_OED) {
            str = str + " aead: " + this.aeadAlgorithm;
        }
        return str + "]";
    }
}
