Commit graph

45 commits

Author SHA1 Message Date
bunnie
cdd1539ba8 promote illegal opcode to a panic
if the engine25519 hits an illegal opcode, really, that's a
software bug that should be fixed. panic, so that we get
a guru meditation and a bug report.
2024-03-28 10:21:27 +08:00
bunnie
4170979f6a add handlers to check for hardware errors and try to recover 2024-03-28 10:20:53 +08:00
bunnie
c0d9b40d9d add logic to catch suspend/resume and opcode errors
also fix a bug where the engine was not being powered off
on release.

Things to note:

- in case of an opcode error, the system will enter an infinite
loop complaining about the error. Maybe i should promote that to
a panic -- it's a thing that should be fixed and should just never
happen
- in case of a suspend/resume during an operation, this is
detected by the loaded microcode length not matching what we
had written. This is a heuristic, but relies on the assumption
that the microcode length would change when the engine is put
through a clean reboot (i.e., it is unlikely that it matches
what we had previously written).
2024-03-28 10:18:27 +08:00
bunnie
c1b910a779 add features for auto-release of hardware and warning on sw fallback
These features should help the crate work more seamlessly with the
existing API, at perhaps some performance penalty that is still
to be determined.
2024-03-28 09:48:50 +08:00
bunnie
94a47207d5 add fallback to field operations
this falls back to fiat-crypto primitives if the hw engine
is unavailable.
2024-03-25 13:43:52 +08:00
bunnie
0b052f5f79 make ensure_engine() falliable
this will trigger software fallback
2024-03-25 13:43:38 +08:00
bunnie
275f586b60 add back in bits_le
needed for software fallback
2024-03-25 13:42:58 +08:00
bunnie
63a24a80b6 add sw fallback for montgomery routines 2024-03-25 13:42:31 +08:00
bunnie
077d5a1fba cleanup warning 2024-03-25 13:42:12 +08:00
bunnie
b6ce2f60a9 cleanup warnings, as much as possible. 2024-03-25 08:04:26 +08:00
bunnie
b486cda2a0
Merge branch 'main' into v4.1.1 2024-03-25 06:59:43 +08:00
David Kotval
0a0a972dfa fix: incorrectly prevented to_radix_2w_size_hint on u32e
This function should be able to be enabled by feature
selection.
2024-03-21 16:35:12 -05:00
bunnie
4fdd15c3af cleanup warnings 2024-03-11 19:12:17 +08:00
bunnie
80fded7589 add functions to allow low-level access from outside the crate
and also make the internal functions use the same conventions
2024-03-11 18:44:17 +08:00
bunnie
4c58a5166f cleanup to refer to local job primitives 2024-03-11 18:15:19 +08:00
bunnie
ebcc3702d3 cleanup field arithmetic routines to refer to local job primitives 2024-03-11 18:14:57 +08:00
bunnie
e53c5e50a5 cleanup warnings now that engine25519 is trimmed 2024-03-11 18:13:47 +08:00
bunnie
fe0e8a2f7a add common components to run jobs inside the backend 2024-03-11 18:13:19 +08:00
pinkforest(she/her)
858c4ca8ae
Address new nightly clippy unnecessary qualifications (#639) 2024-03-07 16:58:20 -07:00
David Kotval
5a9ef20763 wip: make tests compile 2024-03-02 14:36:19 -06:00
David Kotval
b40ec7135e wip: returning to cfg based dependency specification 2024-03-01 13:54:05 -06:00
pinkforest(she/her)
19c7f4a5d5
Fix new nightly redundant import lint warns (#638) 2024-02-29 18:56:52 -07:00
David Kotval
d98a8b11e7 wip: now builds correctly without precomputed-tables enabled 2024-02-18 17:38:36 -06:00
David Kotval
7bf60e4a2b wip: trying to get unifying version 2024-02-18 16:44:04 -06:00
David Kotval
e8fdef83b4 Merge branch 'cfg_fix' into update_to_v4 2024-02-16 15:48:38 -06:00
David Kotval
e5f5371a9c wip: typo in cfg name 2024-02-16 13:37:44 -06:00
Tony Arcieri
50401ab430
curve: mark ValidityCheck trait as allow(dead_code) (#625)
Recent nightlies have started emitting a dead code lint
2024-02-12 11:56:06 -05:00
David Kotval
486cd1315f fix: build.rs now selects accelerated backend for xous 2024-02-08 14:20:02 -06:00
Jimmy Chen
ff1c309b23
Fix nightly build (#619)
* Fix nightly build

* Add nightly feature constraint so AVX-512 requires either x86 or x86_64

Co-authored-by: Tony Arcieri <bascule@gmail.com>

* fmt

---------

Co-authored-by: Michael Rosenberg <micro@fastmail.com>
Co-authored-by: Tony Arcieri <bascule@gmail.com>
Co-authored-by: Michael Rosenberg <michael@mrosenberg.pub>
2024-02-06 15:09:29 -05:00
David Kotval
b7c3eb9b67 fix: incorrect syntax for negation in cfg 2024-02-04 14:27:30 -06:00
David Kotval
81f9189d2f wip: remove betrusted feature 2024-01-12 02:10:08 +00:00
David Kotval
55c5a33411 Merge remote-tracking branch 'upstream/main' into update_to_v4 2023-12-13 17:45:20 -06:00
Michael Rosenberg
81d0756bdc
Made unnecessarily pub contents of field.rs pub(crate) 2023-10-29 22:06:47 -04:00
Michael Rosenberg
cd9378e6fd
Removed unnecessary 'pub use' 2023-10-29 21:53:08 -04:00
Luke Parker
76a8b2a081
Add PrimeFieldBits support to Scalar (#579)
Co-authored-by: Michael Rosenberg <micro@fastmail.com>
Co-authored-by: pinkforest(she/her) <36498018+pinkforest@users.noreply.github.com>
2023-09-19 23:21:43 -04:00
pinkforest(she/her)
533b53a0ec
Deprecate BASEPOINT_ORDER from pub API consts (#581)
* Mark constants::BASEPOINT_ORDER_PRIVATE deprecated from pub API

* Move all BASEPOINT_ORDER use private internally

Co-authored-by: Tony Arcieri <bascule@gmail.com>

* Fix CHANGELOG for 4.1.1

---------

Co-authored-by: Tony Arcieri <bascule@gmail.com>
2023-09-17 23:59:05 -04:00
David Cook
a3a08b01ab
Adapt to new types introduced in fiat-crypto 0.2 (#566) 2023-09-05 10:07:49 -06:00
Tony Arcieri
60dd3100c0
curve: add doc(hidden) to serial backend modules (#568)
We have a lot of backend types leaking via the public API, including
e.g. `FieldElement51`:

https://docs.rs/curve25519-dalek/latest/curve25519_dalek/backend/serial/u64/field/struct.FieldElement51.html

At the very least, these types shouldn't be visible in the rustdoc.

This PR hides them from the docs, but ideally we would hide them
completely from the public API (which might technically be considered a
breaking change, but IMO leaking them at all is a bug).
2023-08-28 02:38:11 -04:00
Tony Arcieri
c058cd9057
curve: Expand lints (#530)
Adds a lints section to the top of lib.rs with the following:

    #![warn(
        clippy::unwrap_used,
        missing_docs,
        rust_2018_idioms,
        unused_lifetimes,
        unused_qualifications
    )]

`warn` is used instead of `deny` to prevent the lints from firing during
local development, however we already configure `-D warnings` in CI so
if any lint fails on checked-in code, it will cause a CI failure.

This commit also fixes or explicitly allows any current violations of
these lints. The main ones were:

- `clippy::unwrap_used`: replaces usages of `unwrap` with `expect`
- `rust_2018_idioms`: no implicit lifetimes, which were present on
  usages of `core::fmt::Formatter`
2023-08-28 02:32:31 -04:00
Michael Rosenberg
8e0cef5b72
curve: Add arbitrary integer multiplication with MontgomeryPoint::mul_bits_be (#555)
There is occasionally [a need](https://github.com/dalek-cryptography/curve25519-dalek/pull/519#issuecomment-1637770888) to multiply a non-prime-order Montgomery point by an integer. There's currently no way to do this, since our only methods are multiplication by `Scalar` (doesn't make sense in the non-prime-order case), and `MontgomeryPoint::mul_base_clamped` clamps the integer before multiplying.

This defines `MontgomeryPoint::mul_bits_be`, which takes a big-endian representation of an integer and multiplies the point by that integer. Its usage is not recommended by default, but it is also not so unsafe as to be gated behind a `hazmat` feature.
2023-08-28 01:58:41 -04:00
pinkforest(she/her)
4373695c50
curve: implement ff and group traits (#562)
Originally authored by @str4d as #473
2023-08-27 14:41:06 -06:00
Rob Ede
b93ace8c7f
Address Clippy lints (#543) 2023-08-27 12:47:12 -06:00
moiseev-signal
bf2c4eea23
curve: Mark scalar::clamp_integer as must_use (#558) 2023-08-12 01:44:09 -04:00
Michael Rosenberg
42b55fd117
ed: Bump ed25519-dalek to 2.0.0 (#559)
* Made clippy happy
2023-08-11 11:38:43 -04:00
pinkforest
40cf5aff99
Workspace curve25519 under curve25519-dalek 2023-06-27 04:00:12 +00:00