diff --git a/.github/workflows/dhkem.yml b/.github/workflows/dhkem.yml index 767c1ae..60f7db8 100644 --- a/.github/workflows/dhkem.yml +++ b/.github/workflows/dhkem.yml @@ -21,7 +21,7 @@ jobs: set-msrv: uses: RustCrypto/actions/.github/workflows/set-msrv.yml@master with: - msrv: 1.74.0 + msrv: 1.85.0 minimal-versions: # temporarily disabled as requested by Tony (https://github.com/RustCrypto/KEMs/pull/15#pullrequestreview-2006378802) diff --git a/.github/workflows/frodo-kem.yml b/.github/workflows/frodo-kem.yml index f1968df..1c6b7ae 100644 --- a/.github/workflows/frodo-kem.yml +++ b/.github/workflows/frodo-kem.yml @@ -25,7 +25,7 @@ jobs: set-msrv: uses: RustCrypto/actions/.github/workflows/set-msrv.yml@master with: - msrv: 1.82.0 + msrv: 1.85.0 build: needs: set-msrv diff --git a/.github/workflows/ml-kem.yml b/.github/workflows/ml-kem.yml index ebf9375..bd61c21 100644 --- a/.github/workflows/ml-kem.yml +++ b/.github/workflows/ml-kem.yml @@ -21,7 +21,7 @@ jobs: set-msrv: uses: RustCrypto/actions/.github/workflows/set-msrv.yml@master with: - msrv: 1.81.0 + msrv: 1.85.0 minimal-versions: # temporarily disabled as requested by Tony (https://github.com/RustCrypto/KEMs/pull/15#pullrequestreview-2006378802) diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml index 457a0da..b663857 100644 --- a/.github/workflows/workspace.yml +++ b/.github/workflows/workspace.yml @@ -21,7 +21,7 @@ jobs: timeout-minutes: 45 steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@1.84 + - uses: dtolnay/rust-toolchain@1.85 with: components: clippy - run: cargo clippy --all-features --all-targets -- -D warnings diff --git a/.github/workflows/x-wing.yml b/.github/workflows/x-wing.yml index 099c75b..0678890 100644 --- a/.github/workflows/x-wing.yml +++ b/.github/workflows/x-wing.yml @@ -22,7 +22,7 @@ jobs: set-msrv: uses: RustCrypto/actions/.github/workflows/set-msrv.yml@master with: - msrv: 1.81.0 + msrv: 1.85.0 minimal-versions: # temporarily disabled as requested by Tony (https://github.com/RustCrypto/KEMs/pull/15#pullrequestreview-2006378802) diff --git a/Cargo.lock b/Cargo.lock index d3a490b..4d5fc3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aes" @@ -73,7 +73,7 @@ dependencies = [ "bitflags", "cexpr", "clang-sys", - "itertools 0.12.1", + "itertools", "lazy_static", "lazycell", "log", @@ -102,6 +102,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block-buffer" +version = "0.11.0-rc.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a229bfd78e4827c91b9b95784f69492c1b77c1ab75a45a8a037b139215086f94" +dependencies = [ + "hybrid-array 0.3.0", +] + [[package]] name = "build-deps" version = "0.1.4" @@ -131,9 +140,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.10" +version = "1.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229" +checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c" dependencies = [ "shlex", ] @@ -186,7 +195,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ - "crypto-common", + "crypto-common 0.1.6", "inout", ] @@ -228,9 +237,9 @@ checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "cmake" -version = "0.1.52" +version = "0.1.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c682c223677e0e5b6b7f63a64b9351844c3f1b1678a68b7ee617e30fb082620e" +checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" dependencies = [ "cc", ] @@ -243,9 +252,9 @@ checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" [[package]] name = "const-oid" -version = "0.9.6" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +checksum = "1cb3c4a0d3776f7535c32793be81d6d5fec0d48ac70955d9834e643aa249a52f" [[package]] name = "cpufeatures" @@ -268,7 +277,7 @@ dependencies = [ "clap", "criterion-plot", "is-terminal", - "itertools 0.10.5", + "itertools", "num-traits", "once_cell", "oorandom", @@ -289,7 +298,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" dependencies = [ "cast", - "itertools 0.10.5", + "itertools", ] [[package]] @@ -331,12 +340,12 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +version = "0.7.0-pre.0" +source = "git+https://github.com/RustCrypto/crypto-bigint.git#21ebb49ddb292c4f75ed909e45cdde54888d049e" dependencies = [ - "generic-array", - "rand_core", + "hybrid-array 0.3.0", + "num-traits", + "rand_core 0.9.3", "subtle", "zeroize", ] @@ -348,10 +357,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", - "rand_core", "typenum", ] +[[package]] +name = "crypto-common" +version = "0.2.0-rc.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "170d71b5b14dec99db7739f6fc7d6ec2db80b78c3acb77db48392ccc3d8a9ea0" +dependencies = [ + "hybrid-array 0.3.0", + "rand_core 0.9.3", +] + +[[package]] +name = "crypto-common" +version = "0.2.0-rc.2" +source = "git+https://github.com/baloo/traits.git?branch=baloo%2Frelax-sized-rng#abd9d63e1d3e1eef4e1ebb845aadbd678faa1cbe" +dependencies = [ + "hybrid-array 0.3.0", +] + [[package]] name = "cstr_core" version = "0.2.6" @@ -371,8 +397,7 @@ checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" [[package]] name = "curve25519-dalek" version = "4.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +source = "git+https://github.com/pinkforest/curve25519-dalek.git?branch=bump-rand-0.9#92ec8d3e0445a9baf0405eca8e595237231a9460" dependencies = [ "cfg-if", "cpufeatures", @@ -386,8 +411,7 @@ dependencies = [ [[package]] name = "curve25519-dalek-derive" version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +source = "git+https://github.com/pinkforest/curve25519-dalek.git?branch=bump-rand-0.9#92ec8d3e0445a9baf0405eca8e595237231a9460" dependencies = [ "proc-macro2", "quote", @@ -396,9 +420,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.9" +version = "0.8.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" +checksum = "82db698b33305f0134faf590b9d1259dc171b5481ac41d5c8146c3b3ee7d4319" dependencies = [ "const-oid", "zeroize", @@ -409,7 +433,7 @@ name = "dhkem" version = "0.0.1-alpha" dependencies = [ "elliptic-curve", - "hex-literal", + "hex-literal 0.4.1", "hkdf", "k256", "kem", @@ -417,7 +441,7 @@ dependencies = [ "p384", "p521", "rand", - "rand_core", + "rand_core 0.9.3", "sha2", "x25519-dalek", "zeroize", @@ -429,8 +453,18 @@ version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer", - "crypto-common", + "block-buffer 0.10.4", + "crypto-common 0.1.6", +] + +[[package]] +name = "digest" +version = "0.11.0-pre.10" +source = "git+https://github.com/baloo/traits.git?branch=baloo%2Frelax-sized-rng#abd9d63e1d3e1eef4e1ebb845aadbd678faa1cbe" +dependencies = [ + "block-buffer 0.11.0-rc.4", + "const-oid", + "crypto-common 0.2.0-rc.2 (git+https://github.com/baloo/traits.git?branch=baloo%2Frelax-sized-rng)", "subtle", ] @@ -442,18 +476,17 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +version = "0.14.0-rc.1" +source = "git+https://github.com/baloo/traits.git?branch=baloo%2Frelax-sized-rng#abd9d63e1d3e1eef4e1ebb845aadbd678faa1cbe" dependencies = [ "base16ct", "crypto-bigint", - "digest", + "digest 0.11.0-pre.10", "ff", - "generic-array", "group", "hkdf", - "rand_core", + "hybrid-array 0.3.0", + "rand_core 0.9.3", "sec1", "subtle", "zeroize", @@ -473,9 +506,9 @@ checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" @@ -489,11 +522,10 @@ dependencies = [ [[package]] name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +version = "0.13.1" +source = "git+https://github.com/zkcrypto/ff.git?branch=release-0.14.0#241caff9bcedafbe279b5a4d875461f66b3f9701" dependencies = [ - "rand_core", + "rand_core 0.9.3", "subtle", ] @@ -511,11 +543,11 @@ dependencies = [ "bincode", "criterion", "hex", - "hybrid-array", + "hybrid-array 0.2.3", "openssl-sys", "postcard", - "rand_chacha", - "rand_core", + "rand_chacha 0.3.1", + "rand_core 0.6.4", "rstest", "safe-oqs", "serde", @@ -524,7 +556,7 @@ dependencies = [ "serde_json", "serde_yaml", "serdect", - "sha3", + "sha3 0.10.8", "subtle", "thiserror", "toml", @@ -582,7 +614,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -593,7 +624,19 @@ checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.13.3+wasi-0.2.2", + "windows-targets", ] [[package]] @@ -605,11 +648,10 @@ checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" [[package]] name = "group" version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +source = "git+https://github.com/baloo/group.git?branch=baloo%2Ftry_from_rng#b0d6ea48fe55327b11ea03f9a965d9e16bb83adc" dependencies = [ "ff", - "rand_core", + "rand_core 0.9.3", "subtle", ] @@ -679,22 +721,28 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "hex-literal" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcaaec4551594c969335c98c903c1397853d4198408ea609190f420500f6be71" + [[package]] name = "hkdf" -version = "0.12.4" +version = "0.13.0-pre.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +checksum = "0aaa7579d1176645cee5dc206aa74873b5b3be479af9606025f9b8905bcf597b" dependencies = [ "hmac", ] [[package]] name = "hmac" -version = "0.12.1" +version = "0.13.0-pre.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +checksum = "62c11fc82c6b89c906b4d26b7b5a305d0b3aebd4b458dd1bd0a7ed98c548a28e" dependencies = [ - "digest", + "digest 0.11.0-pre.10", ] [[package]] @@ -715,11 +763,21 @@ dependencies = [ "typenum", ] +[[package]] +name = "hybrid-array" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dab50e193aebe510fe0e40230145820e02f48dae0cf339ea4204e6e708ff7bd" +dependencies = [ + "typenum", + "zeroize", +] + [[package]] name = "indexmap" -version = "2.7.1" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" +checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" dependencies = [ "equivalent", "hashbrown", @@ -727,9 +785,9 @@ dependencies = [ [[package]] name = "inout" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" dependencies = [ "generic-array", ] @@ -754,15 +812,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.14" @@ -781,9 +830,8 @@ dependencies = [ [[package]] name = "k256" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" +version = "0.14.0-pre.2" +source = "git+https://github.com/baloo/elliptic-curves.git?branch=baloo%2Fgroup%2Ftry-from-rng#4774fd4e2b57ab6268b9f5f0701260686ae52c08" dependencies = [ "cfg-if", "elliptic-curve", @@ -798,13 +846,21 @@ dependencies = [ "cpufeatures", ] +[[package]] +name = "keccak" +version = "0.2.0-pre.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7cdd4f0dc5807b9a2b25dd48a3f58e862606fe7bd47f41ecde36e97422d7e90" +dependencies = [ + "cpufeatures", +] + [[package]] name = "kem" version = "0.3.0-pre.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b8645470337db67b01a7f966decf7d0bafedbae74147d33e641c67a91df239f" +source = "git+https://github.com/baloo/traits.git?branch=baloo%2Frelax-sized-rng#abd9d63e1d3e1eef4e1ebb845aadbd678faa1cbe" dependencies = [ - "rand_core", + "rand_core 0.9.3", "zeroize", ] @@ -875,17 +931,17 @@ name = "ml-kem" version = "0.3.0-pre" dependencies = [ "criterion", - "crypto-common", + "crypto-common 0.2.0-rc.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex", - "hex-literal", - "hybrid-array", + "hex-literal 1.0.0", + "hybrid-array 0.3.0", "kem", "num-rational", "rand", - "rand_core", + "rand_core 0.9.3", "serde", "serde_json", - "sha3", + "sha3 0.11.0-pre.5", "zeroize", ] @@ -952,9 +1008,9 @@ checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" [[package]] name = "openssl-sys" -version = "0.9.104" +version = "0.9.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" +checksum = "8bb61ea9811cc39e3c2069f40b8b8e2e70d8569b361f879786cc7ed48b777cdd" dependencies = [ "cc", "libc", @@ -964,9 +1020,8 @@ dependencies = [ [[package]] name = "p256" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +version = "0.14.0-pre.2" +source = "git+https://github.com/baloo/elliptic-curves.git?branch=baloo%2Fgroup%2Ftry-from-rng#4774fd4e2b57ab6268b9f5f0701260686ae52c08" dependencies = [ "elliptic-curve", "primeorder", @@ -974,9 +1029,8 @@ dependencies = [ [[package]] name = "p384" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe42f1670a52a47d448f14b6a5c61dd78fce51856e68edaa38f7ae3a46b8d6b6" +version = "0.14.0-pre.2" +source = "git+https://github.com/baloo/elliptic-curves.git?branch=baloo%2Fgroup%2Ftry-from-rng#4774fd4e2b57ab6268b9f5f0701260686ae52c08" dependencies = [ "elliptic-curve", "primeorder", @@ -984,12 +1038,12 @@ dependencies = [ [[package]] name = "p521" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc9e2161f1f215afdfce23677034ae137bbd45016a880c2eb3ba8eb95f085b2" +version = "0.14.0-pre.2" +source = "git+https://github.com/baloo/elliptic-curves.git?branch=baloo%2Fgroup%2Ftry-from-rng#4774fd4e2b57ab6268b9f5f0701260686ae52c08" dependencies = [ "base16ct", "elliptic-curve", + "primefield", "primeorder", ] @@ -1007,9 +1061,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "plotters" @@ -1058,33 +1112,37 @@ version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ - "zerocopy", + "zerocopy 0.7.35", ] [[package]] name = "prettyplease" -version = "0.2.29" +version = "0.2.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6924ced06e1f7dfe3fa48d57b9f74f55d8915f5036121bef647ef4b204895fac" +checksum = "5316f57387668042f561aae71480de936257848f9c43ce528e311d89a07cadeb" dependencies = [ "proc-macro2", "syn", ] +[[package]] +name = "primefield" +version = "0.14.0-pre.0" +source = "git+https://github.com/baloo/elliptic-curves.git?branch=baloo%2Fgroup%2Ftry-from-rng#4774fd4e2b57ab6268b9f5f0701260686ae52c08" + [[package]] name = "primeorder" -version = "0.13.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +version = "0.14.0-pre.2" +source = "git+https://github.com/baloo/elliptic-curves.git?branch=baloo%2Fgroup%2Ftry-from-rng#4774fd4e2b57ab6268b9f5f0701260686ae52c08" dependencies = [ "elliptic-curve", ] [[package]] name = "proc-macro-crate" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" +checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" dependencies = [ "toml_edit", ] @@ -1109,13 +1167,13 @@ dependencies = [ [[package]] name = "rand" -version = "0.8.5" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" dependencies = [ - "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.9.0", + "rand_core 0.9.3", + "zerocopy 0.8.23", ] [[package]] @@ -1125,7 +1183,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", ] [[package]] @@ -1134,7 +1202,16 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.15", +] + +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.1", ] [[package]] @@ -1239,9 +1316,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.43" +version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ "bitflags", "errno", @@ -1303,22 +1380,22 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sec1" -version = "0.7.3" +version = "0.8.0-rc.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +checksum = "a017a4aa8f0bd51e9d0184d98042dfe9285218fec098493f47d9a8aa0f1a3f27" dependencies = [ "base16ct", "der", - "generic-array", + "hybrid-array 0.3.0", "subtle", "zeroize", ] [[package]] name = "semver" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f79dfe2d285b0488816f30e700a7438c5a73d816b5b7d3ac72fbc48b0d185e03" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" [[package]] name = "serde" @@ -1405,13 +1482,12 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +version = "0.11.0-pre.5" +source = "git+https://github.com/RustCrypto/hashes.git#e6bc891b48f6bf304d12d248ef4d21b46ee11812" dependencies = [ "cfg-if", "cpufeatures", - "digest", + "digest 0.11.0-pre.10", ] [[package]] @@ -1420,8 +1496,18 @@ version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ - "digest", - "keccak", + "digest 0.10.7", + "keccak 0.1.5", +] + +[[package]] +name = "sha3" +version = "0.11.0-pre.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bc997d7a5fa67cc1e352b2001124d28edb948b4e7a16567f9b3c1e51952524" +dependencies = [ + "digest 0.11.0-pre.10", + "keccak 0.2.0-pre.0", ] [[package]] @@ -1473,18 +1559,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", @@ -1503,9 +1589,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" dependencies = [ "serde", "serde_spanned", @@ -1524,9 +1610,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.22" +version = "0.22.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ "indexmap", "serde", @@ -1581,6 +1667,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasi" +version = "0.13.3+wasi-0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "wasm-bindgen" version = "0.2.100" @@ -1754,13 +1849,22 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.24" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d71a593cc5c42ad7876e2c1fda56f314f3754c084128833e64f1345ff8a03a" +checksum = "0e97b544156e9bebe1a0ffbc03484fc1ffe3100cbce3ffb17eac35f7cdd7ab36" dependencies = [ "memchr", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags", +] + [[package]] name = "x-wing" version = "0.0.1-pre.1" @@ -1769,10 +1873,10 @@ dependencies = [ "kem", "ml-kem", "rand", - "rand_core", + "rand_core 0.9.3", "serde", "serde_json", - "sha3", + "sha3 0.11.0-pre.5", "x25519-dalek", "zeroize", ] @@ -1780,11 +1884,10 @@ dependencies = [ [[package]] name = "x25519-dalek" version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" +source = "git+https://github.com/pinkforest/curve25519-dalek.git?branch=bump-rand-0.9#92ec8d3e0445a9baf0405eca8e595237231a9460" dependencies = [ "curve25519-dalek", - "rand_core", + "rand_core 0.9.3", "zeroize", ] @@ -1795,7 +1898,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "byteorder", - "zerocopy-derive", + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd97444d05a4328b90e75e503a34bad781f14e28a823ad3557f0750df1ebcbc6" +dependencies = [ + "zerocopy-derive 0.8.23", ] [[package]] @@ -1809,6 +1921,17 @@ dependencies = [ "syn", ] +[[package]] +name = "zerocopy-derive" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6352c01d0edd5db859a63e2605f4ea3183ddbd15e2c4a9e7d32184df75e4f154" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "zeroize" version = "1.8.1" diff --git a/Cargo.toml b/Cargo.toml index c516153..f2a0e92 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,36 @@ [workspace] resolver = "2" -members = ["dhkem", "frodo-kem", "ml-kem", "x-wing"] +members = [ + "dhkem", + "frodo-kem", + "ml-kem", + "x-wing" +] [profile.bench] debug = true + +[patch.crates-io] +# https://github.com/RustCrypto/traits/pull/1777 +kem = { git = "https://github.com/baloo/traits.git", branch = "baloo/relax-sized-rng" } +elliptic-curve = { git = "https://github.com/baloo/traits.git", branch = "baloo/relax-sized-rng" } +digest = { git = "https://github.com/baloo/traits.git", branch = "baloo/relax-sized-rng" } + +# https://github.com/RustCrypto/elliptic-curves/pull/1131 +k256 = { git = "https://github.com/baloo/elliptic-curves.git", branch = "baloo/group/try-from-rng" } +p256 = { git = "https://github.com/baloo/elliptic-curves.git", branch = "baloo/group/try-from-rng" } +p384 = { git = "https://github.com/baloo/elliptic-curves.git", branch = "baloo/group/try-from-rng" } +p521 = { git = "https://github.com/baloo/elliptic-curves.git", branch = "baloo/group/try-from-rng" } + +sha2 = { git = "https://github.com/RustCrypto/hashes.git" } + +# https://github.com/zkcrypto/group/pull/57 +# https://github.com/zkcrypto/group/pull/58 +# https://github.com/zkcrypto/group/pull/59 +group = { git = "https://github.com/baloo/group.git", branch = "baloo/try_from_rng" } + +ff = { git = "https://github.com/zkcrypto/ff.git", branch = "release-0.14.0" } + +crypto-bigint = { git = "https://github.com/RustCrypto/crypto-bigint.git" } + +x25519-dalek = { git = "https://github.com/pinkforest/curve25519-dalek.git", branch = "bump-rand-0.9" } diff --git a/dhkem/Cargo.toml b/dhkem/Cargo.toml index ce8fe40..9c2f911 100644 --- a/dhkem/Cargo.toml +++ b/dhkem/Cargo.toml @@ -5,8 +5,8 @@ Pure Rust implementation of Key Encapsulation Mechanism (KEM) adapters for Ellip Diffie Hellman (ECDH) protocols """ version = "0.0.1-alpha" -edition = "2021" -rust-version = "1.74" +edition = "2024" +rust-version = "1.85" license = "Apache-2.0 OR MIT" repository = "https://github.com/RustCrypto/KEMs/tree/master/dhkem" categories = ["cryptography"] @@ -15,14 +15,14 @@ readme = "README.md" [dependencies] kem = "0.3.0-pre.0" -rand_core = "0.6.4" +rand_core = "0.9.0" # optional dependencies -elliptic-curve = { version = "0.13.8", optional = true, default-features = false } -k256 = { version = "0.13.4", optional = true, default-features = false, features = ["arithmetic"] } -p256 = { version = "0.13.2", optional = true, default-features = false, features = ["arithmetic"] } -p384 = { version = "0.13.1", optional = true, default-features = false, features = ["arithmetic"] } -p521 = { version = "0.13.3", optional = true, default-features = false, features = ["arithmetic"] } +elliptic-curve = { version = "0.14.0-rc.1", optional = true, default-features = false } +k256 = { version = "0.14.0-pre.2", optional = true, default-features = false, features = ["arithmetic"] } +p256 = { version = "0.14.0-pre.2", optional = true, default-features = false, features = ["arithmetic"] } +p384 = { version = "0.14.0-pre.2", optional = true, default-features = false, features = ["arithmetic"] } +p521 = { version = "0.14.0-pre.2", optional = true, default-features = false, features = ["arithmetic"] } x25519 = { version = "2.0.1", package = "x25519-dalek", optional = true, default-features = false } zeroize = { version = "1.8.1", optional = true, default-features = false } @@ -38,9 +38,9 @@ zeroize = ["dep:zeroize"] [dev-dependencies] hex-literal = "0.4.1" -hkdf = "0.12.4" -rand = "0.8.5" -sha2 = "0.10.8" +hkdf = "0.13.0-pre.5" +rand = "0.9.0" +sha2 = "0.11.0-pre.5" [package.metadata.docs.rs] all-features = true diff --git a/dhkem/README.md b/dhkem/README.md index 345e97e..7787df0 100644 --- a/dhkem/README.md +++ b/dhkem/README.md @@ -27,13 +27,6 @@ The implementation contained in this crate has never been independently audited! USE AT YOUR OWN RISK! -## Minimum Supported Rust Version - -This crate requires **Rust 1.74** at a minimum. - -We may change the MSRV in the future, but it will be accompanied by a minor -version bump. - ## License Licensed under either of: diff --git a/dhkem/src/ecdh_kem.rs b/dhkem/src/ecdh_kem.rs index 03bf256..6a84b8f 100644 --- a/dhkem/src/ecdh_kem.rs +++ b/dhkem/src/ecdh_kem.rs @@ -3,11 +3,11 @@ use crate::{DhDecapsulator, DhEncapsulator, DhKem}; use core::{convert::Infallible, marker::PhantomData}; use elliptic_curve::{ - ecdh::{EphemeralSecret, SharedSecret}, CurveArithmetic, PublicKey, + ecdh::{EphemeralSecret, SharedSecret}, }; use kem::{Decapsulate, Encapsulate}; -use rand_core::CryptoRngCore; +use rand_core::CryptoRng; /// Generic Elliptic Curve Diffie-Hellman KEM adapter compatible with curves implemented using /// traits from the `elliptic-curve` crate. @@ -21,9 +21,9 @@ where { type Error = Infallible; - fn encapsulate( + fn encapsulate( &self, - rng: &mut impl CryptoRngCore, + rng: &mut R, ) -> Result<(PublicKey, SharedSecret), Self::Error> { // ECDH encapsulation involves creating a new ephemeral key pair and then doing DH let sk = EphemeralSecret::random(rng); @@ -56,8 +56,8 @@ where type EncapsulatedKey = PublicKey; type SharedSecret = SharedSecret; - fn random_keypair( - rng: &mut impl CryptoRngCore, + fn random_keypair( + rng: &mut R, ) -> (Self::DecapsulatingKey, Self::EncapsulatingKey) { let sk = EphemeralSecret::random(rng); let pk = PublicKey::from(&sk); diff --git a/dhkem/src/lib.rs b/dhkem/src/lib.rs index 6dc79c6..542bc3a 100644 --- a/dhkem/src/lib.rs +++ b/dhkem/src/lib.rs @@ -41,12 +41,12 @@ pub use ecdh_kem::EcdhKem; pub use x25519_kem::X25519Kem; use kem::{Decapsulate, Encapsulate}; -use rand_core::CryptoRngCore; +use rand_core::CryptoRng; #[cfg(feature = "ecdh")] use elliptic_curve::{ - sec1::{self, ToEncodedPoint}, CurveArithmetic, PublicKey, + sec1::{self, ToEncodedPoint}, }; #[cfg(feature = "zeroize")] @@ -148,8 +148,8 @@ pub trait DhKem { /// Generates a new (decapsulating key, encapsulating key) keypair for the KEM /// model - fn random_keypair( - rng: &mut impl CryptoRngCore, + fn random_keypair( + rng: &mut R, ) -> (Self::DecapsulatingKey, Self::EncapsulatingKey); } diff --git a/dhkem/src/x25519_kem.rs b/dhkem/src/x25519_kem.rs index 6cd35fd..045ebfe 100644 --- a/dhkem/src/x25519_kem.rs +++ b/dhkem/src/x25519_kem.rs @@ -1,7 +1,7 @@ use crate::{DhDecapsulator, DhEncapsulator, DhKem}; use core::convert::Infallible; use kem::{Decapsulate, Encapsulate}; -use rand_core::CryptoRngCore; +use rand_core::CryptoRng; use x25519::{PublicKey, ReusableSecret, SharedSecret}; /// X22519 Diffie-Hellman KEM adapter. @@ -12,9 +12,9 @@ pub struct X25519Kem; impl Encapsulate for DhEncapsulator { type Error = Infallible; - fn encapsulate( + fn encapsulate( &self, - rng: &mut impl CryptoRngCore, + rng: &mut R, ) -> Result<(PublicKey, SharedSecret), Self::Error> { // ECDH encapsulation involves creating a new ephemeral key pair and then doing DH let sk = ReusableSecret::random_from_rng(rng); @@ -41,8 +41,8 @@ impl DhKem for X25519Kem { type EncapsulatedKey = PublicKey; type SharedSecret = SharedSecret; - fn random_keypair( - rng: &mut impl CryptoRngCore, + fn random_keypair( + rng: &mut R, ) -> (Self::DecapsulatingKey, Self::EncapsulatingKey) { let sk = ReusableSecret::random_from_rng(rng); let pk = PublicKey::from(&sk); diff --git a/dhkem/tests/hpke_p256_test.rs b/dhkem/tests/hpke_p256_test.rs index 3074746..1064f02 100644 --- a/dhkem/tests/hpke_p256_test.rs +++ b/dhkem/tests/hpke_p256_test.rs @@ -29,16 +29,6 @@ impl RngCore for ConstantRng<'_> { dest.copy_from_slice(hd); self.0 = tl; } - - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> { - if dest.len() > self.0.len() { - return Err(rand_core::Error::new("not enough bytes")); - } - let (hd, tl) = self.0.split_at(dest.len()); - dest.copy_from_slice(hd); - self.0 = tl; - Ok(()) - } } // this is only ever ok for testing diff --git a/dhkem/tests/tests.rs b/dhkem/tests/tests.rs index b88423f..48cc5b5 100644 --- a/dhkem/tests/tests.rs +++ b/dhkem/tests/tests.rs @@ -1,6 +1,6 @@ use dhkem::DhKem; use kem::{Decapsulate, Encapsulate}; -use rand::thread_rng; +use rand::rng; trait SecretBytes { fn as_slice(&self) -> &[u8]; @@ -30,7 +30,7 @@ fn test_kem() where ::SharedSecret: SecretBytes, { - let mut rng = thread_rng(); + let mut rng = rng(); let (sk, pk) = K::random_keypair(&mut rng); let (ek, ss1) = pk.encapsulate(&mut rng).expect("never fails"); let ss2 = sk.decapsulate(&ek).expect("never fails"); diff --git a/frodo-kem/CHANGELOG.md b/frodo-kem/CHANGELOG.md index b6d51fb..5e6b1a3 100644 --- a/frodo-kem/CHANGELOG.md +++ b/frodo-kem/CHANGELOG.md @@ -5,5 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.1.0 (UNRELEASED) +### Changed +- Edition changed to 2024 and MSRV bumped to 1.85 ([#118]) +- Relax MSRV policy and allow MSRV bumps in patch releases + +[#118]: https://github.com/RustCrypto/KEMs/pull/118 + ## 0.0.1 (2025-01-19) - Initial release diff --git a/frodo-kem/Cargo.toml b/frodo-kem/Cargo.toml index e823481..6790a1c 100644 --- a/frodo-kem/Cargo.toml +++ b/frodo-kem/Cargo.toml @@ -11,8 +11,8 @@ keywords = ["quantum", "post", "zero", "knowledge", "encryption"] exclude = ["tests/**", "bench/**", "examples/**", ".github/**"] license = "Apache-2.0 OR MIT" readme = "README.md" -edition = "2021" -rust-version = "1.82" +edition = "2024" +rust-version = "1.85" [features] default = [ diff --git a/frodo-kem/README.md b/frodo-kem/README.md index f5d15e5..e8b4b18 100644 --- a/frodo-kem/README.md +++ b/frodo-kem/README.md @@ -23,13 +23,6 @@ The implementation contained in this crate has never been independently audited! USE AT YOUR OWN RISK! -## Minimum Supported Rust Version - -This crate requires **Rust 1.82** at a minimum. - -We may change the MSRV in the future, but it will be accompanied by a minor -version bump. - ## Details This crate provides the following FrodoKEM algorithms: diff --git a/frodo-kem/benches/frodo.rs b/frodo-kem/benches/frodo.rs index 19f3a74..dded1ba 100644 --- a/frodo-kem/benches/frodo.rs +++ b/frodo-kem/benches/frodo.rs @@ -1,5 +1,5 @@ use criterion::{ - criterion_group, criterion_main, measurement::Measurement, BenchmarkGroup, Criterion, + BenchmarkGroup, Criterion, criterion_group, criterion_main, measurement::Measurement, }; use frodo_kem::*; use rand_core::SeedableRng; diff --git a/frodo-kem/benches/safe_oqs.rs b/frodo-kem/benches/safe_oqs.rs index 111d111..22ec02f 100644 --- a/frodo-kem/benches/safe_oqs.rs +++ b/frodo-kem/benches/safe_oqs.rs @@ -1,6 +1,6 @@ //! Benchmarking FrodoKEM against liboqs use criterion::{ - criterion_group, criterion_main, measurement::Measurement, BenchmarkGroup, Criterion, + BenchmarkGroup, Criterion, criterion_group, criterion_main, measurement::Measurement, }; use frodo_kem::*; use rand_core::SeedableRng; diff --git a/frodo-kem/src/hazmat/models.rs b/frodo-kem/src/hazmat/models.rs index 3e7671a..7e64b1e 100644 --- a/frodo-kem/src/hazmat/models.rs +++ b/frodo-kem/src/hazmat/models.rs @@ -846,8 +846,8 @@ impl Expanded for FrodoAes

{ fn expand_a(&self, seed_a: &[u8], a: &mut [u16]) { use aes::{ - cipher::{BlockEncrypt, KeyInit, KeySizeUser}, Aes128Enc, Block, + cipher::{BlockEncrypt, KeyInit, KeySizeUser}, }; debug_assert_eq!(a.len(), P::N_X_N); @@ -1002,8 +1002,8 @@ impl Expanded for FrodoShake

{ fn expand_a(&self, seed_a: &[u8], a: &mut [u16]) { use sha3::{ - digest::{ExtendableOutputReset, Update}, Shake128, + digest::{ExtendableOutputReset, Update}, }; debug_assert_eq!(a.len(), P::N_X_N); diff --git a/frodo-kem/tests/rng.rs b/frodo-kem/tests/rng.rs index a432610..b5aa2fc 100644 --- a/frodo-kem/tests/rng.rs +++ b/frodo-kem/tests/rng.rs @@ -1,10 +1,10 @@ //! Random number generator for testing //! AES-CTR DRBG use aes::{ - cipher::{BlockEncrypt, KeyInit}, Aes256Enc, Block, + cipher::{BlockEncrypt, KeyInit}, }; -use hybrid_array::{typenum::U48, Array}; +use hybrid_array::{Array, typenum::U48}; use rand_core::{CryptoRng, Error, RngCore, SeedableRng}; /// Seed type for the AES-CTR DRBG diff --git a/frodo-kem/tests/rsp_reader.rs b/frodo-kem/tests/rsp_reader.rs index 7b4f818..b227767 100644 --- a/frodo-kem/tests/rsp_reader.rs +++ b/frodo-kem/tests/rsp_reader.rs @@ -1,6 +1,6 @@ //! Reader for Frodo KAT files and test vectors use frodo_kem::*; -use hybrid_array::{typenum::U48, Array}; +use hybrid_array::{Array, typenum::U48}; use std::path::Path; use std::{ fs::File, diff --git a/ml-kem/CHANGELOG.md b/ml-kem/CHANGELOG.md index dd9878b..8abf67e 100644 --- a/ml-kem/CHANGELOG.md +++ b/ml-kem/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.3.0 (UNRELEASED) +### Changed +- Edition changed to 2024 and MSRV bumped to 1.85 ([#118]) +- Relax MSRV policy and allow MSRV bumps in patch releases + +[#118]: https://github.com/RustCrypto/KEMs/pull/118 + ## 0.2.1 (2024-08-17) ### Added - `zeroize` feature ([#51]) diff --git a/ml-kem/Cargo.toml b/ml-kem/Cargo.toml index cff7ccc..e63d770 100644 --- a/ml-kem/Cargo.toml +++ b/ml-kem/Cargo.toml @@ -5,8 +5,8 @@ Pure Rust implementation of the Module-Lattice-Based Key-Encapsulation Mechanism (formerly known as Kyber) as described in FIPS 203 """ version = "0.3.0-pre" -edition = "2021" -rust-version = "1.81" +edition = "2024" +rust-version = "1.85" license = "Apache-2.0 OR MIT" readme = "README.md" homepage = "https://github.com/RustCrypto/KEMs/tree/master/ml-kem" @@ -23,18 +23,18 @@ zeroize = ["dep:zeroize"] [dependencies] kem = "0.3.0-pre.0" -hybrid-array = { version = "0.2", features = ["extra-sizes"] } -rand_core = "0.6.4" -sha3 = { version = "0.10.8", default-features = false } +hybrid-array = { version = "0.3", features = ["extra-sizes"] } +rand_core = "0.9" +sha3 = { version = "0.11.0-pre.4", default-features = false } zeroize = { version = "1.8.1", optional = true, default-features = false } [dev-dependencies] criterion = "0.5.1" hex = { version = "0.4.3", features = ["serde"] } -hex-literal = "0.4.1" +hex-literal = "1" num-rational = { version = "0.4.2", default-features = false, features = ["num-bigint"] } -rand = "0.8.5" -crypto-common = { version = "0.1.6", features = ["rand_core"] } +rand = "0.9" +crypto-common = { version = "0.2.0-rc.2", features = ["rand_core"] } serde = { version = "1.0.208", features = ["derive"] } serde_json = "1.0.125" diff --git a/ml-kem/README.md b/ml-kem/README.md index 75efc6c..0582ff8 100644 --- a/ml-kem/README.md +++ b/ml-kem/README.md @@ -36,13 +36,6 @@ The implementation contained in this crate has never been independently audited! USE AT YOUR OWN RISK! -## Minimum Supported Rust Version - -This crate requires **Rust 1.81** at a minimum. - -We may change the MSRV in the future, but it will be accompanied by a minor -version bump. - ## License Licensed under either of: diff --git a/ml-kem/benches/mlkem.rs b/ml-kem/benches/mlkem.rs index 40018ab..7d2ee4d 100644 --- a/ml-kem/benches/mlkem.rs +++ b/ml-kem/benches/mlkem.rs @@ -1,9 +1,9 @@ use ::kem::{Decapsulate, Encapsulate}; -use criterion::{criterion_group, criterion_main, Criterion}; +use criterion::{Criterion, criterion_group, criterion_main}; use ml_kem::*; fn criterion_benchmark(c: &mut Criterion) { - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); // Key generation c.bench_function("keygen", |b| { diff --git a/ml-kem/src/algebra.rs b/ml-kem/src/algebra.rs index 0f635d4..f57e312 100644 --- a/ml-kem/src/algebra.rs +++ b/ml-kem/src/algebra.rs @@ -1,11 +1,11 @@ use core::ops::{Add, Mul, Sub}; -use hybrid_array::{typenum::U256, Array}; +use hybrid_array::{Array, typenum::U256}; use sha3::digest::XofReader; -use crate::crypto::{PrfOutput, PRF, XOF}; +use crate::crypto::{PRF, PrfOutput, XOF}; use crate::encode::Encode; use crate::param::{ArraySize, CbdSamplingSize}; -use crate::util::{Truncate, B32}; +use crate::util::{B32, Truncate}; #[cfg(feature = "zeroize")] use zeroize::Zeroize; @@ -34,11 +34,7 @@ impl FieldElement { // A fast modular reduction for small numbers `x < 2*q` fn small_reduce(x: u16) -> u16 { - if x < Self::Q { - x - } else { - x - Self::Q - } + if x < Self::Q { x } else { x - Self::Q } } fn barrett_reduce(x: u32) -> u16 { diff --git a/ml-kem/src/compress.rs b/ml-kem/src/compress.rs index 9be0476..6f85861 100644 --- a/ml-kem/src/compress.rs +++ b/ml-kem/src/compress.rs @@ -89,7 +89,7 @@ impl Compress for PolynomialVector { #[cfg(test)] pub(crate) mod test { use super::*; - use hybrid_array::typenum::{U1, U10, U11, U12, U4, U5, U6}; + use hybrid_array::typenum::{U1, U4, U5, U6, U10, U11, U12}; use num_rational::Ratio; #[allow(clippy::cast_possible_truncation)] diff --git a/ml-kem/src/crypto.rs b/ml-kem/src/crypto.rs index 290dc4e..ccd3992 100644 --- a/ml-kem/src/crypto.rs +++ b/ml-kem/src/crypto.rs @@ -1,16 +1,16 @@ #![allow(dead_code)] use hybrid_array::{Array, ArraySize}; -use rand_core::CryptoRngCore; +use rand_core::CryptoRng; use sha3::{ - digest::{ExtendableOutput, Update, XofReader}, Digest, Sha3_256, Sha3_512, Shake128, Shake256, + digest::{ExtendableOutput, Update, XofReader}, }; use crate::param::{CbdSamplingSize, EncodedPolynomial}; use crate::util::B32; -pub fn rand(rng: &mut impl CryptoRngCore) -> Array { +pub fn rand(rng: &mut R) -> Array { let mut val = Array::default(); rng.fill_bytes(&mut val); val @@ -39,7 +39,7 @@ pub fn H(x: impl AsRef<[u8]>) -> B32 { // the `generic-array` crate. It should be pretty cheap though, since there's only one // allocation / no copies. let mut out = B32::default(); - h.finalize_into(out.as_mut_slice().into()); + h.finalize_into(&mut out); out } diff --git a/ml-kem/src/encode.rs b/ml-kem/src/encode.rs index 189d9cd..dcc6e52 100644 --- a/ml-kem/src/encode.rs +++ b/ml-kem/src/encode.rs @@ -1,6 +1,6 @@ use hybrid_array::{ - typenum::{Unsigned, U256}, Array, + typenum::{U256, Unsigned}, }; use crate::algebra::{ @@ -147,7 +147,7 @@ pub(crate) mod test { use core::fmt::Debug; use core::ops::Rem; use hybrid_array::typenum::{ - marker_traits::Zero, operator_aliases::Mod, U1, U10, U11, U12, U2, U3, U4, U5, U6, U8, + U1, U2, U3, U4, U5, U6, U8, U10, U11, U12, marker_traits::Zero, operator_aliases::Mod, }; use rand::Rng; @@ -184,7 +184,7 @@ pub(crate) mod test { assert_eq!(&actual_decoded, decoded); // Test random decode/encode and encode/decode round trips - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); let mut decoded: Array = Array::default(); rng.fill(decoded.as_mut_slice()); let m = match D::USIZE { diff --git a/ml-kem/src/kem.rs b/ml-kem/src/kem.rs index 3e6cf8a..8c8edf7 100644 --- a/ml-kem/src/kem.rs +++ b/ml-kem/src/kem.rs @@ -1,9 +1,9 @@ use core::convert::Infallible; use core::marker::PhantomData; use hybrid_array::typenum::U32; -use rand_core::CryptoRngCore; +use rand_core::CryptoRng; -use crate::crypto::{rand, G, H, J}; +use crate::crypto::{G, H, J, rand}; use crate::param::{DecapsulationKeySize, EncapsulationKeySize, EncodedCiphertext, KemParams}; use crate::pke::{DecryptionKey, EncryptionKey}; use crate::util::B32; @@ -126,7 +126,7 @@ where &self.ek } - pub(crate) fn generate(rng: &mut impl CryptoRngCore) -> Self { + pub(crate) fn generate(rng: &mut R) -> Self { let d: B32 = rand(rng); let z: B32 = rand(rng); Self::generate_deterministic(&d, &z) @@ -190,9 +190,9 @@ where { type Error = Infallible; - fn encapsulate( + fn encapsulate( &self, - rng: &mut impl CryptoRngCore, + rng: &mut R, ) -> Result<(EncodedCiphertext

, SharedKey), Self::Error> { let m: B32 = rand(rng); Ok(self.encapsulate_deterministic_inner(&m)) @@ -234,7 +234,9 @@ where type EncapsulationKey = EncapsulationKey

; /// Generate a new (decapsulation, encapsulation) key pair - fn generate(rng: &mut impl CryptoRngCore) -> (Self::DecapsulationKey, Self::EncapsulationKey) { + fn generate( + rng: &mut R, + ) -> (Self::DecapsulationKey, Self::EncapsulationKey) { let dk = Self::DecapsulationKey::generate(rng); let ek = dk.encapsulation_key().clone(); (dk, ek) @@ -254,14 +256,14 @@ where #[cfg(test)] mod test { use super::*; - use crate::{MlKem1024Params, MlKem512Params, MlKem768Params}; + use crate::{MlKem512Params, MlKem768Params, MlKem1024Params}; use ::kem::{Decapsulate, Encapsulate}; fn round_trip_test

() where P: KemParams, { - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); let dk = DecapsulationKey::

::generate(&mut rng); let ek = dk.encapsulation_key(); @@ -282,7 +284,7 @@ mod test { where P: KemParams, { - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); let dk_original = DecapsulationKey::

::generate(&mut rng); let ek_original = dk_original.encapsulation_key().clone(); diff --git a/ml-kem/src/lib.rs b/ml-kem/src/lib.rs index 61e6f8a..a08ae00 100644 --- a/ml-kem/src/lib.rs +++ b/ml-kem/src/lib.rs @@ -23,7 +23,7 @@ //! ``` //! # use ml_kem::*; //! # use ::kem::{Decapsulate, Encapsulate}; -//! let mut rng = rand::thread_rng(); +//! let mut rng = rand::rng(); //! //! // Generate a (decapsulation key, encapsulation key) pair //! let (dk, ek) = MlKem768::generate(&mut rng); @@ -68,10 +68,10 @@ mod param; use ::kem::{Decapsulate, Encapsulate}; use core::fmt::Debug; use hybrid_array::{ - typenum::{U10, U11, U2, U3, U4, U5}, Array, + typenum::{U2, U3, U4, U5, U10, U11}, }; -use rand_core::CryptoRngCore; +use rand_core::CryptoRng; pub use hybrid_array as array; @@ -142,12 +142,14 @@ pub trait KemCore: Clone { + PartialEq; /// Generate a new (decapsulation, encapsulation) key pair - fn generate(rng: &mut impl CryptoRngCore) -> (Self::DecapsulationKey, Self::EncapsulationKey); + fn generate( + rng: &mut R, + ) -> (Self::DecapsulationKey, Self::EncapsulationKey); /// Generate a new (decapsulation, encapsulation) key pair deterministically #[cfg(feature = "deterministic")] fn generate_deterministic(d: &B32, z: &B32) - -> (Self::DecapsulationKey, Self::EncapsulationKey); + -> (Self::DecapsulationKey, Self::EncapsulationKey); } /// `MlKem512` is the parameter set for security category 1, corresponding to key search on a block @@ -215,7 +217,7 @@ mod test { where K: KemCore, { - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); let (dk, ek) = K::generate(&mut rng); diff --git a/ml-kem/src/param.rs b/ml-kem/src/param.rs index 2a9497c..e75021c 100644 --- a/ml-kem/src/param.rs +++ b/ml-kem/src/param.rs @@ -14,17 +14,17 @@ use core::fmt::Debug; use core::ops::{Add, Div, Mul, Rem, Sub}; use hybrid_array::{ + Array, typenum::{ + Const, ToUInt, U0, U2, U3, U4, U6, U8, U12, U16, U32, U64, U384, operator_aliases::{Gcf, Prod, Quot, Sum}, type_operators::Gcd, - Const, ToUInt, U0, U12, U16, U2, U3, U32, U384, U4, U6, U64, U8, }, - Array, }; use crate::algebra::{FieldElement, NttVector}; use crate::encode::Encode; -use crate::util::{Flatten, Unflatten, B32}; +use crate::util::{B32, Flatten, Unflatten}; /// An array length with other useful properties pub trait ArraySize: hybrid_array::ArraySize + PartialEq + Debug {} diff --git a/ml-kem/src/pke.rs b/ml-kem/src/pke.rs index 571a1d6..848d6c6 100644 --- a/ml-kem/src/pke.rs +++ b/ml-kem/src/pke.rs @@ -1,4 +1,4 @@ -use hybrid_array::typenum::{Unsigned, U1}; +use hybrid_array::typenum::{U1, Unsigned}; use crate::algebra::{NttMatrix, NttVector, Polynomial, PolynomialVector}; use crate::compress::Compress; @@ -149,13 +149,13 @@ where mod test { use super::*; use crate::crypto::rand; - use crate::{MlKem1024Params, MlKem512Params, MlKem768Params}; + use crate::{MlKem512Params, MlKem768Params, MlKem1024Params}; fn round_trip_test

() where P: PkeParams, { - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); let d: B32 = rand(&mut rng); let original = B32::default(); let randomness = B32::default(); @@ -177,7 +177,7 @@ mod test { where P: PkeParams, { - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); let d: B32 = rand(&mut rng); let (dk_original, ek_original) = DecryptionKey::

::generate(&d); diff --git a/ml-kem/src/util.rs b/ml-kem/src/util.rs index 3a4ed98..46f795e 100644 --- a/ml-kem/src/util.rs +++ b/ml-kem/src/util.rs @@ -2,11 +2,11 @@ use core::mem::ManuallyDrop; use core::ops::{Div, Mul, Rem}; use core::ptr; use hybrid_array::{ + Array, ArraySize, typenum::{ + U0, U32, Unsigned, operator_aliases::{Prod, Quot}, - Unsigned, U0, U32, }, - Array, ArraySize, }; /// A 32-byte array, defined here for brevity because it is used several times diff --git a/x-wing/Cargo.toml b/x-wing/Cargo.toml index 9d511d5..0b2d889 100644 --- a/x-wing/Cargo.toml +++ b/x-wing/Cargo.toml @@ -2,8 +2,8 @@ name = "x-wing" description = "Pure Rust implementation of the X-Wing Key Encapsulation Mechanism (draft 06)" version = "0.0.1-pre.1" -edition = "2021" -rust-version = "1.81" +edition = "2024" +rust-version = "1.85" license = "Apache-2.0 OR MIT" readme = "README.md" homepage = "https://github.com/RustCrypto/KEMs/tree/master/x-wing" @@ -13,23 +13,23 @@ keywords = ["crypto", "x-wing", "xwing", "kem", "post-quantum"] exclude = ["src/test-vectors.json"] [features] -getrandom = ["rand_core/getrandom"] +os_rng = ["rand_core/os_rng"] zeroize = ["dep:zeroize", "ml-kem/zeroize", "x25519-dalek/zeroize"] [dependencies] -rand_core = { version = "0.6", default-features = false } +rand_core = { version = "0.9.3", default-features = false } x25519-dalek = { version = "2.0", default-features = false, features = ["static_secrets"] } ml-kem = { version = "=0.3.0-pre", default-features = false, features = ["deterministic"], path = "../ml-kem" } -sha3 = { version = "0.10", default-features = false } +sha3 = { version = "0.11.0-pre.5", default-features = false } kem = "0.3.0-pre.0" zeroize = { version = "1.8.1", optional = true, default-features = true, features = ["zeroize_derive"] } [dev-dependencies] -rand_core = { version = "0.6" } +rand_core = { version = "0.9" } hex = { version = "0.4", features = ["serde"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -rand = "0.8" +rand = "0.9" [package.metadata.docs.rs] all-features = true diff --git a/x-wing/README.md b/x-wing/README.md index 1dc64c7..030c4d7 100644 --- a/x-wing/README.md +++ b/x-wing/README.md @@ -25,13 +25,6 @@ The implementation contained in this crate has never been independently audited! USE AT YOUR OWN RISK! -## Minimum Supported Rust Version - -This crate requires **Rust 1.81** at a minimum. - -We may change the MSRV in the future, but it will be accompanied by a minor -version bump. - ## License Licensed under either of: diff --git a/x-wing/src/lib.rs b/x-wing/src/lib.rs index 79460fe..0643e64 100644 --- a/x-wing/src/lib.rs +++ b/x-wing/src/lib.rs @@ -17,8 +17,9 @@ //! //! ``` //! use kem::{Decapsulate, Encapsulate}; +//! use rand_core::TryRngCore; //! -//! let mut rng = &mut rand::rngs::OsRng; +//! let mut rng = &mut rand::rngs::OsRng.unwrap_err(); //! let (sk, pk) = x_wing::generate_key_pair(rng); //! let (ct, ss_sender) = pk.encapsulate(rng).unwrap(); //! let ss_receiver = sk.decapsulate(&ct).unwrap(); @@ -29,10 +30,10 @@ use core::convert::Infallible; use kem::{Decapsulate, Encapsulate}; use ml_kem::array::ArrayN; -use ml_kem::{kem, EncodedSizeUser, KemCore, MlKem768, MlKem768Params, B32}; -use rand_core::CryptoRngCore; -#[cfg(feature = "getrandom")] -use rand_core::OsRng; +use ml_kem::{B32, EncodedSizeUser, KemCore, MlKem768, MlKem768Params, kem}; +use rand_core::CryptoRng; +#[cfg(feature = "os_rng")] +use rand_core::{OsRng, TryRngCore}; use sha3::digest::core_api::XofReaderCoreWrapper; use sha3::digest::{ExtendableOutput, XofReader}; use sha3::{Sha3_256, Shake256, Shake256ReaderCore}; @@ -75,9 +76,9 @@ pub struct EncapsulationKey { impl Encapsulate for EncapsulationKey { type Error = Infallible; - fn encapsulate( + fn encapsulate( &self, - rng: &mut impl CryptoRngCore, + rng: &mut R, ) -> Result<(Ciphertext, SharedSecret), Self::Error> { // Swapped order of operations compared to RFC, so that usage of the rng matches the RFC let (ct_m, ss_m) = self.pk_m.encapsulate(rng)?; @@ -146,13 +147,14 @@ impl Decapsulate for DecapsulationKey { impl DecapsulationKey { /// Generate a new `DecapsulationKey` using `OsRng`. - #[cfg(feature = "getrandom")] + #[cfg(feature = "os_rng")] + #[must_use] pub fn generate_from_os_rng() -> DecapsulationKey { - Self::generate(&mut OsRng) + Self::generate(&mut OsRng.unwrap_err()) } /// Generate a new `DecapsulationKey` using the provided RNG. - pub fn generate(rng: &mut impl CryptoRngCore) -> DecapsulationKey { + pub fn generate(rng: &mut R) -> DecapsulationKey { let sk = generate(rng); DecapsulationKey { sk } } @@ -236,13 +238,16 @@ impl From<&[u8; CIPHERTEXT_SIZE]> for Ciphertext { } /// Generate a X-Wing key pair using `OsRng`. -#[cfg(feature = "getrandom")] +#[cfg(feature = "os_rng")] +#[must_use] pub fn generate_key_pair_from_os_rng() -> (DecapsulationKey, EncapsulationKey) { - generate_key_pair(&mut OsRng) + generate_key_pair(&mut OsRng.unwrap_err()) } /// Generate a X-Wing key pair using the provided rng. -pub fn generate_key_pair(rng: &mut impl CryptoRngCore) -> (DecapsulationKey, EncapsulationKey) { +pub fn generate_key_pair( + rng: &mut R, +) -> (DecapsulationKey, EncapsulationKey) { let sk = DecapsulationKey::generate(rng); let pk = sk.encapsulation_key(); (sk, pk) @@ -271,7 +276,7 @@ fn read_from(reader: &mut XofReaderCoreWrapper(rng: &mut impl CryptoRngCore) -> [u8; N] { +fn generate(rng: &mut R) -> [u8; N] { let mut random = [0; N]; rng.fill_bytes(&mut random); random @@ -279,7 +284,7 @@ fn generate(rng: &mut impl CryptoRngCore) -> [u8; N] { #[cfg(test)] mod tests { - use rand_core::{impls, CryptoRng, OsRng, RngCore}; + use rand_core::{CryptoRng, OsRng, RngCore, TryRngCore, impls}; use serde::Deserialize; use super::*; @@ -304,13 +309,8 @@ mod tests { } fn fill_bytes(&mut self, dest: &mut [u8]) { - self.try_fill_bytes(dest).unwrap(); - } - - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> { dest.copy_from_slice(&self.seed[0..dest.len()]); self.seed.drain(0..dest.len()); - Ok(()) } } @@ -367,7 +367,7 @@ mod tests { #[test] fn ciphertext_serialize() { - let mut rng = OsRng; + let mut rng = OsRng.unwrap_err(); let ct_a = Ciphertext { ct_m: generate(&mut rng).into(), @@ -383,7 +383,7 @@ mod tests { #[test] fn key_serialize() { - let sk = DecapsulationKey::generate(&mut OsRng); + let sk = DecapsulationKey::generate(&mut OsRng.unwrap_err()); let pk = sk.encapsulation_key(); let sk_bytes = sk.as_bytes();