mirror of
https://github.com/RustCrypto/signatures
synced 2026-06-21 13:45:42 +00:00
Upgrade all crates to the 2024 edition and bump MSRV to 1.85 (#913)
This commit is contained in:
@@ -26,7 +26,7 @@ jobs:
|
||||
- thumbv7em-none-eabi
|
||||
- wasm32-unknown-unknown
|
||||
rust:
|
||||
- 1.81.0 # MSRV
|
||||
- 1.85.0 # MSRV
|
||||
- stable
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -42,7 +42,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
rust:
|
||||
- 1.81.0 # MSRV
|
||||
- 1.85.0 # MSRV
|
||||
- stable
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
- thumbv7em-none-eabi
|
||||
- wasm32-unknown-unknown
|
||||
toolchain:
|
||||
- 1.81.0 # MSRV
|
||||
- 1.85.0 # MSRV
|
||||
- stable
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -42,7 +42,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
toolchain:
|
||||
- 1.81.0 # MSRV
|
||||
- 1.85.0 # MSRV
|
||||
- stable
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
- thumbv7em-none-eabi
|
||||
- wasm32-unknown-unknown
|
||||
toolchain:
|
||||
- 1.81.0 # MSRV
|
||||
- 1.85.0 # MSRV
|
||||
- stable
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -42,7 +42,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
toolchain:
|
||||
- 1.81.0 # MSRV
|
||||
- 1.85.0 # MSRV
|
||||
- stable
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
rust:
|
||||
- 1.81.0 # MSRV
|
||||
- 1.85.0 # MSRV
|
||||
- stable
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -23,7 +23,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
rust:
|
||||
- 1.81.0 # MSRV
|
||||
- 1.85.0 # MSRV
|
||||
- stable
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
- thumbv7em-none-eabi
|
||||
- wasm32-unknown-unknown
|
||||
rust:
|
||||
- 1.81.0 # MSRV
|
||||
- 1.85.0 # MSRV
|
||||
- stable
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -39,7 +39,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
rust:
|
||||
- 1.81.0 # MSRV
|
||||
- 1.85.0 # MSRV
|
||||
- stable
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
- thumbv7em-none-eabi
|
||||
- wasm32-unknown-unknown
|
||||
rust:
|
||||
- 1.81.0 # MSRV
|
||||
- 1.85.0 # MSRV
|
||||
- stable
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
rust:
|
||||
- 1.81.0 # MSRV
|
||||
- 1.85.0 # MSRV
|
||||
- stable
|
||||
test_config:
|
||||
- --no-default-features
|
||||
@@ -84,9 +84,9 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
test-partition: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
|
||||
test-partition: [1, 2, 3, 4]
|
||||
rust:
|
||||
- 1.81.0 # MSRV
|
||||
- 1.85.0 # MSRV
|
||||
- stable
|
||||
test_config:
|
||||
- --no-default-features
|
||||
@@ -109,4 +109,4 @@ jobs:
|
||||
fi
|
||||
|
||||
~/.cargo/bin/cargo-nextest nextest run --archive-file nextest-archive-${{ matrix.rust }}-${{ matrix.test_config }}.tar.zst \
|
||||
--partition count:${{ matrix.test-partition }}/16
|
||||
--partition count:${{ matrix.test-partition }}/4
|
||||
|
||||
@@ -29,6 +29,6 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: 1.81.0
|
||||
toolchain: 1.85.0
|
||||
components: clippy
|
||||
- run: cargo clippy --all-features -- -D warnings
|
||||
|
||||
Generated
+189
-153
@@ -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"
|
||||
@@ -90,11 +90,11 @@ checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.11.0-rc.0"
|
||||
version = "0.11.0-rc.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17092d478f4fadfb35a7e082f62e49f0907fdf048801d9d706277e34f9df8a78"
|
||||
checksum = "a229bfd78e4827c91b9b95784f69492c1b77c1ab75a45a8a037b139215086f94"
|
||||
dependencies = [
|
||||
"crypto-common",
|
||||
"hybrid-array 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -185,9 +185,9 @@ checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce"
|
||||
|
||||
[[package]]
|
||||
name = "const-oid"
|
||||
version = "0.10.0-rc.1"
|
||||
version = "0.10.0-rc.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "610947c93f422f713d1ed0570e7c76307aa3bbfd8db723214fed2045a2e32815"
|
||||
checksum = "68ff6be19477a1bd5441f382916a89bc2a0b2c35db6d41e0f6e8538bf6d6463f"
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
@@ -267,26 +267,23 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
||||
|
||||
[[package]]
|
||||
name = "crypto-bigint"
|
||||
version = "0.6.0-rc.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e43027691f1c055da3da4f7d96af09fcec420d435d5616e51f29afd0811c56a7"
|
||||
version = "0.7.0-pre"
|
||||
source = "git+https://github.com/RustCrypto/crypto-bigint.git#534c2940b1f0aa9ec8ada964ce654cc0e6e1e7bb"
|
||||
dependencies = [
|
||||
"hybrid-array",
|
||||
"hybrid-array 0.2.3",
|
||||
"num-traits",
|
||||
"rand_core",
|
||||
"rand_core 0.9.2",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.2.0-rc.1"
|
||||
version = "0.2.0-rc.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0b8ce8218c97789f16356e7896b3714f26c2ee1079b79c0b7ae7064bb9089fa"
|
||||
checksum = "170d71b5b14dec99db7739f6fc7d6ec2db80b78c3acb77db48392ccc3d8a9ea0"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"hybrid-array",
|
||||
"rand_core",
|
||||
"hybrid-array 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -311,9 +308,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.11.0-pre.9"
|
||||
version = "0.11.0-pre.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf2e3d6615d99707295a9673e889bf363a04b2a466bd320c65a72536f7577379"
|
||||
checksum = "6c478574b20020306f98d61c8ca3322d762e1ff08117422ac6106438605ea516"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"const-oid",
|
||||
@@ -321,23 +318,6 @@ dependencies = [
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dsa"
|
||||
version = "0.7.0-pre.1"
|
||||
dependencies = [
|
||||
"digest",
|
||||
"num-bigint-dig",
|
||||
"num-traits",
|
||||
"pkcs8",
|
||||
"rand",
|
||||
"rand_chacha",
|
||||
"rfc6979",
|
||||
"sha1",
|
||||
"sha2",
|
||||
"signature",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ecdsa"
|
||||
version = "0.17.0-pre.9"
|
||||
@@ -345,7 +325,7 @@ dependencies = [
|
||||
"der",
|
||||
"digest",
|
||||
"elliptic-curve",
|
||||
"hex-literal",
|
||||
"hex-literal 1.0.0",
|
||||
"rfc6979",
|
||||
"serdect",
|
||||
"sha2",
|
||||
@@ -358,9 +338,9 @@ name = "ed25519"
|
||||
version = "2.3.0-pre.0"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"hex-literal",
|
||||
"hex-literal 1.0.0",
|
||||
"pkcs8",
|
||||
"rand_core",
|
||||
"rand_core 0.9.2",
|
||||
"serde",
|
||||
"serde_bytes",
|
||||
"signature",
|
||||
@@ -372,7 +352,7 @@ name = "ed448-signature"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"hex-literal",
|
||||
"hex-literal 1.0.0",
|
||||
"pkcs8",
|
||||
"serde",
|
||||
"serde_bytes",
|
||||
@@ -389,19 +369,18 @@ checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a"
|
||||
[[package]]
|
||||
name = "elliptic-curve"
|
||||
version = "0.14.0-rc.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc43715037532dc2d061e5c97e81b684c28993d52a4fa4eb7d2ce2826d78f2f2"
|
||||
source = "git+https://github.com/RustCrypto/traits.git#28b6e0d3231fa0fb31dc7f6bfdb62d6558bcfdf6"
|
||||
dependencies = [
|
||||
"base16ct",
|
||||
"crypto-bigint",
|
||||
"digest",
|
||||
"ff",
|
||||
"group",
|
||||
"hex-literal",
|
||||
"hybrid-array",
|
||||
"hex-literal 1.0.0",
|
||||
"hybrid-array 0.3.0",
|
||||
"pem-rfc7468",
|
||||
"pkcs8",
|
||||
"rand_core",
|
||||
"rand_core 0.9.2",
|
||||
"sec1",
|
||||
"serdect",
|
||||
"subtle",
|
||||
@@ -437,10 +416,9 @@ checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984"
|
||||
[[package]]
|
||||
name = "ff"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449"
|
||||
source = "git+https://github.com/pinkforest/ff.git?branch=bump-rand-core#c734f7f21d6639bc6494dde538209d0770207c49"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
"rand_core 0.9.2",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
@@ -458,17 +436,28 @@ checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f"
|
||||
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]]
|
||||
name = "group"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63"
|
||||
source = "git+https://github.com/pinkforest/group.git?branch=bump-rand-0.9#06ac6fb11ced26fbf980ee65e74fced4da66ec3e"
|
||||
dependencies = [
|
||||
"ff",
|
||||
"rand_core",
|
||||
"rand_core 0.9.2",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
@@ -503,11 +492,16 @@ 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 = "hmac"
|
||||
version = "0.13.0-pre.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e4b1fb14e4df79f9406b434b60acef9f45c26c50062cccf1346c6103b8c47d58"
|
||||
source = "git+https://github.com/RustCrypto/MACs.git#c7cbed0bd3f7026cc01251cd4602d0db4d0495b9"
|
||||
dependencies = [
|
||||
"digest",
|
||||
]
|
||||
@@ -517,6 +511,15 @@ name = "hybrid-array"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2d35805454dc9f8662a98d6d61886ffe26bd465f5960e0e55345c70d5c0d2a9"
|
||||
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",
|
||||
@@ -524,11 +527,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "inout"
|
||||
version = "0.2.0-rc.1"
|
||||
version = "0.2.0-rc.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "161ac07241f4d11c21b6d82f1fef1c05aec030c0bf568b35281efe453ea450a7"
|
||||
checksum = "ac5e145e8ade9f74c0a5efc60ccb4e714b0144f7e2220b7ca64254feee71c57f"
|
||||
dependencies = [
|
||||
"hybrid-array",
|
||||
"hybrid-array 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -580,15 +583,12 @@ name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
dependencies = [
|
||||
"spin",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.150"
|
||||
version = "0.2.169"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
|
||||
checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
|
||||
|
||||
[[package]]
|
||||
name = "libm"
|
||||
@@ -608,10 +608,10 @@ version = "0.1.0-pre"
|
||||
dependencies = [
|
||||
"digest",
|
||||
"hex",
|
||||
"hex-literal",
|
||||
"hybrid-array",
|
||||
"rand",
|
||||
"rand_core",
|
||||
"hex-literal 0.4.1",
|
||||
"hybrid-array 0.3.0",
|
||||
"rand 0.9.0",
|
||||
"rand_core 0.9.2",
|
||||
"sha2",
|
||||
"signature",
|
||||
"static_assertions",
|
||||
@@ -631,6 +631,27 @@ version = "2.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
|
||||
|
||||
[[package]]
|
||||
name = "ml-dsa"
|
||||
version = "0.1.0-pre.2"
|
||||
dependencies = [
|
||||
"const-oid",
|
||||
"criterion",
|
||||
"hex",
|
||||
"hex-literal 1.0.0",
|
||||
"hybrid-array 0.3.0",
|
||||
"num-traits",
|
||||
"pkcs8",
|
||||
"proptest",
|
||||
"rand 0.9.0",
|
||||
"rand_core 0.9.2",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha3",
|
||||
"signature",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.4.6"
|
||||
@@ -641,23 +662,6 @@ dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint-dig"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"lazy_static",
|
||||
"libm",
|
||||
"num-integer",
|
||||
"num-iter",
|
||||
"num-traits",
|
||||
"rand",
|
||||
"smallvec",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.46"
|
||||
@@ -667,17 +671,6 @@ dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-iter"
|
||||
version = "0.1.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
@@ -708,18 +701,18 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||
|
||||
[[package]]
|
||||
name = "pem-rfc7468"
|
||||
version = "1.0.0-rc.1"
|
||||
version = "1.0.0-rc.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6c1cde4770761bf6bd336f947b9ac1fe700b0a4ec5867cf66cf08597fe89e8c"
|
||||
checksum = "c2dfbfa5c6f0906884269722c5478e72fd4d6c0e24fe600332c6d62359567ce1"
|
||||
dependencies = [
|
||||
"base64ct",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkcs8"
|
||||
version = "0.11.0-rc.1"
|
||||
version = "0.11.0-rc.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eacd2c7141f32aef1cfd1ad0defb5287a3d94592d7ab57c1ae20e3f9f1f0db1f"
|
||||
checksum = "f22636de7c995e997ed3d8d2949b7414d4faba3efa7312a6c0e75d875a14bdd4"
|
||||
dependencies = [
|
||||
"der",
|
||||
"spki",
|
||||
@@ -779,8 +772,8 @@ dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
"lazy_static",
|
||||
"num-traits",
|
||||
"rand",
|
||||
"rand_chacha",
|
||||
"rand 0.8.5",
|
||||
"rand_chacha 0.3.1",
|
||||
"rand_xorshift",
|
||||
"regex-syntax",
|
||||
"rusty-fork",
|
||||
@@ -802,7 +795,7 @@ checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"log",
|
||||
"rand",
|
||||
"rand 0.8.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -832,8 +825,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_chacha 0.3.1",
|
||||
"rand_core 0.6.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94"
|
||||
dependencies = [
|
||||
"rand_chacha 0.9.0",
|
||||
"rand_core 0.9.2",
|
||||
"zerocopy 0.8.20",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -843,7 +847,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.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -852,7 +866,17 @@ version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"getrandom 0.2.11",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a509b1a2ffbe92afab0e55c8fd99dea1c280e8171bd2d88682bb20bc41cbc2c"
|
||||
dependencies = [
|
||||
"getrandom 0.3.1",
|
||||
"zerocopy 0.8.20",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -861,7 +885,7 @@ version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
"rand_core 0.6.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -926,7 +950,7 @@ checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
|
||||
name = "rfc6979"
|
||||
version = "0.5.0-pre.4"
|
||||
dependencies = [
|
||||
"hex-literal",
|
||||
"hex-literal 1.0.0",
|
||||
"hmac",
|
||||
"sha2",
|
||||
"subtle",
|
||||
@@ -974,13 +998,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sec1"
|
||||
version = "0.8.0-rc.2"
|
||||
version = "0.8.0-rc.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce9453a41af5251f8439173d21b0ed2ae5d4a7c411abb76661806a44811a9d2c"
|
||||
checksum = "a017a4aa8f0bd51e9d0184d98042dfe9285218fec098493f47d9a8aa0f1a3f27"
|
||||
dependencies = [
|
||||
"base16ct",
|
||||
"der",
|
||||
"hybrid-array",
|
||||
"hybrid-array 0.3.0",
|
||||
"pkcs8",
|
||||
"serdect",
|
||||
"subtle",
|
||||
@@ -1030,30 +1054,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serdect"
|
||||
version = "0.3.0-rc.0"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a504c8ee181e3e594d84052f983d60afe023f4d94d050900be18062bbbf7b58"
|
||||
checksum = "f42f67da2385b51a5f9652db9c93d78aeaf7610bf5ec366080b6de810604af53"
|
||||
dependencies = [
|
||||
"base16ct",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha1"
|
||||
version = "0.11.0-pre.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9540978cef7a8498211c1b1c14e5ce920fe5bd524ea84f4a3d72d4602515ae93"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.11.0-pre.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "540c0893cce56cdbcfebcec191ec8e0f470dd1889b6e7a0b503e310a94a168f5"
|
||||
source = "git+https://github.com/RustCrypto/hashes.git#0d0369ff7dab69e98acfb8a08f4724dbda285e04"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
@@ -1063,8 +1075,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "sha3"
|
||||
version = "0.11.0-pre.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e485881f388c2818d709796dc883c1ffcadde9d1f0e054f3a5c14974185261a6"
|
||||
source = "git+https://github.com/RustCrypto/hashes.git#0d0369ff7dab69e98acfb8a08f4724dbda285e04"
|
||||
dependencies = [
|
||||
"digest",
|
||||
"keccak",
|
||||
@@ -1072,12 +1083,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "signature"
|
||||
version = "2.3.0-pre.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "054d71959c7051b9042c26af337f05cc930575ed2604d7d3ced3158383e59734"
|
||||
version = "2.3.0-pre.6"
|
||||
source = "git+https://github.com/RustCrypto/traits.git#28b6e0d3231fa0fb31dc7f6bfdb62d6558bcfdf6"
|
||||
dependencies = [
|
||||
"digest",
|
||||
"rand_core",
|
||||
"rand_core 0.9.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1091,38 +1101,26 @@ dependencies = [
|
||||
"ctr",
|
||||
"digest",
|
||||
"hex",
|
||||
"hex-literal",
|
||||
"hex-literal 1.0.0",
|
||||
"hmac",
|
||||
"hybrid-array",
|
||||
"hybrid-array 0.3.0",
|
||||
"num-bigint",
|
||||
"paste",
|
||||
"pkcs8",
|
||||
"proptest",
|
||||
"quickcheck",
|
||||
"quickcheck_macros",
|
||||
"rand",
|
||||
"rand_core",
|
||||
"rand 0.9.0",
|
||||
"rand_core 0.9.2",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"sha3",
|
||||
"signature",
|
||||
"typenum",
|
||||
"zerocopy",
|
||||
"zerocopy 0.7.35",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970"
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
||||
|
||||
[[package]]
|
||||
name = "spki"
|
||||
version = "0.8.0-rc.0"
|
||||
@@ -1233,6 +1231,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.92"
|
||||
@@ -1395,20 +1402,49 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8"
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.7.34"
|
||||
name = "wit-bindgen-rt"
|
||||
version = "0.33.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087"
|
||||
checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c"
|
||||
dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.7.35"
|
||||
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.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dde3bb8c68a8f3f1ed4ac9221aad6b10cece3e60a8e2ea54a6a2dec806d0084c"
|
||||
dependencies = [
|
||||
"zerocopy-derive 0.8.20",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.7.34"
|
||||
version = "0.7.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b"
|
||||
checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.87",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.8.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eea57037071898bf96a6da35fd626f4f27e9cee3ead2a6c703cf09d472b2e700"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
||||
+34
-11
@@ -1,16 +1,18 @@
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
members = [
|
||||
"dsa",
|
||||
#"dsa",
|
||||
"ecdsa",
|
||||
"ed448",
|
||||
"ed25519",
|
||||
"lms",
|
||||
#"ml-dsa",
|
||||
"ml-dsa",
|
||||
"rfc6979",
|
||||
"slh-dsa"
|
||||
"slh-dsa",
|
||||
]
|
||||
exclude = [
|
||||
"dsa", # still on rand_core 0.8
|
||||
]
|
||||
exclude = ["ml-dsa"] # using rand_core v0.9
|
||||
|
||||
[profile.dev]
|
||||
opt-level = 2
|
||||
@@ -18,11 +20,32 @@ opt-level = 2
|
||||
[patch.crates-io]
|
||||
# A global patch crates-io block is used to avoid duplicate dependencies
|
||||
# when pulling a member crate through git
|
||||
dsa = { path = "./dsa" }
|
||||
ecdsa = { path = "./ecdsa" }
|
||||
#dsa = { path = "./dsa" }
|
||||
ecdsa = { path = "./ecdsa" }
|
||||
ed448-signature = { path = "./ed448" }
|
||||
ed25519 = { path = "./ed25519" }
|
||||
lms-signature = { path = "./lms" }
|
||||
#ml-dsa = { path = "./ml-dsa" }
|
||||
rfc6979 = { path = "./rfc6979" }
|
||||
slh-dsa = { path = "./slh-dsa" }
|
||||
ed25519 = { path = "./ed25519" }
|
||||
lms-signature = { path = "./lms" }
|
||||
ml-dsa = { path = "./ml-dsa" }
|
||||
rfc6979 = { path = "./rfc6979" }
|
||||
slh-dsa = { path = "./slh-dsa" }
|
||||
|
||||
# https://github.com/RustCrypto/hashes/pull/652
|
||||
sha2 = { git = "https://github.com/RustCrypto/hashes.git" }
|
||||
sha3 = { git = "https://github.com/RustCrypto/hashes.git" }
|
||||
|
||||
# https://github.com/RustCrypto/traits/pull/1751
|
||||
# https://github.com/RustCrypto/traits/pull/1767
|
||||
elliptic-curve = { git = "https://github.com/RustCrypto/traits.git" }
|
||||
signature = { git = "https://github.com/RustCrypto/traits.git" }
|
||||
|
||||
# https://github.com/RustCrypto/crypto-bigint/pull/762
|
||||
# https://github.com/RustCrypto/crypto-bigint/pull/765
|
||||
crypto-bigint = { git = "https://github.com/RustCrypto/crypto-bigint.git" }
|
||||
|
||||
# https://github.com/zkcrypto/ff/pull/122
|
||||
ff = { git = "https://github.com/pinkforest/ff.git", branch = "bump-rand-core" }
|
||||
# https://github.com/zkcrypto/group/pull/56
|
||||
group = { git = "https://github.com/pinkforest/group.git", branch = "bump-rand-0.9" }
|
||||
|
||||
# https://github.com/RustCrypto/MACs/pull/178
|
||||
hmac = { git = "https://github.com/RustCrypto/MACs.git" }
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
target/
|
||||
Cargo.lock
|
||||
*.pem
|
||||
*.der
|
||||
|
||||
Generated
+400
@@ -0,0 +1,400 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
||||
|
||||
[[package]]
|
||||
name = "base64ct"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.11.0-rc.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fd016a0ddc7cb13661bf5576073ce07330a693f8608a1320b4e20561cc12cdc"
|
||||
dependencies = [
|
||||
"hybrid-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "const-oid"
|
||||
version = "0.10.0-rc.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68ff6be19477a1bd5441f382916a89bc2a0b2c35db6d41e0f6e8538bf6d6463f"
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.2.0-rc.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0b8ce8218c97789f16356e7896b3714f26c2ee1079b79c0b7ae7064bb9089fa"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"hybrid-array",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "der"
|
||||
version = "0.8.0-rc.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82db698b33305f0134faf590b9d1259dc171b5481ac41d5c8146c3b3ee7d4319"
|
||||
dependencies = [
|
||||
"const-oid",
|
||||
"pem-rfc7468",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.11.0-pre.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf2e3d6615d99707295a9673e889bf363a04b2a466bd320c65a72536f7577379"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"const-oid",
|
||||
"crypto-common",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dsa"
|
||||
version = "0.7.0-pre.1"
|
||||
dependencies = [
|
||||
"digest",
|
||||
"num-bigint-dig",
|
||||
"num-traits",
|
||||
"pkcs8",
|
||||
"rand",
|
||||
"rand_chacha",
|
||||
"rfc6979",
|
||||
"sha1",
|
||||
"sha2",
|
||||
"signature",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hmac"
|
||||
version = "0.13.0-pre.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e4b1fb14e4df79f9406b434b60acef9f45c26c50062cccf1346c6103b8c47d58"
|
||||
dependencies = [
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hybrid-array"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2d35805454dc9f8662a98d6d61886ffe26bd465f5960e0e55345c70d5c0d2a9"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
dependencies = [
|
||||
"spin",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.169"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
|
||||
|
||||
[[package]]
|
||||
name = "libm"
|
||||
version = "0.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint-dig"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"lazy_static",
|
||||
"libm",
|
||||
"num-integer",
|
||||
"num-iter",
|
||||
"num-traits",
|
||||
"rand",
|
||||
"smallvec",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.46"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-iter"
|
||||
version = "0.1.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pem-rfc7468"
|
||||
version = "1.0.0-rc.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2dfbfa5c6f0906884269722c5478e72fd4d6c0e24fe600332c6d62359567ce1"
|
||||
dependencies = [
|
||||
"base64ct",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkcs8"
|
||||
version = "0.11.0-rc.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f22636de7c995e997ed3d8d2949b7414d4faba3efa7312a6c0e75d875a14bdd4"
|
||||
dependencies = [
|
||||
"der",
|
||||
"spki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04"
|
||||
dependencies = [
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.93"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[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",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rfc6979"
|
||||
version = "0.5.0-pre.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "871ee76a3eee98b0f805e5d1caf26929f4565073c580c053a55f886fc15dea49"
|
||||
dependencies = [
|
||||
"hmac",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha1"
|
||||
version = "0.11.0-pre.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9540978cef7a8498211c1b1c14e5ce920fe5bd524ea84f4a3d72d4602515ae93"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.11.0-pre.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "540c0893cce56cdbcfebcec191ec8e0f470dd1889b6e7a0b503e310a94a168f5"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signature"
|
||||
version = "2.3.0-pre.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "054d71959c7051b9042c26af337f05cc930575ed2604d7d3ced3158383e59734"
|
||||
dependencies = [
|
||||
"digest",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd"
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.9.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
||||
|
||||
[[package]]
|
||||
name = "spki"
|
||||
version = "0.8.0-rc.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37ac66481418fd7afdc584adcf3be9aa572cf6c2858814494dc2a01755f050bc"
|
||||
dependencies = [
|
||||
"base64ct",
|
||||
"der",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
version = "2.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.98"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.7.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"zerocopy-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.7.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zeroize"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
|
||||
+6
-6
@@ -13,24 +13,24 @@ repository = "https://github.com/RustCrypto/signatures"
|
||||
readme = "README.md"
|
||||
categories = ["cryptography", "no-std"]
|
||||
keywords = ["crypto", "ecc", "nist", "secp256k1", "signature"]
|
||||
edition = "2021"
|
||||
rust-version = "1.81"
|
||||
edition = "2024"
|
||||
rust-version = "1.85"
|
||||
|
||||
[dependencies]
|
||||
elliptic-curve = { version = "0.14.0-rc.1", default-features = false, features = ["digest", "sec1"] }
|
||||
signature = { version = "=2.3.0-pre.4", default-features = false, features = ["rand_core"] }
|
||||
signature = { version = "=2.3.0-pre.6", default-features = false, features = ["rand_core"] }
|
||||
|
||||
# optional dependencies
|
||||
der = { version = "0.8.0-rc.1", optional = true }
|
||||
digest = { version = "=0.11.0-pre.9", optional = true, default-features = false, features = ["oid"] }
|
||||
digest = { version = "=0.11.0-pre.10", optional = true, default-features = false, features = ["oid"] }
|
||||
rfc6979 = { version = "=0.5.0-pre.4", optional = true }
|
||||
serdect = { version = "0.3.0-rc.0", optional = true, default-features = false, features = ["alloc"] }
|
||||
serdect = { version = "0.3", optional = true, default-features = false, features = ["alloc"] }
|
||||
sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false, features = ["oid"] }
|
||||
spki = { version = "0.8.0-rc.0", optional = true, default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
elliptic-curve = { version = "0.14.0-rc.1", default-features = false, features = ["dev"] }
|
||||
hex-literal = "0.4"
|
||||
hex-literal = "1"
|
||||
sha2 = { version = "=0.11.0-pre.4", default-features = false }
|
||||
|
||||
[features]
|
||||
|
||||
+1
-8
@@ -39,13 +39,6 @@ properly assessed for a specific elliptic curve.
|
||||
|
||||
USE AT YOUR OWN RISK!
|
||||
|
||||
## Minimum Supported Rust Version
|
||||
|
||||
This crate requires **Rust 1.73** at a minimum.
|
||||
|
||||
We may change the MSRV in the future, but it will be accompanied by a minor
|
||||
version bump.
|
||||
|
||||
## License
|
||||
|
||||
All crates licensed under either of
|
||||
@@ -70,7 +63,7 @@ dual licensed as above, without any additional terms or conditions.
|
||||
[build-image]: https://github.com/RustCrypto/signatures/actions/workflows/ecdsa.yml/badge.svg
|
||||
[build-link]: https://github.com/RustCrypto/signatures/actions/workflows/ecdsa.yml
|
||||
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
|
||||
[rustc-image]: https://img.shields.io/badge/rustc-1.73+-blue.svg
|
||||
[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg
|
||||
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
|
||||
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260048-signatures
|
||||
|
||||
|
||||
+42
-36
@@ -8,22 +8,22 @@ use core::{
|
||||
fmt::{self, Debug},
|
||||
ops::{Add, Range},
|
||||
};
|
||||
use der::{asn1::UintRef, Decode, Encode, FixedTag, Header, Length, Reader, Tag, Writer};
|
||||
use der::{Decode, Encode, FixedTag, Header, Length, Reader, Tag, Writer, asn1::UintRef};
|
||||
use elliptic_curve::{
|
||||
array::{typenum::Unsigned, Array, ArraySize},
|
||||
consts::U9,
|
||||
FieldBytesSize,
|
||||
array::{Array, ArraySize, typenum::Unsigned},
|
||||
consts::U9,
|
||||
};
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
use {
|
||||
alloc::{boxed::Box, vec::Vec},
|
||||
signature::SignatureEncoding,
|
||||
spki::{der::asn1::BitString, SignatureBitStringEncoding},
|
||||
spki::{SignatureBitStringEncoding, der::asn1::BitString},
|
||||
};
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serdect::serde::{de, ser, Deserialize, Serialize};
|
||||
use serdect::serde::{Deserialize, Serialize, de, ser};
|
||||
|
||||
/// Maximum overhead of an ASN.1 DER-encoded ECDSA signature for a given curve:
|
||||
/// 9-bytes.
|
||||
@@ -422,45 +422,51 @@ mod tests {
|
||||
assert!(Signature::from_der(&[]).is_err());
|
||||
assert!(Signature::from_der(&[der::Tag::Sequence.into()]).is_err());
|
||||
assert!(Signature::from_der(&[der::Tag::Sequence.into(), 0x00]).is_err());
|
||||
assert!(Signature::from_der(&[
|
||||
der::Tag::Sequence.into(),
|
||||
0x03,
|
||||
der::Tag::Integer.into(),
|
||||
0x01,
|
||||
0x01
|
||||
])
|
||||
.is_err());
|
||||
assert!(
|
||||
Signature::from_der(&[
|
||||
der::Tag::Sequence.into(),
|
||||
0x03,
|
||||
der::Tag::Integer.into(),
|
||||
0x01,
|
||||
0x01
|
||||
])
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_asn1_non_der_signature() {
|
||||
// A minimal 8-byte ASN.1 signature parses OK.
|
||||
assert!(Signature::from_der(&[
|
||||
der::Tag::Sequence.into(),
|
||||
0x06, // length of below
|
||||
der::Tag::Integer.into(),
|
||||
0x01, // length of value
|
||||
0x01, // value=1
|
||||
der::Tag::Integer.into(),
|
||||
0x01, // length of value
|
||||
0x01, // value=1
|
||||
])
|
||||
.is_ok());
|
||||
assert!(
|
||||
Signature::from_der(&[
|
||||
der::Tag::Sequence.into(),
|
||||
0x06, // length of below
|
||||
der::Tag::Integer.into(),
|
||||
0x01, // length of value
|
||||
0x01, // value=1
|
||||
der::Tag::Integer.into(),
|
||||
0x01, // length of value
|
||||
0x01, // value=1
|
||||
])
|
||||
.is_ok()
|
||||
);
|
||||
|
||||
// But length fields that are not minimally encoded should be rejected, as they are not
|
||||
// valid DER, cf.
|
||||
// https://github.com/google/wycheproof/blob/2196000605e4/testvectors/ecdsa_secp256k1_sha256_test.json#L57-L66
|
||||
assert!(Signature::from_der(&[
|
||||
der::Tag::Sequence.into(),
|
||||
0x81, // extended length: 1 length byte to come
|
||||
0x06, // length of below
|
||||
der::Tag::Integer.into(),
|
||||
0x01, // length of value
|
||||
0x01, // value=1
|
||||
der::Tag::Integer.into(),
|
||||
0x01, // length of value
|
||||
0x01, // value=1
|
||||
])
|
||||
.is_err());
|
||||
assert!(
|
||||
Signature::from_der(&[
|
||||
der::Tag::Sequence.into(),
|
||||
0x81, // extended length: 1 length byte to come
|
||||
0x06, // length of below
|
||||
der::Tag::Integer.into(),
|
||||
0x01, // length of value
|
||||
0x01, // value=1
|
||||
der::Tag::Integer.into(),
|
||||
0x01, // length of value
|
||||
0x01, // value=1
|
||||
])
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -40,10 +40,10 @@ macro_rules! new_signing_test {
|
||||
($curve:path, $vectors:expr) => {
|
||||
use $crate::{
|
||||
elliptic_curve::{
|
||||
array::{typenum::Unsigned, Array},
|
||||
Curve, CurveArithmetic, FieldBytes, NonZeroScalar, Scalar,
|
||||
array::{Array, typenum::Unsigned},
|
||||
bigint::Encoding,
|
||||
group::ff::PrimeField,
|
||||
Curve, CurveArithmetic, FieldBytes, NonZeroScalar, Scalar,
|
||||
},
|
||||
hazmat::sign_prehashed,
|
||||
};
|
||||
@@ -84,14 +84,14 @@ macro_rules! new_signing_test {
|
||||
macro_rules! new_verification_test {
|
||||
($curve:path, $vectors:expr) => {
|
||||
use $crate::{
|
||||
Signature, VerifyingKey,
|
||||
elliptic_curve::{
|
||||
AffinePoint, CurveArithmetic, Scalar,
|
||||
array::Array,
|
||||
group::ff::PrimeField,
|
||||
sec1::{EncodedPoint, FromEncodedPoint},
|
||||
AffinePoint, CurveArithmetic, Scalar,
|
||||
},
|
||||
signature::hazmat::PrehashVerifier,
|
||||
Signature, VerifyingKey,
|
||||
};
|
||||
|
||||
#[test]
|
||||
@@ -147,9 +147,9 @@ macro_rules! new_verification_test {
|
||||
macro_rules! new_wycheproof_test {
|
||||
($name:ident, $test_name: expr, $curve:path) => {
|
||||
use $crate::{
|
||||
Signature,
|
||||
elliptic_curve::{bigint::Integer, sec1::EncodedPoint},
|
||||
signature::Verifier,
|
||||
Signature,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
||||
+7
-5
@@ -12,18 +12,18 @@
|
||||
|
||||
use crate::{EcdsaCurve, Error, Result};
|
||||
use core::cmp;
|
||||
use elliptic_curve::{array::typenum::Unsigned, FieldBytes};
|
||||
use elliptic_curve::{FieldBytes, array::typenum::Unsigned};
|
||||
|
||||
#[cfg(feature = "arithmetic")]
|
||||
use {
|
||||
crate::{RecoveryId, SignatureSize},
|
||||
elliptic_curve::{
|
||||
CurveArithmetic, NonZeroScalar, ProjectivePoint, Scalar,
|
||||
ff::PrimeField,
|
||||
group::{Curve as _, Group},
|
||||
ops::{Invert, LinearCombination, MulByGenerator, Reduce},
|
||||
point::AffineCoordinates,
|
||||
scalar::IsHigh,
|
||||
CurveArithmetic, NonZeroScalar, ProjectivePoint, Scalar,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -31,8 +31,8 @@ use {
|
||||
use {
|
||||
elliptic_curve::FieldBytesSize,
|
||||
signature::{
|
||||
digest::{core_api::BlockSizeUser, Digest, FixedOutput, FixedOutputReset},
|
||||
PrehashSignature,
|
||||
digest::{Digest, FixedOutput, FixedOutputReset, core_api::BlockSizeUser},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -40,7 +40,7 @@ use {
|
||||
use elliptic_curve::FieldBytesEncoding;
|
||||
|
||||
#[cfg(any(feature = "arithmetic", feature = "digest"))]
|
||||
use crate::{elliptic_curve::array::ArraySize, Signature};
|
||||
use crate::{Signature, elliptic_curve::array::ArraySize};
|
||||
|
||||
/// Bind a preferred [`Digest`] algorithm to an elliptic curve type.
|
||||
///
|
||||
@@ -265,7 +265,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn bits2field_size_greater() {
|
||||
let prehash = hex!("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB");
|
||||
let prehash = hex!(
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||
);
|
||||
let field_bytes = bits2field::<MockCurve>(&prehash).unwrap();
|
||||
assert_eq!(
|
||||
field_bytes.as_slice(),
|
||||
|
||||
+7
-7
@@ -73,7 +73,7 @@ mod verifying;
|
||||
pub use crate::recovery::RecoveryId;
|
||||
|
||||
// Re-export the `elliptic-curve` crate (and select types)
|
||||
pub use elliptic_curve::{self, sec1::EncodedPoint, PrimeCurve};
|
||||
pub use elliptic_curve::{self, PrimeCurve, sec1::EncodedPoint};
|
||||
|
||||
// Re-export the `signature` crate (and select types)
|
||||
pub use signature::{self, Error, Result, SignatureEncoding};
|
||||
@@ -85,8 +85,8 @@ pub use crate::verifying::VerifyingKey;
|
||||
|
||||
use core::{fmt, ops::Add};
|
||||
use elliptic_curve::{
|
||||
array::{typenum::Unsigned, Array, ArraySize},
|
||||
FieldBytes, FieldBytesSize, ScalarPrimitive,
|
||||
array::{Array, ArraySize, typenum::Unsigned},
|
||||
};
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
@@ -96,23 +96,23 @@ use alloc::vec::Vec;
|
||||
use {
|
||||
core::str,
|
||||
elliptic_curve::{
|
||||
scalar::IsHigh, subtle::ConditionallySelectable, CurveArithmetic, NonZeroScalar,
|
||||
CurveArithmetic, NonZeroScalar, scalar::IsHigh, subtle::ConditionallySelectable,
|
||||
},
|
||||
};
|
||||
|
||||
#[cfg(feature = "digest")]
|
||||
use digest::{
|
||||
const_oid::{AssociatedOid, ObjectIdentifier},
|
||||
Digest,
|
||||
const_oid::{AssociatedOid, ObjectIdentifier},
|
||||
};
|
||||
|
||||
#[cfg(feature = "pkcs8")]
|
||||
use elliptic_curve::pkcs8::spki::{
|
||||
der::AnyRef, AlgorithmIdentifierRef, AssociatedAlgorithmIdentifier,
|
||||
AlgorithmIdentifierRef, AssociatedAlgorithmIdentifier, der::AnyRef,
|
||||
};
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serdect::serde::{de, ser, Deserialize, Serialize};
|
||||
use serdect::serde::{Deserialize, Serialize, de, ser};
|
||||
|
||||
#[cfg(all(feature = "alloc", feature = "pkcs8"))]
|
||||
use elliptic_curve::pkcs8::spki::{
|
||||
@@ -431,7 +431,7 @@ where
|
||||
type Err = Error;
|
||||
|
||||
fn from_str(hex: &str) -> Result<Self> {
|
||||
if hex.as_bytes().len() != C::FieldBytesSize::USIZE * 4 {
|
||||
if hex.len() != C::FieldBytesSize::USIZE * 4 {
|
||||
return Err(Error::new());
|
||||
}
|
||||
|
||||
|
||||
+24
-24
@@ -4,35 +4,35 @@ use crate::{Error, Result};
|
||||
|
||||
#[cfg(feature = "signing")]
|
||||
use {
|
||||
crate::{hazmat::sign_prehashed_rfc6979, SigningKey},
|
||||
elliptic_curve::{subtle::CtOption, FieldBytes},
|
||||
crate::{SigningKey, hazmat::sign_prehashed_rfc6979},
|
||||
elliptic_curve::{FieldBytes, subtle::CtOption},
|
||||
signature::{
|
||||
DigestSigner, RandomizedDigestSigner, Signer,
|
||||
digest::FixedOutput,
|
||||
hazmat::{PrehashSigner, RandomizedPrehashSigner},
|
||||
rand_core::CryptoRngCore,
|
||||
DigestSigner, RandomizedDigestSigner, Signer,
|
||||
rand_core::TryCryptoRng,
|
||||
},
|
||||
};
|
||||
|
||||
#[cfg(feature = "verifying")]
|
||||
use {
|
||||
crate::{hazmat::verify_prehashed, VerifyingKey},
|
||||
crate::{VerifyingKey, hazmat::verify_prehashed},
|
||||
elliptic_curve::{
|
||||
AffinePoint, FieldBytesEncoding, FieldBytesSize, Group, PrimeField, ProjectivePoint,
|
||||
bigint::CheckedAdd,
|
||||
ops::{LinearCombination, Reduce},
|
||||
point::DecompressPoint,
|
||||
sec1::{self, FromEncodedPoint, ToEncodedPoint},
|
||||
AffinePoint, FieldBytesEncoding, FieldBytesSize, Group, PrimeField, ProjectivePoint,
|
||||
},
|
||||
};
|
||||
|
||||
#[cfg(any(feature = "signing", feature = "verifying"))]
|
||||
use {
|
||||
crate::{
|
||||
hazmat::{bits2field, DigestPrimitive},
|
||||
EcdsaCurve, Signature, SignatureSize,
|
||||
hazmat::{DigestPrimitive, bits2field},
|
||||
},
|
||||
elliptic_curve::{array::ArraySize, ops::Invert, CurveArithmetic, Scalar},
|
||||
elliptic_curve::{CurveArithmetic, Scalar, array::ArraySize, ops::Invert},
|
||||
signature::digest::Digest,
|
||||
};
|
||||
|
||||
@@ -61,7 +61,7 @@ impl RecoveryId {
|
||||
/// - `is_y_odd`: is the affine y-coordinate of 𝑘×𝑮 odd?
|
||||
/// - `is_x_reduced`: did the affine x-coordinate of 𝑘×𝑮 overflow the curve order?
|
||||
pub const fn new(is_y_odd: bool, is_x_reduced: bool) -> Self {
|
||||
Self((is_x_reduced as u8) << 1 | (is_y_odd as u8))
|
||||
Self(((is_x_reduced as u8) << 1) | (is_y_odd as u8))
|
||||
}
|
||||
|
||||
/// Did the affine x-coordinate of 𝑘×𝑮 overflow the curve order?
|
||||
@@ -185,14 +185,14 @@ where
|
||||
{
|
||||
/// Sign the given message prehash, using the given rng for the RFC6979 Section 3.6 "additional
|
||||
/// data", returning a signature and recovery ID.
|
||||
pub fn sign_prehash_recoverable_with_rng(
|
||||
pub fn sign_prehash_recoverable_with_rng<R: TryCryptoRng + ?Sized>(
|
||||
&self,
|
||||
rng: &mut impl CryptoRngCore,
|
||||
rng: &mut R,
|
||||
prehash: &[u8],
|
||||
) -> Result<(Signature<C>, RecoveryId)> {
|
||||
let z = bits2field::<C>(prehash)?;
|
||||
let mut ad = FieldBytes::<C>::default();
|
||||
rng.fill_bytes(&mut ad);
|
||||
rng.try_fill_bytes(&mut ad).map_err(|_| Error::new())?;
|
||||
sign_prehashed_rfc6979::<C, C::Digest>(self.as_nonzero_scalar(), &z, &ad)
|
||||
}
|
||||
|
||||
@@ -237,9 +237,9 @@ where
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
fn sign_prehash_with_rng(
|
||||
fn sign_prehash_with_rng<R: TryCryptoRng + ?Sized>(
|
||||
&self,
|
||||
rng: &mut impl CryptoRngCore,
|
||||
rng: &mut R,
|
||||
prehash: &[u8],
|
||||
) -> Result<(Signature<C>, RecoveryId)> {
|
||||
self.sign_prehash_recoverable_with_rng(rng, prehash)
|
||||
@@ -254,9 +254,9 @@ where
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
fn try_sign_digest_with_rng(
|
||||
fn try_sign_digest_with_rng<R: TryCryptoRng + ?Sized>(
|
||||
&self,
|
||||
rng: &mut impl CryptoRngCore,
|
||||
rng: &mut R,
|
||||
msg_digest: D,
|
||||
) -> Result<(Signature<C>, RecoveryId)> {
|
||||
self.sign_prehash_with_rng(rng, &msg_digest.finalize_fixed())
|
||||
@@ -403,17 +403,17 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn is_x_reduced() {
|
||||
assert_eq!(RecoveryId::try_from(0).unwrap().is_x_reduced(), false);
|
||||
assert_eq!(RecoveryId::try_from(1).unwrap().is_x_reduced(), false);
|
||||
assert_eq!(RecoveryId::try_from(2).unwrap().is_x_reduced(), true);
|
||||
assert_eq!(RecoveryId::try_from(3).unwrap().is_x_reduced(), true);
|
||||
assert!(!RecoveryId::try_from(0).unwrap().is_x_reduced());
|
||||
assert!(!RecoveryId::try_from(1).unwrap().is_x_reduced());
|
||||
assert!(RecoveryId::try_from(2).unwrap().is_x_reduced());
|
||||
assert!(RecoveryId::try_from(3).unwrap().is_x_reduced());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn is_y_odd() {
|
||||
assert_eq!(RecoveryId::try_from(0).unwrap().is_y_odd(), false);
|
||||
assert_eq!(RecoveryId::try_from(1).unwrap().is_y_odd(), true);
|
||||
assert_eq!(RecoveryId::try_from(2).unwrap().is_y_odd(), false);
|
||||
assert_eq!(RecoveryId::try_from(3).unwrap().is_y_odd(), true);
|
||||
assert!(!RecoveryId::try_from(0).unwrap().is_y_odd());
|
||||
assert!(RecoveryId::try_from(1).unwrap().is_y_odd());
|
||||
assert!(!RecoveryId::try_from(2).unwrap().is_y_odd());
|
||||
assert!(RecoveryId::try_from(3).unwrap().is_y_odd());
|
||||
}
|
||||
}
|
||||
|
||||
+25
-23
@@ -1,24 +1,23 @@
|
||||
//! ECDSA signing: producing signatures using a [`SigningKey`].
|
||||
|
||||
use crate::{
|
||||
ecdsa_oid_for_digest,
|
||||
hazmat::{bits2field, sign_prehashed_rfc6979, DigestPrimitive},
|
||||
EcdsaCurve, Error, Result, Signature, SignatureSize, SignatureWithOid,
|
||||
EcdsaCurve, Error, Result, Signature, SignatureSize, SignatureWithOid, ecdsa_oid_for_digest,
|
||||
hazmat::{DigestPrimitive, bits2field, sign_prehashed_rfc6979},
|
||||
};
|
||||
use core::fmt::{self, Debug};
|
||||
use digest::{const_oid::AssociatedOid, Digest, FixedOutput};
|
||||
use digest::{Digest, FixedOutput, const_oid::AssociatedOid};
|
||||
use elliptic_curve::{
|
||||
CurveArithmetic, FieldBytes, NonZeroScalar, Scalar, SecretKey,
|
||||
array::ArraySize,
|
||||
group::ff::PrimeField,
|
||||
ops::Invert,
|
||||
subtle::{Choice, ConstantTimeEq, CtOption},
|
||||
zeroize::{Zeroize, ZeroizeOnDrop},
|
||||
CurveArithmetic, FieldBytes, NonZeroScalar, Scalar, SecretKey,
|
||||
};
|
||||
use signature::{
|
||||
hazmat::{PrehashSigner, RandomizedPrehashSigner},
|
||||
rand_core::CryptoRngCore,
|
||||
DigestSigner, RandomizedDigestSigner, RandomizedSigner, Signer,
|
||||
hazmat::{PrehashSigner, RandomizedPrehashSigner},
|
||||
rand_core::{CryptoRng, TryCryptoRng},
|
||||
};
|
||||
|
||||
#[cfg(feature = "der")]
|
||||
@@ -29,14 +28,13 @@ use {core::str::FromStr, elliptic_curve::pkcs8::DecodePrivateKey};
|
||||
|
||||
#[cfg(feature = "pkcs8")]
|
||||
use crate::elliptic_curve::{
|
||||
AffinePoint,
|
||||
pkcs8::{
|
||||
self,
|
||||
self, ObjectIdentifier,
|
||||
der::AnyRef,
|
||||
spki::{AlgorithmIdentifier, AssociatedAlgorithmIdentifier, SignatureAlgorithmIdentifier},
|
||||
ObjectIdentifier,
|
||||
},
|
||||
sec1::{self, FromEncodedPoint, ToEncodedPoint},
|
||||
AffinePoint,
|
||||
};
|
||||
|
||||
#[cfg(feature = "verifying")]
|
||||
@@ -83,7 +81,7 @@ where
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
/// Generate a cryptographically random [`SigningKey`].
|
||||
pub fn random(rng: &mut impl CryptoRngCore) -> Self {
|
||||
pub fn random<R: CryptoRng + ?Sized>(rng: &mut R) -> Self {
|
||||
NonZeroScalar::<C>::random(rng).into()
|
||||
}
|
||||
|
||||
@@ -182,9 +180,9 @@ where
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
fn try_sign_digest_with_rng(
|
||||
fn try_sign_digest_with_rng<R: TryCryptoRng + ?Sized>(
|
||||
&self,
|
||||
rng: &mut impl CryptoRngCore,
|
||||
rng: &mut R,
|
||||
msg_digest: D,
|
||||
) -> Result<Signature<C>> {
|
||||
self.sign_prehash_with_rng(rng, &msg_digest.finalize_fixed())
|
||||
@@ -197,14 +195,14 @@ where
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
fn sign_prehash_with_rng(
|
||||
fn sign_prehash_with_rng<R: TryCryptoRng + ?Sized>(
|
||||
&self,
|
||||
rng: &mut impl CryptoRngCore,
|
||||
rng: &mut R,
|
||||
prehash: &[u8],
|
||||
) -> Result<Signature<C>> {
|
||||
let z = bits2field::<C>(prehash)?;
|
||||
let mut ad = FieldBytes::<C>::default();
|
||||
rng.fill_bytes(&mut ad);
|
||||
rng.try_fill_bytes(&mut ad).map_err(|_| Error::new())?;
|
||||
Ok(sign_prehashed_rfc6979::<C, C::Digest>(&self.secret_scalar, &z, &ad)?.0)
|
||||
}
|
||||
}
|
||||
@@ -216,7 +214,11 @@ where
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
fn try_sign_with_rng(&self, rng: &mut impl CryptoRngCore, msg: &[u8]) -> Result<Signature<C>> {
|
||||
fn try_sign_with_rng<R: TryCryptoRng + ?Sized>(
|
||||
&self,
|
||||
rng: &mut R,
|
||||
msg: &[u8],
|
||||
) -> Result<Signature<C>> {
|
||||
self.try_sign_digest_with_rng(rng, C::Digest::new_with_prefix(msg))
|
||||
}
|
||||
}
|
||||
@@ -285,9 +287,9 @@ where
|
||||
der::MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<der::MaxOverhead> + ArraySize,
|
||||
{
|
||||
fn try_sign_digest_with_rng(
|
||||
fn try_sign_digest_with_rng<R: TryCryptoRng + ?Sized>(
|
||||
&self,
|
||||
rng: &mut impl CryptoRngCore,
|
||||
rng: &mut R,
|
||||
msg_digest: D,
|
||||
) -> Result<der::Signature<C>> {
|
||||
RandomizedDigestSigner::<D, Signature<C>>::try_sign_digest_with_rng(self, rng, msg_digest)
|
||||
@@ -304,9 +306,9 @@ where
|
||||
der::MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<der::MaxOverhead> + ArraySize,
|
||||
{
|
||||
fn sign_prehash_with_rng(
|
||||
fn sign_prehash_with_rng<R: TryCryptoRng + ?Sized>(
|
||||
&self,
|
||||
rng: &mut impl CryptoRngCore,
|
||||
rng: &mut R,
|
||||
prehash: &[u8],
|
||||
) -> Result<der::Signature<C>> {
|
||||
RandomizedPrehashSigner::<Signature<C>>::sign_prehash_with_rng(self, rng, prehash)
|
||||
@@ -323,9 +325,9 @@ where
|
||||
der::MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<der::MaxOverhead> + ArraySize,
|
||||
{
|
||||
fn try_sign_with_rng(
|
||||
fn try_sign_with_rng<R: TryCryptoRng + ?Sized>(
|
||||
&self,
|
||||
rng: &mut impl CryptoRngCore,
|
||||
rng: &mut R,
|
||||
msg: &[u8],
|
||||
) -> Result<der::Signature<C>> {
|
||||
RandomizedSigner::<Signature<C>>::try_sign_with_rng(self, rng, msg).map(Into::into)
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
//! ECDSA verifying: checking signatures are authentic using a [`VerifyingKey`].
|
||||
|
||||
use crate::{
|
||||
hazmat::{self, bits2field, DigestPrimitive},
|
||||
EcdsaCurve, Error, Result, Signature, SignatureSize,
|
||||
hazmat::{self, DigestPrimitive, bits2field},
|
||||
};
|
||||
use core::{cmp::Ordering, fmt::Debug};
|
||||
use elliptic_curve::{
|
||||
AffinePoint, CurveArithmetic, FieldBytesSize, ProjectivePoint, PublicKey,
|
||||
array::ArraySize,
|
||||
point::PointCompression,
|
||||
scalar::IsHigh,
|
||||
sec1::{self, CompressedPoint, EncodedPoint, FromEncodedPoint, ToEncodedPoint},
|
||||
AffinePoint, CurveArithmetic, FieldBytesSize, ProjectivePoint, PublicKey,
|
||||
};
|
||||
use signature::{
|
||||
DigestVerifier, Verifier,
|
||||
digest::{Digest, FixedOutput},
|
||||
hazmat::PrehashVerifier,
|
||||
DigestVerifier, Verifier,
|
||||
};
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
@@ -29,21 +29,20 @@ use {core::str::FromStr, elliptic_curve::pkcs8::DecodePublicKey};
|
||||
|
||||
#[cfg(feature = "pkcs8")]
|
||||
use elliptic_curve::pkcs8::{
|
||||
self,
|
||||
self, AssociatedOid, ObjectIdentifier,
|
||||
der::AnyRef,
|
||||
spki::{
|
||||
self, AlgorithmIdentifier, AssociatedAlgorithmIdentifier, SignatureAlgorithmIdentifier,
|
||||
},
|
||||
AssociatedOid, ObjectIdentifier,
|
||||
};
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serdect::serde::{de, ser, Deserialize, Serialize};
|
||||
use serdect::serde::{Deserialize, Serialize, de, ser};
|
||||
|
||||
#[cfg(feature = "sha2")]
|
||||
use {
|
||||
crate::{
|
||||
SignatureWithOid, ECDSA_SHA224_OID, ECDSA_SHA256_OID, ECDSA_SHA384_OID, ECDSA_SHA512_OID,
|
||||
ECDSA_SHA224_OID, ECDSA_SHA256_OID, ECDSA_SHA384_OID, ECDSA_SHA512_OID, SignatureWithOid,
|
||||
},
|
||||
sha2::{Sha224, Sha256, Sha384, Sha512},
|
||||
};
|
||||
|
||||
+6
-6
@@ -14,15 +14,15 @@ repository = "https://github.com/RustCrypto/signatures"
|
||||
readme = "README.md"
|
||||
categories = ["cryptography", "no-std"]
|
||||
keywords = ["crypto", "curve25519", "ecc", "signature", "signing"]
|
||||
edition = "2021"
|
||||
rust-version = "1.81"
|
||||
edition = "2024"
|
||||
rust-version = "1.85"
|
||||
|
||||
[dependencies]
|
||||
# TODO(tarcieri): relax requirement back to `2` before next release
|
||||
signature = { version = "=2.3.0-pre.4", default-features = false }
|
||||
signature = { version = "=2.3.0-pre.6", default-features = false }
|
||||
|
||||
# optional dependencies
|
||||
pkcs8 = { version = "0.11.0-rc.1", optional = true }
|
||||
pkcs8 = { version = "0.11.0-rc.2", optional = true }
|
||||
serde = { version = "1", optional = true, default-features = false }
|
||||
serde_bytes = { version = "0.11", optional = true }
|
||||
zeroize = { version = "1", optional = true, default-features = false }
|
||||
@@ -30,9 +30,9 @@ zeroize = { version = "1", optional = true, default-features = false }
|
||||
[dev-dependencies]
|
||||
bincode = "1"
|
||||
#ed25519-dalek = { version = "2", features = ["rand_core"] }
|
||||
hex-literal = "0.4"
|
||||
hex-literal = "1"
|
||||
#ring-compat = { version = "0.8", default-features = false, features = ["signature"] }
|
||||
rand_core = { version = "0.6", features = ["std"] }
|
||||
rand_core = { version = "0.9", features = ["std"] }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
|
||||
+1
-10
@@ -24,15 +24,6 @@ to be written abstractly in such a way that different signer/verifier
|
||||
providers can be plugged in, enabling support for using different
|
||||
Ed25519 implementations, including HSMs or Cloud KMS services.
|
||||
|
||||
## Minimum Supported Rust Version
|
||||
|
||||
This crate requires **Rust 1.72** at a minimum.
|
||||
|
||||
Our policy is to allow MSRV to be raised in future released without that
|
||||
qualifing as a SemVer-breaking change, but it will be accompanied by a minor
|
||||
version bump, ensuring if you lock to a minor version MSRV will be preserved
|
||||
for the default feature set.
|
||||
|
||||
## SemVer Policy
|
||||
|
||||
- All on-by-default features of this library are covered by SemVer
|
||||
@@ -64,7 +55,7 @@ dual licensed as above, without any additional terms or conditions.
|
||||
[build-image]: https://github.com/RustCrypto/signatures/actions/workflows/ed25519.yml/badge.svg
|
||||
[build-link]: https://github.com/RustCrypto/signatures/actions/workflows/ed25519.yml
|
||||
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
|
||||
[rustc-image]: https://img.shields.io/badge/rustc-1.72+-blue.svg
|
||||
[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg
|
||||
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
|
||||
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260048-signatures
|
||||
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ impl str::FromStr for Signature {
|
||||
type Err = Error;
|
||||
|
||||
fn from_str(hex: &str) -> signature::Result<Self> {
|
||||
if hex.as_bytes().len() != Signature::BYTE_SIZE * 2 {
|
||||
if hex.len() != Signature::BYTE_SIZE * 2 {
|
||||
return Err(Error::new());
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -274,11 +274,11 @@ pub use signature::{self, Error, SignatureEncoding};
|
||||
|
||||
#[cfg(feature = "pkcs8")]
|
||||
pub use crate::pkcs8::{
|
||||
spki::{
|
||||
der::{oid::ObjectIdentifier, AnyRef},
|
||||
AlgorithmIdentifierRef, AssociatedAlgorithmIdentifier,
|
||||
},
|
||||
KeypairBytes, PublicKeyBytes,
|
||||
spki::{
|
||||
AlgorithmIdentifierRef, AssociatedAlgorithmIdentifier,
|
||||
der::{AnyRef, oid::ObjectIdentifier},
|
||||
},
|
||||
};
|
||||
|
||||
use core::fmt;
|
||||
@@ -288,8 +288,8 @@ use alloc::vec::Vec;
|
||||
|
||||
#[cfg(all(feature = "alloc", feature = "pkcs8"))]
|
||||
use pkcs8::spki::{
|
||||
der::{self, asn1::BitString},
|
||||
SignatureBitStringEncoding,
|
||||
der::{self, asn1::BitString},
|
||||
};
|
||||
|
||||
/// Size of a single component of an Ed25519 signature.
|
||||
|
||||
@@ -15,16 +15,16 @@
|
||||
//! breaking changes when using this module.
|
||||
|
||||
pub use pkcs8::{
|
||||
spki, DecodePrivateKey, DecodePublicKey, Error, ObjectIdentifier, PrivateKeyInfoRef, Result,
|
||||
DecodePrivateKey, DecodePublicKey, Error, ObjectIdentifier, PrivateKeyInfoRef, Result, spki,
|
||||
};
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
pub use pkcs8::{spki::EncodePublicKey, EncodePrivateKey};
|
||||
pub use pkcs8::{EncodePrivateKey, spki::EncodePublicKey};
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
pub use pkcs8::der::{
|
||||
asn1::{BitStringRef, OctetStringRef},
|
||||
Document, SecretDocument,
|
||||
asn1::{BitStringRef, OctetStringRef},
|
||||
};
|
||||
|
||||
use core::fmt;
|
||||
@@ -351,7 +351,9 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
valid_keypair.to_bytes().unwrap(),
|
||||
hex!("D4EE72DBF913584AD5B6D8F1F769F8AD3AFE7C28CBF1D4FBE097A88F4475584219BF44096984CDFE8541BAC167DC3B96C85086AA30B6B6CB0C5C38AD703166E1")
|
||||
hex!(
|
||||
"D4EE72DBF913584AD5B6D8F1F769F8AD3AFE7C28CBF1D4FBE097A88F4475584219BF44096984CDFE8541BAC167DC3B96C85086AA30B6B6CB0C5C38AD703166E1"
|
||||
)
|
||||
);
|
||||
|
||||
let invalid_keypair = KeypairBytes {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! `serde` support.
|
||||
|
||||
use crate::{Signature, SignatureBytes};
|
||||
use ::serde::{de, ser, Deserialize, Serialize};
|
||||
use ::serde::{Deserialize, Serialize, de, ser};
|
||||
use core::fmt;
|
||||
|
||||
impl Serialize for Signature {
|
||||
@@ -72,7 +72,7 @@ impl<'de> serde_bytes::Deserialize<'de> for Signature {
|
||||
{
|
||||
struct ByteArrayVisitor;
|
||||
|
||||
impl<'de> de::Visitor<'de> for ByteArrayVisitor {
|
||||
impl de::Visitor<'_> for ByteArrayVisitor {
|
||||
type Value = SignatureBytes;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
|
||||
+15
-4
@@ -16,19 +16,28 @@ const TEST_1_SIGNATURE: [u8; Signature::BYTE_SIZE] = hex!(
|
||||
#[test]
|
||||
fn display() {
|
||||
let sig = Signature::from_bytes(&TEST_1_SIGNATURE);
|
||||
assert_eq!(sig.to_string(), "E5564300C360AC729086E2CC806E828A84877F1EB8E5D974D873E065224901555FB8821590A33BACC61E39701CF9B46BD25BF5F0595BBE24655141438E7A100B")
|
||||
assert_eq!(
|
||||
sig.to_string(),
|
||||
"E5564300C360AC729086E2CC806E828A84877F1EB8E5D974D873E065224901555FB8821590A33BACC61E39701CF9B46BD25BF5F0595BBE24655141438E7A100B"
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lower_hex() {
|
||||
let sig = Signature::from_bytes(&TEST_1_SIGNATURE);
|
||||
assert_eq!(format!("{:x}", sig), "e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b")
|
||||
assert_eq!(
|
||||
format!("{:x}", sig),
|
||||
"e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b"
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn upper_hex() {
|
||||
let sig = Signature::from_bytes(&TEST_1_SIGNATURE);
|
||||
assert_eq!(format!("{:X}", sig), "E5564300C360AC729086E2CC806E828A84877F1EB8E5D974D873E065224901555FB8821590A33BACC61E39701CF9B46BD25BF5F0595BBE24655141438E7A100B")
|
||||
assert_eq!(
|
||||
format!("{:X}", sig),
|
||||
"E5564300C360AC729086E2CC806E828A84877F1EB8E5D974D873E065224901555FB8821590A33BACC61E39701CF9B46BD25BF5F0595BBE24655141438E7A100B"
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -45,6 +54,8 @@ fn from_str_upper() {
|
||||
|
||||
#[test]
|
||||
fn from_str_rejects_mixed_case() {
|
||||
let result = Signature::from_str("E5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b");
|
||||
let result = Signature::from_str(
|
||||
"E5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b",
|
||||
);
|
||||
assert!(result.is_err());
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "ed448-signature"
|
||||
version = "0.0.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
authors = ["RustCrypto Developers"]
|
||||
license = "Apache-2.0 OR MIT"
|
||||
description = """
|
||||
@@ -15,20 +15,20 @@ repository = "https://github.com/RustCrypto/signatures"
|
||||
readme = "README.md"
|
||||
categories = ["cryptography", "no-std"]
|
||||
keywords = ["crypto", "curve448", "ecc", "signature", "signing"]
|
||||
rust-version = "1.81"
|
||||
rust-version = "1.85"
|
||||
|
||||
[dependencies]
|
||||
# TODO(tarcieri): relax requirement back to `2` before next release
|
||||
signature = { version = "=2.3.0-pre.4", default-features = false }
|
||||
signature = { version = "=2.3.0-pre.6", default-features = false }
|
||||
|
||||
# optional dependencies
|
||||
pkcs8 = { version = "=0.11.0-rc.1", optional = true }
|
||||
pkcs8 = { version = "0.11.0-rc.1", optional = true }
|
||||
serde = { version = "1", optional = true, default-features = false }
|
||||
serde_bytes = { version = "0.11", optional = true }
|
||||
zeroize = { version = "1", optional = true, default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
hex-literal = "0.4"
|
||||
hex-literal = "1"
|
||||
bincode = "1"
|
||||
|
||||
[features]
|
||||
|
||||
+1
-10
@@ -24,15 +24,6 @@ to be written abstractly in such a way that different signer/verifier
|
||||
providers can be plugged in, enabling support for using different
|
||||
Ed448 implementations, including HSMs or Cloud KMS services.
|
||||
|
||||
## Minimum Supported Rust Version
|
||||
|
||||
This crate requires **Rust 1.72** at a minimum.
|
||||
|
||||
Our policy is to allow MSRV to be raised in future released without that
|
||||
qualifing as a SemVer-breaking change, but it will be accompanied by a minor
|
||||
version bump, ensuring if you lock to a minor version MSRV will be preserved
|
||||
for the default feature set.
|
||||
|
||||
## SemVer Policy
|
||||
|
||||
- All on-by-default features of this library are covered by SemVer
|
||||
@@ -64,7 +55,7 @@ dual licensed as above, without any additional terms or conditions.
|
||||
[build-image]: https://github.com/RustCrypto/signatures/actions/workflows/ed448.yml/badge.svg
|
||||
[build-link]: https://github.com/RustCrypto/signatures/actions/workflows/ed448.yml
|
||||
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
|
||||
[rustc-image]: https://img.shields.io/badge/rustc-1.712-blue.svg
|
||||
[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg
|
||||
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
|
||||
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260048-signatures
|
||||
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ impl str::FromStr for Signature {
|
||||
type Err = Error;
|
||||
|
||||
fn from_str(hex: &str) -> signature::Result<Self> {
|
||||
if hex.as_bytes().len() != Signature::BYTE_SIZE * 2 {
|
||||
if hex.len() != Signature::BYTE_SIZE * 2 {
|
||||
return Err(Error::new());
|
||||
}
|
||||
|
||||
|
||||
+12
-8
@@ -15,16 +15,16 @@
|
||||
//! breaking changes when using this module.
|
||||
|
||||
pub use pkcs8::{
|
||||
spki, DecodePrivateKey, DecodePublicKey, Error, ObjectIdentifier, PrivateKeyInfoRef, Result,
|
||||
DecodePrivateKey, DecodePublicKey, Error, ObjectIdentifier, PrivateKeyInfoRef, Result, spki,
|
||||
};
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
pub use pkcs8::{spki::EncodePublicKey, EncodePrivateKey};
|
||||
pub use pkcs8::{EncodePrivateKey, spki::EncodePublicKey};
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
pub use pkcs8::der::{
|
||||
asn1::{BitStringRef, OctetStringRef},
|
||||
Document, SecretDocument,
|
||||
asn1::{BitStringRef, OctetStringRef},
|
||||
};
|
||||
|
||||
#[cfg(feature = "zeroize")]
|
||||
@@ -271,11 +271,13 @@ mod tests {
|
||||
use super::{KeypairBytes, PublicKeyBytes};
|
||||
use hex_literal::hex;
|
||||
|
||||
const SECRET_KEY_BYTES: [u8; 57] =
|
||||
hex!("8A57471AA375074DC7D75EA2252E9933BB15C107E4F9A2F9CFEA6C418BEBB0774D1ABB671B58B96EFF95F35D63F2418422A59C7EAE3E00D70F");
|
||||
const SECRET_KEY_BYTES: [u8; 57] = hex!(
|
||||
"8A57471AA375074DC7D75EA2252E9933BB15C107E4F9A2F9CFEA6C418BEBB0774D1ABB671B58B96EFF95F35D63F2418422A59C7EAE3E00D70F"
|
||||
);
|
||||
|
||||
const PUBLIC_KEY_BYTES: [u8; 57] =
|
||||
hex!("f27f9809412035541b681c69fbe69b9d25a6af506d914ecef7d973fca04ccd33a8b96a0868211382ca08fe06b72e8c0cb3297f3a9d6bc02380");
|
||||
const PUBLIC_KEY_BYTES: [u8; 57] = hex!(
|
||||
"f27f9809412035541b681c69fbe69b9d25a6af506d914ecef7d973fca04ccd33a8b96a0868211382ca08fe06b72e8c0cb3297f3a9d6bc02380"
|
||||
);
|
||||
|
||||
#[test]
|
||||
fn to_bytes() {
|
||||
@@ -286,7 +288,9 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
valid_keypair.to_bytes().unwrap(),
|
||||
hex!("8A57471AA375074DC7D75EA2252E9933BB15C107E4F9A2F9CFEA6C418BEBB0774D1ABB671B58B96EFF95F35D63F2418422A59C7EAE3E00D70Ff27f9809412035541b681c69fbe69b9d25a6af506d914ecef7d973fca04ccd33a8b96a0868211382ca08fe06b72e8c0cb3297f3a9d6bc02380")
|
||||
hex!(
|
||||
"8A57471AA375074DC7D75EA2252E9933BB15C107E4F9A2F9CFEA6C418BEBB0774D1ABB671B58B96EFF95F35D63F2418422A59C7EAE3E00D70Ff27f9809412035541b681c69fbe69b9d25a6af506d914ecef7d973fca04ccd33a8b96a0868211382ca08fe06b72e8c0cb3297f3a9d6bc02380"
|
||||
)
|
||||
);
|
||||
|
||||
let invalid_keypair = KeypairBytes {
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
//! `serde` support.
|
||||
|
||||
use crate::{Signature, SignatureBytes};
|
||||
use ::serde::{de, ser, Deserialize, Serialize};
|
||||
use ::serde::{Deserialize, Serialize, de, ser};
|
||||
use core::fmt;
|
||||
|
||||
impl Serialize for Signature {
|
||||
@@ -70,7 +70,7 @@ impl<'de> serde_bytes::Deserialize<'de> for Signature {
|
||||
{
|
||||
struct ByteArrayVisitor;
|
||||
|
||||
impl<'de> de::Visitor<'de> for ByteArrayVisitor {
|
||||
impl de::Visitor<'_> for ByteArrayVisitor {
|
||||
type Value = SignatureBytes;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
|
||||
+15
-4
@@ -20,19 +20,28 @@ const TEST_1_SIGNATURE: [u8; Signature::BYTE_SIZE] = hex!(
|
||||
#[test]
|
||||
fn display() {
|
||||
let sig = Signature::from_bytes(&TEST_1_SIGNATURE);
|
||||
assert_eq!(sig.to_string(), "533A37F6BBE457251F023C0D88F976AE2DFB504A843E34D2074FD823D41A591F2B233F034F628281F2FD7A22DDD47D7828C59BD0A21BFD3980FF0D2028D4B18A9DF63E006C5D1C2D345B925D8DC00B4104852DB99AC5C7CDDA8530A113A0F4DBB61149F05A7363268C71D95808FF2E652600")
|
||||
assert_eq!(
|
||||
sig.to_string(),
|
||||
"533A37F6BBE457251F023C0D88F976AE2DFB504A843E34D2074FD823D41A591F2B233F034F628281F2FD7A22DDD47D7828C59BD0A21BFD3980FF0D2028D4B18A9DF63E006C5D1C2D345B925D8DC00B4104852DB99AC5C7CDDA8530A113A0F4DBB61149F05A7363268C71D95808FF2E652600"
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lower_hex() {
|
||||
let sig = Signature::from_bytes(&TEST_1_SIGNATURE);
|
||||
assert_eq!(format!("{:x}", sig), "533a37f6bbe457251f023c0d88f976ae2dfb504a843e34d2074fd823d41a591f2b233f034f628281f2fd7a22ddd47d7828c59bd0a21bfd3980ff0d2028d4b18a9df63e006c5d1c2d345b925d8dc00b4104852db99ac5c7cdda8530a113a0f4dbb61149f05a7363268c71d95808ff2e652600")
|
||||
assert_eq!(
|
||||
format!("{:x}", sig),
|
||||
"533a37f6bbe457251f023c0d88f976ae2dfb504a843e34d2074fd823d41a591f2b233f034f628281f2fd7a22ddd47d7828c59bd0a21bfd3980ff0d2028d4b18a9df63e006c5d1c2d345b925d8dc00b4104852db99ac5c7cdda8530a113a0f4dbb61149f05a7363268c71d95808ff2e652600"
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn upper_hex() {
|
||||
let sig = Signature::from_bytes(&TEST_1_SIGNATURE);
|
||||
assert_eq!(format!("{:X}", sig), "533A37F6BBE457251F023C0D88F976AE2DFB504A843E34D2074FD823D41A591F2B233F034F628281F2FD7A22DDD47D7828C59BD0A21BFD3980FF0D2028D4B18A9DF63E006C5D1C2D345B925D8DC00B4104852DB99AC5C7CDDA8530A113A0F4DBB61149F05A7363268C71D95808FF2E652600")
|
||||
assert_eq!(
|
||||
format!("{:X}", sig),
|
||||
"533A37F6BBE457251F023C0D88F976AE2DFB504A843E34D2074FD823D41A591F2B233F034F628281F2FD7A22DDD47D7828C59BD0A21BFD3980FF0D2028D4B18A9DF63E006C5D1C2D345B925D8DC00B4104852DB99AC5C7CDDA8530A113A0F4DBB61149F05A7363268C71D95808FF2E652600"
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -49,6 +58,8 @@ fn from_str_upper() {
|
||||
|
||||
#[test]
|
||||
fn from_str_rejects_mixed_case() {
|
||||
let result = Signature::from_str("533A37f6bbe457251f023c0d88f976ae2dfb504a843e34d2074fd823d41a591f2b233f034f628281f2fd7a22ddd47d7828c59bd0a21bfd3980ff0d2028d4b18a9df63e006c5d1c2d345b925d8dc00b4104852db99ac5c7cdda8530a113a0f4dbb61149f05a7363268c71d95808ff2e652600");
|
||||
let result = Signature::from_str(
|
||||
"533A37f6bbe457251f023c0d88f976ae2dfb504a843e34d2074fd823d41a591f2b233f034f628281f2fd7a22ddd47d7828c59bd0a21bfd3980ff0d2028d4b18a9df63e006c5d1c2d345b925d8dc00b4104852db99ac5c7cdda8530a113a0f4dbb61149f05a7363268c71d95808ff2e652600",
|
||||
);
|
||||
assert!(result.is_err());
|
||||
}
|
||||
|
||||
@@ -21,7 +21,9 @@ fn decode_pkcs8_v1() {
|
||||
// $ openssl asn1parse -inform der -in tests/examples/pkcs8-v1.der
|
||||
assert_eq!(
|
||||
keypair.secret_key,
|
||||
&hex!("8A57471AA375074DC7D75EA2252E9933BB15C107E4F9A2F9CFEA6C418BEBB0774D1ABB671B58B96EFF95F35D63F2418422A59C7EAE3E00D70F")[..]
|
||||
&hex!(
|
||||
"8A57471AA375074DC7D75EA2252E9933BB15C107E4F9A2F9CFEA6C418BEBB0774D1ABB671B58B96EFF95F35D63F2418422A59C7EAE3E00D70F"
|
||||
)[..]
|
||||
);
|
||||
|
||||
assert_eq!(keypair.public_key, None);
|
||||
@@ -35,7 +37,9 @@ fn decode_public_key() {
|
||||
// $ openssl pkey -inform der -in tests/examples/pkcs8-v1.der -pubout -text
|
||||
assert_eq!(
|
||||
public_key.as_ref(),
|
||||
&hex!("f27f9809412035541b681c69fbe69b9d25a6af506d914ecef7d973fca04ccd33a8b96a0868211382ca08fe06b72e8c0cb3297f3a9d6bc02380")
|
||||
&hex!(
|
||||
"f27f9809412035541b681c69fbe69b9d25a6af506d914ecef7d973fca04ccd33a8b96a0868211382ca08fe06b72e8c0cb3297f3a9d6bc02380"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -2,23 +2,23 @@
|
||||
name = "lms-signature"
|
||||
description = "Pure Rust implementation of Leighton-Micali Hash-Based Signatures (RFC 8554)"
|
||||
version = "0.1.0-pre"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
license = "Apache-2.0 OR MIT"
|
||||
homepage = "https://github.com/RustCrypto/signatures/tree/master/lms"
|
||||
repository = "https://github.com/RustCrypto/signatures"
|
||||
readme = "README.md"
|
||||
rust-version = "1.81"
|
||||
rust-version = "1.85"
|
||||
categories = ["cryptography"]
|
||||
keywords = ["crypto", "signature"]
|
||||
|
||||
[dependencies]
|
||||
digest = "=0.11.0-pre.9"
|
||||
hybrid-array = { version = "0.2.0-rc.11", features = ["extra-sizes", "zeroize"] }
|
||||
rand = "0.8.5"
|
||||
digest = "=0.11.0-pre.10"
|
||||
hybrid-array = { version = "0.3", features = ["extra-sizes", "zeroize"] }
|
||||
rand = "0.9.0"
|
||||
sha2 = "=0.11.0-pre.4"
|
||||
static_assertions = "1.1.0"
|
||||
rand_core = "0.6.4"
|
||||
signature = { version = "2.3.0-pre.0", features = ["digest", "std", "rand_core"] }
|
||||
rand_core = "0.9.0"
|
||||
signature = { version = "=2.3.0-pre.6", features = ["digest", "std", "rand_core"] }
|
||||
typenum = { version = "1.17.0", features = ["const-generics"] }
|
||||
zeroize = "1.8.1"
|
||||
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ dual licensed as above, without any additional terms or conditions.
|
||||
[build-image]: https://github.com/RustCrypto/signatures/actions/workflows/lms.yml/badge.svg
|
||||
[build-link]: https://github.com/RustCrypto/signatures/actions/workflows/lms.yml
|
||||
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
|
||||
[rustc-image]: https://img.shields.io/badge/rustc-1.73+-blue.svg
|
||||
[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg
|
||||
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
|
||||
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260048-signatures
|
||||
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ mod public;
|
||||
pub mod signature;
|
||||
|
||||
pub use modes::{
|
||||
LmsMode, LmsSha256M32H10, LmsSha256M32H15, LmsSha256M32H20, LmsSha256M32H25, LmsSha256M32H5,
|
||||
LmsMode, LmsSha256M32H5, LmsSha256M32H10, LmsSha256M32H15, LmsSha256M32H20, LmsSha256M32H25,
|
||||
};
|
||||
pub use private::SigningKey;
|
||||
pub use public::VerifyingKey;
|
||||
@@ -23,7 +23,7 @@ mod tests {
|
||||
use crate::{lms::SigningKey, ots::LmsOtsSha256N32W4};
|
||||
|
||||
fn test_sign_and_verify<Mode: LmsMode>() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::rng();
|
||||
|
||||
// Generate a fresh keypair
|
||||
let mut sk = SigningKey::<Mode>::new(&mut rng);
|
||||
|
||||
+29
-29
@@ -8,7 +8,7 @@ use std::{
|
||||
marker::PhantomData,
|
||||
ops::{Shl, Sub},
|
||||
};
|
||||
use typenum::{bit::B1, Add1, Shleft, Sub1, U1, U10, U15, U20, U25, U5};
|
||||
use typenum::{Add1, Shleft, Sub1, U1, U5, U10, U15, U20, U25, bit::B1};
|
||||
|
||||
/// The basic trait that must be implemented for any valid LMS mode
|
||||
pub trait LmsMode: Typecode + Clone {
|
||||
@@ -45,13 +45,13 @@ pub struct LmsModeInternal<
|
||||
}
|
||||
|
||||
impl<
|
||||
OtsMode: LmsOtsMode,
|
||||
Hasher: Digest,
|
||||
TreeLen: ArraySize,
|
||||
const M: usize,
|
||||
const H: usize,
|
||||
const TC: u32,
|
||||
> Clone for LmsModeInternal<OtsMode, Hasher, TreeLen, M, H, TC>
|
||||
OtsMode: LmsOtsMode,
|
||||
Hasher: Digest,
|
||||
TreeLen: ArraySize,
|
||||
const M: usize,
|
||||
const H: usize,
|
||||
const TC: u32,
|
||||
> Clone for LmsModeInternal<OtsMode, Hasher, TreeLen, M, H, TC>
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
*self
|
||||
@@ -59,24 +59,24 @@ impl<
|
||||
}
|
||||
|
||||
impl<
|
||||
OtsMode: LmsOtsMode,
|
||||
Hasher: Digest,
|
||||
TreeLen: ArraySize,
|
||||
const M: usize,
|
||||
const H: usize,
|
||||
const TC: u32,
|
||||
> Copy for LmsModeInternal<OtsMode, Hasher, TreeLen, M, H, TC>
|
||||
OtsMode: LmsOtsMode,
|
||||
Hasher: Digest,
|
||||
TreeLen: ArraySize,
|
||||
const M: usize,
|
||||
const H: usize,
|
||||
const TC: u32,
|
||||
> Copy for LmsModeInternal<OtsMode, Hasher, TreeLen, M, H, TC>
|
||||
{
|
||||
}
|
||||
|
||||
impl<
|
||||
OtsMode: LmsOtsMode,
|
||||
Hasher: Digest,
|
||||
HLen: ArraySize,
|
||||
const M: usize,
|
||||
const H: usize,
|
||||
const TC: u32,
|
||||
> LmsMode for LmsModeInternal<OtsMode, Hasher, HLen, M, H, TC>
|
||||
OtsMode: LmsOtsMode,
|
||||
Hasher: Digest,
|
||||
HLen: ArraySize,
|
||||
const M: usize,
|
||||
const H: usize,
|
||||
const TC: u32,
|
||||
> LmsMode for LmsModeInternal<OtsMode, Hasher, HLen, M, H, TC>
|
||||
where
|
||||
HLen: Add<typenum::B1>,
|
||||
U1: Shl<<HLen as Add<B1>>::Output>,
|
||||
@@ -94,13 +94,13 @@ where
|
||||
}
|
||||
|
||||
impl<
|
||||
Hasher: Digest,
|
||||
OtsMode: LmsOtsMode,
|
||||
TreeLen: ArraySize,
|
||||
const M: usize,
|
||||
const H: usize,
|
||||
const TC: u32,
|
||||
> Typecode for LmsModeInternal<OtsMode, Hasher, TreeLen, M, H, TC>
|
||||
Hasher: Digest,
|
||||
OtsMode: LmsOtsMode,
|
||||
TreeLen: ArraySize,
|
||||
const M: usize,
|
||||
const H: usize,
|
||||
const TC: u32,
|
||||
> Typecode for LmsModeInternal<OtsMode, Hasher, TreeLen, M, H, TC>
|
||||
{
|
||||
const TYPECODE: u32 = TC;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ use crate::types::{Identifier, Typecode};
|
||||
|
||||
use digest::{Digest, Output, OutputSizeUser};
|
||||
use hybrid_array::{Array, ArraySize};
|
||||
use rand::{CryptoRng, Rng};
|
||||
use rand::Rng;
|
||||
use rand_core::{CryptoRng, TryCryptoRng};
|
||||
use signature::{Error, RandomizedSignerMut};
|
||||
|
||||
use core::array::TryFromSliceError;
|
||||
@@ -105,9 +106,9 @@ impl<Mode: LmsMode> SigningKey<Mode> {
|
||||
|
||||
// this implements the algorithm from Appendix D in <https://datatracker.ietf.org/doc/html/rfc8554#appendix-D>
|
||||
impl<Mode: LmsMode> RandomizedSignerMut<Signature<Mode>> for SigningKey<Mode> {
|
||||
fn try_sign_with_rng(
|
||||
fn try_sign_with_rng<R: TryCryptoRng + ?Sized>(
|
||||
&mut self,
|
||||
rng: &mut impl rand_core::CryptoRngCore,
|
||||
rng: &mut R,
|
||||
msg: &[u8],
|
||||
) -> Result<Signature<Mode>, Error> {
|
||||
if self.q >= Mode::LEAVES {
|
||||
@@ -201,7 +202,7 @@ impl<'a, Mode: LmsMode> TryFrom<&'a [u8]> for SigningKey<Mode> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{SigningKey, VerifyingKey};
|
||||
use crate::lms::modes::{LmsSha256M32H10, LmsSha256M32H5};
|
||||
use crate::lms::modes::{LmsSha256M32H5, LmsSha256M32H10};
|
||||
use crate::ots::modes::{LmsOtsSha256N32W4, LmsOtsSha256N32W8};
|
||||
use hex_literal::hex;
|
||||
use hybrid_array::Array;
|
||||
@@ -371,7 +372,7 @@ mod tests {
|
||||
SigningKey::<LmsSha256M32H10<LmsOtsSha256N32W4>>::new_from_seed(id, seed).unwrap();
|
||||
|
||||
let lms_priv_bytes: Array<_, _> = lms_priv.into();
|
||||
let lms_priv_bytes: &[u8] = &*lms_priv_bytes;
|
||||
let lms_priv_bytes: &[u8] = &lms_priv_bytes;
|
||||
let lms_priv: SigningKey<LmsSha256M32H10<LmsOtsSha256N32W4>> =
|
||||
lms_priv_bytes.try_into().unwrap();
|
||||
|
||||
@@ -392,7 +393,7 @@ mod tests {
|
||||
let lms_pub = lms_priv.public();
|
||||
|
||||
let lms_pub_bytes: Array<_, _> = lms_pub.into();
|
||||
let lms_pub_bytes: &[u8] = &*lms_pub_bytes;
|
||||
let lms_pub_bytes: &[u8] = &lms_pub_bytes;
|
||||
let lms_pub: VerifyingKey<LmsSha256M32H10<LmsOtsSha256N32W4>> =
|
||||
lms_pub_bytes.try_into().unwrap();
|
||||
|
||||
|
||||
@@ -159,9 +159,9 @@ mod tests {
|
||||
use std::ops::Add;
|
||||
|
||||
use crate::{
|
||||
lms::modes::*,
|
||||
lms::SigningKey,
|
||||
lms::VerifyingKey,
|
||||
lms::modes::*,
|
||||
ots::{LmsOtsSha256N32W4, LmsOtsSha256N32W8},
|
||||
};
|
||||
use digest::OutputSizeUser;
|
||||
@@ -258,7 +258,7 @@ mod tests {
|
||||
<Mode::Hasher as OutputSizeUser>::OutputSize: Add<U24>,
|
||||
Sum<<Mode::Hasher as OutputSizeUser>::OutputSize, U24>: ArraySize,
|
||||
{
|
||||
let rng = rand::thread_rng();
|
||||
let rng = rand::rng();
|
||||
let lms_priv = SigningKey::<Mode>::new(rng);
|
||||
let lms_pub = lms_priv.public();
|
||||
let lms_pub_serialized: Array<u8, Sum<<Mode::Hasher as OutputSizeUser>::OutputSize, U24>> =
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
use crate::error::LmsDeserializeError;
|
||||
use crate::lms::LmsMode;
|
||||
use crate::ots::modes::LmsOtsMode;
|
||||
use crate::ots::Signature as OtsSignature;
|
||||
use crate::ots::modes::LmsOtsMode;
|
||||
use hybrid_array::{Array, ArraySize};
|
||||
use signature::SignatureEncoding;
|
||||
|
||||
@@ -141,13 +141,15 @@ mod tests {
|
||||
use crate::ots::modes::*;
|
||||
use hex_literal::hex;
|
||||
use hybrid_array::ArraySize;
|
||||
use rand::thread_rng;
|
||||
use rand::rng;
|
||||
use signature::{RandomizedSignerMut, Verifier};
|
||||
use typenum::{Prod, Sum, U1, U4};
|
||||
|
||||
#[test]
|
||||
fn test_deserialize_kat1() {
|
||||
let pk_bytes = hex!("0000000500000004d2f14ff6346af964569f7d6cb880a1b66c5004917da6eafe4d9ef6c6407b3db0e5485b122d9ebe15cda93cfec582d7ab");
|
||||
let pk_bytes = hex!(
|
||||
"0000000500000004d2f14ff6346af964569f7d6cb880a1b66c5004917da6eafe4d9ef6c6407b3db0e5485b122d9ebe15cda93cfec582d7ab"
|
||||
);
|
||||
let sig_bytes = hex!(
|
||||
"
|
||||
0000000a
|
||||
@@ -266,7 +268,7 @@ mod tests {
|
||||
U4,
|
||||
>: ArraySize,
|
||||
{
|
||||
let mut rng = thread_rng();
|
||||
let mut rng = rng();
|
||||
let mut sk = SigningKey::<Mode>::new(&mut rng);
|
||||
let pk = sk.public();
|
||||
let msg = b"Hello, world!";
|
||||
|
||||
+4
-14
@@ -26,7 +26,7 @@ pub mod tests {
|
||||
use digest::OutputSizeUser;
|
||||
use hex_literal::hex;
|
||||
use hybrid_array::{Array, ArraySize};
|
||||
use rand::thread_rng;
|
||||
use rand::rng;
|
||||
use rand_core::{CryptoRng, RngCore};
|
||||
use signature::RandomizedSignerMut;
|
||||
use signature::Verifier;
|
||||
@@ -41,7 +41,7 @@ pub mod tests {
|
||||
<Mode::Hasher as OutputSizeUser>::OutputSize: Add<U2>,
|
||||
Sum<<Mode::Hasher as OutputSizeUser>::OutputSize, U2>: ArraySize,
|
||||
{
|
||||
let mut rng = thread_rng();
|
||||
let mut rng = rng();
|
||||
let mut sk = SigningKey::<Mode>::new(0, [0xcc; ID_LEN], &mut rng);
|
||||
let pk = sk.public();
|
||||
let msg = "this is a test message".as_bytes();
|
||||
@@ -65,7 +65,7 @@ pub mod tests {
|
||||
<Mode::Hasher as OutputSizeUser>::OutputSize: Add<U2>,
|
||||
Sum<<Mode::Hasher as OutputSizeUser>::OutputSize, U2>: ArraySize,
|
||||
{
|
||||
let mut rng = thread_rng();
|
||||
let mut rng = rng();
|
||||
let mut sk = SigningKey::<Mode>::new(0, [0xcc; ID_LEN], &mut rng);
|
||||
let mut pk = sk.public();
|
||||
let msg = "this is a test message".as_bytes();
|
||||
@@ -127,7 +127,7 @@ pub mod tests {
|
||||
/// Constant RNG for testing purposes only.
|
||||
pub struct ConstantRng<'a>(pub &'a [u8]);
|
||||
|
||||
impl<'a> RngCore for ConstantRng<'a> {
|
||||
impl RngCore for ConstantRng<'_> {
|
||||
fn next_u32(&mut self) -> u32 {
|
||||
let (head, tail) = self.0.split_at(4);
|
||||
self.0 = tail;
|
||||
@@ -145,16 +145,6 @@ pub mod tests {
|
||||
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(())
|
||||
}
|
||||
}
|
||||
|
||||
/// WARNING: This is not a secure cryptographic RNG. It is only used for testing.
|
||||
|
||||
@@ -5,8 +5,8 @@ use hybrid_array::{Array, ArraySize};
|
||||
use sha2::Sha256;
|
||||
use static_assertions::const_assert_eq;
|
||||
use std::marker::PhantomData;
|
||||
use typenum::consts::{U133, U265, U34, U67};
|
||||
use typenum::Unsigned;
|
||||
use typenum::consts::{U34, U67, U133, U265};
|
||||
|
||||
/// The basic trait that must be implemented by any OTS mode.
|
||||
pub trait LmsOtsMode: Typecode {
|
||||
@@ -93,7 +93,7 @@ impl<Hasher: Digest, const W: usize, PP: ArraySize, const TC: u32> LmsOtsMode
|
||||
type PLen = PP;
|
||||
const N: usize = Hasher::OutputSize::USIZE;
|
||||
const W: usize = W;
|
||||
const U: usize = (8 * Self::N + W - 1) / W;
|
||||
const U: usize = (8 * Self::N).div_ceil(W);
|
||||
const V: usize = ((((1 << W) - 1) * Self::U).ilog2() as usize / W) + 1;
|
||||
const P: usize = Self::U + Self::V;
|
||||
const LS: usize = 16 - Self::V * W;
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::ots::signature::Signature;
|
||||
use crate::types::Identifier;
|
||||
use digest::{Digest, Output};
|
||||
use hybrid_array::Array;
|
||||
use rand_core::CryptoRngCore;
|
||||
use rand_core::{CryptoRng, TryCryptoRng};
|
||||
use signature::{Error, RandomizedSignerMut};
|
||||
use zeroize::Zeroize;
|
||||
//use std::mem::MaybeUninit;
|
||||
@@ -29,7 +29,7 @@ impl<Mode: LmsOtsMode> SigningKey<Mode> {
|
||||
// generic_array::ArrayBuilder's internal implementation
|
||||
/// If LM-OTS is being used directly, q MUST be set to the all-zero value
|
||||
/// <https://datatracker.ietf.org/doc/html/rfc8554#section-4>
|
||||
pub fn new(q: u32, id: Identifier, rng: &mut impl CryptoRngCore) -> Self {
|
||||
pub fn new<R: CryptoRng>(q: u32, id: Identifier, rng: &mut R) -> Self {
|
||||
let mut seed: Array<u8, Mode::NLen> = Array::default();
|
||||
rng.fill_bytes(&mut seed);
|
||||
Self::new_from_seed(q, id, seed)
|
||||
@@ -96,9 +96,9 @@ impl<Mode: LmsOtsMode> SigningKey<Mode> {
|
||||
}
|
||||
|
||||
impl<Mode: LmsOtsMode> RandomizedSignerMut<Signature<Mode>> for SigningKey<Mode> {
|
||||
fn try_sign_with_rng(
|
||||
fn try_sign_with_rng<R: TryCryptoRng + ?Sized>(
|
||||
&mut self,
|
||||
rng: &mut impl CryptoRngCore,
|
||||
rng: &mut R,
|
||||
msg: &[u8],
|
||||
) -> Result<Signature<Mode>, Error> {
|
||||
if !self.valid {
|
||||
@@ -107,7 +107,7 @@ impl<Mode: LmsOtsMode> RandomizedSignerMut<Signature<Mode>> for SigningKey<Mode>
|
||||
|
||||
// Generate the message randomizer C
|
||||
let mut c = <Output<Mode::Hasher>>::default();
|
||||
rng.fill_bytes(&mut c);
|
||||
rng.try_fill_bytes(&mut c).map_err(|_| Error::new())?;
|
||||
|
||||
// Q is the randomized message hash
|
||||
let q = Mode::Hasher::new()
|
||||
|
||||
@@ -123,12 +123,11 @@ mod tests {
|
||||
use crate::ots::private::SigningKey;
|
||||
use crate::ots::public::VerifyingKey;
|
||||
use hybrid_array::Array;
|
||||
use rand::thread_rng;
|
||||
use rand::rng;
|
||||
|
||||
#[test]
|
||||
fn test_serde() {
|
||||
let pk =
|
||||
SigningKey::<LmsOtsSha256N32W8>::new(0, [0xbb; ID_LEN], &mut thread_rng()).public();
|
||||
let pk = SigningKey::<LmsOtsSha256N32W8>::new(0, [0xbb; ID_LEN], &mut rng()).public();
|
||||
let pk_serialized: Array<u8, _> = pk.clone().into();
|
||||
let bytes = pk_serialized.as_slice();
|
||||
let pk_deserialized = VerifyingKey::<LmsOtsSha256N32W8>::try_from(bytes);
|
||||
|
||||
Generated
-1099
File diff suppressed because it is too large
Load Diff
+5
-8
@@ -5,8 +5,8 @@ Pure Rust implementation of ML-DSA (formerly known as CRYSTALS-Dilithium) as
|
||||
described in FIPS-204 (final)
|
||||
"""
|
||||
version = "0.1.0-pre.2"
|
||||
edition = "2021"
|
||||
rust-version = "1.81"
|
||||
edition = "2024"
|
||||
rust-version = "1.85"
|
||||
license = "Apache-2.0 OR MIT"
|
||||
homepage = "https://github.com/RustCrypto/signatures/tree/master/ml-dsa"
|
||||
repository = "https://github.com/RustCrypto/signatures"
|
||||
@@ -22,10 +22,10 @@ alloc = ["pkcs8?/alloc"]
|
||||
pkcs8 = ["dep:const-oid", "dep:pkcs8"]
|
||||
|
||||
[dependencies]
|
||||
hybrid-array = { version = "0.2.3", features = ["extra-sizes"] }
|
||||
hybrid-array = { version = "0.3", features = ["extra-sizes"] }
|
||||
num-traits = "0.2.19"
|
||||
rand_core = { version = "0.9", optional = true }
|
||||
sha3 = "0.10.8"
|
||||
sha3 = "=0.11.0-pre.4"
|
||||
signature = "=2.3.0-pre.6"
|
||||
zeroize = { version = "1.8.1", optional = true, default-features = false }
|
||||
|
||||
@@ -35,7 +35,7 @@ pkcs8 = { version = "0.11.0-rc.2", default-features = false, optional = true }
|
||||
[dev-dependencies]
|
||||
criterion = "0.5.1"
|
||||
hex = { version = "0.4.3", features = ["serde"] }
|
||||
hex-literal = "0.4.1"
|
||||
hex-literal = "1"
|
||||
pkcs8 = { version = "0.11.0-rc.2", features = ["pem"] }
|
||||
proptest = "1"
|
||||
rand = "0.9"
|
||||
@@ -45,6 +45,3 @@ serde_json = "1.0.132"
|
||||
[[bench]]
|
||||
name = "ml_dsa"
|
||||
harness = false
|
||||
|
||||
[profile.dev]
|
||||
opt-level = 2
|
||||
|
||||
+1
-8
@@ -20,13 +20,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
|
||||
|
||||
All crates licensed under either of
|
||||
@@ -49,7 +42,7 @@ dual licensed as above, without any additional terms or conditions.
|
||||
[build-image]: https://github.com/RustCrypto/signatures/actions/workflows/ml-dsa.yml/badge.svg
|
||||
[build-link]: https://github.com/RustCrypto/signatures/actions/workflows/ml-dsa.yml
|
||||
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
|
||||
[rustc-image]: https://img.shields.io/badge/rustc-1.81+-blue.svg
|
||||
[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg
|
||||
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
|
||||
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260048-signatures
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use criterion::{Criterion, criterion_group, criterion_main};
|
||||
use hybrid_array::{Array, ArraySize};
|
||||
use ml_dsa::{KeyGen, MlDsa65, Signature, SigningKey, VerifyingKey, B32};
|
||||
use ml_dsa::{B32, KeyGen, MlDsa65, Signature, SigningKey, VerifyingKey};
|
||||
use rand::{CryptoRng, RngCore};
|
||||
|
||||
pub fn rand<L: ArraySize>(rng: &mut (impl RngCore + CryptoRng)) -> Array<u8, L> {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
pub use crate::module_lattice::algebra::Field;
|
||||
pub use crate::module_lattice::util::Truncate;
|
||||
use hybrid_array::{
|
||||
typenum::{Shleft, Unsigned, U1, U13},
|
||||
ArraySize,
|
||||
typenum::{Shleft, U1, U13, Unsigned},
|
||||
};
|
||||
|
||||
use crate::define_field;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use hybrid_array::Array;
|
||||
use sha3::{
|
||||
digest::{ExtendableOutput, XofReader},
|
||||
Shake128, Shake256,
|
||||
digest::{ExtendableOutput, XofReader},
|
||||
};
|
||||
|
||||
use crate::module_lattice::encode::ArraySize;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::module_lattice::encode::{ArraySize, Encode, EncodingSize, VectorEncodingSize};
|
||||
use core::ops::Add;
|
||||
use hybrid_array::{
|
||||
typenum::{Len, Length, Sum, Unsigned},
|
||||
Array,
|
||||
typenum::{Len, Length, Sum, Unsigned},
|
||||
};
|
||||
|
||||
use crate::algebra::{Elem, Polynomial, Vector};
|
||||
@@ -111,9 +111,9 @@ pub(crate) mod test {
|
||||
use crate::module_lattice::encode::*;
|
||||
use core::ops::Rem;
|
||||
use hybrid_array::typenum::{
|
||||
U1, U2, U3, U4, U6, U7, U8, U9, U10, U13, U17, U19,
|
||||
marker_traits::Zero,
|
||||
operator_aliases::{Diff, Mod, Shleft},
|
||||
U1, U10, U13, U17, U19, U2, U3, U4, U6, U7, U8, U9,
|
||||
};
|
||||
use rand::Rng;
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
use crate::module_lattice::util::Truncate;
|
||||
use hybrid_array::{
|
||||
typenum::{Unsigned, U256},
|
||||
Array,
|
||||
typenum::{U256, Unsigned},
|
||||
};
|
||||
|
||||
use crate::algebra::{AlgebraExt, BaseField, Decompose, Elem, Field, Polynomial, Vector};
|
||||
|
||||
+8
-8
@@ -42,11 +42,11 @@ mod module_lattice;
|
||||
|
||||
use core::convert::{AsRef, TryFrom, TryInto};
|
||||
use hybrid_array::{
|
||||
typenum::{
|
||||
Diff, Length, Prod, Quot, Shleft, Unsigned, U1, U17, U19, U2, U32, U4, U48, U5, U55, U6,
|
||||
U64, U7, U75, U8, U80, U88,
|
||||
},
|
||||
Array,
|
||||
typenum::{
|
||||
Diff, Length, Prod, Quot, Shleft, U1, U2, U4, U5, U6, U7, U8, U17, U19, U32, U48, U55, U64,
|
||||
U75, U80, U88, Unsigned,
|
||||
},
|
||||
};
|
||||
|
||||
#[cfg(feature = "rand_core")]
|
||||
@@ -59,20 +59,20 @@ use zeroize::{Zeroize, ZeroizeOnDrop};
|
||||
use {
|
||||
const_oid::db::fips204,
|
||||
pkcs8::{
|
||||
AlgorithmIdentifierRef, PrivateKeyInfoRef,
|
||||
der::{self, AnyRef},
|
||||
spki::{
|
||||
self, AlgorithmIdentifier, AssociatedAlgorithmIdentifier, SignatureAlgorithmIdentifier,
|
||||
SubjectPublicKeyInfoRef,
|
||||
},
|
||||
AlgorithmIdentifierRef, PrivateKeyInfoRef,
|
||||
},
|
||||
};
|
||||
|
||||
#[cfg(all(feature = "alloc", feature = "pkcs8"))]
|
||||
use pkcs8::{
|
||||
EncodePrivateKey, EncodePublicKey,
|
||||
der::asn1::{BitString, BitStringRef, OctetStringRef},
|
||||
spki::{SignatureBitStringEncoding, SubjectPublicKeyInfo},
|
||||
EncodePrivateKey, EncodePublicKey,
|
||||
};
|
||||
|
||||
use crate::algebra::{AlgebraExt, Elem, NttMatrix, NttVector, Truncate, Vector};
|
||||
@@ -412,7 +412,7 @@ impl<P: MlDsaParams> SigningKey<P> {
|
||||
/// or if it fails to get enough randomness.
|
||||
// Algorithm 2 ML-DSA.Sign
|
||||
#[cfg(feature = "rand_core")]
|
||||
pub fn sign_randomized<R: TryCryptoRng>(
|
||||
pub fn sign_randomized<R: TryCryptoRng + ?Sized>(
|
||||
&self,
|
||||
M: &[u8],
|
||||
ctx: &[u8],
|
||||
@@ -497,7 +497,7 @@ impl<P: MlDsaParams> signature::Signer<Signature<P>> for SigningKey<P> {
|
||||
/// method.
|
||||
#[cfg(feature = "rand_core")]
|
||||
impl<P: MlDsaParams> signature::RandomizedSigner<Signature<P>> for SigningKey<P> {
|
||||
fn try_sign_with_rng<R: TryCryptoRng>(
|
||||
fn try_sign_with_rng<R: TryCryptoRng + ?Sized>(
|
||||
&self,
|
||||
rng: &mut R,
|
||||
msg: &[u8],
|
||||
|
||||
@@ -2,7 +2,7 @@ use super::util::Truncate;
|
||||
|
||||
use core::fmt::Debug;
|
||||
use core::ops::{Add, Mul, Neg, Sub};
|
||||
use hybrid_array::{typenum::U256, Array, ArraySize};
|
||||
use hybrid_array::{Array, ArraySize, typenum::U256};
|
||||
use num_traits::PrimInt;
|
||||
|
||||
#[cfg(feature = "zeroize")]
|
||||
@@ -55,11 +55,7 @@ macro_rules! define_field {
|
||||
const BARRETT_MULTIPLIER: Self::LongLong = (1 << Self::BARRETT_SHIFT) / Self::QLL;
|
||||
|
||||
fn small_reduce(x: Self::Int) -> Self::Int {
|
||||
if x < Self::Q {
|
||||
x
|
||||
} else {
|
||||
x - Self::Q
|
||||
}
|
||||
if x < Self::Q { x } else { x - Self::Q }
|
||||
}
|
||||
|
||||
fn barrett_reduce(x: Self::Long) -> Self::Int {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use core::fmt::Debug;
|
||||
use core::ops::{Div, Mul, Rem};
|
||||
use hybrid_array::{
|
||||
typenum::{Gcd, Gcf, Prod, Quot, Unsigned, U0, U256, U32, U8},
|
||||
Array,
|
||||
typenum::{Gcd, Gcf, Prod, Quot, U0, U8, U32, U256, Unsigned},
|
||||
};
|
||||
use num_traits::One;
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ use core::mem::ManuallyDrop;
|
||||
use core::ops::{Div, Mul, Rem};
|
||||
use core::ptr;
|
||||
use hybrid_array::{
|
||||
typenum::{Prod, Quot, Unsigned, U0},
|
||||
Array, ArraySize,
|
||||
typenum::{Prod, Quot, U0, Unsigned},
|
||||
};
|
||||
|
||||
/// Safely truncate an unsigned integer value to shorter representation
|
||||
@@ -109,8 +109,8 @@ where
|
||||
mod test {
|
||||
use super::*;
|
||||
use hybrid_array::{
|
||||
typenum::{U2, U5},
|
||||
Array,
|
||||
typenum::{U2, U5},
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
||||
+1
-1
@@ -145,8 +145,8 @@ impl Mul<&NttPolynomial> for &NttPolynomial {
|
||||
mod test {
|
||||
use super::*;
|
||||
use hybrid_array::{
|
||||
typenum::{U2, U3},
|
||||
Array,
|
||||
typenum::{U2, U3},
|
||||
};
|
||||
|
||||
use crate::algebra::*;
|
||||
|
||||
+4
-4
@@ -17,11 +17,11 @@ use crate::module_lattice::encode::{
|
||||
ArraySize, Encode, EncodedPolynomialSize, EncodedVectorSize, EncodingSize,
|
||||
};
|
||||
use hybrid_array::{
|
||||
typenum::{
|
||||
Diff, Len, Length, Prod, Shleft, Sum, Unsigned, U0, U1, U128, U13, U2, U23, U32, U320, U4,
|
||||
U416, U64,
|
||||
},
|
||||
Array,
|
||||
typenum::{
|
||||
Diff, Len, Length, Prod, Shleft, Sum, U0, U1, U2, U4, U13, U23, U32, U64, U128, U320, U416,
|
||||
Unsigned,
|
||||
},
|
||||
};
|
||||
|
||||
use crate::algebra::{Polynomial, Vector};
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
use hybrid_array::{
|
||||
typenum::{U32, U64},
|
||||
Array,
|
||||
typenum::{U32, U64},
|
||||
};
|
||||
|
||||
/// A 32-byte array, defined here for brevity because it is used several times
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
use core::ops::Deref;
|
||||
use ml_dsa::{KeyPair, MlDsa44, MlDsa65, MlDsa87, MlDsaParams, SigningKey, VerifyingKey};
|
||||
use pkcs8::{
|
||||
der::{pem::LineEnding, AnyRef},
|
||||
spki::AssociatedAlgorithmIdentifier,
|
||||
DecodePrivateKey, DecodePublicKey, EncodePrivateKey, EncodePublicKey,
|
||||
der::{AnyRef, pem::LineEnding},
|
||||
spki::AssociatedAlgorithmIdentifier,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use ml_dsa::{
|
||||
signature::{Signer, Verifier},
|
||||
KeyGen, KeyPair, MlDsa44, MlDsa65, MlDsa87, Signature,
|
||||
signature::{Signer, Verifier},
|
||||
};
|
||||
use proptest::prelude::*;
|
||||
|
||||
|
||||
+3
-3
@@ -12,13 +12,13 @@ repository = "https://github.com/RustCrypto/signatures"
|
||||
readme = "README.md"
|
||||
categories = ["cryptography", "no-std"]
|
||||
keywords = ["dsa", "ecdsa", "signature"]
|
||||
edition = "2021"
|
||||
rust-version = "1.81"
|
||||
edition = "2024"
|
||||
rust-version = "1.85"
|
||||
|
||||
[dependencies]
|
||||
hmac = { version = "=0.13.0-pre.4", default-features = false, features = ["reset"] }
|
||||
subtle = { version = "2", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
hex-literal = "0.4"
|
||||
hex-literal = "1"
|
||||
sha2 = "=0.11.0-pre.4"
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ Algorithm described in RFC 6979 § 3.2:
|
||||
|
||||
## Minimum Supported Rust Version
|
||||
|
||||
This crate requires **Rust 1.72** at a minimum.
|
||||
This crate requires **Rust 1.85** at a minimum.
|
||||
|
||||
We may change the MSRV in the future, but it will be accompanied by a minor
|
||||
version bump.
|
||||
@@ -46,7 +46,7 @@ dual licensed as above, without any additional terms or conditions.
|
||||
[build-image]: https://github.com/RustCrypto/signatures/actions/workflows/rfc6979.yml/badge.svg
|
||||
[build-link]: https://github.com/RustCrypto/signatures/actions/workflows/rfc6979.yml
|
||||
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
|
||||
[rustc-image]: https://img.shields.io/badge/rustc-1.72+-blue.svg
|
||||
[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg
|
||||
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
|
||||
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260048-signatures
|
||||
|
||||
|
||||
+5
-4
@@ -42,12 +42,12 @@ mod ct;
|
||||
pub use hmac::digest::array::typenum::consts;
|
||||
|
||||
use hmac::{
|
||||
SimpleHmac,
|
||||
digest::{
|
||||
Digest, FixedOutput, FixedOutputReset, KeyInit, Mac,
|
||||
array::{Array, ArraySize},
|
||||
core_api::BlockSizeUser,
|
||||
Digest, FixedOutput, FixedOutputReset, KeyInit, Mac,
|
||||
},
|
||||
SimpleHmac,
|
||||
};
|
||||
|
||||
/// Deterministically generate ephemeral scalar `k`.
|
||||
@@ -188,8 +188,9 @@ where
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
Array,
|
||||
consts::{U21, U66},
|
||||
generate_k, Array,
|
||||
generate_k,
|
||||
};
|
||||
use hex_literal::hex;
|
||||
use sha2::{Digest, Sha256, Sha512};
|
||||
@@ -228,7 +229,7 @@ mod tests {
|
||||
h[2..].copy_from_slice(&Sha512::digest(message));
|
||||
|
||||
let aad = b"";
|
||||
let k = generate_k::<Sha512, U66>(&x.into(), &q.into(), &h.into(), aad);
|
||||
let k = generate_k::<Sha512, U66>(&x.into(), &q.into(), &h, aad);
|
||||
|
||||
let expected_k = hex!(
|
||||
"01DAE2EA071F8110DC26882D4D5EAE0621A3256FC8847FB9022E2B7D28E6F10198B1574FDD03A9053C08A1854A168AA5A57470EC97DD5CE090124EF52A2F7ECBFFD3"
|
||||
|
||||
+11
-11
@@ -5,8 +5,8 @@ Pure Rust implementation of SLH-DSA (aka SPHINCS+) as described in the
|
||||
FIPS-205 standard
|
||||
"""
|
||||
version = "0.2.0-pre"
|
||||
edition = "2021"
|
||||
rust-version = "1.81"
|
||||
edition = "2024"
|
||||
rust-version = "1.85"
|
||||
license = "Apache-2.0 OR MIT"
|
||||
homepage = "https://github.com/RustCrypto/signatures/tree/master/slh-dsa"
|
||||
repository = "https://github.com/RustCrypto/signatures"
|
||||
@@ -15,20 +15,20 @@ categories = ["cryptography"]
|
||||
keywords = ["crypto", "signature"]
|
||||
|
||||
[dependencies]
|
||||
hybrid-array = { version = "0.2.0-rc.10", features = ["extra-sizes"] }
|
||||
hybrid-array = { version = "0.3", features = ["extra-sizes"] }
|
||||
typenum = { version = "1.17.0", features = ["const-generics"] }
|
||||
sha3 = { version = "=0.11.0-pre.4", default-features = false }
|
||||
zerocopy = { version = "0.7.34", features = ["derive"] }
|
||||
rand_core = { version = "0.6.4" }
|
||||
signature = { version = "2.3.0-pre.4", features = ["rand_core"] }
|
||||
rand_core = { version = "0.9.2" }
|
||||
signature = { version = "=2.3.0-pre.6", features = ["rand_core"] }
|
||||
hmac = "=0.13.0-pre.4"
|
||||
sha2 = { version = "=0.11.0-pre.4", default-features = false }
|
||||
digest = "=0.11.0-pre.9"
|
||||
pkcs8 = { version = "=0.11.0-rc.1", default-features = false }
|
||||
digest = "=0.11.0-pre.10"
|
||||
pkcs8 = { version = "0.11.0-rc.1", default-features = false }
|
||||
const-oid = { version = "0.10.0-rc.1", features = ["db"] }
|
||||
|
||||
[dev-dependencies]
|
||||
hex-literal = "0.4.1"
|
||||
hex-literal = "1"
|
||||
hex = { version = "0.4.1", features = ["serde"] }
|
||||
num-bigint = "0.4.4"
|
||||
quickcheck = "1"
|
||||
@@ -38,12 +38,12 @@ criterion = "0.5"
|
||||
aes = "=0.9.0-pre.2"
|
||||
cipher = "=0.5.0-pre.7"
|
||||
ctr = "=0.10.0-pre.2"
|
||||
rand_core = "0.6.4"
|
||||
rand_core = "0.9.2"
|
||||
paste = "1.0.15"
|
||||
rand = "0.8.5"
|
||||
rand = "0.9"
|
||||
serde_json = "1.0.124"
|
||||
serde = { version = "1.0.207", features = ["derive"] }
|
||||
pkcs8 = { version = "=0.11.0-rc.1", features = ["pem"] }
|
||||
pkcs8 = { version = "0.11.0-rc.1", features = ["pem"] }
|
||||
|
||||
[lib]
|
||||
bench = false
|
||||
|
||||
+1
-8
@@ -17,13 +17,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.75** at a minimum.
|
||||
|
||||
We may change the MSRV in the future, but it will be accompanied by a minor
|
||||
version bump.
|
||||
|
||||
## License
|
||||
|
||||
All crates licensed under either of
|
||||
@@ -46,7 +39,7 @@ dual licensed as above, without any additional terms or conditions.
|
||||
[build-image]: https://github.com/RustCrypto/signatures/actions/workflows/slh-dsa.yml/badge.svg
|
||||
[build-link]: https://github.com/RustCrypto/signatures/actions/workflows/slh-dsa.yml
|
||||
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
|
||||
[rustc-image]: https://img.shields.io/badge/rustc-1.75+-blue.svg
|
||||
[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg
|
||||
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
|
||||
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260048-signatures
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
use criterion::{Criterion, black_box, criterion_group, criterion_main};
|
||||
use signature::{Keypair, Signer, Verifier};
|
||||
use slh_dsa::*;
|
||||
|
||||
pub fn sign_benchmark<P: ParameterSet>(c: &mut Criterion) {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::rng();
|
||||
let sk = SigningKey::<P>::new(&mut rng);
|
||||
c.bench_function(&format!("sign: {}", P::NAME), |b| {
|
||||
b.iter(|| {
|
||||
@@ -15,7 +15,7 @@ pub fn sign_benchmark<P: ParameterSet>(c: &mut Criterion) {
|
||||
}
|
||||
|
||||
pub fn verify_benchmark<P: ParameterSet>(c: &mut Criterion) {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::rng();
|
||||
let sk = SigningKey::<P>::new(&mut rng);
|
||||
let msg = b"Hello, world!";
|
||||
let sig = sk.try_sign(msg).unwrap();
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
use hybrid_array::Array;
|
||||
use typenum::U22;
|
||||
|
||||
use zerocopy::byteorder::big_endian::{U32, U64};
|
||||
use zerocopy::AsBytes;
|
||||
use zerocopy::byteorder::big_endian::{U32, U64};
|
||||
|
||||
/// `Address` represents a hash address as defined by FIPS-205 section 4.2
|
||||
pub trait Address: AsRef<[u8]> {
|
||||
|
||||
+10
-10
@@ -3,7 +3,7 @@ use core::fmt::Debug;
|
||||
use hybrid_array::{Array, ArraySize};
|
||||
use typenum::Unsigned;
|
||||
|
||||
use crate::{address, PkSeed, SkSeed};
|
||||
use crate::{PkSeed, SkSeed, address};
|
||||
|
||||
use crate::hypertree::HypertreeParams;
|
||||
use crate::util::base_2b;
|
||||
@@ -199,7 +199,7 @@ pub(crate) trait ForsParams: HypertreeParams {
|
||||
for j in 0..Self::A::U32 {
|
||||
adrs.tree_height.set(j + 1);
|
||||
adrs.tree_index.set(adrs.tree_index.get() >> 1);
|
||||
if indices[i as usize] >> j & 1 == 0 {
|
||||
if (indices[i as usize] >> j) & 1 == 0 {
|
||||
node = Self::h(pk_seed, &adrs, &node, &sig.0[i as usize].auth[j as usize]);
|
||||
} else {
|
||||
node = Self::h(pk_seed, &adrs, &sig.0[i as usize].auth[j as usize], &node);
|
||||
@@ -214,10 +214,10 @@ pub(crate) trait ForsParams: HypertreeParams {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use self::address::ForsTree;
|
||||
use crate::util::macros::test_parameter_sets;
|
||||
use crate::Shake128f;
|
||||
use crate::util::macros::test_parameter_sets;
|
||||
|
||||
use rand::{thread_rng, Rng, RngCore};
|
||||
use rand::{Rng, RngCore, rng};
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -472,7 +472,7 @@ mod tests {
|
||||
|
||||
fn test_sign_verify<Fors: ForsParams>() {
|
||||
// Generate random sk_seed, pk_seed, message, index, address
|
||||
let mut rng = thread_rng();
|
||||
let mut rng = rng();
|
||||
|
||||
let sk_seed = SkSeed::new(&mut rng);
|
||||
|
||||
@@ -481,12 +481,12 @@ mod tests {
|
||||
let mut msg = Array::<u8, Fors::MD>::default();
|
||||
rng.fill_bytes(msg.as_mut_slice());
|
||||
|
||||
let idx_tree = rng.gen_range(
|
||||
let idx_tree = rng.random_range(
|
||||
0..=(1u64
|
||||
.wrapping_shl(Fors::H::U32 - Fors::HPrime::U32)
|
||||
.wrapping_sub(1)),
|
||||
);
|
||||
let idx_leaf = rng.gen_range(0..(1 << (Fors::HPrime::USIZE)));
|
||||
let idx_leaf = rng.random_range(0..(1 << (Fors::HPrime::USIZE)));
|
||||
|
||||
let mut adrs = ForsTree::new(idx_tree, idx_leaf);
|
||||
let mut pks = Array::<Array<u8, Fors::N>, Fors::K>::default();
|
||||
@@ -505,7 +505,7 @@ mod tests {
|
||||
|
||||
fn test_sign_verify_failure<Fors: ForsParams>() {
|
||||
// Generate random sk_seed, pk_seed, message, index, address
|
||||
let mut rng = thread_rng();
|
||||
let mut rng = rng();
|
||||
|
||||
let sk_seed = SkSeed::new(&mut rng);
|
||||
|
||||
@@ -514,12 +514,12 @@ mod tests {
|
||||
let mut msg = Array::<u8, Fors::MD>::default();
|
||||
rng.fill_bytes(msg.as_mut_slice());
|
||||
|
||||
let idx_tree = rng.gen_range(
|
||||
let idx_tree = rng.random_range(
|
||||
0..=(1u64
|
||||
.wrapping_shl(Fors::H::U32 - Fors::HPrime::U32)
|
||||
.wrapping_sub(1)),
|
||||
);
|
||||
let idx_leaf = rng.gen_range(0..(1 << (Fors::HPrime::USIZE)));
|
||||
let idx_leaf = rng.random_range(0..(1 << (Fors::HPrime::USIZE)));
|
||||
|
||||
let mut adrs = ForsTree::new(idx_tree, idx_leaf);
|
||||
let mut pks = Array::<Array<u8, Fors::N>, Fors::K>::default();
|
||||
|
||||
@@ -12,7 +12,7 @@ use hybrid_array::{Array, ArraySize};
|
||||
pub use sha2::*;
|
||||
pub use shake::*;
|
||||
|
||||
use crate::{address::Address, PkSeed, SkPrf, SkSeed};
|
||||
use crate::{PkSeed, SkPrf, SkSeed, address::Address};
|
||||
|
||||
/// A trait specifying the hash functions described in FIPS-205 section 10
|
||||
pub(crate) trait HashSuite: Sized + Clone + Debug + PartialEq + Eq {
|
||||
@@ -113,6 +113,8 @@ mod tests {
|
||||
// Exercises the mgf1_sha512 function
|
||||
#[test]
|
||||
fn h_msg_sha2_256_f() {
|
||||
h_msg::<Sha2_256f>(&hex!("8c86dfb66392d1b647df0deab90be68fb6f988513e84d3ef75fa68591122bb5d74f6413672db5164e56492b7ca2c2e0335"));
|
||||
h_msg::<Sha2_256f>(&hex!(
|
||||
"8c86dfb66392d1b647df0deab90be68fb6f988513e84d3ef75fa68591122bb5d74f6413672db5164e56492b7ca2c2e0335"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ use core::fmt::Debug;
|
||||
|
||||
use crate::hashes::HashSuite;
|
||||
use crate::{
|
||||
address::Address, fors::ForsParams, hypertree::HypertreeParams, wots::WotsParams,
|
||||
xmss::XmssParams, ParameterSet,
|
||||
ParameterSet, address::Address, fors::ForsParams, hypertree::HypertreeParams, wots::WotsParams,
|
||||
xmss::XmssParams,
|
||||
};
|
||||
use crate::{PkSeed, SkPrf, SkSeed};
|
||||
use const_oid::db::fips205;
|
||||
@@ -14,7 +14,7 @@ use digest::{Digest, KeyInit, Mac};
|
||||
use hmac::Hmac;
|
||||
use hybrid_array::{Array, ArraySize};
|
||||
use sha2::{Sha256, Sha512};
|
||||
use typenum::{Diff, Sum, U, U128, U16, U24, U30, U32, U34, U39, U42, U47, U49, U64};
|
||||
use typenum::{Diff, Sum, U, U16, U24, U30, U32, U34, U39, U42, U47, U49, U64, U128};
|
||||
|
||||
/// Implementation of the MGF1 XOF
|
||||
fn mgf1<H: Digest, L: ArraySize>(seed: &[u8]) -> Array<u8, L> {
|
||||
|
||||
+10
-10
@@ -1,4 +1,4 @@
|
||||
use crate::{signing_key::SkSeed, PkSeed};
|
||||
use crate::{PkSeed, signing_key::SkSeed};
|
||||
use core::fmt::Debug;
|
||||
use hybrid_array::{Array, ArraySize};
|
||||
use typenum::Unsigned;
|
||||
@@ -130,12 +130,12 @@ pub trait HypertreeParams: XmssParams + Sized {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{hashes::Shake128f, util::macros::test_parameter_sets, PkSeed};
|
||||
use crate::{PkSeed, hashes::Shake128f, util::macros::test_parameter_sets};
|
||||
use hybrid_array::Array;
|
||||
use rand::{thread_rng, Rng};
|
||||
use rand::{Rng, rng};
|
||||
|
||||
fn test_ht_sign_verify<HTMode: HypertreeParams>() {
|
||||
let mut rng = thread_rng();
|
||||
let mut rng = rng();
|
||||
|
||||
let sk_seed = SkSeed::new(&mut rng);
|
||||
|
||||
@@ -144,12 +144,12 @@ mod tests {
|
||||
let mut m = Array::<u8, HTMode::N>::default();
|
||||
rng.fill(m.as_mut_slice());
|
||||
|
||||
let idx_tree = rng.gen_range(
|
||||
let idx_tree = rng.random_range(
|
||||
0..=(1u64
|
||||
.wrapping_shl(HTMode::H::U32 - HTMode::HPrime::U32)
|
||||
.wrapping_sub(1)),
|
||||
);
|
||||
let idx_leaf = rng.gen_range(0..(1 << (HTMode::HPrime::USIZE)));
|
||||
let idx_leaf = rng.random_range(0..(1 << (HTMode::HPrime::USIZE)));
|
||||
|
||||
let mut adrs = WotsHash::default();
|
||||
adrs.tree_adrs_low.set(0);
|
||||
@@ -167,7 +167,7 @@ mod tests {
|
||||
test_parameter_sets!(test_ht_sign_verify);
|
||||
|
||||
fn test_ht_sign_verify_fail<HTMode: HypertreeParams>() {
|
||||
let mut rng = thread_rng();
|
||||
let mut rng = rng();
|
||||
|
||||
let sk_seed = SkSeed::new(&mut rng);
|
||||
|
||||
@@ -176,12 +176,12 @@ mod tests {
|
||||
let mut m = Array::<u8, HTMode::N>::default();
|
||||
rng.fill(m.as_mut_slice());
|
||||
|
||||
let idx_tree = rng.gen_range(
|
||||
let idx_tree = rng.random_range(
|
||||
0..=(1u64
|
||||
.wrapping_shl(HTMode::H::U32 - HTMode::HPrime::U32)
|
||||
.wrapping_sub(1)),
|
||||
);
|
||||
let idx_leaf = rng.gen_range(0..(1 << (HTMode::HPrime::USIZE)));
|
||||
let idx_leaf = rng.random_range(0..(1 << (HTMode::HPrime::USIZE)));
|
||||
|
||||
let mut adrs = WotsHash::default();
|
||||
adrs.tree_adrs_low.set(0);
|
||||
@@ -206,7 +206,7 @@ mod tests {
|
||||
#[cfg(feature = "alloc")]
|
||||
fn test_ht_sign_kat() {
|
||||
use hex_literal::hex;
|
||||
use sha3::{digest::ExtendableOutput, Shake256};
|
||||
use sha3::{Shake256, digest::ExtendableOutput};
|
||||
|
||||
let sk_seed = SkSeed(Array([1; 16]));
|
||||
let pk_seed = PkSeed(Array([2; 16]));
|
||||
|
||||
+9
-9
@@ -24,7 +24,7 @@
|
||||
//! use slh_dsa::*;
|
||||
//! use signature::*;
|
||||
//!
|
||||
//! let mut rng = rand::thread_rng();
|
||||
//! let mut rng = rand::rng();
|
||||
//!
|
||||
//! // Generate a signing key using the SHAKE128f parameter set
|
||||
//! let sk = SigningKey::<Shake128f>::new(&mut rng);
|
||||
@@ -86,7 +86,7 @@ mod tests {
|
||||
use util::macros::test_parameter_sets;
|
||||
|
||||
fn test_sign_verify<P: ParameterSet>() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::rng();
|
||||
let sk = SigningKey::<P>::new(&mut rng);
|
||||
let vk = sk.verifying_key();
|
||||
let msg = b"Hello, world!";
|
||||
@@ -98,7 +98,7 @@ mod tests {
|
||||
// Check signature fails on modified message
|
||||
#[test]
|
||||
fn test_sign_verify_shake_128f_fail_on_modified_message() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::rng();
|
||||
let sk = SigningKey::<Shake128f>::new(&mut rng);
|
||||
let msg = b"Hello, world!";
|
||||
let modified_msg = b"Goodbye, world!";
|
||||
@@ -111,7 +111,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_sign_verify_fail_with_wrong_verifying_key() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::rng();
|
||||
let sk = SigningKey::<Shake128f>::new(&mut rng);
|
||||
let wrong_sk = SigningKey::<Shake128f>::new(&mut rng); // Generate a different signing key
|
||||
let msg = b"Hello, world!";
|
||||
@@ -125,14 +125,14 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_sign_verify_fail_on_modified_signature() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::rng();
|
||||
let sk = SigningKey::<Shake128f>::new(&mut rng);
|
||||
let msg = b"Hello, world!";
|
||||
|
||||
let mut sig_bytes = sk.try_sign(msg).unwrap().to_bytes();
|
||||
// Randomly modify one byte in the signature
|
||||
let sig_len = sig_bytes.len();
|
||||
let random_byte_index = rng.gen_range(0..sig_len);
|
||||
let random_byte_index = rng.random_range(0..sig_len);
|
||||
sig_bytes[random_byte_index] ^= 0xff; // Invert one byte to ensure it's different
|
||||
let sig = (&sig_bytes).into();
|
||||
|
||||
@@ -145,7 +145,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_successive_signatures_not_equal() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::rng();
|
||||
let sk = SigningKey::<Shake128f>::new(&mut rng);
|
||||
let msg = b"Hello, world!";
|
||||
|
||||
@@ -160,7 +160,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_sign_verify_nonempty_context() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::rng();
|
||||
let sk = SigningKey::<Shake128f>::new(&mut rng);
|
||||
let vk = sk.verifying_key();
|
||||
let msg = b"Hello, world!";
|
||||
@@ -171,7 +171,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_sign_verify_wrong_context() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::rng();
|
||||
let sk = SigningKey::<Shake128f>::new(&mut rng);
|
||||
let vk = sk.verifying_key();
|
||||
let msg = b"Hello, world!";
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
use crate::ParameterSet;
|
||||
use crate::hashes::{
|
||||
Sha2_128f, Sha2_128s, Sha2_192f, Sha2_192s, Sha2_256f, Sha2_256s, Shake128f, Shake192f,
|
||||
Shake192s, Shake256f, Shake256s,
|
||||
};
|
||||
use crate::hypertree::HypertreeSig;
|
||||
use crate::ParameterSet;
|
||||
use crate::{fors::ForsSignature, Shake128s};
|
||||
use crate::{Shake128s, fors::ForsSignature};
|
||||
use ::signature::{Error, SignatureEncoding};
|
||||
use hybrid_array::sizes::{U16224, U17088, U29792, U35664, U49856, U7856};
|
||||
use hybrid_array::sizes::{U7856, U16224, U17088, U29792, U35664, U49856};
|
||||
use hybrid_array::{Array, ArraySize};
|
||||
use pkcs8::{der::AnyRef, spki::AssociatedAlgorithmIdentifier, AlgorithmIdentifierRef};
|
||||
use pkcs8::{AlgorithmIdentifierRef, der::AnyRef, spki::AssociatedAlgorithmIdentifier};
|
||||
use typenum::Unsigned;
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
@@ -24,7 +24,6 @@ use pkcs8::{
|
||||
/// small devices. The stack representation consumes `P::SigLen` bytes
|
||||
///
|
||||
/// There are no invariants maintained by this struct - every field is a hash value
|
||||
|
||||
pub struct Signature<P: ParameterSet> {
|
||||
pub(crate) randomizer: Array<u8, P::N>,
|
||||
pub(crate) fors_sig: ForsSignature<P>,
|
||||
@@ -180,15 +179,15 @@ impl SignatureLen for Sha2_256f {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::SigningKey;
|
||||
use crate::signature_encoding::Signature;
|
||||
use crate::util::macros::test_parameter_sets;
|
||||
use crate::SigningKey;
|
||||
use crate::{hashes::*, ParameterSet};
|
||||
use crate::{ParameterSet, hashes::*};
|
||||
use hybrid_array::Array;
|
||||
use signature::{SignatureEncoding, Signer};
|
||||
|
||||
fn test_serialize_deserialize<P: ParameterSet>() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::rng();
|
||||
let sk = SigningKey::<P>::new(&mut rng);
|
||||
let msg = b"Hello, world!";
|
||||
let sig = sk.try_sign(msg).unwrap();
|
||||
@@ -206,7 +205,7 @@ mod tests {
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
fn test_serialize_deserialize_vec<P: ParameterSet>() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::rng();
|
||||
let sk = SigningKey::<P>::new(&mut rng);
|
||||
let msg = b"Hello, world!";
|
||||
let sig = sk.try_sign(msg).unwrap();
|
||||
@@ -225,7 +224,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_deserialize_fail_on_incorrect_length() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::rng();
|
||||
let sk = SigningKey::<Shake128f>::new(&mut rng);
|
||||
let msg = b"Hello, world!";
|
||||
let sig = sk.try_sign(msg).unwrap();
|
||||
|
||||
+17
-13
@@ -3,18 +3,21 @@ use crate::signature_encoding::Signature;
|
||||
use crate::util::split_digest;
|
||||
use crate::verifying_key::VerifyingKey;
|
||||
use crate::{ParameterSet, PkSeed, Sha2L1, Sha2L35, Shake, VerifyingKeyLen};
|
||||
use ::signature::{Error, KeypairRef, RandomizedSigner, Signer};
|
||||
use ::signature::{
|
||||
Error, KeypairRef, RandomizedSigner, Signer,
|
||||
rand_core::{CryptoRng, TryCryptoRng},
|
||||
};
|
||||
use hybrid_array::{Array, ArraySize};
|
||||
use pkcs8::{
|
||||
der::AnyRef,
|
||||
spki::{AlgorithmIdentifier, AssociatedAlgorithmIdentifier, SignatureAlgorithmIdentifier},
|
||||
};
|
||||
use typenum::{Unsigned, U, U16, U24, U32};
|
||||
use typenum::{U, U16, U24, U32, Unsigned};
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
use pkcs8::{
|
||||
der::{self, asn1::OctetStringRef},
|
||||
EncodePrivateKey,
|
||||
der::{self, asn1::OctetStringRef},
|
||||
};
|
||||
|
||||
// NewTypes for ensuring hash argument order correctness
|
||||
@@ -32,7 +35,7 @@ impl<N: ArraySize> From<&[u8]> for SkSeed<N> {
|
||||
}
|
||||
}
|
||||
impl<N: ArraySize> SkSeed<N> {
|
||||
pub(crate) fn new(rng: &mut impl rand_core::CryptoRngCore) -> Self {
|
||||
pub(crate) fn new<R: CryptoRng + ?Sized>(rng: &mut R) -> Self {
|
||||
let mut bytes = Array::<u8, N>::default();
|
||||
rng.fill_bytes(bytes.as_mut_slice());
|
||||
Self(bytes)
|
||||
@@ -53,7 +56,7 @@ impl<N: ArraySize> From<&[u8]> for SkPrf<N> {
|
||||
}
|
||||
}
|
||||
impl<N: ArraySize> SkPrf<N> {
|
||||
pub(crate) fn new(rng: &mut impl rand_core::CryptoRngCore) -> Self {
|
||||
pub(crate) fn new<R: CryptoRng + ?Sized>(rng: &mut R) -> Self {
|
||||
let mut bytes = Array::<u8, N>::default();
|
||||
rng.fill_bytes(bytes.as_mut_slice());
|
||||
Self(bytes)
|
||||
@@ -76,7 +79,7 @@ pub trait SigningKeyLen: VerifyingKeyLen {
|
||||
|
||||
impl<P: ParameterSet> SigningKey<P> {
|
||||
/// Create a new `SigningKey` from a cryptographic random number generator
|
||||
pub fn new(rng: &mut impl rand_core::CryptoRngCore) -> Self {
|
||||
pub fn new<R: CryptoRng + ?Sized>(rng: &mut R) -> Self {
|
||||
let sk_seed = SkSeed::new(rng);
|
||||
let sk_prf = SkPrf::new(rng);
|
||||
let pk_seed = PkSeed::new(rng);
|
||||
@@ -204,13 +207,14 @@ impl<P: ParameterSet> Signer<Signature<P>> for SigningKey<P> {
|
||||
}
|
||||
|
||||
impl<P: ParameterSet> RandomizedSigner<Signature<P>> for SigningKey<P> {
|
||||
fn try_sign_with_rng(
|
||||
fn try_sign_with_rng<R: TryCryptoRng + ?Sized>(
|
||||
&self,
|
||||
rng: &mut impl signature::rand_core::CryptoRngCore,
|
||||
rng: &mut R,
|
||||
msg: &[u8],
|
||||
) -> Result<Signature<P>, signature::Error> {
|
||||
let mut randomizer = Array::<u8, P::N>::default();
|
||||
rng.fill_bytes(randomizer.as_mut_slice());
|
||||
rng.try_fill_bytes(randomizer.as_mut_slice())
|
||||
.map_err(|_| signature::Error::new())?;
|
||||
self.try_sign_with_context(msg, &[], Some(&randomizer))
|
||||
}
|
||||
}
|
||||
@@ -289,10 +293,10 @@ impl<M> SigningKeyLen for Shake<U32, M> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{util::macros::test_parameter_sets, ParameterSet, SigningKey};
|
||||
use crate::{ParameterSet, SigningKey, util::macros::test_parameter_sets};
|
||||
|
||||
fn test_serialize_deserialize<P: ParameterSet>() {
|
||||
let mut rng: rand::prelude::ThreadRng = rand::thread_rng();
|
||||
let mut rng: rand::prelude::ThreadRng = rand::rng();
|
||||
let sk = SigningKey::<P>::new(&mut rng);
|
||||
let bytes = sk.to_bytes();
|
||||
let sk2 = SigningKey::<P>::try_from(bytes.as_slice()).unwrap();
|
||||
@@ -302,7 +306,7 @@ mod tests {
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
fn test_serialize_deserialize_vec<P: ParameterSet>() {
|
||||
let mut rng: rand::prelude::ThreadRng = rand::thread_rng();
|
||||
let mut rng: rand::prelude::ThreadRng = rand::rng();
|
||||
let sk = SigningKey::<P>::new(&mut rng);
|
||||
let vec = sk.to_vec();
|
||||
let sk2 = SigningKey::<P>::try_from(vec.as_slice()).unwrap();
|
||||
@@ -313,7 +317,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_deserialize_fail_on_incorrect_length() {
|
||||
let mut rng: rand::prelude::ThreadRng = rand::thread_rng();
|
||||
let mut rng: rand::prelude::ThreadRng = rand::rng();
|
||||
let sk = SigningKey::<Shake128f>::new(&mut rng);
|
||||
let bytes = sk.to_bytes();
|
||||
let incorrect_bytes = &bytes[..bytes.len() - 1];
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
use crate::fors::ForsParams;
|
||||
use hybrid_array::{typenum::Unsigned, Array, ArraySize};
|
||||
use hybrid_array::{Array, ArraySize, typenum::Unsigned};
|
||||
|
||||
// Algorithm 3
|
||||
pub fn base_2b<OutLen: ArraySize, B: Unsigned>(x: &[u8]) -> Array<u16, OutLen> {
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
use crate::address::ForsTree;
|
||||
use crate::signature_encoding::Signature;
|
||||
use crate::util::split_digest;
|
||||
use crate::ParameterSet;
|
||||
use crate::Sha2L1;
|
||||
use crate::Sha2L35;
|
||||
use crate::Shake;
|
||||
use crate::address::ForsTree;
|
||||
use crate::signature_encoding::Signature;
|
||||
use crate::util::split_digest;
|
||||
use ::signature::{Error, Verifier};
|
||||
use hybrid_array::{Array, ArraySize};
|
||||
use pkcs8::{der, spki};
|
||||
use typenum::{Unsigned, U, U16, U24, U32};
|
||||
use rand_core::CryptoRng;
|
||||
use typenum::{U, U16, U24, U32, Unsigned};
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
use pkcs8::EncodePublicKey;
|
||||
@@ -33,7 +34,7 @@ impl<N: ArraySize> From<&[u8]> for PkSeed<N> {
|
||||
}
|
||||
}
|
||||
impl<N: ArraySize> PkSeed<N> {
|
||||
pub(crate) fn new(rng: &mut impl rand_core::RngCore) -> Self {
|
||||
pub(crate) fn new<R: CryptoRng + ?Sized>(rng: &mut R) -> Self {
|
||||
let mut bytes = Array::<u8, N>::default();
|
||||
rng.fill_bytes(bytes.as_mut_slice());
|
||||
Self(bytes)
|
||||
@@ -216,7 +217,7 @@ mod tests {
|
||||
use signature::*;
|
||||
#[test]
|
||||
fn test_vk_serialize_deserialize() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::rng();
|
||||
let sk = SigningKey::<Shake128f>::new(&mut rng);
|
||||
let vk = sk.verifying_key();
|
||||
let vk_bytes: Array<u8, _> = (&vk).into();
|
||||
|
||||
+6
-6
@@ -1,10 +1,10 @@
|
||||
use hybrid_array::{Array, ArraySize};
|
||||
use typenum::generic_const_mappings::U;
|
||||
use typenum::Unsigned;
|
||||
use typenum::generic_const_mappings::U;
|
||||
|
||||
use crate::hashes::HashSuite;
|
||||
use crate::util::base_2b;
|
||||
use crate::{address, PkSeed, SkSeed};
|
||||
use crate::{PkSeed, SkSeed, address};
|
||||
use core::fmt::Debug;
|
||||
|
||||
// WOTS+ in general is parameterized on these values
|
||||
@@ -148,10 +148,10 @@ pub(crate) trait WotsParams: HashSuite {
|
||||
}
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{util::macros::test_parameter_sets, PkSeed, SkSeed};
|
||||
use crate::{PkSeed, SkSeed, util::macros::test_parameter_sets};
|
||||
use hex_literal::hex;
|
||||
use hybrid_array::Array;
|
||||
use rand::{thread_rng, RngCore};
|
||||
use rand::{RngCore, rng};
|
||||
|
||||
use crate::{address::WotsHash, hashes::Shake128f};
|
||||
|
||||
@@ -159,7 +159,7 @@ mod tests {
|
||||
|
||||
fn test_sign_verify<Wots: WotsParams>() {
|
||||
// Generate random sk_seed, pk_seed, message, address
|
||||
let mut rng = thread_rng();
|
||||
let mut rng = rng();
|
||||
|
||||
let sk_seed = SkSeed::new(&mut rng);
|
||||
|
||||
@@ -182,7 +182,7 @@ mod tests {
|
||||
|
||||
fn test_sign_verify_fail<Wots: WotsParams>() {
|
||||
// Generate random sk_seed, pk_seed, message
|
||||
let mut rng = thread_rng();
|
||||
let mut rng = rng();
|
||||
|
||||
let sk_seed = SkSeed::new(&mut rng);
|
||||
|
||||
|
||||
+7
-7
@@ -2,8 +2,8 @@ use hybrid_array::{Array, ArraySize};
|
||||
use typenum::Unsigned;
|
||||
|
||||
use crate::wots::WotsSig;
|
||||
use crate::{address, wots::WotsParams};
|
||||
use crate::{PkSeed, SkSeed};
|
||||
use crate::{address, wots::WotsParams};
|
||||
use core::fmt::Debug;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
@@ -137,14 +137,14 @@ where {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use crate::util::macros::test_parameter_sets;
|
||||
use crate::PkSeed;
|
||||
use crate::SkSeed;
|
||||
use crate::util::macros::test_parameter_sets;
|
||||
use hex_literal::hex;
|
||||
use hybrid_array::Array;
|
||||
use rand::thread_rng;
|
||||
use rand::Rng;
|
||||
use rand::RngCore;
|
||||
use rand::rng;
|
||||
|
||||
use typenum::Unsigned;
|
||||
|
||||
@@ -206,7 +206,7 @@ mod tests {
|
||||
|
||||
fn test_sign_verify<Xmss: XmssParams>() {
|
||||
// Generate random sk_seed, pk_seed, message, index, address
|
||||
let mut rng = thread_rng();
|
||||
let mut rng = rng();
|
||||
|
||||
let sk_seed = SkSeed::new(&mut rng);
|
||||
|
||||
@@ -215,7 +215,7 @@ mod tests {
|
||||
let mut msg = Array::<u8, _>::default();
|
||||
rng.fill_bytes(msg.as_mut_slice());
|
||||
|
||||
let idx = rng.gen_range(0..(1 << Xmss::HPrime::U32));
|
||||
let idx = rng.random_range(0..(1 << Xmss::HPrime::U32));
|
||||
|
||||
let adrs = WotsHash::default();
|
||||
|
||||
@@ -231,7 +231,7 @@ mod tests {
|
||||
|
||||
fn test_sign_verify_fail<Xmss: XmssParams>() {
|
||||
// Generate random sk_seed, pk_seed, message, index, address
|
||||
let mut rng = thread_rng();
|
||||
let mut rng = rng();
|
||||
|
||||
let sk_seed = SkSeed::new(&mut rng);
|
||||
|
||||
@@ -240,7 +240,7 @@ mod tests {
|
||||
let mut msg = Array::<u8, _>::default();
|
||||
rng.fill_bytes(msg.as_mut_slice());
|
||||
|
||||
let idx = rng.gen_range(0..(1 << Xmss::HPrime::U32));
|
||||
let idx = rng.random_range(0..(1 << Xmss::HPrime::U32));
|
||||
|
||||
let adrs = WotsHash::default();
|
||||
|
||||
|
||||
@@ -8,8 +8,9 @@ use std::{array::from_fn, fmt::Write};
|
||||
|
||||
use aes::Aes256;
|
||||
use cipher::{KeyIvInit, StreamCipher};
|
||||
use core::{error, fmt};
|
||||
use ctr::Ctr128BE;
|
||||
use rand_core::{CryptoRng, RngCore};
|
||||
use rand_core::{CryptoRng, RngCore, TryCryptoRng, TryRngCore};
|
||||
use sha2::Digest;
|
||||
use signature::Keypair;
|
||||
use signature::SignatureEncoding;
|
||||
@@ -47,11 +48,6 @@ impl RngCore for KatRng {
|
||||
self.update(None);
|
||||
}
|
||||
|
||||
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand::Error> {
|
||||
self.fill_bytes(dest);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn next_u32(&mut self) -> u32 {
|
||||
rand_core::impls::next_u32_via_fill(self)
|
||||
}
|
||||
@@ -66,15 +62,12 @@ impl CryptoRng for KatRng {}
|
||||
// Mock RNG that just returns a pre-determined bytestring
|
||||
struct ConstRng(Vec<u8>);
|
||||
|
||||
impl RngCore for ConstRng {
|
||||
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::Error> {
|
||||
impl TryRngCore for ConstRng {
|
||||
type Error = RandError;
|
||||
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), RandError> {
|
||||
let len = dest.len();
|
||||
if len > self.0.len() {
|
||||
return Err(rand::Error::new("not enough bytes"));
|
||||
return Err(RandError);
|
||||
}
|
||||
|
||||
dest.iter_mut()
|
||||
@@ -83,16 +76,32 @@ impl RngCore for ConstRng {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn next_u32(&mut self) -> u32 {
|
||||
rand_core::impls::next_u32_via_fill(self)
|
||||
fn try_next_u32(&mut self) -> Result<u32, RandError> {
|
||||
let mut buf = [0; 4];
|
||||
self.try_fill_bytes(&mut buf)?;
|
||||
Ok(u32::from_le_bytes(buf))
|
||||
}
|
||||
|
||||
fn next_u64(&mut self) -> u64 {
|
||||
rand_core::impls::next_u64_via_fill(self)
|
||||
fn try_next_u64(&mut self) -> Result<u64, RandError> {
|
||||
let mut buf = [0; 8];
|
||||
self.try_fill_bytes(&mut buf)?;
|
||||
Ok(u64::from_le_bytes(buf))
|
||||
}
|
||||
}
|
||||
|
||||
impl CryptoRng for ConstRng {}
|
||||
/// Not enough bytes error
|
||||
#[derive(Debug)]
|
||||
struct RandError;
|
||||
|
||||
impl fmt::Display for RandError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "not enough bytes")
|
||||
}
|
||||
}
|
||||
|
||||
impl error::Error for RandError {}
|
||||
|
||||
impl TryCryptoRng for ConstRng {}
|
||||
|
||||
const ITERS: usize = 10;
|
||||
fn test_kat<P: ParameterSet + VerifyingKeyLen>(expected: &str)
|
||||
@@ -124,11 +133,11 @@ where
|
||||
rng.fill_bytes(&mut seed);
|
||||
let mut seed_rng = ConstRng(seed);
|
||||
|
||||
let sk = SigningKey::<P>::new(&mut seed_rng);
|
||||
let sk = SigningKey::<P>::new(&mut seed_rng.unwrap_mut());
|
||||
let pk = sk.verifying_key();
|
||||
|
||||
writeln!(resp, "pk = {}", hex::encode_upper(&pk.to_bytes())).unwrap();
|
||||
writeln!(resp, "sk = {}", hex::encode_upper(&sk.to_bytes())).unwrap();
|
||||
writeln!(resp, "pk = {}", hex::encode_upper(pk.to_bytes())).unwrap();
|
||||
writeln!(resp, "sk = {}", hex::encode_upper(sk.to_bytes())).unwrap();
|
||||
|
||||
let mut opt_rand = vec![0; P::VkLen::USIZE / 2];
|
||||
rng.fill_bytes(opt_rand.as_mut());
|
||||
|
||||
Reference in New Issue
Block a user