package org.bouncycastle.bcpg;

import java.io.IOException;
import org.bouncycastle.util.Arrays;
import org.bouncycastle.util.Strings;

/* JADX INFO: loaded from: classes2.dex */
public class LiteralDataPacket extends InputStreamPacket {
    byte[] fileName;
    int format;
    long modDate;

    LiteralDataPacket(BCPGInputStream bCPGInputStream) throws IOException {
        this(bCPGInputStream, false);
    }

    LiteralDataPacket(BCPGInputStream bCPGInputStream, boolean z) throws IOException {
        super(bCPGInputStream, 11, z);
        this.format = bCPGInputStream.read();
        int i = bCPGInputStream.read();
        if (i < 0) {
            throw new MalformedPacketException("File name size cannot be negative.");
        }
        this.fileName = new byte[i];
        for (int i2 = 0; i2 != this.fileName.length; i2++) {
            int i3 = bCPGInputStream.read();
            if (i3 < 0) {
                throw new IOException("literal data truncated in header");
            }
            this.fileName[i2] = (byte) i3;
        }
        this.modDate = StreamUtil.readTime(bCPGInputStream);
        if (this.modDate < 0) {
            throw new IOException("literal data truncated in header");
        }
    }

    public String getFileName() {
        return Strings.fromUTF8ByteArray(this.fileName);
    }

    public int getFormat() {
        return this.format;
    }

    public long getModificationTime() {
        return this.modDate;
    }

    public byte[] getRawFileName() {
        return Arrays.clone(this.fileName);
    }
}
