package org.bouncycastle.openpgp;

import org.bouncycastle.bcpg.UserAttributeSubpacket;
import org.bouncycastle.bcpg.UserDataPacket;
import org.bouncycastle.bcpg.attr.ImageAttribute;

/* JADX INFO: loaded from: classes.dex */
public class PGPUserAttributeSubpacketVector implements UserDataPacket {
    UserAttributeSubpacket[] packets;

    PGPUserAttributeSubpacketVector(UserAttributeSubpacket[] userAttributeSubpacketArr) {
        this.packets = userAttributeSubpacketArr;
    }

    public static PGPUserAttributeSubpacketVector fromSubpackets(UserAttributeSubpacket[] userAttributeSubpacketArr) {
        if (userAttributeSubpacketArr == null) {
            userAttributeSubpacketArr = new UserAttributeSubpacket[0];
        }
        return new PGPUserAttributeSubpacketVector(userAttributeSubpacketArr);
    }

    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof PGPUserAttributeSubpacketVector)) {
            return false;
        }
        PGPUserAttributeSubpacketVector pGPUserAttributeSubpacketVector = (PGPUserAttributeSubpacketVector) obj;
        if (pGPUserAttributeSubpacketVector.packets.length != this.packets.length) {
            return false;
        }
        for (int i = 0; i != this.packets.length; i++) {
            if (!pGPUserAttributeSubpacketVector.packets[i].equals(this.packets[i])) {
                return false;
            }
        }
        return true;
    }

    public ImageAttribute getImageAttribute() {
        UserAttributeSubpacket subpacket = getSubpacket(1);
        if (subpacket == null) {
            return null;
        }
        return (ImageAttribute) subpacket;
    }

    public UserAttributeSubpacket getSubpacket(int i) {
        for (int i2 = 0; i2 != this.packets.length; i2++) {
            if (this.packets[i2].getType() == i) {
                return this.packets[i2];
            }
        }
        return null;
    }

    public int hashCode() {
        int iHashCode = 0;
        for (int i = 0; i != this.packets.length; i++) {
            iHashCode ^= this.packets[i].hashCode();
        }
        return iHashCode;
    }

    UserAttributeSubpacket[] toSubpacketArray() {
        return this.packets;
    }
}
