mirror of
https://github.com/rosenpass/rosenpass.git
synced 2025-12-18 21:34:37 +03:00
Compare commits
2 Commits
docu-tests
...
bench
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d58aa363cd | ||
|
|
1b233bc600 |
2
.github/workflows/qc.yaml
vendored
2
.github/workflows/qc.yaml
vendored
@@ -51,7 +51,7 @@ jobs:
|
|||||||
# liboqs requires quite a lot of stack memory, thus we adjust
|
# liboqs requires quite a lot of stack memory, thus we adjust
|
||||||
# the default stack size picked for new threads (which is used
|
# the default stack size picked for new threads (which is used
|
||||||
# by `cargo test`) to be _big enough_. Setting it to 8 MiB
|
# by `cargo test`) to be _big enough_. Setting it to 8 MiB
|
||||||
- run: RUST_MIN_STACK=8388608 cargo bench --no-run --workspace
|
- run: RUST_MIN_STACK=8388608 cargo bench --workspace
|
||||||
|
|
||||||
cargo-audit:
|
cargo-audit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
/// compares two slices of memory content and returns an integer indicating the relationship between
|
/// Compares two slices of memory containing arbitrary-length little endian unsigned integers
|
||||||
/// the slices
|
/// and returns an integer indicating the relationship between the slices.
|
||||||
///
|
///
|
||||||
/// ## Returns
|
/// ## Returns
|
||||||
/// - <0 if the first byte that does not match both slices has a lower value in `a` than in `b`
|
///
|
||||||
/// - 0 if the contents are equal
|
/// - -1 if a < b
|
||||||
/// - >0 if the first byte that does not match both slices has a higher value in `a` than in `b`
|
/// - 0 if a = b
|
||||||
|
/// - 1 if a > b
|
||||||
///
|
///
|
||||||
/// ## Leaks
|
/// ## Leaks
|
||||||
/// If the two slices have differents lengths, the function will return immediately. This
|
/// If the two slices have differents lengths, the function will return immediately. This
|
||||||
@@ -15,6 +16,23 @@
|
|||||||
/// considered safe.
|
/// considered safe.
|
||||||
///
|
///
|
||||||
/// ## Tests
|
/// ## Tests
|
||||||
|
///
|
||||||
|
/// ```rust
|
||||||
|
/// use rosenpass_constant_time::compare;
|
||||||
|
/// assert_eq!(compare(&[], &[]), 0);
|
||||||
|
///
|
||||||
|
/// assert_eq!(compare(&[0], &[1]), -1);
|
||||||
|
/// assert_eq!(compare(&[0], &[0]), 0);
|
||||||
|
/// assert_eq!(compare(&[1], &[0]), 1);
|
||||||
|
///
|
||||||
|
/// assert_eq!(compare(&[0, 0], &[1, 0]), -1);
|
||||||
|
/// assert_eq!(compare(&[0, 0], &[0, 0]), 0);
|
||||||
|
/// assert_eq!(compare(&[1, 0], &[0, 0]), 1);
|
||||||
|
///
|
||||||
|
/// assert_eq!(compare(&[1, 0], &[0, 1]), -1);
|
||||||
|
/// assert_eq!(compare(&[0, 1], &[0, 0]), 1);
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
/// For discussion on how to ensure the constant-time execution of this function, see
|
/// For discussion on how to ensure the constant-time execution of this function, see
|
||||||
/// <https://github.com/rosenpass/rosenpass/issues/232>
|
/// <https://github.com/rosenpass/rosenpass/issues/232>
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|||||||
Reference in New Issue
Block a user