A whimsical STROBE based encryption protocol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Benchmarks, code tidy-up & optimisations

+658 -52
+1
.gitignore
··· 1 + .cargo/ 1 2 /target
+530
Cargo.lock
··· 13 13 ] 14 14 15 15 [[package]] 16 + name = "aho-corasick" 17 + version = "1.1.4" 18 + source = "registry+https://github.com/rust-lang/crates.io-index" 19 + checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" 20 + dependencies = [ 21 + "memchr", 22 + ] 23 + 24 + [[package]] 25 + name = "alloca" 26 + version = "0.4.0" 27 + source = "registry+https://github.com/rust-lang/crates.io-index" 28 + checksum = "e5a7d05ea6aea7e9e64d25b9156ba2fee3fdd659e34e41063cd2fc7cd020d7f4" 29 + dependencies = [ 30 + "cc", 31 + ] 32 + 33 + [[package]] 34 + name = "anes" 35 + version = "0.1.6" 36 + source = "registry+https://github.com/rust-lang/crates.io-index" 37 + checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" 38 + 39 + [[package]] 40 + name = "anstyle" 41 + version = "1.0.14" 42 + source = "registry+https://github.com/rust-lang/crates.io-index" 43 + checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" 44 + 45 + [[package]] 16 46 name = "anyhow" 17 47 version = "1.0.102" 18 48 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 40 70 ] 41 71 42 72 [[package]] 73 + name = "bumpalo" 74 + version = "3.20.2" 75 + source = "registry+https://github.com/rust-lang/crates.io-index" 76 + checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" 77 + 78 + [[package]] 79 + name = "cast" 80 + version = "0.3.0" 81 + source = "registry+https://github.com/rust-lang/crates.io-index" 82 + checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" 83 + 84 + [[package]] 85 + name = "cc" 86 + version = "1.2.60" 87 + source = "registry+https://github.com/rust-lang/crates.io-index" 88 + checksum = "43c5703da9466b66a946814e1adf53ea2c90f10063b86290cc9eb67ce3478a20" 89 + dependencies = [ 90 + "find-msvc-tools", 91 + "shlex", 92 + ] 93 + 94 + [[package]] 43 95 name = "cfg-if" 44 96 version = "1.0.4" 45 97 source = "registry+https://github.com/rust-lang/crates.io-index" 46 98 checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" 47 99 48 100 [[package]] 101 + name = "chacha20" 102 + version = "0.10.0" 103 + source = "registry+https://github.com/rust-lang/crates.io-index" 104 + checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601" 105 + dependencies = [ 106 + "cfg-if", 107 + "cipher", 108 + "cpufeatures", 109 + ] 110 + 111 + [[package]] 112 + name = "chacha20poly1305" 113 + version = "0.11.0-rc.3" 114 + source = "registry+https://github.com/rust-lang/crates.io-index" 115 + checksum = "1c9ed179664f12fd6f155f6dd632edf5f3806d48c228c67ff78366f2a0eb6b5e" 116 + dependencies = [ 117 + "aead", 118 + "chacha20", 119 + "cipher", 120 + "poly1305", 121 + ] 122 + 123 + [[package]] 124 + name = "ciborium" 125 + version = "0.2.2" 126 + source = "registry+https://github.com/rust-lang/crates.io-index" 127 + checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" 128 + dependencies = [ 129 + "ciborium-io", 130 + "ciborium-ll", 131 + "serde", 132 + ] 133 + 134 + [[package]] 135 + name = "ciborium-io" 136 + version = "0.2.2" 137 + source = "registry+https://github.com/rust-lang/crates.io-index" 138 + checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" 139 + 140 + [[package]] 141 + name = "ciborium-ll" 142 + version = "0.2.2" 143 + source = "registry+https://github.com/rust-lang/crates.io-index" 144 + checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" 145 + dependencies = [ 146 + "ciborium-io", 147 + "half", 148 + ] 149 + 150 + [[package]] 151 + name = "cipher" 152 + version = "0.5.1" 153 + source = "registry+https://github.com/rust-lang/crates.io-index" 154 + checksum = "e34d8227fe1ba289043aeb13792056ff80fd6de1a9f49137a5f499de8e8c78ea" 155 + dependencies = [ 156 + "block-buffer", 157 + "crypto-common", 158 + "inout", 159 + ] 160 + 161 + [[package]] 162 + name = "clap" 163 + version = "4.6.1" 164 + source = "registry+https://github.com/rust-lang/crates.io-index" 165 + checksum = "1ddb117e43bbf7dacf0a4190fef4d345b9bad68dfc649cb349e7d17d28428e51" 166 + dependencies = [ 167 + "clap_builder", 168 + ] 169 + 170 + [[package]] 171 + name = "clap_builder" 172 + version = "4.6.0" 173 + source = "registry+https://github.com/rust-lang/crates.io-index" 174 + checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" 175 + dependencies = [ 176 + "anstyle", 177 + "clap_lex", 178 + ] 179 + 180 + [[package]] 181 + name = "clap_lex" 182 + version = "1.1.0" 183 + source = "registry+https://github.com/rust-lang/crates.io-index" 184 + checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" 185 + 186 + [[package]] 49 187 name = "cmov" 50 188 version = "0.5.3" 51 189 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 61 199 ] 62 200 63 201 [[package]] 202 + name = "criterion" 203 + version = "0.8.2" 204 + source = "registry+https://github.com/rust-lang/crates.io-index" 205 + checksum = "950046b2aa2492f9a536f5f4f9a3de7b9e2476e575e05bd6c333371add4d98f3" 206 + dependencies = [ 207 + "alloca", 208 + "anes", 209 + "cast", 210 + "ciborium", 211 + "clap", 212 + "criterion-plot", 213 + "itertools", 214 + "num-traits", 215 + "oorandom", 216 + "page_size", 217 + "plotters", 218 + "rayon", 219 + "regex", 220 + "serde", 221 + "serde_json", 222 + "tinytemplate", 223 + "walkdir", 224 + ] 225 + 226 + [[package]] 227 + name = "criterion-plot" 228 + version = "0.8.2" 229 + source = "registry+https://github.com/rust-lang/crates.io-index" 230 + checksum = "d8d80a2f4f5b554395e47b5d8305bc3d27813bacb73493eb1001e8f76dae29ea" 231 + dependencies = [ 232 + "cast", 233 + "itertools", 234 + ] 235 + 236 + [[package]] 237 + name = "crossbeam-deque" 238 + version = "0.8.6" 239 + source = "registry+https://github.com/rust-lang/crates.io-index" 240 + checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" 241 + dependencies = [ 242 + "crossbeam-epoch", 243 + "crossbeam-utils", 244 + ] 245 + 246 + [[package]] 247 + name = "crossbeam-epoch" 248 + version = "0.9.18" 249 + source = "registry+https://github.com/rust-lang/crates.io-index" 250 + checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" 251 + dependencies = [ 252 + "crossbeam-utils", 253 + ] 254 + 255 + [[package]] 256 + name = "crossbeam-utils" 257 + version = "0.8.21" 258 + source = "registry+https://github.com/rust-lang/crates.io-index" 259 + checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" 260 + 261 + [[package]] 262 + name = "crunchy" 263 + version = "0.2.4" 264 + source = "registry+https://github.com/rust-lang/crates.io-index" 265 + checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" 266 + 267 + [[package]] 64 268 name = "crypto-common" 65 269 version = "0.2.1" 66 270 source = "registry+https://github.com/rust-lang/crates.io-index" 67 271 checksum = "77727bb15fa921304124b128af125e7e3b968275d1b108b379190264f4423710" 68 272 dependencies = [ 273 + "getrandom", 69 274 "hybrid-array", 70 275 "rand_core", 71 276 ] ··· 90 295 ] 91 296 92 297 [[package]] 298 + name = "either" 299 + version = "1.15.0" 300 + source = "registry+https://github.com/rust-lang/crates.io-index" 301 + checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" 302 + 303 + [[package]] 93 304 name = "equivalent" 94 305 version = "1.0.2" 95 306 source = "registry+https://github.com/rust-lang/crates.io-index" 96 307 checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" 97 308 98 309 [[package]] 310 + name = "find-msvc-tools" 311 + version = "0.1.9" 312 + source = "registry+https://github.com/rust-lang/crates.io-index" 313 + checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" 314 + 315 + [[package]] 99 316 name = "foldhash" 100 317 version = "0.1.5" 101 318 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 113 330 "rand_core", 114 331 "wasip2", 115 332 "wasip3", 333 + ] 334 + 335 + [[package]] 336 + name = "half" 337 + version = "2.7.1" 338 + source = "registry+https://github.com/rust-lang/crates.io-index" 339 + checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" 340 + dependencies = [ 341 + "cfg-if", 342 + "crunchy", 343 + "zerocopy", 116 344 ] 117 345 118 346 [[package]] ··· 181 409 ] 182 410 183 411 [[package]] 412 + name = "itertools" 413 + version = "0.13.0" 414 + source = "registry+https://github.com/rust-lang/crates.io-index" 415 + checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" 416 + dependencies = [ 417 + "either", 418 + ] 419 + 420 + [[package]] 184 421 name = "itoa" 185 422 version = "1.0.18" 186 423 source = "registry+https://github.com/rust-lang/crates.io-index" 187 424 checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" 425 + 426 + [[package]] 427 + name = "js-sys" 428 + version = "0.3.95" 429 + source = "registry+https://github.com/rust-lang/crates.io-index" 430 + checksum = "2964e92d1d9dc3364cae4d718d93f227e3abb088e747d92e0395bfdedf1c12ca" 431 + dependencies = [ 432 + "once_cell", 433 + "wasm-bindgen", 434 + ] 188 435 189 436 [[package]] 190 437 name = "keccak" ··· 267 514 ] 268 515 269 516 [[package]] 517 + name = "once_cell" 518 + version = "1.21.4" 519 + source = "registry+https://github.com/rust-lang/crates.io-index" 520 + checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" 521 + 522 + [[package]] 523 + name = "oorandom" 524 + version = "11.1.5" 525 + source = "registry+https://github.com/rust-lang/crates.io-index" 526 + checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" 527 + 528 + [[package]] 529 + name = "page_size" 530 + version = "0.6.0" 531 + source = "registry+https://github.com/rust-lang/crates.io-index" 532 + checksum = "30d5b2194ed13191c1999ae0704b7839fb18384fa22e49b57eeaa97d79ce40da" 533 + dependencies = [ 534 + "libc", 535 + "winapi", 536 + ] 537 + 538 + [[package]] 539 + name = "plotters" 540 + version = "0.3.7" 541 + source = "registry+https://github.com/rust-lang/crates.io-index" 542 + checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" 543 + dependencies = [ 544 + "num-traits", 545 + "plotters-backend", 546 + "plotters-svg", 547 + "wasm-bindgen", 548 + "web-sys", 549 + ] 550 + 551 + [[package]] 552 + name = "plotters-backend" 553 + version = "0.3.7" 554 + source = "registry+https://github.com/rust-lang/crates.io-index" 555 + checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" 556 + 557 + [[package]] 558 + name = "plotters-svg" 559 + version = "0.3.7" 560 + source = "registry+https://github.com/rust-lang/crates.io-index" 561 + checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" 562 + dependencies = [ 563 + "plotters-backend", 564 + ] 565 + 566 + [[package]] 567 + name = "poly1305" 568 + version = "0.9.0-rc.6" 569 + source = "registry+https://github.com/rust-lang/crates.io-index" 570 + checksum = "19feddcbdf17fad33f40041c7f9e768faf19455f32a6d52ba1b8b65ffc7b1cae" 571 + dependencies = [ 572 + "cpufeatures", 573 + "universal-hash", 574 + ] 575 + 576 + [[package]] 270 577 name = "prettyplease" 271 578 version = "0.2.37" 272 579 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 307 614 checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" 308 615 309 616 [[package]] 617 + name = "rayon" 618 + version = "1.12.0" 619 + source = "registry+https://github.com/rust-lang/crates.io-index" 620 + checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d" 621 + dependencies = [ 622 + "either", 623 + "rayon-core", 624 + ] 625 + 626 + [[package]] 627 + name = "rayon-core" 628 + version = "1.13.0" 629 + source = "registry+https://github.com/rust-lang/crates.io-index" 630 + checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" 631 + dependencies = [ 632 + "crossbeam-deque", 633 + "crossbeam-utils", 634 + ] 635 + 636 + [[package]] 637 + name = "regex" 638 + version = "1.12.3" 639 + source = "registry+https://github.com/rust-lang/crates.io-index" 640 + checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" 641 + dependencies = [ 642 + "aho-corasick", 643 + "memchr", 644 + "regex-automata", 645 + "regex-syntax", 646 + ] 647 + 648 + [[package]] 649 + name = "regex-automata" 650 + version = "0.4.14" 651 + source = "registry+https://github.com/rust-lang/crates.io-index" 652 + checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" 653 + dependencies = [ 654 + "aho-corasick", 655 + "memchr", 656 + "regex-syntax", 657 + ] 658 + 659 + [[package]] 660 + name = "regex-syntax" 661 + version = "0.8.10" 662 + source = "registry+https://github.com/rust-lang/crates.io-index" 663 + checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" 664 + 665 + [[package]] 666 + name = "rustversion" 667 + version = "1.0.22" 668 + source = "registry+https://github.com/rust-lang/crates.io-index" 669 + checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" 670 + 671 + [[package]] 672 + name = "same-file" 673 + version = "1.0.6" 674 + source = "registry+https://github.com/rust-lang/crates.io-index" 675 + checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" 676 + dependencies = [ 677 + "winapi-util", 678 + ] 679 + 680 + [[package]] 310 681 name = "semver" 311 682 version = "1.0.28" 312 683 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 375 746 ] 376 747 377 748 [[package]] 749 + name = "shlex" 750 + version = "1.3.0" 751 + source = "registry+https://github.com/rust-lang/crates.io-index" 752 + checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" 753 + 754 + [[package]] 378 755 name = "syn" 379 756 version = "2.0.117" 380 757 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 386 763 ] 387 764 388 765 [[package]] 766 + name = "tinytemplate" 767 + version = "1.2.1" 768 + source = "registry+https://github.com/rust-lang/crates.io-index" 769 + checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" 770 + dependencies = [ 771 + "serde", 772 + "serde_json", 773 + ] 774 + 775 + [[package]] 389 776 name = "typenum" 390 777 version = "1.19.0" 391 778 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 404 791 checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" 405 792 406 793 [[package]] 794 + name = "universal-hash" 795 + version = "0.6.1" 796 + source = "registry+https://github.com/rust-lang/crates.io-index" 797 + checksum = "f4987bdc12753382e0bec4a65c50738ffaabc998b9cdd1f952fb5f39b0048a96" 798 + dependencies = [ 799 + "crypto-common", 800 + "ctutils", 801 + ] 802 + 803 + [[package]] 804 + name = "walkdir" 805 + version = "2.5.0" 806 + source = "registry+https://github.com/rust-lang/crates.io-index" 807 + checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" 808 + dependencies = [ 809 + "same-file", 810 + "winapi-util", 811 + ] 812 + 813 + [[package]] 407 814 name = "wasip2" 408 815 version = "1.0.3+wasi-0.2.9" 409 816 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 422 829 ] 423 830 424 831 [[package]] 832 + name = "wasm-bindgen" 833 + version = "0.2.118" 834 + source = "registry+https://github.com/rust-lang/crates.io-index" 835 + checksum = "0bf938a0bacb0469e83c1e148908bd7d5a6010354cf4fb73279b7447422e3a89" 836 + dependencies = [ 837 + "cfg-if", 838 + "once_cell", 839 + "rustversion", 840 + "wasm-bindgen-macro", 841 + "wasm-bindgen-shared", 842 + ] 843 + 844 + [[package]] 845 + name = "wasm-bindgen-macro" 846 + version = "0.2.118" 847 + source = "registry+https://github.com/rust-lang/crates.io-index" 848 + checksum = "eeff24f84126c0ec2db7a449f0c2ec963c6a49efe0698c4242929da037ca28ed" 849 + dependencies = [ 850 + "quote", 851 + "wasm-bindgen-macro-support", 852 + ] 853 + 854 + [[package]] 855 + name = "wasm-bindgen-macro-support" 856 + version = "0.2.118" 857 + source = "registry+https://github.com/rust-lang/crates.io-index" 858 + checksum = "9d08065faf983b2b80a79fd87d8254c409281cf7de75fc4b773019824196c904" 859 + dependencies = [ 860 + "bumpalo", 861 + "proc-macro2", 862 + "quote", 863 + "syn", 864 + "wasm-bindgen-shared", 865 + ] 866 + 867 + [[package]] 868 + name = "wasm-bindgen-shared" 869 + version = "0.2.118" 870 + source = "registry+https://github.com/rust-lang/crates.io-index" 871 + checksum = "5fd04d9e306f1907bd13c6361b5c6bfc7b3b3c095ed3f8a9246390f8dbdee129" 872 + dependencies = [ 873 + "unicode-ident", 874 + ] 875 + 876 + [[package]] 425 877 name = "wasm-encoder" 426 878 version = "0.244.0" 427 879 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 456 908 ] 457 909 458 910 [[package]] 911 + name = "web-sys" 912 + version = "0.3.95" 913 + source = "registry+https://github.com/rust-lang/crates.io-index" 914 + checksum = "4f2dfbb17949fa2088e5d39408c48368947b86f7834484e87b73de55bc14d97d" 915 + dependencies = [ 916 + "js-sys", 917 + "wasm-bindgen", 918 + ] 919 + 920 + [[package]] 459 921 name = "wharrgarbl" 460 922 version = "0.1.0" 461 923 dependencies = [ 462 924 "aead", 925 + "chacha20poly1305", 926 + "criterion", 463 927 "ctutils", 464 928 "getrandom", 465 929 "hybrid-array", ··· 494 958 ] 495 959 496 960 [[package]] 961 + name = "winapi" 962 + version = "0.3.9" 963 + source = "registry+https://github.com/rust-lang/crates.io-index" 964 + checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 965 + dependencies = [ 966 + "winapi-i686-pc-windows-gnu", 967 + "winapi-x86_64-pc-windows-gnu", 968 + ] 969 + 970 + [[package]] 971 + name = "winapi-i686-pc-windows-gnu" 972 + version = "0.4.0" 973 + source = "registry+https://github.com/rust-lang/crates.io-index" 974 + checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 975 + 976 + [[package]] 977 + name = "winapi-util" 978 + version = "0.1.11" 979 + source = "registry+https://github.com/rust-lang/crates.io-index" 980 + checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" 981 + dependencies = [ 982 + "windows-sys", 983 + ] 984 + 985 + [[package]] 986 + name = "winapi-x86_64-pc-windows-gnu" 987 + version = "0.4.0" 988 + source = "registry+https://github.com/rust-lang/crates.io-index" 989 + checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 990 + 991 + [[package]] 992 + name = "windows-link" 993 + version = "0.2.1" 994 + source = "registry+https://github.com/rust-lang/crates.io-index" 995 + checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" 996 + 997 + [[package]] 998 + name = "windows-sys" 999 + version = "0.61.2" 1000 + source = "registry+https://github.com/rust-lang/crates.io-index" 1001 + checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" 1002 + dependencies = [ 1003 + "windows-link", 1004 + ] 1005 + 1006 + [[package]] 497 1007 name = "wit-bindgen" 498 1008 version = "0.51.0" 499 1009 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 585 1095 "serde_json", 586 1096 "unicode-xid", 587 1097 "wasmparser", 1098 + ] 1099 + 1100 + [[package]] 1101 + name = "zerocopy" 1102 + version = "0.8.48" 1103 + source = "registry+https://github.com/rust-lang/crates.io-index" 1104 + checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9" 1105 + dependencies = [ 1106 + "zerocopy-derive", 1107 + ] 1108 + 1109 + [[package]] 1110 + name = "zerocopy-derive" 1111 + version = "0.8.48" 1112 + source = "registry+https://github.com/rust-lang/crates.io-index" 1113 + checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" 1114 + dependencies = [ 1115 + "proc-macro2", 1116 + "quote", 1117 + "syn", 588 1118 ] 589 1119 590 1120 [[package]]
+15 -4
Cargo.toml
··· 13 13 aead = { version = "0.6.0-rc.10" } 14 14 ctutils = { version = "0.4.2", default-features = false } 15 15 zeroize = { version = "1.8.2", default-features = false } 16 + rand_core = { version = "0.10", default-features = false } 16 17 hybrid-array = { version = "0.4.10" } 17 18 18 19 [package] ··· 23 24 version.workspace = true 24 25 authors.workspace = true 25 26 26 - [features] 27 - parallel = ["wharrgarbl-strobe/parallel"] 28 - 29 27 [dependencies] 30 28 wharrgarbl-utils = { path = "./wharrgarbl-utils", version = "0.1" } 31 29 wharrgarbl-strobe = { path = "./wharrgarbl-strobe", version = "0.1" } ··· 33 31 zeroize.workspace = true 34 32 ml-kem = { version = "0.3.0-rc.2", features = ["zeroize"] } 35 33 hybrid-array = { workspace = true, features = ["alloc"] } 36 - rand_core = { version = "0.10", default-features = false } 34 + rand_core.workspace = true 37 35 aead.workspace = true 38 36 39 37 [dev-dependencies] 40 38 getrandom = { version = "0.4.2", features = ["sys_rng"] } 41 39 aead = { version = "0.6.0-rc.10", features = ["alloc"] } 40 + chacha20poly1305 = "=0.11.0-rc.3" 41 + criterion = { version ="0.8.2", features = ["html_reports"] } 42 + 43 + [[bench]] 44 + name = "garbl_bench" 45 + path = "benches/garbl_bench.rs" 46 + harness = false 47 + 48 + [profile.bench] 49 + lto = true 50 + codegen-units = 1 51 + debug = false 52 + panic = "abort"
+63
benches/garbl_bench.rs
··· 1 + use core::hint::black_box; 2 + 3 + use aead::{AeadInOut, KeyInit}; 4 + use criterion::{Criterion, criterion_main}; 5 + use hybrid_array::Array; 6 + 7 + fn generate_text() -> Vec<u8> { 8 + let text = "Lorem ipsum dolor sit amet"; 9 + 10 + let text = String::from(text); 11 + 12 + text.repeat(128).as_bytes().to_vec() 13 + } 14 + 15 + fn wharrgarbl_benchmark(c: &mut Criterion) { 16 + use wharrgarbl::transport::AeadStrobe; 17 + use wharrgarbl_strobe::Sec128; 18 + 19 + let key = Array([77u8; 32]); 20 + let nonce = Array([12u8; 16]); 21 + 22 + let transport = AeadStrobe::<Sec128>::new(&key); 23 + 24 + c.bench_function("WHGL TRANSPORT ROUNDTRIP", |b| { 25 + b.iter_batched_ref( 26 + generate_text, 27 + |text| { 28 + let _ = transport.encrypt_in_place(&nonce, b"bench", black_box(text)); 29 + let _ = transport.decrypt_in_place(&nonce, b"bench", black_box(text)); 30 + }, 31 + criterion::BatchSize::LargeInput, 32 + ); 33 + }); 34 + } 35 + 36 + fn chacha20poly1305_benchmark(c: &mut Criterion) { 37 + use chacha20poly1305::{ChaCha20Poly1305, KeyInit}; 38 + 39 + let key = Array([77u8; 32]); 40 + let nonce = Array([12u8; 12]); 41 + 42 + let transport = ChaCha20Poly1305::new(&key); 43 + 44 + c.bench_function("CHACHAPOLY TRANSPORT ROUNDTRIP", |b| { 45 + b.iter_batched_ref( 46 + generate_text, 47 + |text| { 48 + let _ = transport.encrypt_in_place(&nonce, b"bench", black_box(text)); 49 + let _ = transport.decrypt_in_place(&nonce, b"bench", black_box(text)); 50 + }, 51 + criterion::BatchSize::LargeInput, 52 + ); 53 + }); 54 + } 55 + 56 + pub fn benches() { 57 + let mut criterion: Criterion<_> = Criterion::default().configure_from_args(); 58 + 59 + wharrgarbl_benchmark(&mut criterion); 60 + chacha20poly1305_benchmark(&mut criterion); 61 + } 62 + 63 + criterion_main!(benches);
+10 -13
src/handshake.rs
··· 1 1 use core::marker::PhantomData; 2 2 3 3 use aead::Buffer; 4 + use alloc::boxed::Box; 4 5 use hybrid_array::{Array, typenum::Unsigned}; 5 6 use ml_kem::{Encapsulate, Kem, KeyExport, ParameterSet, TryKeyInit, kem::Decapsulate}; 6 7 use rand_core::CryptoRng; ··· 14 15 pub struct ClientHandshake<S: StrobeSecurity, K: Kem + ParameterSet> { 15 16 kem_sec: PhantomData<K>, 16 17 strobe: StrobeState<S>, 17 - decap: Option<K::DecapsulationKey>, 18 + decap: Option<Box<K::DecapsulationKey>>, 18 19 } 19 20 20 21 impl<S: StrobeSecurity, K: Kem + ParameterSet> ClientHandshake<S, K> ··· 28 29 strobe.key(psk); 29 30 } 30 31 31 - strobe.meta_ad(&K::K::to_u16().to_le_bytes()); 32 + strobe.meta_ad(&K::K::to_u8().to_le_bytes()); 32 33 strobe.meta_ad(&S::to_bytes()); 33 34 34 35 Self { ··· 42 43 let mut tag: aead::Tag<AeadStrobe<S>> = Default::default(); 43 44 let (decap, encap) = K::generate_keypair_from_rng(rng); 44 45 45 - buf.extend_from_slice(&encap.to_bytes())?; 46 + self.decap = Some(Box::new(decap)); 46 47 47 - let rachet_bytes = S::to_usize() >> 3; 48 + buf.extend_from_slice(&encap.to_bytes())?; 48 49 49 50 self.strobe.send_clr(buf.as_ref()); 50 51 self.strobe.send_mac(&mut tag); 51 - self.strobe.ratchet(rachet_bytes); 52 + self.strobe.ratchet(S::ratchet_bytes()); 52 53 53 54 buf.extend_from_slice(&tag)?; 54 55 55 - self.decap = Some(decap); 56 - 57 56 Ok(()) 58 57 } 59 58 ··· 68 67 let (ciphertext, tag) = ciphertext.split_at(tag); 69 68 70 69 let tag: aead::Tag<AeadStrobe<S>> = tag.try_into().unwrap(); 71 - let rachet_bytes = S::to_usize() >> 3; 72 70 73 71 self.strobe.recv_clr(ciphertext); 74 72 self.strobe.recv_mac(&tag)?; 75 - self.strobe.ratchet(rachet_bytes); 73 + self.strobe.ratchet(S::ratchet_bytes()); 76 74 77 75 let shared = decap 78 76 .decapsulate_slice(ciphertext) ··· 109 107 strobe.key(psk); 110 108 } 111 109 112 - strobe.meta_ad(&K::K::to_u16().to_le_bytes()); 110 + strobe.meta_ad(&K::K::to_u8().to_le_bytes()); 113 111 strobe.meta_ad(&S::to_bytes()); 114 112 115 113 Self { ··· 133 131 let (encap, tag) = buf.as_ref().split_at(tag); 134 132 135 133 let tag: aead::Tag<AeadStrobe<S>> = tag.try_into().unwrap(); 136 - let rachet_bytes = S::to_usize() >> 3; 137 134 138 135 self.strobe.recv_clr(encap); 139 136 self.strobe.recv_mac(&tag)?; 140 - self.strobe.ratchet(rachet_bytes); 137 + self.strobe.ratchet(S::ratchet_bytes()); 141 138 142 139 let encap = K::EncapsulationKey::new_from_slice(encap).map_err(|_| aead::Error)?; 143 140 ··· 149 146 150 147 self.strobe.send_clr(cipher.as_ref()); 151 148 self.strobe.send_mac(&mut tag); 152 - self.strobe.ratchet(rachet_bytes); 149 + self.strobe.ratchet(S::ratchet_bytes()); 153 150 154 151 buf.extend_from_slice(cipher.as_ref())?; 155 152 buf.extend_from_slice(&tag)?;
+6 -6
src/lib.rs
··· 2 2 #![forbid(unsafe_code)] 3 3 4 4 use ml_kem::{MlKem512, MlKem768}; 5 - use wharrgarbl_strobe::{Sec128, Sec256}; 5 + pub use wharrgarbl_strobe::{Sec128, Sec256}; 6 6 7 7 pub mod handshake; 8 8 pub mod transport; ··· 10 10 extern crate alloc; 11 11 12 12 /// Version of WHARRGARBL that this crate implements. 13 - pub static WHARRGHARBL_PROTO: &str = "WGBL-v0.0-STv1.0.2"; 13 + pub static WHARRGHARBL_PROTO: &str = "WGBL-v0.1-STv1.0.2"; 14 14 15 15 pub mod utils { 16 16 pub use wharrgarbl_utils::BufferSlice; 17 17 } 18 18 19 - pub type ClientHandshake128L1 = handshake::ClientHandshake<Sec128, MlKem512>; 20 - pub type ServerHandshake128L1 = handshake::ServerHandshake<Sec128, MlKem512>; 21 - pub type ClientHandshake256L3 = handshake::ClientHandshake<Sec256, MlKem768>; 22 - pub type ServerHandshake256L3 = handshake::ServerHandshake<Sec256, MlKem768>; 19 + pub type ClientHandshake128 = handshake::ClientHandshake<Sec128, MlKem512>; 20 + pub type ServerHandshake128 = handshake::ServerHandshake<Sec128, MlKem512>; 21 + pub type ClientHandshake256 = handshake::ClientHandshake<Sec256, MlKem768>; 22 + pub type ServerHandshake256 = handshake::ServerHandshake<Sec256, MlKem768>;
+9
src/transport.rs
··· 24 24 type KeySize = U32; 25 25 } 26 26 27 + impl<S: StrobeSecurity> aead::KeyInit for AeadStrobe<S> { 28 + fn new(key: &Key<Self>) -> Self { 29 + Self { 30 + key: *key, 31 + param: PhantomData, 32 + } 33 + } 34 + } 35 + 27 36 impl<S: StrobeSecurity> aead::AeadInOut for AeadStrobe<S> { 28 37 fn encrypt_inout_detached( 29 38 &self,
+1 -4
wharrgarbl-strobe/Cargo.toml
··· 7 7 version.workspace = true 8 8 license.workspace = true 9 9 10 - [features] 11 - parallel = ["keccak/parallel"] 12 - 13 10 [dependencies] 14 11 wharrgarbl-utils = { path = "../wharrgarbl-utils", version = "0.1" } 15 12 aead.workspace = true 16 13 zeroize.workspace = true 17 14 ctutils.workspace = true 18 - keccak = "0.2" 15 + keccak = { version = "0.2", features = ["parallel"] } 19 16 hybrid-array.workspace = true 20 17 21 18 [dev-dependencies]
+1
wharrgarbl-strobe/src/keccakf.rs
··· 39 39 } 40 40 41 41 /// Performs the keccakf\[1600\] permutation on an aligned byte buffer 42 + #[inline] 42 43 pub(crate) fn permute_f1600(&mut self) { 43 44 let mut keccak_block = [0u64; KECCAK_BLOCK_SIZE]; 44 45
+17 -10
wharrgarbl-strobe/src/strobe.rs
··· 46 46 pub fn $name(&mut self, data: &mut [u8]) { 47 47 let flags = $flags; 48 48 let prev_flags = self.prev_flags; 49 - let more = prev_flags.ct_eq(&flags); 49 + let more = prev_flags == flags; 50 50 self.operate(flags, data, more); 51 51 } 52 52 )* ··· 62 62 pub fn $name(&mut self, data: &[u8]) { 63 63 let flags = $flags; 64 64 let prev_flags = self.prev_flags; 65 - let more = prev_flags.ct_eq(&flags); 65 + let more = prev_flags == flags; 66 66 self.operate_no_mutate(flags, data, more); 67 67 } 68 68 )* ··· 147 147 /// 148 148 /// This is a modification to the Strobe API surface to prevent misuse of op calls, 149 149 /// preventing panics/errors so that the compiler can optimise better. 150 + #[inline] 150 151 pub fn reset_ops(&mut self) { 151 152 // This prevents streaming so to always make the prev_flags == flags 152 153 // comparison always fail ··· 154 155 } 155 156 156 157 // Runs the permutation function on the internal state 158 + #[inline] 157 159 fn permutation_f(&mut self) { 158 160 self.state.0[self.position] ^= self.start as u8; 159 161 self.state.0[self.position + 1] ^= 0x04; ··· 168 170 fn increment_position(&mut self, increment: usize) { 169 171 self.position += increment; 170 172 171 - if self.position.ct_eq(&self.rate).to_bool() { 173 + if self.position == self.rate { 172 174 self.permutation_f(); 173 175 } 174 176 } ··· 268 270 269 271 /// Mixes the current state index and flags into the state, accounting for whether we are 270 272 /// sending or receiving 273 + #[inline] 271 274 fn begin_op(&mut self, mut flags: OpFlags) { 272 275 if flags.contains(OpFlags::TRANSPORT).to_bool() { 273 276 let op_role = role::SENDER.ct_select(&role::RECEIVER, flags.contains(OpFlags::INBOUND)); ··· 293 296 /// Performs the state / data transformation that corresponds to the given flags. If `more` is 294 297 /// given, this will treat `data` as a continuation of the data given in the previous 295 298 /// call to `operate`. 296 - fn operate(&mut self, mut flags: OpFlags, data: &mut [u8], more: Choice) { 299 + #[inline] 300 + fn operate(&mut self, mut flags: OpFlags, data: &mut [u8], more: bool) { 297 301 self.prev_flags = flags; 298 302 299 303 // If `more` isn't set, this is a new operation. Do the begin_op sequence 300 - if !more.to_bool() { 304 + if !more { 301 305 self.begin_op(flags); 302 306 } 303 307 ··· 334 338 /// Performs the state transformation that corresponds to the given flags. If `more` is given, 335 339 /// this will treat `data` as a continuation of the data given in the previous call to 336 340 /// `operate`. This uses non-mutating variants of the specializations of the `duplex` function. 337 - fn operate_no_mutate(&mut self, mut flags: OpFlags, data: &[u8], more: Choice) { 341 + #[inline] 342 + fn operate_no_mutate(&mut self, mut flags: OpFlags, data: &[u8], more: bool) { 338 343 self.prev_flags = flags; 339 344 340 345 // If `more` isn't set, this is a new operation. Do the begin_op sequence 341 - if !more.to_bool() { 346 + if !more { 342 347 self.begin_op(flags); 343 348 } 344 349 ··· 356 361 ops[index](self, data); 357 362 } 358 363 364 + #[inline] 359 365 fn recv_mac_inner(&mut self, flags: OpFlags, mac_copy: &mut [u8]) -> Result<(), aead::Error> { 360 366 // recv_mac can never be streamed 361 - self.operate(flags, mac_copy, Choice::FALSE); 367 + self.operate(flags, mac_copy, false); 362 368 363 369 // Constant-time MAC check. This accumulates the truth values of byte == 0 364 370 let all_zero = mac_copy ··· 384 390 self.recv_mac_inner(ops::META_RECV_MAC, &mut mac_copy) 385 391 } 386 392 393 + #[inline] 387 394 fn ratchet_inner(&mut self, mut flags: OpFlags, num_bytes_to_zero: usize) { 388 - let more = self.prev_flags.ct_eq(&flags); 395 + let more = self.prev_flags == flags; 389 396 390 397 // We don't make an `operate` call, since this is a super special case. That means we have 391 398 // to make the `begin_op` call manually. 392 399 self.prev_flags = flags; 393 400 394 - if !more.to_bool() { 401 + if !more { 395 402 self.begin_op(flags); 396 403 } 397 404
+5 -15
wharrgarbl-strobe/src/traits.rs
··· 4 4 use crate::keccakf::KECCAK_BUFFER_SIZE; 5 5 6 6 pub trait StrobeSecurity: Unsigned { 7 - fn to_bytes() -> [u8; 2]; 8 - fn rate() -> usize; 9 - } 10 - 11 - impl StrobeSecurity for U128 { 12 7 fn to_bytes() -> [u8; 2] { 13 8 Self::to_u16().to_le_bytes() 14 9 } 15 - 16 10 fn rate() -> usize { 17 11 KECCAK_BUFFER_SIZE - (Self::to_usize()) / 4 - 2 18 12 } 19 - } 20 - 21 - impl StrobeSecurity for U256 { 22 - fn to_bytes() -> [u8; 2] { 23 - Self::to_u16().to_le_bytes() 24 - } 25 - 26 - fn rate() -> usize { 27 - KECCAK_BUFFER_SIZE - (Self::to_usize()) / 4 - 2 13 + fn ratchet_bytes() -> usize { 14 + Self::to_usize() >> 3 28 15 } 29 16 } 17 + 18 + impl StrobeSecurity for U128 {} 19 + impl StrobeSecurity for U256 {}