Files
setec_fs_manager/third_party/xz-embedded/xz_crc64.c

42 lines
751 B
C
Raw Normal View History

v1.2.0 — Linux Flasher, Kali Creator, fixed flashing & counterfeit detection New features: - Linux Flasher tab: download+decompress+flash pipeline for RPi OS, Ubuntu, Debian, Fedora, Kali, DietPi, Alpine, Arch ARM with built-in image catalog - Kali Creator tab: 4 sub-tabs for USB/SD, VM creation, Docker/Podman container pulls, and cloud image downloads - DownloadManager: async downloads with resume support and speed tracking - Decompressor: streaming .xz (xz-embedded), .gz (zlib), .zip decompression - ImageCatalog: built-in catalog + remote fetch from rpi-imager JSON endpoint - SevenZipExtractor: QProcess wrapper for 7z.exe with progress parsing - Bundled xz-embedded third-party library for native XZ decompression Bug fixes: - Fixed VirtualDisk::flashToDisk() — added FSCTL_ALLOW_EXTENDED_DASD_IO, FSCTL_LOCK_VOLUME, FSCTL_DISMOUNT_VOLUME, 32MB aligned buffers, WriteFile retry logic (3 attempts), FlushFileBuffers before close - Fixed VirtualDisk::captureFromDisk() with same improvements - Fixed ImagingTab::onFlashIso() — now populates targetVolumeLetters from disk snapshot so IsoFlasher can properly lock/dismount volumes - Fixed SD card counterfeit detection false positives: - Changed from write-one-read-one to write-all-then-read-all algorithm to properly detect NAND address wrapping on fake cards - Added volume lock/dismount before probing to prevent filesystem interference (journal writes, metadata updates) - Added FSCTL_ALLOW_EXTENDED_DASD_IO for probes near end of disk - Fixed overly aggressive vendor string check — USB card readers legitimately report "USB"/"Mass Storage", no longer flagged - Added handle re-open between write and verify phases to defeat USB reader hardware cache - README: documented how to unlock the secret menu, added new feature docs
2026-03-12 12:51:35 -07:00
/*
* XZ decompressor - CRC64
*
* Based on xz-embedded by Lasse Collin (public domain).
* CRC64 with polynomial 0xC96C5795D7870F42 (ECMA-182).
*/
#include "xz_private.h"
uint64_t xz_crc64_table[256];
void xz_crc64_init(void)
{
static int done = 0;
uint64_t i, j, r;
if (done)
return;
for (i = 0; i < 256; ++i) {
r = i;
for (j = 0; j < 8; ++j)
r = (r >> 1) ^ (UINT64_C(0xC96C5795D7870F42) & ~((r & 1) - 1));
xz_crc64_table[i] = r;
}
done = 1;
}
uint64_t xz_crc64(const uint8_t *buf, size_t size, uint64_t crc)
{
crc = ~crc;
while (size > 0) {
crc = xz_crc64_table[(crc ^ *buf) & 0xFF] ^ (crc >> 8);
++buf;
--size;
}
return ~crc;
}