diff --git a/Cargo.lock b/Cargo.lock index 887acd5..97fde01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,6 +104,7 @@ dependencies = [ "tracing-subscriber", "unic-langid", "wincompatlib", + "xxhash-rust", ] [[package]] @@ -2616,6 +2617,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "xxhash-rust" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53be06678ed9e83edb1745eb72efc0bbcd7b5c3c35711a860906aed827a13d61" + [[package]] name = "zerocopy" version = "0.7.32" diff --git a/Cargo.toml b/Cargo.toml index 5f704e7..5b41479 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -72,4 +72,5 @@ mlua = { version = "0.9.4", features = ["luajit", "vendored", "serialize"] } md-5 = { version = "0.10.6", features = ["asm"] } sha1 = { version = "0.10.6", features = ["asm"] } +xxhash-rust = { version = "0.8.8", features = ["xxh32", "xxh64", "xxh3"] } crc32fast = "1.3.2" diff --git a/repository/integrations/V1_SPECIFICATION.md b/repository/integrations/V1_SPECIFICATION.md index 984f911..0b67c55 100644 --- a/repository/integrations/V1_SPECIFICATION.md +++ b/repository/integrations/V1_SPECIFICATION.md @@ -188,7 +188,7 @@ type IntegrityInfo = { ### HashType ```ts -type HashType = 'md5' | 'sha1' | 'crc32' | 'xxhash32' | 'xxhash64'; +type HashType = 'md5' | 'sha1' | 'crc32' | 'xxhash32' | 'xxhash64' | 'xxhash3/64' | 'xxhash3/128'; ``` Launcher will try to use `v1_integrity_hash` if given hash doesn't belong to the `HashType` type diff --git a/src/games/integrations/standards/integrity.rs b/src/games/integrations/standards/integrity.rs index 99a1bd0..d12ccf5 100644 --- a/src/games/integrations/standards/integrity.rs +++ b/src/games/integrations/standards/integrity.rs @@ -43,8 +43,15 @@ pub enum HashType { Md5, Sha1, Crc32, + + // Older generation xxhash-es Xxhash32, Xxhash64, + + // New generation xxhash-es + Xxhash3_64, + Xxhash3_128, + Custom(String) } @@ -53,11 +60,13 @@ impl HashType { match standard { IntegrationStandard::V1 => { match value.as_ref() { - "md5" => Ok(Self::Md5), - "sha1" => Ok(Self::Sha1), - "crc32" => Ok(Self::Crc32), - "xxhash32" => Ok(Self::Xxhash32), - "xxhash64" => Ok(Self::Xxhash64), + "md5" => Ok(Self::Md5), + "sha1" => Ok(Self::Sha1), + "crc32" => Ok(Self::Crc32), + "xxhash32" => Ok(Self::Xxhash32), + "xxhash64" => Ok(Self::Xxhash64), + "xxhash3/64" => Ok(Self::Xxhash3_64), + "xxhash3/128" => Ok(Self::Xxhash3_128), name => Ok(Self::Custom(name.to_string())) } @@ -69,11 +78,13 @@ impl HashType { match standard { IntegrationStandard::V1 => { match self { - Self::Md5 => "md5", - Self::Sha1 => "sha1", - Self::Crc32 => "crc32", - Self::Xxhash32 => "xxhash32", - Self::Xxhash64 => "xxhash64", + Self::Md5 => "md5", + Self::Sha1 => "sha1", + Self::Crc32 => "crc32", + Self::Xxhash32 => "xxhash32", + Self::Xxhash64 => "xxhash64", + Self::Xxhash3_64 => "xxhash3/64", + Self::Xxhash3_128 => "xxhash3/128", Self::Custom(name) => name } diff --git a/src/ui/components/tasks_queue/verify_integrity_task.rs b/src/ui/components/tasks_queue/verify_integrity_task.rs index ec37a85..c1721f5 100644 --- a/src/ui/components/tasks_queue/verify_integrity_task.rs +++ b/src/ui/components/tasks_queue/verify_integrity_task.rs @@ -156,6 +156,11 @@ impl QueuedTask for VerifyIntegrityQueuedTask { hasher.finalize().to_string() } + HashType::Xxhash32 => format!("{:x}", xxhash_rust::xxh32::xxh32(&data, 0)), + HashType::Xxhash64 => format!("{:x}", xxhash_rust::xxh64::xxh64(&data, 0)), + HashType::Xxhash3_64 => format!("{:x}", xxhash_rust::xxh3::xxh3_64(&data)), + HashType::Xxhash3_128 => format!("{:x}", xxhash_rust::xxh3::xxh3_128(&data)), + HashType::Custom(name) if has_integrity_hash => { game.driver.integrity_hash(&name, data)? }