From 72735fce13e777669e162c08f66181d9a4a77780 Mon Sep 17 00:00:00 2001 From: iHsin Date: Tue, 9 Apr 2024 23:00:23 +0800 Subject: [PATCH] refactpr: remove boringssl --- Cargo.lock | 279 +++++++----------- clash_lib/Cargo.toml | 10 +- clash_lib/src/common/crypto.rs | 184 ++++-------- .../src/proxy/vmess/vmess_impl/header.rs | 49 +-- .../src/proxy/vmess/vmess_impl/stream.rs | 56 ++-- clash_lib/src/proxy/vmess/vmess_impl/user.rs | 66 +---- 6 files changed, 229 insertions(+), 415 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6017f5365..a8639c6d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -294,9 +294,9 @@ checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" [[package]] name = "async-compression" -version = "0.4.6" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a116f46a969224200a0a97f29cfd4c50e7534e4b4826bd23ea2c3c533039c82c" +checksum = "07dbbf24db18d609b1462965249abdf49129ccad073ec257da372adc83259c60" dependencies = [ "flate2", "futures-core", @@ -316,7 +316,7 @@ checksum = "30c5ef0ede93efbf733c1a727f3b6b5a1060bbedd5600183e66f6e4be4af0ec5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -338,7 +338,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -349,7 +349,7 @@ checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -459,7 +459,7 @@ dependencies = [ "serde_path_to_error", "serde_urlencoded", "sha1", - "sync_wrapper 1.0.0", + "sync_wrapper 1.0.1", "tokio", "tokio-tungstenite", "tower", @@ -515,7 +515,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -586,26 +586,6 @@ dependencies = [ "which", ] -[[package]] -name = "bindgen" -version = "0.68.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "726e4313eb6ec35d2730258ad4e15b547ee75d6afaa1361a922e78e59b7d8078" -dependencies = [ - "bitflags 2.5.0", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "peeking_take_while", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "syn 2.0.55", -] - [[package]] name = "bindgen" version = "0.69.4" @@ -625,7 +605,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.55", + "syn 2.0.58", "which", ] @@ -683,7 +663,7 @@ checksum = "e0b121a9fe0df916e362fb3271088d071159cdf11db0e4182d02152850756eff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -739,31 +719,6 @@ dependencies = [ "serde_with", ] -[[package]] -name = "boring" -version = "4.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8259fc1ea91894a550190683fbcda307d1ef85f2875d93a2b1ab3cab58b62fea" -dependencies = [ - "bitflags 2.5.0", - "boring-sys", - "foreign-types", - "libc", - "once_cell", -] - -[[package]] -name = "boring-sys" -version = "4.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace69f2e0d89d2c5e0874efe47f46259ff794fe8cbddfca72132c817611ad471" -dependencies = [ - "bindgen 0.68.1", - "cmake", - "fs_extra", - "fslock", -] - [[package]] name = "boringtun" version = "0.6.0" @@ -816,9 +771,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "by_address" @@ -866,9 +821,9 @@ dependencies = [ [[package]] name = "caret" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a472d18b7a8b73ecefb280476c3d2b832ac4920dfd0928f3fab94c46b659c4a" +checksum = "2d55bb9904b8ef817fd66664cba4ecacac936781105c1016b0d2e13b900218db" [[package]] name = "cast" @@ -878,9 +833,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.90" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" dependencies = [ "jobserver", "libc", @@ -1032,7 +987,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.0", + "strsim 0.11.1", ] [[package]] @@ -1044,7 +999,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1072,6 +1027,7 @@ dependencies = [ name = "clash_lib" version = "0.1.15" dependencies = [ + "aead", "aes", "aes-gcm", "anyhow", @@ -1082,8 +1038,6 @@ dependencies = [ "axum-macros", "base64 0.22.0", "bollard", - "boring", - "boring-sys", "boringtun", "brotli", "byteorder", @@ -1092,6 +1046,7 @@ dependencies = [ "chacha20poly1305", "chrono", "console-subscriber", + "const-fnv1a-hash", "crc32fast", "criterion", "ctor", @@ -1132,6 +1087,7 @@ dependencies = [ "rand", "regex", "register-count", + "ring-compat", "rustls 0.21.8", "rustls-pemfile", "security-framework", @@ -1168,15 +1124,6 @@ dependencies = [ "webpki-roots", ] -[[package]] -name = "cmake" -version = "0.1.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" -dependencies = [ - "cc", -] - [[package]] name = "coarsetime" version = "0.1.34" @@ -1253,6 +1200,12 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "const-fnv1a-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b13ea120a812beba79e34316b3942a857c86ec1593cb34f27bb28272ce2cca" + [[package]] name = "const-oid" version = "0.9.6" @@ -1435,7 +1388,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad291aa74992b9b7a7e88c38acbbf6ad7e107f1d90ee8775b7bc1fc3394f485c" dependencies = [ "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1472,7 +1425,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1520,7 +1473,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1542,7 +1495,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core 0.20.8", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1584,7 +1537,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1598,9 +1551,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", "pem-rfc7468", @@ -1667,7 +1620,7 @@ dependencies = [ "quote", "sha3", "strum 0.25.0", - "syn 2.0.55", + "syn 2.0.58", "void", ] @@ -1786,7 +1739,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1803,9 +1756,9 @@ checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" [[package]] name = "downcast-rs" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" [[package]] name = "dyn-clone" @@ -1917,7 +1870,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1930,7 +1883,7 @@ dependencies = [ "num-traits", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1973,9 +1926,9 @@ dependencies = [ [[package]] name = "event-listener" -version = "5.2.0" +version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b5fb89194fa3cad959b833185b3063ba881dbfc7030680b314250779fb4cc91" +checksum = "6d9944b8ca13534cdfb2800775f8dd4902ff3fc75a50101466decadfdf322a24" dependencies = [ "concurrent-queue", "parking", @@ -2050,27 +2003,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foreign-types" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" -dependencies = [ - "foreign-types-macros", - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-macros" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.55", -] - [[package]] name = "foreign-types-shared" version = "0.3.1" @@ -2094,9 +2026,9 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "fs-mistrust" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0af38a7e00ec1cc0cae8002d3cc9738ebb97d623bc519ca8a9b471e9bc8cdb75" +checksum = "5764b75624acb3ec878488145198a8fed761ca18fe26759d4ac4c7543fd2373a" dependencies = [ "derive_builder_fork_arti", "dirs", @@ -2109,12 +2041,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "fs_extra" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" - [[package]] name = "fsevent-sys" version = "4.1.0" @@ -2196,7 +2122,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -2262,9 +2188,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "js-sys", @@ -2314,9 +2240,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", @@ -2352,9 +2278,9 @@ dependencies = [ [[package]] name = "half" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" dependencies = [ "cfg-if", "crunchy", @@ -2508,7 +2434,7 @@ dependencies = [ "futures-channel", "futures-io", "futures-util", - "h2 0.3.25", + "h2 0.3.26", "http 0.2.12", "idna 0.4.0", "ipnet", @@ -2561,7 +2487,7 @@ dependencies = [ "cfg-if", "enum-as-inner 0.6.0", "futures-util", - "h2 0.3.25", + "h2 0.3.26", "hickory-proto", "hickory-resolver", "http 0.2.12", @@ -2719,7 +2645,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2 0.3.25", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "httparse", @@ -3148,13 +3074,12 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libredox" -version = "0.0.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.5.0", "libc", - "redox_syscall 0.4.1", ] [[package]] @@ -3380,7 +3305,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -3568,7 +3493,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -3621,9 +3546,9 @@ dependencies = [ [[package]] name = "opentelemetry-http" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cbfa5308166ca861434f0b0913569579b8e587430a3d6bcd7fd671921ec145a" +checksum = "7690dc77bf776713848c4faa6501157469017eaf332baccd4eb1cea928743d94" dependencies = [ "async-trait", "bytes", @@ -3907,7 +3832,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -3936,14 +3861,14 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -4095,7 +4020,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7" dependencies = [ "proc-macro2", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -4198,14 +4123,14 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] name = "prost-types" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "193898f59edcf43c26227dcd4c8427f00d99d61e95dcde58dabd49fa291d470e" +checksum = "3235c33eb02c1f1e212abdbe34c78b264b038fb58ca612664343271e36e55ffe" dependencies = [ "prost", ] @@ -4402,9 +4327,9 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", "libredox", @@ -4473,9 +4398,9 @@ dependencies = [ [[package]] name = "retry-error" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e700775c6b1ef3b76bda447c1d88921334a6127600cc041140b29dc8582f19" +checksum = "d7dea0c97723329951a3ed41ce0de8b8e389de3de4b815fb86ff57f6ab868f04" [[package]] name = "rfc6979" @@ -4680,9 +4605,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" [[package]] name = "ryu" @@ -4692,9 +4617,9 @@ checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "safelog" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4dd088c4f8f20154e72ef45c78b31b1225b19b448dd3b0f37d605de1b8b8ef5" +checksum = "5ea892f8598a3682b6ed10ed9d8522b50366a792953eda37e1d9ddf01e183e3f" dependencies = [ "derive_more", "educe", @@ -4827,7 +4752,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -4862,13 +4787,13 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" +checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -4919,7 +4844,7 @@ dependencies = [ "darling 0.20.8", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -4957,7 +4882,7 @@ checksum = "b93fb4adc70021ac1b47f7d45e8cc4169baaa7ea58483bc5b721d19a26202212" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -5251,9 +5176,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strsim" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" @@ -5283,7 +5208,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -5296,7 +5221,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -5318,9 +5243,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.55" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", @@ -5335,9 +5260,9 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "sync_wrapper" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "384595c11a4e2969895cad5a8c4029115f5ab956a9e5ef4de79d11a426e5f20c" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" [[package]] name = "tap" @@ -5398,7 +5323,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -5536,7 +5461,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -5694,7 +5619,7 @@ dependencies = [ "axum 0.6.20", "base64 0.21.7", "bytes", - "h2 0.3.25", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "hyper 0.14.28", @@ -5721,7 +5646,7 @@ dependencies = [ "axum 0.6.20", "base64 0.21.7", "bytes", - "h2 0.3.25", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "hyper 0.14.28", @@ -6577,7 +6502,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -6911,7 +6836,7 @@ checksum = "9881bea7cbe687e36c9ab3b778c36cd0487402e270304e8b1296d5085303c1a2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -6946,7 +6871,7 @@ checksum = "b3fd98999db9227cf28e59d83e1f120f42bc233d4b152e8fab9bc87d5bb1e0f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -7016,7 +6941,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", "wasm-bindgen-shared", ] @@ -7038,7 +6963,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -7095,9 +7020,9 @@ dependencies = [ [[package]] name = "widestring" -version = "1.0.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" +checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" [[package]] name = "winapi" @@ -7388,7 +7313,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -7408,7 +7333,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] diff --git a/clash_lib/Cargo.toml b/clash_lib/Cargo.toml index faf9e6d71..66d841dba 100644 --- a/clash_lib/Cargo.toml +++ b/clash_lib/Cargo.toml @@ -35,8 +35,8 @@ foreign-types-shared = "0.3.1" network-interface = "1.1.3" base64 = "0.22" uuid = { version = "1.8.0", features = ["v4", "fast-rng", "macro-diagnostics", "serde"] } -boring = "4.5.0" -boring-sys = "4.5.0" +# boring = "4.5.0" +# boring-sys = "4.5.0" ip_network_table-deps-treebitmap = "0.5.0" once_cell = "1.18.0" @@ -54,11 +54,14 @@ brotli = "4.0.0" hmac = "0.12.1" sha1 = "0.10" sha2 = "0.10.8" -md-5 = "0.10.5" +md-5 = "0.10" chacha20poly1305 = "0.10" +aead = { version = "0.5.2", features = ["std"] } aes = "0.8.4" aes-gcm = "0.10" cfb-mode = "0.8.2" +const-fnv1a-hash = "1" + filetime = "0.2" axum = { version = "0.7", features = ["ws"] } tower-http = { version = "0.5.2", features = ["fs", "trace", "cors"] } @@ -89,6 +92,7 @@ rustls = { version = "0.21", features=["dangerous_configuration", "quic"] } rustls-pemfile = "1.0.4" webpki-roots = "0.25" dhcproto = "0.11" +ring-compat = { version = "0.8", features = ["aead"] } rand = "0.8" diff --git a/clash_lib/src/common/crypto.rs b/clash_lib/src/common/crypto.rs index 10b32c640..e1c5e107e 100644 --- a/clash_lib/src/common/crypto.rs +++ b/clash_lib/src/common/crypto.rs @@ -1,10 +1,7 @@ -use std::ffi::CStr; - -use crate::Error; - use aes::cipher::{AsyncStreamCipher, KeyIvInit}; use aes_gcm::aes::cipher::Unsigned; use aes_gcm::{AeadInPlace, KeyInit}; +use anyhow::Ok; pub fn aes_cfb_encrypt(key: &[u8], iv: &[u8], data: &mut [u8]) -> anyhow::Result<()> { match key.len() { @@ -42,126 +39,65 @@ pub fn aes_cfb_decrypt(key: &[u8], iv: &[u8], data: &mut [u8]) -> anyhow::Result } } -pub fn aes_gcm_seal( +pub fn aes_gcm_encrypt( key: &[u8], nonce: &[u8], - data: &[u8], - ad: Option<&[u8]>, + plaintext: &[u8], + associated_data: Option<&[u8]>, ) -> anyhow::Result> { - unsafe { - let ctx = boring_sys::EVP_AEAD_CTX_new( - match key.len() { - 16 => boring_sys::EVP_aead_aes_128_gcm(), - 24 => boring_sys::EVP_aead_aes_192_gcm(), - 32 => boring_sys::EVP_aead_aes_256_gcm(), - _ => anyhow::bail!("invalid key length"), - }, - key.as_ptr(), - key.len(), - boring_sys::EVP_AEAD_DEFAULT_TAG_LENGTH as _, - ); - - let mut out = vec![0u8; data.len() + boring_sys::EVP_AEAD_MAX_OVERHEAD as usize]; - - let mut out_len = 0; - - let rv = boring_sys::EVP_AEAD_CTX_seal( - ctx, - out.as_mut_ptr(), - &mut out_len, - out.len(), - nonce.as_ptr(), - nonce.len(), - data.as_ptr(), - data.len(), - match ad { - Some(ad) => ad.as_ptr(), - None => std::ptr::null(), - }, - match ad { - Some(ad) => ad.len(), - None => 0, - }, - ); - - boring_sys::EVP_AEAD_CTX_free(ctx); - - return if rv != 1 { - Err(Error::Crypto( - CStr::from_ptr( - boring_sys::ERR_reason_error_string(boring_sys::ERR_get_error()) as _, - ) - .to_str() - .expect("openssl error string is not utf8") - .to_owned(), - ) - .into()) - } else { - out.truncate(out_len); - Ok(out) - }; + let mut buffer = Vec::with_capacity(plaintext.len() + 16); + buffer.append(&mut plaintext.to_vec()); + match key.len() { + 16 => { + let cipher = ring_compat::aead::Aes128Gcm::new_from_slice(key)?; + cipher.encrypt_in_place( + nonce.into(), + associated_data.unwrap_or_default(), + &mut buffer, + )?; + } + 32 => { + let cipher = ring_compat::aead::Aes256Gcm::new_from_slice(key)?; + cipher.encrypt_in_place( + nonce.into(), + associated_data.unwrap_or_default(), + &mut buffer, + )?; + } + _ => return Err(anyhow!("Illegal key size {}", key.len())), } + Ok(buffer) } -pub fn aes_gcm_open( +/// TODO +pub fn aes_gcm_decrypt( key: &[u8], nonce: &[u8], - data: &[u8], - ad: Option<&[u8]>, + ciphertext: &[u8], + associated_data: Option<&[u8]>, ) -> anyhow::Result> { - unsafe { - let ctx = boring_sys::EVP_AEAD_CTX_new( - match key.len() { - 16 => boring_sys::EVP_aead_aes_128_gcm(), - 24 => boring_sys::EVP_aead_aes_192_gcm(), - 32 => boring_sys::EVP_aead_aes_256_gcm(), - _ => anyhow::bail!("invalid key length"), - }, - key.as_ptr(), - key.len(), - boring_sys::EVP_AEAD_DEFAULT_TAG_LENGTH as _, - ); - - let mut out = vec![0u8; data.len()]; - - let mut out_len = 0; - - let rv = boring_sys::EVP_AEAD_CTX_open( - ctx, - out.as_mut_ptr(), - &mut out_len, - out.len(), - nonce.as_ptr(), - nonce.len(), - data.as_ptr(), - data.len(), - match ad { - Some(ad) => ad.as_ptr(), - None => std::ptr::null(), - }, - match ad { - Some(ad) => ad.len(), - None => 0, - }, - ); - - boring_sys::EVP_AEAD_CTX_free(ctx); - - return if rv != 1 { - Err(Error::Crypto( - CStr::from_ptr( - boring_sys::ERR_reason_error_string(boring_sys::ERR_get_error()) as _, - ) - .to_str() - .expect("openssl error string is not utf8") - .to_owned(), - ) - .into()) - } else { - out.truncate(out_len); - Ok(out) - }; + let mut buffer = ciphertext.to_vec(); + match key.len() { + 16 => { + let cipher = ring_compat::aead::Aes128Gcm::new_from_slice(key)?; + cipher.decrypt_in_place( + nonce.into(), + associated_data.unwrap_or_default(), + &mut buffer, + )?; + } + 32 => { + let cipher = ring_compat::aead::Aes256Gcm::new_from_slice(key)?; + cipher.decrypt_in_place( + nonce.into(), + associated_data.unwrap_or_default(), + &mut buffer, + )?; + } + _ => return Err(anyhow!("Illegal key size {}", key.len())), } + buffer.shrink_to_fit(); + Ok(buffer) } pub trait AeadCipherHelper: AeadInPlace { @@ -214,9 +150,9 @@ impl AeadCipherHelper for chacha20poly1305::ChaCha20Poly1305 { #[cfg(test)] mod tests { - use crate::common::{crypto::aes_gcm_open, utils}; + use crate::common::{crypto::aes_gcm_decrypt, utils}; - use super::{aes_cfb_encrypt, aes_gcm_seal}; + use super::{aes_cfb_encrypt, aes_gcm_encrypt}; #[test] fn test_aes_cfb_256() { @@ -242,30 +178,26 @@ mod tests { #[test] fn test_aes_gcm_seal_ok() { let key = "1234567890123456".as_bytes(); - let nonce = "456".as_bytes(); + let nonce = "456456456456".as_bytes(); // it has to be 12 bytes let data = "789".as_bytes(); let ad = "abc".as_bytes(); - let encrypted = aes_gcm_seal(key, nonce, data, Some(ad)).expect("sealed"); + let encrypted = aes_gcm_encrypt(key, nonce, data, Some(ad)).expect("sealed"); - let decrypted = aes_gcm_open(key, nonce, &encrypted, Some(ad)).expect("opened"); + let decrypted = aes_gcm_decrypt(key, nonce, &encrypted, Some(ad)).expect("opened"); assert_eq!(decrypted, data); } #[test] fn test_aes_gcm_seal_fail() { let key = "1234567890123456".as_bytes(); - let nonce = "456".as_bytes(); + let nonce = "456456456456".as_bytes(); // it has to be 12 bytes let data = "789".as_bytes(); let ad = "abc".as_bytes(); - let encrypted = aes_gcm_seal(key, nonce, data, Some(ad)).expect("sealed"); + let encrypted = aes_gcm_encrypt(key, nonce, data, Some(ad)).expect("sealed"); let key2 = "1234567890123457".as_bytes(); - let decrypted = aes_gcm_open(key2, nonce, &encrypted, Some(ad)); + let decrypted = aes_gcm_decrypt(key2, nonce, &encrypted, Some(ad)); assert!(decrypted.is_err()); - assert_eq!( - decrypted.unwrap_err().to_string(), - "crypto error: BAD_DECRYPT" - ); } } diff --git a/clash_lib/src/proxy/vmess/vmess_impl/header.rs b/clash_lib/src/proxy/vmess/vmess_impl/header.rs index 97d944b83..76c553d62 100644 --- a/clash_lib/src/proxy/vmess/vmess_impl/header.rs +++ b/clash_lib/src/proxy/vmess/vmess_impl/header.rs @@ -1,4 +1,6 @@ -use bytes::{BufMut, BytesMut}; +use aead::{generic_array::GenericArray, KeyInit}; +use aes::cipher::BlockEncrypt; +use bytes::{Buf, BufMut, BytesMut}; use crate::common::{crypto, errors::map_io_error, utils}; @@ -20,14 +22,15 @@ fn create_auth_id(cmd_key: [u8; 16], timestamp: u64) -> [u8; 16] { let zero = crc32fast::hash(buf.as_ref()); buf.put_u32(zero); - let mut aes_key = boring_sys::AES_KEY::default(); let pk = kdf::vmess_kdf_1_one_shot(&cmd_key[..], KDF_SALT_CONST_AUTH_ID_ENCRYPTION_KEY); - unsafe { - boring_sys::AES_set_encrypt_key(pk.as_ptr() as _, 128, &mut aes_key); - boring_sys::AES_encrypt(buf.as_mut_ptr() as _, buf.as_mut_ptr() as _, &aes_key); - } - - buf.freeze()[..16].try_into().unwrap() + let pk: [u8; 16] = pk[..16].try_into().unwrap(); // That's wired + let key = GenericArray::from(pk); + let cipher = aes::Aes128::new(&key); + let mut block = [0u8; 16]; + buf.copy_to_slice(&mut block); + let mut block = GenericArray::from(block); + cipher.encrypt_block(&mut block); + block.as_slice()[..16].try_into().unwrap() } pub(crate) fn seal_vmess_aead_header( @@ -52,7 +55,7 @@ pub(crate) fn seal_vmess_aead_header( &connection_nonce[..], )[..12]; - let header_len_encrypted = crypto::aes_gcm_seal( + let header_len_encrypted = crypto::aes_gcm_encrypt( payload_header_length_aead_key, payload_header_length_aead_nonce, (data.len() as u16).to_be_bytes().as_ref(), @@ -73,7 +76,7 @@ pub(crate) fn seal_vmess_aead_header( &connection_nonce[..], )[..12]; - let payload_encrypted = crypto::aes_gcm_seal( + let payload_encrypted = crypto::aes_gcm_encrypt( payload_header_aead_key, payload_header_aead_nonce, &data, @@ -92,8 +95,6 @@ pub(crate) fn seal_vmess_aead_header( #[cfg(test)] mod tests { - use bytes::{BufMut, BytesMut}; - use crate::{ common::crypto, proxy::vmess::vmess_impl::kdf::{ @@ -104,6 +105,9 @@ mod tests { KDF_SALT_CONST_VMESS_HEADER_PAYLOAD_LENGTH_AEAD_KEY, }, }; + use aead::{generic_array::GenericArray, KeyInit}; + use aes::cipher::BlockEncrypt; + use bytes::{Buf, BufMut, BytesMut}; #[test] fn test_create_auth_id() { @@ -119,15 +123,18 @@ mod tests { buf.put_u32(zero); let cmd_key = "1234567890123456".as_bytes(); - let mut aes_key = boring_sys::AES_KEY::default(); - let pk = kdf::vmess_kdf_1_one_shot(cmd_key, KDF_SALT_CONST_AUTH_ID_ENCRYPTION_KEY); - unsafe { - boring_sys::AES_set_encrypt_key(pk.as_ptr() as _, 128, &mut aes_key); - boring_sys::AES_encrypt(buf.as_mut_ptr() as _, buf.as_mut_ptr() as _, &aes_key); - } + let pk = kdf::vmess_kdf_1_one_shot(&cmd_key[..], KDF_SALT_CONST_AUTH_ID_ENCRYPTION_KEY); + let pk: [u8; 16] = pk[..16].try_into().unwrap(); // That's wired + let key = GenericArray::from(pk); + let cipher = aes::Aes128::new(&key); + let mut block = [0u8; 16]; + buf.copy_to_slice(&mut block); + let mut block = GenericArray::from(block); + cipher.encrypt_block(&mut block); + let block: [u8; 16] = block.as_slice()[..16].try_into().unwrap(); assert_eq!( - buf.freeze()[..16], + block.to_vec(), vec![55, 189, 144, 149, 192, 213, 241, 57, 37, 21, 179, 197, 135, 54, 86, 79] ); } @@ -152,7 +159,7 @@ mod tests { &connection_nonce[..], )[..12]; - let header_len_encrypted = crypto::aes_gcm_seal( + let header_len_encrypted = crypto::aes_gcm_encrypt( payload_header_length_aead_key, payload_header_length_aead_nonce, (data.len() as u16).to_be_bytes().as_ref(), @@ -173,7 +180,7 @@ mod tests { &connection_nonce[..], )[..12]; - let payload_encrypted = crypto::aes_gcm_seal( + let payload_encrypted = crypto::aes_gcm_encrypt( payload_header_aead_key, payload_header_aead_nonce, &data, diff --git a/clash_lib/src/proxy/vmess/vmess_impl/stream.rs b/clash_lib/src/proxy/vmess/vmess_impl/stream.rs index 2fb919098..982b040ce 100644 --- a/clash_lib/src/proxy/vmess/vmess_impl/stream.rs +++ b/clash_lib/src/proxy/vmess/vmess_impl/stream.rs @@ -4,6 +4,8 @@ use aes_gcm::Aes128Gcm; use bytes::{BufMut, BytesMut}; use chacha20poly1305::ChaCha20Poly1305; use futures::ready; + +use md5::Md5; use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt, ReadBuf}; use crate::{ @@ -23,7 +25,7 @@ use super::{ self, KDF_SALT_CONST_AEAD_RESP_HEADER_LEN_IV, KDF_SALT_CONST_AEAD_RESP_HEADER_LEN_KEY, KDF_SALT_CONST_AEAD_RESP_HEADER_PAYLOAD_IV, KDF_SALT_CONST_AEAD_RESP_HEADER_PAYLOAD_KEY, }, - user::{ID, ID_BYTES_LEN}, + user::ID, Security, CHUNK_SIZE, COMMAND_TCP, COMMAND_UDP, OPTION_CHUNK_STREAM, SECURITY_AES_128_GCM, SECURITY_CHACHA20_POLY1305, SECURITY_NONE, VERSION, }; @@ -225,6 +227,8 @@ where S: AsyncWrite + Unpin, { async fn send_handshake_request(&mut self) -> std::io::Result<()> { + use hmac::{Hmac, Mac}; + type HmacMd5 = Hmac; let Self { ref mut stream, ref req_body_key, @@ -246,21 +250,10 @@ where let mut mbuf = BytesMut::new(); if !is_aead { - let mut hash = [0u8; boring_sys::EVP_MAX_MD_SIZE as usize]; - let mut out_len: u32 = 0; - - unsafe { - boring_sys::HMAC( - boring_sys::EVP_md5(), - id.uuid.as_bytes().as_ptr() as _, - ID_BYTES_LEN, - now.to_be_bytes().as_mut_ptr() as _, - 8, - &mut hash as _, - &mut out_len as _, - ); - } - mbuf.put_slice(&hash[..out_len as _]) + let mut mac = + HmacMd5::new_from_slice(id.uuid.as_bytes()).expect("key len expected to be 16"); + mac.update(now.to_be_bytes().as_slice()); + mbuf.put_slice(&mac.finalize().into_bytes()); } let mut buf = BytesMut::new(); @@ -289,10 +282,8 @@ where buf.put_slice(&padding); } - unsafe { - let sum = boring_sys::OPENSSL_hash32(buf.as_mut_ptr() as _, buf.len()); - buf.put_slice(sum.to_be_bytes().as_ref()); - } + let sum = const_fnv1a_hash::fnv1a_hash_32(&buf, None); + buf.put_slice(&sum.to_be_bytes()); if !is_aead { let mut data = buf.to_vec(); @@ -363,7 +354,7 @@ where KDF_SALT_CONST_AEAD_RESP_HEADER_LEN_IV, )[..12]; - let decrypted_response_header_len = crypto::aes_gcm_open( + let decrypted_response_header_len = crypto::aes_gcm_decrypt( aead_response_header_length_encryption_key, aead_response_header_length_encryption_iv, this.read_buf.split().as_ref(), @@ -402,7 +393,7 @@ where KDF_SALT_CONST_AEAD_RESP_HEADER_PAYLOAD_IV, )[..12]; - let buf = crypto::aes_gcm_open( + let buf = crypto::aes_gcm_decrypt( aead_response_header_payload_encryption_key, aead_response_header_payload_encryption_iv, this.read_buf.split().as_ref(), @@ -576,17 +567,12 @@ where } fn hash_timestamp(timestamp: u64) -> [u8; 16] { - unsafe { - let mut ctx = boring_sys::MD5_CTX::default(); - boring_sys::MD5_Init(&mut ctx); - - boring_sys::MD5_Update(&mut ctx, timestamp.to_be_bytes().as_ptr() as _, 8); - boring_sys::MD5_Update(&mut ctx, timestamp.to_be_bytes().as_ptr() as _, 8); - boring_sys::MD5_Update(&mut ctx, timestamp.to_be_bytes().as_ptr() as _, 8); - boring_sys::MD5_Update(&mut ctx, timestamp.to_be_bytes().as_ptr() as _, 8); - - let mut hash = [0u8; 16]; - boring_sys::MD5_Final(hash.as_mut_ptr() as _, &mut ctx); - hash - } + use md5::Digest; + let mut hasher = md5::Md5::new(); + // TODO Why four times? + hasher.update(timestamp.to_be_bytes()); + hasher.update(timestamp.to_be_bytes()); + hasher.update(timestamp.to_be_bytes()); + hasher.update(timestamp.to_be_bytes()); + hasher.finalize().into() } diff --git a/clash_lib/src/proxy/vmess/vmess_impl/user.rs b/clash_lib/src/proxy/vmess/vmess_impl/user.rs index b9fa267a0..ae9a0d912 100644 --- a/clash_lib/src/proxy/vmess/vmess_impl/user.rs +++ b/clash_lib/src/proxy/vmess/vmess_impl/user.rs @@ -1,11 +1,9 @@ -use boring_sys::MD5_DIGEST_LENGTH; - -pub const ID_BYTES_LEN: usize = 16; +use md5::Digest; #[derive(Clone)] pub struct ID { pub uuid: uuid::Uuid, - pub cmd_key: [u8; MD5_DIGEST_LENGTH as _], + pub cmd_key: [u8; 16], } pub fn new_alter_id_list(primary: &ID, alter_id_count: u16) -> Vec { @@ -25,61 +23,23 @@ pub fn new_alter_id_list(primary: &ID, alter_id_count: u16) -> Vec { alter_id_list } +/// TODO docs pub fn new_id(uuid: &uuid::Uuid) -> ID { let uuid = uuid.to_owned(); - let mut cmd_key = [0u8; MD5_DIGEST_LENGTH as _]; - - let mut ctx = boring_sys::MD5_CTX::default(); - unsafe { - boring_sys::MD5_Init(&mut ctx as _); - boring_sys::MD5_Update( - &mut ctx as _, - uuid.as_bytes().as_ptr() as _, - uuid.as_bytes().len(), - ); - boring_sys::MD5_Update( - &mut ctx as _, - b"c48619fe-8f02-49e0-b9e9-edf763e17e21".as_ptr() as _, - 36, - ); - boring_sys::MD5_Final(cmd_key.as_mut_ptr() as _, &mut ctx as _); - } - + let mut hasher = md5::Md5::new(); + hasher.update(uuid.as_bytes()); + hasher.update(b"c48619fe-8f02-49e0-b9e9-edf763e17e21"); // What? + let cmd_key: [u8; 16] = hasher.finalize().into(); ID { uuid, cmd_key } } +/// TODO docs fn next_id(i: &uuid::Uuid) -> uuid::Uuid { - let mut ctx = boring_sys::MD5_CTX::default(); - unsafe { - boring_sys::MD5_Init(&mut ctx as _); - boring_sys::MD5_Update( - &mut ctx as _, - i.as_bytes().as_ptr() as _, - i.as_bytes().len(), - ); - boring_sys::MD5_Update( - &mut ctx as _, - b"16167dc8-16b6-4e6d-b8bb-65dd68113a81".as_ptr() as _, - 36, - ); - let mut buf = [0u8; MD5_DIGEST_LENGTH as _]; - /* - loop { - boring_sys::MD5_Final(buf.as_mut_ptr() as _, &mut ctx as _); - if i.as_bytes() != buf.as_slice() { - return uuid::Uuid::from_bytes(buf); - } - - boring_sys::MD5_Update( - &mut ctx as _, - b"533eff8a-4113-4b10-b5ce-0f5d76b98cd2".as_ptr() as _, - 36, - ); - } - */ - boring_sys::MD5_Final(buf.as_mut_ptr() as _, &mut ctx as _); - uuid::Uuid::from_bytes(buf) - } + let mut hasher = md5::Md5::new(); + hasher.update(i.as_bytes()); + hasher.update(b"16167dc8-16b6-4e6d-b8bb-65dd68113a81"); // Why? + let buf: [u8; 16] = hasher.finalize().into(); + uuid::Uuid::from_bytes(buf) } #[cfg(test)]