         return indexBytes.count + 4
     }
 
-    private static func processFooter(_ streamHeader: (checkType: Int, flagsCRC: UInt32),
+    private static func processFooter(_ streamHeader: (checkType: UInt8, flagsCRC: UInt32),
                                       _ indexSize: Int,
                                       _ pointerData: inout DataWithPointer) throws {
         let footerCRC = pointerData.uint32FromAlignedBytes(count: 4)

        // Flags in the footer should be the same as in the header.
        guard footerStreamFlags[0] == 0
            else { throw XZError.fieldReservedValue }
        guard footerStreamFlags[1] & 0x0F == streamHeader.checkType.toUInt8()
            else { throw XZError.wrongArchiveInfo }
        guard footerStreamFlags[1] & 0xF0 == 0
            else { throw XZError.fieldReservedValue }

        return Data(bytes: out)
    }

    private static func processStreamHeader(_ pointerData: inout DataWithPointer) throws -> (checkType: UInt8, flagsCRC: UInt32) {
        // Check magic number.
        guard pointerData.uint64FromAlignedBytes(count: 6) == 0x005A587A37FD
            else { throw XZError.wrongMagic }

        let flagsBytes = pointerData.alignedBytes(count: 2)

        // First, we need to check for corruption in flags,
        //  so we compare CRC32 of flags to the value stored in archive.
        let flagsCRC = pointerData.uint32FromAlignedBytes(count: 4)
        guard CheckSums.crc32(flagsBytes) == flagsCRC
            else { throw XZError.wrongInfoCRC }

        // If data is not corrupted, then some bits must be equal to zero.
        guard flagsBytes[0] == 0 && flagsBytes[1] & 0xF0 == 0
            else { throw XZError.fieldReservedValue }

        // Four bits of second flags byte indicate type of redundancy check.
        let checkType = flagsBytes[1] & 0x0F
        switch checkType {
        case 0x00, 0x01, 0x04, 0x0A:
            break
        default:
            throw XZError.fieldReservedValue
        }

        return (checkType, flagsCRC)
    }
