Commit Graph

828 Commits

Author SHA1 Message Date
Tony Arcieri 2b4e0cc8c7 Bump hybrid-array to v0.2.0-rc.3 (#800) 2024-01-28 19:18:48 -07:00
Tony Arcieri ef35987cd1 dsa: add missing backtick in CHANGELOG.md 2024-01-28 09:33:43 -07:00
Tony Arcieri cd99984e7d dsa: v0.6.3 CHANGELOG.md entry
This is a backport which was released in #799
2024-01-28 09:32:30 -07:00
Friedel Ziegelmayer b90db64bcb feat(dsa): implement `SigningKey::sign_prehashed_rfc6979 (#798)
Allows to use other digest algorithms.
2024-01-27 12:03:58 -07:00
dependabot[bot] ab263a9c43 build(deps): bump actions/cache from 3 to 4 (#797)
Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-22 07:41:03 -07:00
Tony Arcieri 43e4fd03f6 ecdsa v0.17.0-pre.4 (#796) ecdsa/v0.17.0-pre.4 2024-01-19 12:23:27 -07:00
Tony Arcieri fa7eb4bc2f rfc6979: restore generate_k_mut (#795)
Restores a version of `generate_k` which operates over byte slices as
opposed to fixed-size `Array`s.

Useful for implementing `dsa`.
2024-01-18 13:03:35 -07:00
Tony Arcieri ff9a2058bd ecdsa: use NonZeroScalar arguments to sign_prehashed (#794)
Provides type-level enforcement that these parameters are non-zero
2024-01-17 19:07:59 -07:00
Tony Arcieri 3ed9867409 ecdsa: remove SignPrimitive and VerifyPrimitive traits (#793)
The backstory of these traits was once upon a time we didn't yet have
the trait structure in place to express algorithms like ECDSA signing
and verification generically, so each crate (at the time just `k256` and
`p256`) had a nearly duplicated implementation of ECDSA, with `k256`
including tweaks for low-S normalization.

Now the `ecdsa` crate contains fully generic implementations of both
algorithms, and with the `EcdsaCurve` trait, carries a `NORMALIZE_S`
preference, so these traits are just needless indirection at this point.

This removes the traits, converting non-trivial methods into static
functions in the `hazmat` module, namely `sign_prehashed_rfc6979`.
2024-01-17 18:18:59 -07:00
Tony Arcieri c5206d43db ecdsa: use EcdsaCurve in bounds (#792)
Replaces previous `PrimeCurve` bounds with the new `EcdsaCurve` trait
(which has a supertrait bound on `PrimeCurve`).
2024-01-17 16:14:01 -07:00
Tony Arcieri 56b8b7acdf ecdsa: move EcdsaCurve trait to toplevel (#791)
Moves the trait added in #787 out of the `hazmat` module and into the
toplevel, so it's available regardless of whether or not the `hazmat`
feature has been enabled.
2024-01-17 14:20:52 -07:00
Tony Arcieri 3992dc30e0 ecdsa: don't feature-gate EcdsaCurve (#790)
There's no reason for it to be gated on `arithmetic`. It can be provided
in all use cases.
2024-01-17 13:09:03 -07:00
Tony Arcieri 7bc69e132d ecdsa v0.17.0-pre.3 (#789) ecdsa/v0.17.0-pre.3 2024-01-17 12:37:32 -07:00
Tony Arcieri 1c8963a5a2 rfc6979 v0.5.0-pre.2 (#788) rfc6979/v0.5.0-pre.2 2024-01-17 12:23:29 -07:00
Tony Arcieri 9eda95a623 ecdsa: add EcdsaCurve marker trait (#787)
This trait is the intended successor to the `SignPrimitive` and
`VerifyPrimitive` traits.

Currently the only reason for a non-default impl of those traits is to
handle low-S normalization. The `EcdsaCurve` trait now not only marks
the curve as being safe for use with ECDSA, but also captures this
decision regarding low-S normalization so it doesn't have to be
expressed in code.
2024-01-17 12:16:17 -07:00
Tony Arcieri 81adf2e2fc ecdsa: add DER support to SignatureWithOid (#786)
Adds the following methods:

- `from_der_with_digest`
- `from_der_with_oid`
- `to_der`

These handle deserializing/serializing ASN.1 DER-encoded signatures.
2024-01-17 10:17:26 -07:00
Tony Arcieri 4a94edb56a Bump digest, elliptic-curve, and signature; MSRV 1.72 (#785)
Bumps the following dependencies:
- `digest` v0.11.0-pre.7
- `elliptic-curve` v0.14.0-pre.3
- `signature` v2.3.0-pre.2
2024-01-17 10:07:35 -07:00
Tony Arcieri 970aacfaea ecdsa: gate pkcs8::Encode*Key impls under alloc+pkcs8 (#783)
...rather than `pem`, as these can be used to encode DER without having
full `pem` support enabled.

Closes #721
2024-01-17 08:09:20 -07:00
Tony Arcieri 55e4450a65 rfc6979: add P-521 + SHA-512 test vectors (#775)
These now work after #781
2024-01-16 21:30:51 -07:00
Tony Arcieri f6426cfb13 rfc6979: add K-163 test vector; fix nonaligned use (#781)
RFC6979 Appendix A.1. provides a "Detailed Example" which exercises
several edge cases in the protocol:

- `bits2int` for an input which is not byte-aligned
- Rejecting inputs which exceed the modulus

This commit adds what was missing from the previous implementation which
assumed inputs were always aligned to the size of the digest output: a
constant-time right shift by the number of bits by which the modulus is
smaller than a byte-aligned value.
2024-01-16 21:25:52 -07:00
Tony Arcieri 32edd0d630 ecdsa: make Signature::normalize_s infallible (#780)
Unconditionally returns a normalized signature, regardless of whether
the signature was normalized to begin with.

Closes #736
2024-01-16 18:33:49 -07:00
Tony Arcieri 83359e104d ecdsa: reduce z mod q when performing RFC6979 (#777)
The RFC specifies this, however we were not performing it.

Going forward, it would be nice to be able to refactor these APIs to
operate over a `Scalar` which we know is always reduced.
2024-01-16 17:57:05 -07:00
dependabot[bot] 0f53fb823c build(deps): bump serde_bytes from 0.11.13 to 0.11.14 (#764)
Bumps [serde_bytes](https://github.com/serde-rs/bytes) from 0.11.13 to 0.11.14.
- [Release notes](https://github.com/serde-rs/bytes/releases)
- [Commits](https://github.com/serde-rs/bytes/compare/0.11.13...0.11.14)

---
updated-dependencies:
- dependency-name: serde_bytes
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-16 16:14:29 -07:00
Tony Arcieri 8e12e1c7cd ecdsa: remove OutputSize bounds on DigestPrimitive (#774)
Notably for curves like P-521, the digest used to compute the signature
is smaller than a serialized field element (SHA-512 w\ 64-byte output vs
66-byte serialized field elements).

To support such curves, we need to remove this bound.

The already implemented `bits2field` function as defined in
RFC6979 § 2.3.2 and SEC1 § 2.3.8 handles producing a serialized field
element from an input which may be a different size.
2024-01-16 14:06:50 -07:00
Tony Arcieri 2472e1cb7f rfc6979: add generate_k_mut; remove digest bounds (#773)
Adds an API which writes `k` into an output buffer rather than
allocating and returning it, which also accepts slices as inputs. This
makes it possible to use `rfc6979` to implement the `dsa` crate.

Also removes output size bounds on the underlying digest function, which
aren't actually relevant to the implementation at all since HMAC-DRBG
writes a variable-sized amount of output. This makes it possible to use
`rfc6979` + `ecdsa` in conjunction with `p521`, which has unusually
sized scalars (66-bytes) which don't match the output size of the
underlying digest function (SHA-512, which has a 64-byte output).
2024-01-16 09:57:05 -07:00
Bernd Krietenstein b41c216560 Fixed rfc reference in comment. (#772) 2024-01-12 05:55:44 -07:00
Tony Arcieri 9be9453f82 ecdsa: bump elliptic-curve to v0.14.0-pre.2 (#771)
Also cuts a v0.17.0-pre.2 release of `ecdsa`.
ecdsa/v0.17.0-pre.2
2024-01-10 17:47:59 -07:00
Tony Arcieri 2cb7693956 ecdsa: fix new_wycheproof_test! macro (#770)
Updates `from_exact_iter` => `from_iter`
2024-01-10 14:11:13 -07:00
Tony Arcieri 1e5e29cc50 Bump elliptic-curve and signature dependencies (#769)
As well as bumping `hybrid-array` to v0.2.0-rc.0 and `digest` to
v0.11.0-pre.4.

Also cuts `ecdsa` v0.17.0-pre.1 and `rfc6979` v0.5.0-pre.1
ecdsa/v0.17.0-pre.1 rfc6979/v0.5.0-pre.1
2024-01-10 13:34:47 -07:00
Tony Arcieri d935382d8d ecdsa: fix dev macros (#768)
The method changed from `GenericArray::from_slice` to
`Array::ref_from_slice`.

This has been renamed back upstream in `hybrid-array` to simplify
people's upgrades, but for now we need to rename it until we can upgrade
`hybrid-array` again.

Longer term the method will be deprecated, so this is temporary anyway.
2024-01-10 08:16:08 -07:00
Tony Arcieri 6881696f22 ecdsa v0.17.0-pre.0 (#767) ecdsa/v0.17.0-pre.0 2024-01-09 13:39:05 -07:00
Tony Arcieri d7b08e0711 rfc6979 v0.5.0-pre.0 (#766) rfc6979/v0.5.0-pre.0 2024-01-09 13:22:27 -07:00
Tony Arcieri 4ee30f578e Bump signature to v2.3.0-pre.0; MSRV 1.71 (#765)
For `ecdsa` crate: MSRV is 1.73 due to a bump of `elliptic-curve` to
v0.14.0-pre.0.

This commit begins the next round of breaking changes and bumps all
crates to prerelease versions.

The main change in `signature` is an upgrade of the `digest` crate to
v0.11.0-pre.3, which is what brings the new MSRV 1.71 requirement.
2024-01-09 12:07:49 -07:00
dependabot[bot] fedfe874d5 build(deps): bump serde_bytes from 0.11.12 to 0.11.13 (#763)
Bumps [serde_bytes](https://github.com/serde-rs/bytes) from 0.11.12 to 0.11.13.
- [Release notes](https://github.com/serde-rs/bytes/releases)
- [Commits](https://github.com/serde-rs/bytes/compare/0.11.12...0.11.13)

---
updated-dependencies:
- dependency-name: serde_bytes
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-27 07:42:59 -07:00
dependabot[bot] e3a163c76b build(deps): bump elliptic-curve from 0.13.7 to 0.13.8 (#760)
Bumps [elliptic-curve](https://github.com/RustCrypto/traits) from 0.13.7 to 0.13.8.
- [Commits](https://github.com/RustCrypto/traits/compare/elliptic-curve-v0.13.7...elliptic-curve-v0.13.8)

---
updated-dependencies:
- dependency-name: elliptic-curve
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-29 07:59:25 -07:00
dependabot[bot] f0d273960b build(deps): bump spki from 0.7.2 to 0.7.3 (#762)
Bumps [spki](https://github.com/RustCrypto/formats) from 0.7.2 to 0.7.3.
- [Commits](https://github.com/RustCrypto/formats/compare/spki/v0.7.2...spki/v0.7.3)

---
updated-dependencies:
- dependency-name: spki
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-29 07:38:12 -07:00
Alexander Kjäll 571d31fec7 ed25519: use u64 instead of usize in test (#761) 2023-11-21 10:18:22 -07:00
Tony Arcieri 2f3be45884 Cargo.lock: bump signature to v2.2.0 (#759) 2023-11-16 09:25:04 -07:00
Tony Arcieri 89232d6a96 ecdsa v0.16.9 (#758) ecdsa/v0.16.9 2023-11-16 08:56:01 -07:00
Tony Arcieri 4654dc5e09 dsa v0.6.2 (#757) dsa/v0.6.2 2023-11-16 08:26:04 -07:00
Tony Arcieri 250f6525fc dsa+ecdsa: support signature up to v2.2 (#756)
The v2.2.0 release bumped MSRV to 1.60, however that's still compatible
with the MSRV of `dsa` and `ecdsa`, which are both MSRV 1.65.
2023-11-16 07:59:11 -07:00
Tony Arcieri 3895f21a08 Cargo.lock: bump dependencies (#755)
Updates the following dependencies:

    $ cargo update
    Updating crates.io index
    Updating byteorder v1.4.3 -> v1.5.0
    Updating cc v1.0.79 -> v1.0.83
    Updating const-oid v0.9.2 -> v0.9.5
    Updating cpufeatures v0.2.6 -> v0.2.11
    Updating crypto-bigint v0.5.1 -> v0.5.4
    Updating curve25519-dalek v4.0.0 -> v4.1.1
    Updating curve25519-dalek-derive v0.1.0 -> v0.1.1
    Updating ecdsa v0.16.2 -> v0.16.8
    Updating ed25519 v2.2.0 -> v2.2.3
    Updating ed25519-dalek v2.0.0 -> v2.1.0
    Updating elliptic-curve v0.13.6 -> v0.13.7
    Updating fiat-crypto v0.1.20 -> v0.2.4
    Updating getrandom v0.2.8 -> v0.2.11
    Updating libc v0.2.140 -> v0.2.150
    Updating libm v0.2.6 -> v0.2.8
    Updating num-bigint-dig v0.8.2 -> v0.8.4
    Updating p256 v0.13.0 -> v0.13.2
    Updating platforms v3.0.2 -> v3.2.0
    Updating primeorder v0.13.0 -> v0.13.6
    Updating proc-macro2 v1.0.56 -> v1.0.69
    Updating quote v1.0.26 -> v1.0.33
    Updating ring v0.17.2 -> v0.17.5
    Updating sec1 v0.7.1 -> v0.7.3
    Updating semver v1.0.17 -> v1.0.20
    Updating serde v1.0.166 -> v1.0.192
      Adding serde_derive v1.0.192
    Updating signature v2.0.0 -> v2.1.0
    Updating smallvec v1.10.0 -> v1.11.2
    Updating syn v2.0.16 -> v2.0.39
    Updating typenum v1.16.0 -> v1.17.0
    Updating unicode-ident v1.0.8 -> v1.0.12
    Updating zeroize v1.6.0 -> v1.6.1
2023-11-16 07:42:58 -07:00
ashWhiteHat fb866b4933 ed448: add documentation (#750) 2023-11-12 18:41:37 -07:00
dependabot[bot] 8516671bb5 build(deps): bump actions/checkout from 3 to 4 (#749)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-17 08:30:42 -06:00
Tony Arcieri d939aa7e18 README.md: fixup ed448 entry in crate table 2023-10-15 13:21:22 -06:00
Tony Arcieri 6ed5faea44 ed25519 v2.2.3 (#748) ed25519/v2.2.3 2023-10-15 13:13:26 -06:00
ashWhiteHat d9c304cf91 ed448: Ed448 Implementation (#727) 2023-10-15 12:47:41 -06:00
Tony Arcieri e8d4d23a43 ed25519: hexify Debug impl on Signature (#747)
Formats the `R` and `s` signature components as hexidecimal to make the
representation more compact, as requested in #723:

ed25519::Signature {
    R: 0x3f3e3d3c3b3a393837363534333231302f2e2d2c2b2a29282726252423222120,
    s: 0x1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100,
}
2023-10-15 12:47:01 -06:00
Guillaume Charmetant 8f37b6039f Enable pkcs8/std feature when std is enabled (#746)
When we enable the `std` feature and the `pkcs8` dependency is enabled (by the `pem` feature), enable the `std` feature of `pkcs8`.

This makes it easier to work with the re-exported `pkcs8::Error` type because without the `std` feature it does not impl the  `std::error::Error` marker trait.
2023-10-10 08:26:17 -06:00
dependabot[bot] a34e476403 build(deps): bump num-traits from 0.2.16 to 0.2.17 (#745)
Bumps [num-traits](https://github.com/rust-num/num-traits) from 0.2.16 to 0.2.17.
- [Changelog](https://github.com/rust-num/num-traits/blob/master/RELEASES.md)
- [Commits](https://github.com/rust-num/num-traits/compare/num-traits-0.2.16...num-traits-0.2.17)

---
updated-dependencies:
- dependency-name: num-traits
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-09 08:36:45 -06:00