diff --git a/Cargo.lock b/Cargo.lock index 3121f3e..9030f9f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,26 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "aead" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" +dependencies = [ + "generic-array", + "rand_core 0.6.4", +] + +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common 0.1.7", + "generic-array", +] + [[package]] name = "aead" version = "0.6.1" @@ -9,7 +29,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1973cfbc1a2daf9cf550e74e1f088c28e7f7d8c1e1418fb6c9dc5184b7e84c99" dependencies = [ "crypto-common 0.2.2", - "inout", + "inout 0.2.2", +] + +[[package]] +name = "aes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +dependencies = [ + "cfg-if", + "cipher 0.3.0", + "cpufeatures 0.2.17", + "opaque-debug", ] [[package]] @@ -18,23 +50,37 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35f0f96ce78e38c3dc6d8948aa8163d06385be74000f3c7a95bf1eef35d3ea32" dependencies = [ - "cipher", + "cipher 0.5.2", "cpubits", "cpufeatures 0.3.1", ] +[[package]] +name = "aes-gcm" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc3be92e19a7ef47457b8e6f90707e12b6ac5d20c6f3866584fa3be0787d839f" +dependencies = [ + "aead 0.4.3", + "aes 0.7.5", + "cipher 0.3.0", + "ctr 0.7.0", + "ghash 0.4.4", + "subtle", +] + [[package]] name = "aes-gcm" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f2b8006a0c83f52b62ba44a97b58bf76fe2f70a329e588f67f89691d93d498f" dependencies = [ - "aead", - "aes", - "cipher", - "ctr", + "aead 0.6.1", + "aes 0.9.3", + "cipher 0.5.2", + "ctr 0.10.1", "ctutils", - "ghash", + "ghash 0.6.0", ] [[package]] @@ -76,7 +122,49 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d305a54bcb99974213b4c78a486c34091e83c5d6d6572f7f4331c904ea9d127" dependencies = [ - "thiserror", + "thiserror 2.0.18", +] + +[[package]] +name = "bitcoin-hpke" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d37a54c486727c1d1ae9cc28dcf78b6e6ba20dcb88e8c892f1437d9ce215dc8c" +dependencies = [ + "aead 0.5.2", + "chacha20poly1305 0.10.1", + "digest 0.10.7", + "generic-array", + "hkdf 0.12.4", + "hmac 0.12.1", + "rand_core 0.6.4", + "secp256k1", + "sha2 0.10.9", + "subtle", + "zeroize", +] + +[[package]] +name = "bitcoin-ohttp" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87a803a4b54e44635206b53329c78c0029d0c70926288ac2f07f4bb1267546cb" +dependencies = [ + "aead 0.4.3", + "aes-gcm 0.9.2", + "bitcoin-hpke", + "byteorder", + "chacha20poly1305 0.8.0", + "hex", + "hkdf 0.11.0", + "lazy_static", + "log", + "rand 0.8.8", + "serde", + "serde_derive", + "sha2 0.9.9", + "thiserror 1.0.69", + "toml 0.5.11", ] [[package]] @@ -89,6 +177,15 @@ dependencies = [ "tokio", ] +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + [[package]] name = "block-buffer" version = "0.10.4" @@ -142,6 +239,29 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +[[package]] +name = "chacha20" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fee7ad89dc1128635074c268ee661f90c3f7e83d9fd12910608c36b47d6c3412" +dependencies = [ + "cfg-if", + "cipher 0.3.0", + "cpufeatures 0.1.5", + "zeroize", +] + +[[package]] +name = "chacha20" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" +dependencies = [ + "cfg-if", + "cipher 0.4.4", + "cpufeatures 0.2.17", +] + [[package]] name = "chacha20" version = "0.10.2" @@ -149,21 +269,67 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" dependencies = [ "cfg-if", - "cipher", + "cipher 0.5.2", "cpufeatures 0.3.1", "rand_core 0.10.1", ] +[[package]] +name = "chacha20poly1305" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1580317203210c517b6d44794abfbe600698276db18127e37ad3e69bf5e848e5" +dependencies = [ + "aead 0.4.3", + "chacha20 0.7.1", + "cipher 0.3.0", + "poly1305 0.7.2", + "zeroize", +] + +[[package]] +name = "chacha20poly1305" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" +dependencies = [ + "aead 0.5.2", + "chacha20 0.9.1", + "cipher 0.4.4", + "poly1305 0.8.0", + "zeroize", +] + [[package]] name = "chacha20poly1305" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b89e1c441e926b9c82a8d023f6e1b7ae0adcfaa7d621814e4d60789bac751cb" dependencies = [ - "aead", - "chacha20", - "cipher", - "poly1305", + "aead 0.6.1", + "chacha20 0.10.2", + "cipher 0.5.2", + "poly1305 0.9.1", +] + +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common 0.1.7", + "inout 0.1.4", + "zeroize", ] [[package]] @@ -174,7 +340,7 @@ checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c" dependencies = [ "block-buffer 0.12.1", "crypto-common 0.2.2", - "inout", + "inout 0.2.2", ] [[package]] @@ -195,6 +361,15 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae" +[[package]] +name = "cpufeatures" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" +dependencies = [ + "libc", +] + [[package]] name = "cpufeatures" version = "0.2.17" @@ -235,6 +410,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ "generic-array", + "rand_core 0.6.4", "typenum", ] @@ -249,13 +425,32 @@ dependencies = [ "rand_core 0.10.1", ] +[[package]] +name = "crypto-mac" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25fab6889090c8133f3deb8f73ba3c65a7f456f66436fc012a1b1e272b1e103e" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "ctr" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a232f92a03f37dd7d7dd2adc67166c77e9cd88de5b019b9a9eecfaeaf7bfd481" +dependencies = [ + "cipher 0.3.0", +] + [[package]] name = "ctr" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baaca1c4b237092596f64d571e9db6ce4109c4ef9742e27590f1709594461f21" dependencies = [ - "cipher", + "cipher 0.5.2", ] [[package]] @@ -310,6 +505,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + [[package]] name = "digest" version = "0.10.7" @@ -318,6 +522,7 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", "crypto-common 0.1.7", + "subtle", ] [[package]] @@ -356,7 +561,7 @@ dependencies = [ "digest 0.11.3", "ff", "group", - "hkdf", + "hkdf 0.13.0", "hybrid-array", "rand_core 0.10.1", "sec1", @@ -540,13 +745,23 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "ghash" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" +dependencies = [ + "opaque-debug", + "polyval 0.5.3", +] + [[package]] name = "ghash" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eecf2d5dc9b66b732b97707a0210906b1d30523eb773193ab777c0c84b3e8d5" dependencies = [ - "polyval", + "polyval 0.7.3", ] [[package]] @@ -572,13 +787,51 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hkdf" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01706d578d5c281058480e673ae4086a9f4710d8df1ad80a5b03e39ece5f886b" +dependencies = [ + "digest 0.9.0", + "hmac 0.11.0", +] + +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac 0.12.1", +] + [[package]] name = "hkdf" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4aaa26c720c68b866f2c96ef5c1264b3e6f473fe5d4ce61cd44bbe913e553018" dependencies = [ - "hmac", + "hmac 0.13.0", +] + +[[package]] +name = "hmac" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +dependencies = [ + "crypto-mac", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", ] [[package]] @@ -596,18 +849,18 @@ version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5324110b02044183df000f0bd7d2d7e61f1000631508627e77f63983b6fdffb" dependencies = [ - "aead", - "aes-gcm", - "chacha20poly1305", + "aead 0.6.1", + "aes-gcm 0.11.1", + "chacha20poly1305 0.11.0", "getrandom 0.4.3", - "hkdf", + "hkdf 0.13.0", "hybrid-array", "ml-kem", "p256", "p384", "p521", "rand_core 0.10.1", - "sha2", + "sha2 0.11.0", "sha3 0.12.0", "shake", "subtle", @@ -895,6 +1148,15 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "inout" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" +dependencies = [ + "generic-array", +] + [[package]] name = "inout" version = "0.2.2" @@ -1041,22 +1303,22 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc53603e4bf77342fe8409611972078761604e4370330c4ee5abac49f079b464" dependencies = [ - "aead", - "aes-gcm", + "aead 0.6.1", + "aes-gcm 0.11.1", "byteorder", - "chacha20poly1305", + "chacha20poly1305 0.11.0", "futures", "hex", - "hkdf", + "hkdf 0.13.0", "hpke", "log", "pin-project", "rand 0.10.2", "serde", "serde_derive", - "sha2", - "thiserror", - "toml", + "sha2 0.11.0", + "thiserror 2.0.18", + "toml 0.9.12+spec-1.1.0", ] [[package]] @@ -1064,13 +1326,14 @@ name = "ohttp-client" version = "0.0.1" dependencies = [ "bhttp", + "bitcoin-ohttp", "bitreq", "getrandom 0.2.17", "getrandom 0.3.4", "getrandom 0.4.3", "ohttp", "ohttp-relay", - "thiserror", + "thiserror 2.0.18", "tokio", "url", "wasm-bindgen", @@ -1105,6 +1368,12 @@ version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + [[package]] name = "p256" version = "0.14.0" @@ -1172,6 +1441,28 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" +[[package]] +name = "poly1305" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" +dependencies = [ + "cpufeatures 0.2.17", + "opaque-debug", + "universal-hash 0.4.0", +] + +[[package]] +name = "poly1305" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" +dependencies = [ + "cpufeatures 0.2.17", + "opaque-debug", + "universal-hash 0.5.1", +] + [[package]] name = "poly1305" version = "0.9.1" @@ -1179,7 +1470,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e2d0073b297041425c7c3df6eb4792d598a15323fe63346852b092eca02904c" dependencies = [ "cpufeatures 0.3.1", - "universal-hash", + "universal-hash 0.6.1", +] + +[[package]] +name = "polyval" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "opaque-debug", + "universal-hash 0.4.0", ] [[package]] @@ -1190,7 +1493,7 @@ checksum = "f0fa31d631f2b2cb2a544d0aa321ce847a94764d701ca2becc411138b93d49cd" dependencies = [ "cpubits", "cpufeatures 0.3.1", - "universal-hash", + "universal-hash 0.6.1", ] [[package]] @@ -1257,13 +1560,24 @@ version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" +[[package]] +name = "rand" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + [[package]] name = "rand" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" dependencies = [ - "rand_chacha", + "rand_chacha 0.9.0", "rand_core 0.9.5", ] @@ -1273,11 +1587,21 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" dependencies = [ - "chacha20", + "chacha20 0.10.2", "getrandom 0.4.3", "rand_core 0.10.1", ] +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + [[package]] name = "rand_chacha" version = "0.9.0" @@ -1288,6 +1612,15 @@ dependencies = [ "rand_core 0.9.5", ] +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + [[package]] name = "rand_core" version = "0.9.5" @@ -1397,6 +1730,25 @@ dependencies = [ "zeroize", ] +[[package]] +name = "secp256k1" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9465315bc9d4566e1724f0fffcbcc446268cb522e60f9a27bcded6b19c108113" +dependencies = [ + "rand 0.8.8", + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4387882333d3aa8cb20530a17c69a3752e97837832f34f6dccc760e715001d9" +dependencies = [ + "cc", +] + [[package]] name = "semver" version = "1.0.28" @@ -1452,6 +1804,30 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures 0.2.17", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "digest 0.10.7", +] + [[package]] name = "sha2" version = "0.11.0" @@ -1575,13 +1951,33 @@ dependencies = [ "syn", ] +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + [[package]] name = "thiserror" version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" dependencies = [ - "thiserror-impl", + "thiserror-impl 2.0.18", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -1675,6 +2071,15 @@ dependencies = [ "tokio", ] +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + [[package]] name = "toml" version = "0.9.12+spec-1.1.0" @@ -1800,7 +2205,7 @@ dependencies = [ "log", "rand 0.9.5", "sha1", - "thiserror", + "thiserror 2.0.18", "utf-8", ] @@ -1827,6 +2232,26 @@ version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" +[[package]] +name = "universal-hash" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common 0.1.7", + "subtle", +] + [[package]] name = "universal-hash" version = "0.6.1" diff --git a/Cargo.toml b/Cargo.toml index ee0976a..399e22d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,9 +30,13 @@ wasm = ["wasm_js", "dep:wasm-bindgen"] # for downstream integration tests, and build the `ohttp-test-harness` binary # used by the JS e2e. harness = ["bitreq", "dep:ohttp-relay", "dep:tokio"] +# Experimental: also accept DHKEM(secp256k1, HKDF-SHA256) key configs, via +# `bitcoin-ohttp`. +secp256k1 = ["dep:bitcoin-ohttp"] [dependencies] bhttp = "0.7.2" +bitcoin-ohttp = { version = "0.6.0", optional = true } bitreq = { version = "0.3.7", features = ["async", "proxy"], optional = true } getrandom = { version = "0.3", features = ["std"] } # Feature-unification shim: pulls getrandom 0.2 with `js` so the transitive diff --git a/README.md b/README.md index 5b32b00..4bbb779 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,10 @@ The client uses whichever KEM a gateway advertises, so it works with every KEM [`ohttp`](https://crates.io/crates/ohttp) implements: DHKEM(X25519, HKDF-SHA256), DHKEM(P-256, HKDF-SHA256), and X-Wing (ML-KEM-768 + X25519). +The experimental `secp256k1` feature adds DHKEM(secp256k1, HKDF-SHA256) via +[`bitcoin-ohttp`](https://crates.io/crates/bitcoin-ohttp), alongside the KEMs +above. Each key config is handled by the backend that supports its KEM. + ## Sans-IO by default By default the crate does **no network IO**. You encapsulate a request, send the diff --git a/src/error.rs b/src/error.rs index 524f363..672da94 100644 --- a/src/error.rs +++ b/src/error.rs @@ -2,6 +2,9 @@ pub enum Error { #[error("ohttp: {0}")] Ohttp(#[from] ohttp::Error), + #[cfg(feature = "secp256k1")] + #[error("bitcoin-ohttp: {0}")] + BitcoinOhttp(#[from] bitcoin_ohttp::Error), #[error("bhttp: {0}")] Bhttp(#[from] bhttp::Error), #[error("url: {0}")] diff --git a/src/harness.rs b/src/harness.rs index f78be7b..f12c5e5 100644 --- a/src/harness.rs +++ b/src/harness.rs @@ -56,7 +56,7 @@ impl TestHarness { // Gateway: serves its key config, opts in to relaying, and // decapsulates requests, forwarding them to the inner target. - let key_config = crate::KeyConfig::new( + let key_config = ohttp::KeyConfig::new( 1, ohttp::hpke::Kem::X25519Sha256, vec![ohttp::SymmetricSuite::new( @@ -170,7 +170,7 @@ fn handle_gateway_request( ("GET", GATEWAY_PATH) => ( 200, vec![("content-type".into(), "application/ohttp-keys".into())], - crate::KeyConfig::encode_list(&[server.config()]).unwrap(), + ohttp::KeyConfig::encode_list(&[server.config()]).unwrap(), ), ("POST", GATEWAY_PATH) => { assert_eq!(req.header("content-type"), Some("message/ohttp-req")); diff --git a/src/lib.rs b/src/lib.rs index ffaf119..06bb571 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -55,7 +55,6 @@ use std::sync::Once; use bhttp::{Message, Mode}; -pub use ohttp::KeyConfig; pub use url::Url; mod error; @@ -84,6 +83,61 @@ pub mod harness; /// Media type of an encapsulated request, per RFC 9458. pub const OHTTP_REQ_CONTENT_TYPE: &str = "message/ohttp-req"; +/// A gateway key config, held by whichever OHTTP backend supports its KEM. +#[derive(Debug, Clone)] +pub struct KeyConfig(KeyConfigInner); + +#[derive(Debug, Clone)] +#[allow(clippy::large_enum_variant)] // One per client. +enum KeyConfigInner { + Ohttp(ohttp::KeyConfig), + #[cfg(feature = "secp256k1")] + Secp256k1(bitcoin_ohttp::KeyConfig), +} + +impl From for KeyConfig { + fn from(config: ohttp::KeyConfig) -> Self { + Self(KeyConfigInner::Ohttp(config)) + } +} + +#[cfg(feature = "secp256k1")] +impl From for KeyConfig { + fn from(config: bitcoin_ohttp::KeyConfig) -> Self { + Self(KeyConfigInner::Secp256k1(config)) + } +} + +impl KeyConfig { + /// Decode one config with the backend that supports its KEM, or `None` + /// if no backend in this build does. + fn decode(encoded: &[u8]) -> Result, Error> { + match ohttp::KeyConfig::decode(encoded) { + Ok(config) => return Ok(Some(config.into())), + Err(ohttp::Error::Unsupported) => {} + Err(e) => return Err(e.into()), + } + // FIXME: `bitcoin-ohttp` 0.6 keeps AES-128-GCM suites when decoding, but + // its secp256k1 sender cannot use them: a config listing AES-128-GCM + // before ChaCha20Poly1305 fails to encapsulate with `InvalidKeyType`. + #[cfg(feature = "secp256k1")] + match bitcoin_ohttp::KeyConfig::decode(encoded) { + Ok(config) => return Ok(Some(config.into())), + Err(bitcoin_ohttp::Error::Unsupported) => {} + Err(e) => return Err(e.into()), + } + Ok(None) + } + + fn encode(&self) -> Result, Error> { + Ok(match &self.0 { + KeyConfigInner::Ohttp(config) => config.encode()?, + #[cfg(feature = "secp256k1")] + KeyConfigInner::Secp256k1(config) => config.encode()?, + }) + } +} + /// Parse the body of a gateway key endpoint response /// (`application/ohttp-keys`, RFC 9540) into the first usable [`KeyConfig`]. /// @@ -91,7 +145,19 @@ pub const OHTTP_REQ_CONTENT_TYPE: &str = "message/ohttp-req"; /// capabilities; unusable ones are skipped. pub fn parse_key_config(bytes: &[u8]) -> Result { init(); - KeyConfig::decode_list(bytes)? + let mut configs = Vec::new(); + let mut rest = bytes; + while let Some((len, tail)) = rest.split_first_chunk::<2>() { + let (config, tail) = tail + .split_at_checked(usize::from(u16::from_be_bytes(*len))) + .ok_or(ohttp::Error::Truncated)?; + configs.extend(KeyConfig::decode(config)?); + rest = tail; + } + if !rest.is_empty() { + return Err(ohttp::Error::Truncated.into()); + } + configs .into_iter() .find(has_usable_suite) .ok_or(Error::NoKeyConfig) @@ -112,7 +178,11 @@ fn has_usable_suite(config: &KeyConfig) -> bool { fn init() { static INIT: Once = Once::new(); - INIT.call_once(ohttp::init); + INIT.call_once(|| { + ohttp::init(); + #[cfg(feature = "secp256k1")] + bitcoin_ohttp::init(); + }); } /// An OHTTP client bound to a relay, a target origin, and a gateway key config. @@ -204,8 +274,20 @@ impl OhttpClient { } let bhttp_bytes = write_bhttp_payload(&inner, self.known_length)?; - let (encapsulated, ctx) = ohttp::ClientRequest::from_config(&mut self.key_config.clone())? - .encapsulate(&bhttp_bytes)?; + let (encapsulated, ctx) = match &self.key_config.0 { + KeyConfigInner::Ohttp(config) => { + let (encapsulated, ctx) = ohttp::ClientRequest::from_config(&mut config.clone())? + .encapsulate(&bhttp_bytes)?; + (encapsulated, ResponseContextInner::Ohttp(ctx)) + } + #[cfg(feature = "secp256k1")] + KeyConfigInner::Secp256k1(config) => { + let (encapsulated, ctx) = + bitcoin_ohttp::ClientRequest::from_config(&mut config.clone())? + .encapsulate(&bhttp_bytes)?; + (encapsulated, ResponseContextInner::Secp256k1(ctx)) + } + }; Ok(( OhttpRequest { url: self.relay.clone(), @@ -304,12 +386,22 @@ pub struct OhttpRequest { /// One-shot context to decapsulate the response to a single encapsulated /// request. Consumed by [`decapsulate`](ResponseContext::decapsulate). -pub struct ResponseContext(ohttp::ClientResponse); +pub struct ResponseContext(ResponseContextInner); + +enum ResponseContextInner { + Ohttp(ohttp::ClientResponse), + #[cfg(feature = "secp256k1")] + Secp256k1(bitcoin_ohttp::ClientResponse), +} impl ResponseContext { /// Decapsulate the raw body of the relay's response into the inner response. pub fn decapsulate(self, encapsulated: &[u8]) -> Result { - let bhttp_bytes = self.0.decapsulate(encapsulated)?; + let bhttp_bytes = match self.0 { + ResponseContextInner::Ohttp(ctx) => ctx.decapsulate(encapsulated)?, + #[cfg(feature = "secp256k1")] + ResponseContextInner::Secp256k1(ctx) => ctx.decapsulate(encapsulated)?, + }; let inner = Message::read_bhttp(&mut Cursor::new(&bhttp_bytes[..]))?; let status = inner.control().status().ok_or(Error::NotAResponse)?.code(); let headers = inner @@ -365,7 +457,7 @@ impl Response { mod tests { use super::*; use ohttp::hpke::{Aead, Kdf, Kem}; - use ohttp::SymmetricSuite; + use ohttp::{KeyConfig, SymmetricSuite}; /// Every KEM `ohttp` implements, including the post-quantum X-Wing. const SUPPORTED_KEMS: [Kem; 3] = [Kem::X25519Sha256, Kem::P256Sha256, Kem::XWing]; @@ -384,11 +476,11 @@ mod tests { .unwrap() } - fn test_client(config: KeyConfig) -> OhttpClient { + fn test_client(config: impl Into) -> OhttpClient { OhttpClient::new( Url::parse("https://relay.example/").unwrap(), Url::parse("https://target.example:8443/").unwrap(), - config, + config.into(), ) } @@ -450,7 +542,7 @@ mod tests { let client = OhttpClient::new( Url::parse("https://relay.example/").unwrap(), Url::parse("https://target.example/").unwrap(), - server.config().clone(), + server.config().clone().into(), ); let (req, _) = client @@ -475,7 +567,7 @@ mod tests { let client = OhttpClient::new( Url::parse("https://relay.example/").unwrap(), Url::parse("https://target.example/").unwrap(), - test_key_config(), + test_key_config().into(), ); assert!(matches!( @@ -495,7 +587,7 @@ mod tests { let client = OhttpClient::new( Url::parse("https://relay.example/").unwrap(), Url::parse("https://target.example/api").unwrap(), - server.config().clone(), + server.config().clone().into(), ); let (req, _) = client @@ -565,6 +657,41 @@ mod tests { } } + #[cfg(feature = "secp256k1")] + #[test] + fn round_trips_with_secp256k1() { + use bitcoin_ohttp::hpke::{Aead, Kdf, Kem}; + + init(); + let config = bitcoin_ohttp::KeyConfig::new( + 1, + Kem::K256Sha256, + vec![bitcoin_ohttp::SymmetricSuite::new( + Kdf::HkdfSha256, + Aead::ChaCha20Poly1305, + )], + ) + .unwrap(); + let server = bitcoin_ohttp::Server::new(config).unwrap(); + let encoded = bitcoin_ohttp::KeyConfig::encode_list(&[server.config()]).unwrap(); + let client = test_client(parse_key_config(&encoded).unwrap()); + + let (req, ctx) = client.encapsulate("GET", "/", &[], &[], None).unwrap(); + let (_, server_ctx) = server.decapsulate(&req.body).unwrap(); + + let mut inner_res = Message::response(bhttp::StatusCode::try_from(200u16).unwrap()); + inner_res.write_content(b"ok"); + let mut res_bytes = Vec::new(); + inner_res + .write_bhttp(Mode::KnownLength, &mut res_bytes) + .unwrap(); + let enc_res = server_ctx.encapsulate(&res_bytes).unwrap(); + + let response = ctx.decapsulate(&enc_res).unwrap(); + assert_eq!(response.status(), 200); + assert_eq!(response.body(), b"ok"); + } + /// Encode `configs` as an `application/ohttp-keys` list, prefixing each /// with its two-byte length (mirrors `KeyConfig::encode_list`, but takes /// raw bytes so tests can build configs the crate refuses to construct).