Simplify integration test

This commit is contained in:
Prabhpreet Dua
2024-04-15 22:10:40 +05:30
parent a3e91a95df
commit b56af8b696
7 changed files with 372 additions and 225 deletions

383
Cargo.lock generated
View File

@@ -141,7 +141,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [ dependencies = [
"hermit-abi 0.1.19", "hermit-abi 0.1.19",
"libc", "libc",
"winapi", "winapi 0.3.9",
] ]
[[package]] [[package]]
@@ -158,11 +158,12 @@ checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837"
dependencies = [ dependencies = [
"addr2line", "addr2line",
"cc", "cc",
"cfg-if", "cfg-if 1.0.0",
"libc", "libc",
"miniz_oxide", "miniz_oxide",
"object", "object",
"rustc-demangle", "rustc-demangle",
"serde",
] ]
[[package]] [[package]]
@@ -171,6 +172,15 @@ version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
[[package]]
name = "bincode"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "bindgen" name = "bindgen"
version = "0.65.1" version = "0.65.1"
@@ -245,38 +255,6 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "camino"
version = "1.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c"
dependencies = [
"serde",
]
[[package]]
name = "cargo-platform"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc"
dependencies = [
"serde",
]
[[package]]
name = "cargo_metadata"
version = "0.15.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a"
dependencies = [
"camino",
"cargo-platform",
"semver",
"serde",
"serde_json",
"thiserror",
]
[[package]] [[package]]
name = "cast" name = "cast"
version = "0.3.0" version = "0.3.0"
@@ -302,6 +280,12 @@ dependencies = [
"nom", "nom",
] ]
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
version = "1.0.0" version = "1.0.0"
@@ -314,7 +298,7 @@ version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"cipher", "cipher",
"cpufeatures", "cpufeatures",
] ]
@@ -508,13 +492,22 @@ version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216"
[[package]]
name = "crossbeam-channel"
version = "0.5.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95"
dependencies = [
"crossbeam-utils",
]
[[package]] [[package]]
name = "crossbeam-deque" name = "crossbeam-deque"
version = "0.8.3" version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"crossbeam-epoch", "crossbeam-epoch",
"crossbeam-utils", "crossbeam-utils",
] ]
@@ -526,7 +519,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cfg-if", "cfg-if 1.0.0",
"crossbeam-utils", "crossbeam-utils",
"memoffset", "memoffset",
"scopeguard", "scopeguard",
@@ -534,12 +527,9 @@ dependencies = [
[[package]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.8.16" version = "0.8.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
dependencies = [
"cfg-if",
]
[[package]] [[package]]
name = "crypto-common" name = "crypto-common"
@@ -614,6 +604,46 @@ dependencies = [
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
[[package]]
name = "fastrand"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984"
[[package]]
name = "findshlibs"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40b9e59cd0f7e0806cca4be089683ecb6434e602038df21fe6bf6711b2f07f64"
dependencies = [
"cc",
"lazy_static",
"libc",
"winapi 0.3.9",
]
[[package]]
name = "fnv"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "fuchsia-zircon"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
dependencies = [
"bitflags 1.3.2",
"fuchsia-zircon-sys",
]
[[package]]
name = "fuchsia-zircon-sys"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
[[package]] [[package]]
name = "generic-array" name = "generic-array"
version = "0.14.7" version = "0.14.7"
@@ -624,15 +654,26 @@ dependencies = [
"version_check", "version_check",
] ]
[[package]]
name = "getrandom"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
dependencies = [
"cfg-if 1.0.0",
"libc",
"wasi 0.9.0+wasi-snapshot-preview1",
]
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.11" version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"libc", "libc",
"wasi", "wasi 0.11.0+wasi-snapshot-preview1",
] ]
[[package]] [[package]]
@@ -752,6 +793,34 @@ dependencies = [
"generic-array", "generic-array",
] ]
[[package]]
name = "iovec"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
dependencies = [
"libc",
]
[[package]]
name = "ipc-channel"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "342d636452fbc2895574e0b319b23c014fd01c9ed71dcd87f6a4a8e2f948db4b"
dependencies = [
"bincode",
"crossbeam-channel",
"fnv",
"lazy_static",
"libc",
"mio 0.6.23",
"rand 0.7.3",
"serde",
"tempfile",
"uuid",
"winapi 0.3.9",
]
[[package]] [[package]]
name = "is-terminal" name = "is-terminal"
version = "0.4.9" version = "0.4.9"
@@ -796,6 +865,16 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "kernel32-sys"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
dependencies = [
"winapi 0.2.8",
"winapi-build",
]
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "1.4.0" version = "1.4.0"
@@ -831,8 +910,8 @@ version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"winapi", "winapi 0.3.9",
] ]
[[package]] [[package]]
@@ -878,7 +957,7 @@ version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fa0916b001582d253822171bd23f4a0229d32b9507fae236f5da8cad515ba7c" checksum = "0fa0916b001582d253822171bd23f4a0229d32b9507fae236f5da8cad515ba7c"
dependencies = [ dependencies = [
"getrandom", "getrandom 0.2.11",
"libc", "libc",
"windows-sys 0.45.0", "windows-sys 0.45.0",
] ]
@@ -898,6 +977,25 @@ dependencies = [
"adler", "adler",
] ]
[[package]]
name = "mio"
version = "0.6.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4"
dependencies = [
"cfg-if 0.1.10",
"fuchsia-zircon",
"fuchsia-zircon-sys",
"iovec",
"kernel32-sys",
"libc",
"log",
"miow",
"net2",
"slab",
"winapi 0.2.8",
]
[[package]] [[package]]
name = "mio" name = "mio"
version = "0.8.11" version = "0.8.11"
@@ -906,10 +1004,33 @@ checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c"
dependencies = [ dependencies = [
"libc", "libc",
"log", "log",
"wasi", "wasi 0.11.0+wasi-snapshot-preview1",
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "miow"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d"
dependencies = [
"kernel32-sys",
"net2",
"winapi 0.2.8",
"ws2_32-sys",
]
[[package]]
name = "net2"
version = "0.2.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b13b648036a2339d06de780866fbdfda0dde886de7b3af2ddeba8b14f4ee34ac"
dependencies = [
"cfg-if 0.1.10",
"libc",
"winapi 0.3.9",
]
[[package]] [[package]]
name = "nom" name = "nom"
version = "7.1.3" version = "7.1.3"
@@ -1050,6 +1171,20 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "procspawn"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d59f115c63b1eed96002d9df8dfe022ba07e0d70b42890d34bc34f4342bae6b"
dependencies = [
"backtrace",
"findshlibs",
"ipc-channel",
"libc",
"serde",
"winapi 0.3.9",
]
[[package]] [[package]]
name = "psm" name = "psm"
version = "0.1.21" version = "0.1.21"
@@ -1068,6 +1203,19 @@ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]]
name = "rand"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
dependencies = [
"getrandom 0.1.16",
"libc",
"rand_chacha 0.2.2",
"rand_core 0.5.1",
"rand_hc",
]
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.8.5" version = "0.8.5"
@@ -1075,8 +1223,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [ dependencies = [
"libc", "libc",
"rand_chacha", "rand_chacha 0.3.1",
"rand_core", "rand_core 0.6.4",
]
[[package]]
name = "rand_chacha"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
dependencies = [
"ppv-lite86",
"rand_core 0.5.1",
] ]
[[package]] [[package]]
@@ -1086,7 +1244,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [ dependencies = [
"ppv-lite86", "ppv-lite86",
"rand_core", "rand_core 0.6.4",
]
[[package]]
name = "rand_core"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
dependencies = [
"getrandom 0.1.16",
] ]
[[package]] [[package]]
@@ -1095,7 +1262,16 @@ version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [ dependencies = [
"getrandom", "getrandom 0.2.11",
]
[[package]]
name = "rand_hc"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
dependencies = [
"rand_core 0.5.1",
] ]
[[package]] [[package]]
@@ -1118,6 +1294,15 @@ dependencies = [
"crossbeam-utils", "crossbeam-utils",
] ]
[[package]]
name = "redox_syscall"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
dependencies = [
"bitflags 1.3.2",
]
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.10.2" version = "1.10.2"
@@ -1156,12 +1341,12 @@ dependencies = [
"criterion", "criterion",
"env_logger", "env_logger",
"home", "home",
"libc",
"log", "log",
"memoffset", "memoffset",
"mio", "mio 0.8.11",
"paste", "paste",
"rand", "procspawn",
"rand 0.8.5",
"rosenpass-cipher-traits", "rosenpass-cipher-traits",
"rosenpass-ciphers", "rosenpass-ciphers",
"rosenpass-constant-time", "rosenpass-constant-time",
@@ -1171,7 +1356,6 @@ dependencies = [
"serde", "serde",
"stacker", "stacker",
"static_assertions", "static_assertions",
"test-binary",
"test_bin", "test_bin",
"thiserror", "thiserror",
"toml", "toml",
@@ -1203,7 +1387,7 @@ name = "rosenpass-constant-time"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"memsec", "memsec",
"rand", "rand 0.8.5",
"rosenpass-to", "rosenpass-to",
] ]
@@ -1240,7 +1424,7 @@ dependencies = [
"anyhow", "anyhow",
"log", "log",
"memsec", "memsec",
"rand", "rand 0.8.5",
"rosenpass-to", "rosenpass-to",
"rosenpass-util", "rosenpass-util",
"zeroize", "zeroize",
@@ -1323,9 +1507,6 @@ name = "semver"
version = "1.0.21" version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "serde" name = "serde"
@@ -1373,6 +1554,15 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "slab"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67"
dependencies = [
"autocfg",
]
[[package]] [[package]]
name = "spin" name = "spin"
version = "0.9.8" version = "0.9.8"
@@ -1395,10 +1585,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c886bd4480155fd3ef527d45e9ac8dd7118a898a46530b7b94c3e21866259fce" checksum = "c886bd4480155fd3ef527d45e9ac8dd7118a898a46530b7b94c3e21866259fce"
dependencies = [ dependencies = [
"cc", "cc",
"cfg-if", "cfg-if 1.0.0",
"libc", "libc",
"psm", "psm",
"winapi", "winapi 0.3.9",
] ]
[[package]] [[package]]
@@ -1430,6 +1620,19 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "tempfile"
version = "3.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa"
dependencies = [
"cfg-if 1.0.0",
"fastrand",
"redox_syscall",
"rustix",
"windows-sys 0.52.0",
]
[[package]] [[package]]
name = "termcolor" name = "termcolor"
version = "1.4.0" version = "1.4.0"
@@ -1439,19 +1642,6 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "test-binary"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c7cb854285c40b61c0fade358bf63a2bb1226688a1ea11432ea65349209e6e3"
dependencies = [
"camino",
"cargo_metadata",
"once_cell",
"paste",
"thiserror",
]
[[package]] [[package]]
name = "test_bin" name = "test_bin"
version = "0.4.0" version = "0.4.0"
@@ -1556,6 +1746,15 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
name = "uuid"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0"
dependencies = [
"getrandom 0.2.11",
]
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.4" version = "0.9.4"
@@ -1572,6 +1771,12 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.11.0+wasi-snapshot-preview1" version = "0.11.0+wasi-snapshot-preview1"
@@ -1584,7 +1789,7 @@ version = "0.2.88"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"wasm-bindgen-macro", "wasm-bindgen-macro",
] ]
@@ -1654,6 +1859,12 @@ dependencies = [
"rustix", "rustix",
] ]
[[package]]
name = "winapi"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.9" version = "0.3.9"
@@ -1664,6 +1875,12 @@ dependencies = [
"winapi-x86_64-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu",
] ]
[[package]]
name = "winapi-build"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
[[package]] [[package]]
name = "winapi-i686-pc-windows-gnu" name = "winapi-i686-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"
@@ -1676,7 +1893,7 @@ version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
dependencies = [ dependencies = [
"winapi", "winapi 0.3.9",
] ]
[[package]] [[package]]
@@ -1892,6 +2109,16 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "ws2_32-sys"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
dependencies = [
"winapi 0.2.8",
"winapi-build",
]
[[package]] [[package]]
name = "zerocopy" name = "zerocopy"
version = "0.7.32" version = "0.7.32"

View File

@@ -57,7 +57,6 @@ mio = { version = "0.8.11", features = ["net", "os-poll"] }
oqs-sys = { version = "0.8", default-features = false, features = ['classic_mceliece', 'kyber'] } oqs-sys = { version = "0.8", default-features = false, features = ['classic_mceliece', 'kyber'] }
blake2 = "0.10.6" blake2 = "0.10.6"
chacha20poly1305 = { version = "0.10.1", default-features = false, features = [ "std", "heapless" ] } chacha20poly1305 = { version = "0.10.1", default-features = false, features = [ "std", "heapless" ] }
libc = "0.2"
zerocopy = { version = "0.7.32", features = ["derive"] } zerocopy = { version = "0.7.32", features = ["derive"] }
home = "0.5.9" home = "0.5.9"
test-binary = "3.0.2" procspawn = "1.0.0"

View File

@@ -13,11 +13,6 @@ readme = "readme.md"
name = "rosenpass" name = "rosenpass"
path = "src/main.rs" path = "src/main.rs"
[[bin]]
name = "rp-it-dos"
required-features = ["integration_test_dos_exchange"]
path = "src/main.rs"
[[bench]] [[bench]]
name = "handshake" name = "handshake"
harness = false harness = false
@@ -41,7 +36,6 @@ toml = { workspace = true }
clap = { workspace = true } clap = { workspace = true }
mio = { workspace = true } mio = { workspace = true }
rand = { workspace = true } rand = { workspace = true }
libc={workspace = true,optional=true}
zerocopy = { workspace = true } zerocopy = { workspace = true }
home = { workspace = true } home = { workspace = true }
@@ -51,9 +45,5 @@ anyhow = { workspace = true }
[dev-dependencies] [dev-dependencies]
criterion = { workspace = true } criterion = { workspace = true }
test_bin = { workspace = true } test_bin = { workspace = true }
test-binary = { workspace = true }
stacker = { workspace = true } stacker = { workspace = true }
libc = { workspace = true} procspawn = {workspace = true}
[features]
integration_test_dos_exchange = ["dep:libc"]

View File

@@ -34,13 +34,7 @@ use rosenpass_util::b64::{b64_writer, fmt_b64};
const IPV4_ANY_ADDR: Ipv4Addr = Ipv4Addr::new(0, 0, 0, 0); const IPV4_ANY_ADDR: Ipv4Addr = Ipv4Addr::new(0, 0, 0, 0);
const IPV6_ANY_ADDR: Ipv6Addr = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0); const IPV6_ANY_ADDR: Ipv6Addr = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0);
#[cfg(feature = "integration_test_dos_exchange")]
const UNDER_LOAD_RATIO: f64 = 0.001;
#[cfg(feature = "integration_test_dos_exchange")]
const DURATION_UPDATE_UNDER_LOAD_STATUS: Duration = Duration::from_millis(10);
#[cfg(not(feature = "integration_test_dos_exchange"))]
const UNDER_LOAD_RATIO: f64 = 0.5; const UNDER_LOAD_RATIO: f64 = 0.5;
#[cfg(not(feature = "integration_test_dos_exchange"))]
const DURATION_UPDATE_UNDER_LOAD_STATUS: Duration = Duration::from_millis(100); const DURATION_UPDATE_UNDER_LOAD_STATUS: Duration = Duration::from_millis(100);
fn ipv4_any_binding() -> SocketAddr { fn ipv4_any_binding() -> SocketAddr {
@@ -82,6 +76,12 @@ pub enum DoSOperation {
UnderLoad, UnderLoad,
Normal, Normal,
} }
/// Integration test flags for AppServer
#[derive(Debug, Default)]
pub struct AppServerTestFlags {
/// Enable DoS operation permanently
pub enable_dos_permanently: bool,
}
/// Holds the state of the application, namely the external IO /// Holds the state of the application, namely the external IO
/// ///
@@ -101,6 +101,7 @@ pub struct AppServer {
pub non_blocking_polls_count: usize, pub non_blocking_polls_count: usize,
pub unpolled_count: usize, pub unpolled_count: usize,
pub last_update_time: Instant, pub last_update_time: Instant,
pub test_flags: AppServerTestFlags,
} }
/// A socket pointer is an index assigned to a socket; /// A socket pointer is an index assigned to a socket;
@@ -407,6 +408,7 @@ impl AppServer {
pk: SPk, pk: SPk,
addrs: Vec<SocketAddr>, addrs: Vec<SocketAddr>,
verbosity: Verbosity, verbosity: Verbosity,
test_flags: AppServerTestFlags,
) -> anyhow::Result<Self> { ) -> anyhow::Result<Self> {
// setup mio // setup mio
let mio_poll = mio::Poll::new()?; let mio_poll = mio::Poll::new()?;
@@ -505,6 +507,7 @@ impl AppServer {
non_blocking_polls_count: 0, non_blocking_polls_count: 0,
unpolled_count: 0, unpolled_count: 0,
last_update_time: Instant::now(), last_update_time: Instant::now(),
test_flags
}) })
} }
@@ -816,52 +819,33 @@ impl AppServer {
self.unpolled_count += 1; self.unpolled_count += 1;
} }
//Reset blocking poll count if waiting for more than BLOCKING_POLL_COUNT_DURATION if self.test_flags.enable_dos_permanently {
if self.last_update_time.elapsed() > DURATION_UPDATE_UNDER_LOAD_STATUS { self.under_load = DoSOperation::UnderLoad;
self.last_update_time = Instant::now(); } else {
let total_polls = self.blocking_polls_count + self.non_blocking_polls_count; //Reset blocking poll count if waiting for more than BLOCKING_POLL_COUNT_DURATION
if self.last_update_time.elapsed() > DURATION_UPDATE_UNDER_LOAD_STATUS {
self.last_update_time = Instant::now();
let total_polls = self.blocking_polls_count + self.non_blocking_polls_count;
let load_ratio = if total_polls > 0 { let load_ratio = if total_polls > 0 {
self.non_blocking_polls_count as f64 / total_polls as f64 self.non_blocking_polls_count as f64 / total_polls as f64
} else if self.unpolled_count > 0 { } else if self.unpolled_count > 0 {
//There are no polls, so we are under load //There are no polls, so we are under load
1.0 1.0
} else { } else {
0.0 0.0
}; };
#[cfg(feature = "integration_test_dos_exchange")] if load_ratio > UNDER_LOAD_RATIO {
let prev_under_load = self.under_load; self.under_load = DoSOperation::UnderLoad;
if load_ratio > UNDER_LOAD_RATIO { } else {
self.under_load = DoSOperation::UnderLoad;
//Test feature- if under load goes to normal operation, write to file
#[cfg(feature = "integration_test_dos_exchange")]
{
if prev_under_load == DoSOperation::Normal {
let sem_name = b"/rp_integration_test_under_dos\0";
// Create or open a semaphore
let sem = unsafe {
libc::sem_open(sem_name.as_ptr() as *const i8, libc::O_CREAT, 0o644, 0)
};
if sem == libc::SEM_FAILED {
panic!("Failed to create or open semaphore");
}
// Post semaphore
unsafe { libc::sem_post(sem) };
}
}
} else {
// Don't switch to normal operation if executing integration test for DoS exchange
if cfg!(not(feature = "integration_test_dos_exchange")) {
self.under_load = DoSOperation::Normal; self.under_load = DoSOperation::Normal;
} }
}
self.blocking_polls_count = 0; self.blocking_polls_count = 0;
self.non_blocking_polls_count = 0; self.non_blocking_polls_count = 0;
self.unpolled_count = 0; self.unpolled_count = 0;
}
} }
// drain all sockets // drain all sockets

View File

@@ -6,7 +6,7 @@ use rosenpass_secret_memory::file::StoreSecret;
use rosenpass_util::file::{LoadValue, LoadValueB64}; use rosenpass_util::file::{LoadValue, LoadValueB64};
use std::path::PathBuf; use std::path::PathBuf;
use crate::app_server; use crate::app_server::{self, AppServerTestFlags};
use crate::app_server::AppServer; use crate::app_server::AppServer;
use crate::protocol::{SPk, SSk, SymKey}; use crate::protocol::{SPk, SSk, SymKey};
@@ -150,7 +150,7 @@ impl CliCommand {
/// ///
/// ## TODO /// ## TODO
/// - This method consumes the [`CliCommand`] value. It might be wise to use a reference... /// - This method consumes the [`CliCommand`] value. It might be wise to use a reference...
pub fn run(self) -> anyhow::Result<()> { pub fn run(self, test_flags: AppServerTestFlags) -> anyhow::Result<()> {
use CliCommand::*; use CliCommand::*;
match self { match self {
Man => { Man => {
@@ -257,7 +257,7 @@ impl CliCommand {
let config = config::Rosenpass::load(config_file)?; let config = config::Rosenpass::load(config_file)?;
config.validate()?; config.validate()?;
Self::event_loop(config)?; Self::event_loop(config, test_flags)?;
} }
Exchange { Exchange {
@@ -274,7 +274,7 @@ impl CliCommand {
config.config_file_path = p; config.config_file_path = p;
} }
config.validate()?; config.validate()?;
Self::event_loop(config)?; Self::event_loop(config, test_flags)?;
} }
Validate { config_files } => { Validate { config_files } => {
@@ -296,7 +296,7 @@ impl CliCommand {
Ok(()) Ok(())
} }
fn event_loop(config: config::Rosenpass) -> anyhow::Result<()> { fn event_loop(config: config::Rosenpass, test_flags: AppServerTestFlags) -> anyhow::Result<()> {
// load own keys // load own keys
let sk = SSk::load(&config.secret_key)?; let sk = SSk::load(&config.secret_key)?;
let pk = SPk::load(&config.public_key)?; let pk = SPk::load(&config.public_key)?;
@@ -307,6 +307,7 @@ impl CliCommand {
pk, pk,
config.listen, config.listen,
config.verbosity, config.verbosity,
test_flags
)?); )?);
for cfg_peer in config.peers { for cfg_peer in config.peers {

View File

@@ -1,6 +1,6 @@
use clap::Parser; use clap::Parser;
use log::error; use log::error;
use rosenpass::cli::CliArgs; use rosenpass::{app_server::AppServerTestFlags, cli::CliArgs};
use std::process::exit; use std::process::exit;
/// Catches errors, prints them through the logger, then exits /// Catches errors, prints them through the logger, then exits
@@ -26,7 +26,7 @@ pub fn main() {
// error!("error dummy"); // error!("error dummy");
} }
match args.command.run() { match args.command.run(AppServerTestFlags::default()) {
Ok(_) => {} Ok(_) => {}
Err(e) => { Err(e) => {
error!("{e}"); error!("{e}");

View File

@@ -1,5 +1,8 @@
use std::{fs, net::UdpSocket, path::PathBuf, process::Stdio, time::Duration}; use std::{fs, net::UdpSocket, path::PathBuf, process::Stdio, time::Duration};
use clap::Parser;
use rosenpass::{app_server::AppServerTestFlags, cli::CliArgs};
const BIN: &str = "rosenpass"; const BIN: &str = "rosenpass";
// check that we can generate keys // check that we can generate keys
@@ -124,22 +127,12 @@ fn check_exchange_under_normal() {
} }
// check that we can trigger a DoS condition and we can exchange keys under DoS // check that we can trigger a DoS condition and we can exchange keys under DoS
// This test creates a responder (server) with the feature flag "integration_test_dos_exchange". The feature flag posts a semaphore // This test creates a responder (server) with the feature flag "integration_test_always_under_load" to always be under load condition for the test.
// (linux) to indicate that the server is under load condition. It also modifies the responders behaviour to be permanently under DoS condition
// once triggered, and makes the DoS mechanism more sensitive to be easily triggered.
// The test also creates a thread to send UDP packets to the server to trigger the DoS condition. The test waits for the server to
// be under load condition and then stops the DoS attack. The test then starts the client (initiator) to exchange keys. The test checks that the keys are exchanged successfully under load condition.
#[test] #[test]
fn check_exchange_under_dos() { fn check_exchange_under_dos() {
//Generate binary with responder with feature integration_test procspawn::init();
let server_test_bin = test_binary::TestBinary::relative_to_parent(
"rp-it-dos",
&PathBuf::from_iter(["Cargo.toml"]),
)
.with_feature("integration_test_dos_exchange")
.build()
.unwrap();
//Generate binary with responder with feature integration_test
let tmpdir = PathBuf::from(env!("CARGO_TARGET_TMPDIR")).join("exchange-dos"); let tmpdir = PathBuf::from(env!("CARGO_TARGET_TMPDIR")).join("exchange-dos");
fs::create_dir_all(&tmpdir).unwrap(); fs::create_dir_all(&tmpdir).unwrap();
@@ -162,90 +155,46 @@ fn check_exchange_under_dos() {
assert!(pub_key_path.is_file()); assert!(pub_key_path.is_file());
} }
//Create a semaphore. The server will unblock this semaphore after it is under load condition.
//There are parameters setup under app_server to remain in load condition once triggered for this test feature.
let sem_name = b"/rp_integration_test_under_dos\0";
let sem = unsafe { libc::sem_open(sem_name.as_ptr() as *const i8, libc::O_CREAT, 0o644, 1) };
unsafe {
libc::sem_wait(sem);
}
// start first process, the server // start first process, the server
let port = loop { let port = loop {
if let Some(port) = find_udp_socket() { if let Some(port) = find_udp_socket() {
break port; break port;
} }
}; };
let listen_addr = format!("localhost:{port}"); let listen_addr = format!("localhost:{port}");
let mut server = std::process::Command::new(server_test_bin)
.args(["--log-level", "debug"]) let mut server_cmd = std::process::Command::new(BIN);
.args(["exchange", "secret-key"])
server_cmd.args(["exchange", "secret-key"])
.arg(&secret_key_paths[0]) .arg(&secret_key_paths[0])
.arg("public-key") .arg("public-key")
.arg(&public_key_paths[0]) .arg(&public_key_paths[0])
.args(["listen", &listen_addr, "verbose", "peer", "public-key"]) .args(["listen", &listen_addr, "verbose", "peer", "public-key"])
.arg(&public_key_paths[1]) .arg(&public_key_paths[1])
.arg("outfile") .arg("outfile")
.arg(&shared_key_paths[0]) .arg(&shared_key_paths[0]);
//.stdout(Stdio::null())
//.stderr(Stdio::null())
.spawn()
.expect("Test setup failed- Failed to start {server_bin}");
//Create a UDP socket for DOS sender
let socket = UdpSocket::bind("127.0.0.1:0").expect("couldn't bind to address");
let server_addr = listen_addr.clone();
//Create thread safe atomic bool to stop the DoS attack let server_cmd: Vec<String> = server_cmd
let stop_dos = std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false)); .get_args()
let stop_dos_handle = stop_dos.clone(); .into_iter()
.fold(vec![BIN.to_string()], |mut acc, x| {
if let Some(s) = x.to_str() {
acc.push(s.to_string());
}
acc
});
//Spawn a thread to send DoS packets let mut server = procspawn::spawn(server_cmd, |server_cmd: Vec<String>| {
let dos_attack = std::thread::spawn(move || { let cli = CliArgs::try_parse_from(server_cmd.iter()).unwrap();
while stop_dos.load(std::sync::atomic::Ordering::Relaxed) == false { cli.command.run(AppServerTestFlags {
let buf = [0; 10]; enable_dos_permanently: true,
socket }).unwrap();
.send_to(&buf, &server_addr)
.expect("couldn't send data");
std::thread::sleep(Duration::from_micros(10));
}
}); });
//Wait till we are under load condition for upto 5 seconds
let mut ts = libc::timespec {
tv_sec: 0,
tv_nsec: 0,
};
let now = std::time::SystemTime::now();
let timeout_absolute = now + Duration::from_secs(5);
if let Ok(duration) = timeout_absolute.duration_since(std::time::SystemTime::UNIX_EPOCH) {
ts.tv_sec = duration.as_secs() as libc::time_t;
ts.tv_nsec = duration.subsec_nanos() as _;
} else {
panic!("Test setup failed- Failed to calculate timeout for semaphore");
}
let mut failed_wait = false;
if (unsafe { libc::sem_timedwait(sem, &ts) } == -1) {
failed_wait = true;
}
// Close and unlink the semaphore
if unsafe { libc::sem_close(sem) } == -1 {
panic!("Test setup failed- Failed to close semaphore");
}
if unsafe { libc::sem_unlink(sem_name.as_ptr() as *const i8) } == -1 {
panic!("Test setup failed- Failed to unlink semaphore");
}
if failed_wait {
panic!("Failed to wait for semaphore- load condition not reached");
}
//Stop DoS attack
stop_dos_handle.store(true, std::sync::atomic::Ordering::Relaxed);
// start second process, the client // start second process, the client
let mut client = test_bin::get_test_bin(BIN) let mut client = test_bin::get_test_bin(BIN)
.args(["--log-level", "debug"])
.args(["exchange", "secret-key"]) .args(["exchange", "secret-key"])
.arg(&secret_key_paths[1]) .arg(&secret_key_paths[1])
.arg("public-key") .arg("public-key")
@@ -255,8 +204,6 @@ fn check_exchange_under_dos() {
.args(["endpoint", &listen_addr]) .args(["endpoint", &listen_addr])
.arg("outfile") .arg("outfile")
.arg(&shared_key_paths[1]) .arg(&shared_key_paths[1])
//.stdout(Stdio::null())
//.stderr(Stdio::null())
.spawn() .spawn()
.expect("Failed to start {BIN}"); .expect("Failed to start {BIN}");
@@ -266,7 +213,6 @@ fn check_exchange_under_dos() {
// time's up, kill the childs // time's up, kill the childs
server.kill().unwrap(); server.kill().unwrap();
client.kill().unwrap(); client.kill().unwrap();
dos_attack.join().unwrap();
// read the shared keys they created // read the shared keys they created
let shared_keys: Vec<_> = shared_key_paths let shared_keys: Vec<_> = shared_key_paths