Skip to content

Commit

Permalink
Merge branch 'master' into migrate-to-hybrid-array
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov authored Oct 20, 2023
2 parents 36baf45 + 29de876 commit b078e66
Show file tree
Hide file tree
Showing 15 changed files with 269 additions and 26 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/cpufeatures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,15 @@ jobs:
# Isolate this crate from workspace which is otherwise MSRV 1.56 due to 2021 edition crates
- run: rm ../Cargo.toml
- run: cross test --target ${{ matrix.target }}

# Build-only tests
build-only:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: RustCrypto/actions/cargo-cache@master
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- run: rustup target add loongarch64-unknown-linux-gnu
- run: cargo build --target loongarch64-unknown-linux-gnu
39 changes: 23 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions block-buffer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- `ReadBuffer` type ([#823])
- `serialize` and `deserialize` methods ([#823])
- Optional implementation of the `Zeroize` trait ([#963])

### Changed
- Supported block sizes are now bounded by the `crypto_common::BlockSizes` trait,
Expand All @@ -20,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `EagerBuffer::set_data` method. Use the `ReadBuffer` type instead. ([#823])

[#823]: https://github.com/RustCrypto/utils/pull/823
[#963]: https://github.com/RustCrypto/utils/pull/963

## 0.10.3 (2022-09-04)
### Added
Expand Down
1 change: 1 addition & 0 deletions block-buffer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ readme = "README.md"

[dependencies]
crypto-common = "0.2.0-pre"
zeroize = { version = "1.4", optional = true, default-features = false }

[dev-dependencies]
hex-literal = "0.3.3"
11 changes: 11 additions & 0 deletions block-buffer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use array::{
};
use core::{fmt, ops::Add, slice};
use crypto_common::{BlockSizeUser, BlockSizes};
#[cfg(feature = "zeroize")]
use zeroize::Zeroize;

mod read;
mod sealed;
Expand Down Expand Up @@ -330,3 +332,12 @@ impl<BS: BlockSizes> BlockBuffer<BS, Lazy> {
Ok(Self { buffer, pos })
}
}

#[cfg(feature = "zeroize")]
impl<BS: BlockSizes, K: BufferKind> Zeroize for BlockBuffer<BS, K> {
#[inline]
fn zeroize(&mut self) {
self.buffer.zeroize();
self.pos.zeroize();
}
}
10 changes: 10 additions & 0 deletions block-buffer/src/read.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use super::{Block, Error};
use core::{fmt, slice};
use crypto_common::{BlockSizeUser, BlockSizes};
#[cfg(feature = "zeroize")]
use zeroize::Zeroize;

/// Buffer for reading block-generated data.
pub struct ReadBuffer<BS: BlockSizes> {
Expand Down Expand Up @@ -146,3 +148,11 @@ impl<BS: BlockSizes> ReadBuffer<BS> {
(blocks, right)
}
}

#[cfg(feature = "zeroize")]
impl<BS: BlockSizes> Zeroize for ReadBuffer<BS> {
#[inline]
fn zeroize(&mut self) {
self.buffer.zeroize();
}
}
3 changes: 3 additions & 0 deletions block-buffer/src/sealed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use core::slice;

/// Sealed trait for buffer kinds.
pub trait Sealed {
#[cfg(not(feature = "zeroize"))]
type Pos: Default + Clone;
#[cfg(feature = "zeroize")]
type Pos: Default + Clone + zeroize::Zeroize;

fn get_pos(buf: &[u8], pos: &Self::Pos) -> usize;

Expand Down
12 changes: 12 additions & 0 deletions cmov/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.3.1 (2023-10-14)
### Added
- `CmovEq` impl for slices ([#954])

### Changed
- Use `#[inline]` instead of `#[inline(always)]` ([#924])
- `CmovEq` now invokes XOR within the ASM block ([#925])

[#924]: https://github.com/RustCrypto/utils/pull/924
[#925]: https://github.com/RustCrypto/utils/pull/925
[#954]: https://github.com/RustCrypto/utils/pull/954

## 0.3.0 (2023-04-02)
### Added
- `miri` support by forcing the `portable` backend ([#864])
Expand Down
2 changes: 1 addition & 1 deletion cmov/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ constant-time and not be rewritten as branches by the compiler.
Provides wrappers for the CMOV family of instructions on x86/x86_64
and CSEL on AArch64.
"""
version = "0.3.0"
version = "0.3.1"
authors = ["RustCrypto Developers"]
license = "Apache-2.0 OR MIT"
repository = "https://github.com/RustCrypto/utils/tree/master/cmov"
Expand Down
6 changes: 6 additions & 0 deletions cpufeatures/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.2.10 (2023-10-20)
### Added
- LoongArch64 target support ([#955])

[#955]: https://github.com/RustCrypto/utils/pull/955

## 0.2.9 (2023-07-05)
### Added
- Support for `avx512vbmi` and `avx512vbmi2` target features ([#926])
Expand Down
15 changes: 9 additions & 6 deletions cpufeatures/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "cpufeatures"
version = "0.2.9"
version = "0.2.10"
description = """
Lightweight runtime CPU feature detection for x86/x86_64 and aarch64 with
no_std support and support for mobile targets including Android and iOS
Lightweight runtime CPU feature detection for aarch64, loongarch64, and x86/x86_64 targets,
with no_std support and support for mobile targets including Android and iOS
"""
authors = ["RustCrypto Developers"]
license = "MIT OR Apache-2.0"
Expand All @@ -15,10 +15,13 @@ edition = "2018"
readme = "README.md"

[target.'cfg(all(target_arch = "aarch64", target_vendor = "apple"))'.dependencies]
libc = "0.2.95"
libc = "0.2.149"

[target.'cfg(all(target_arch = "aarch64", target_os = "linux"))'.dependencies]
libc = "0.2.95"
libc = "0.2.149"

[target.'cfg(all(target_arch = "loongarch64", target_os = "linux"))'.dependencies]
libc = "0.2.149"

[target.aarch64-linux-android.dependencies]
libc = "0.2.95"
libc = "0.2.149"
22 changes: 21 additions & 1 deletion cpufeatures/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![Project Chat][chat-image]][chat-link]
[![Build Status][build-image]][build-link]

Lightweight and efficient runtime CPU feature detection for `aarch64` and
Lightweight and efficient runtime CPU feature detection for `aarch64`, `loongarch64`, and
`x86`/`x86_64` targets.

Supports `no_std` as well as mobile targets including iOS and Android,
Expand All @@ -31,6 +31,26 @@ Target features:
- `sha2`*
- `sha3`*

## `loongarch64`

Linux only (LoongArch64 does not support OS-independent feature detection)

Target features:

- `lam`*
- `ual`*
- `fpu`*
- `lsx`*
- `lasx`*
- `crc32`*
- `complex`*
- `crypto`*
- `lvz`*
- `lbt.x86`*
- `lbt.arm`*
- `lbt.mips`*
- `ptw`*

## `x86`/`x86_64`

OS independent and `no_std`-friendly
Expand Down
34 changes: 32 additions & 2 deletions cpufeatures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@
//! - `sha2`*
//! - `sha3`*
//!
//! ## `loongarch64`
//!
//! Linux only (LoongArch64 does not support OS-independent feature detection)
//!
//! Target features:
//!
//! - `lam`*
//! - `ual`*
//! - `fpu`*
//! - `lsx`*
//! - `lasx`*
//! - `crc32`*
//! - `complex`*
//! - `crypto`*
//! - `lvz`*
//! - `lbt.x86`*
//! - `lbt.arm`*
//! - `lbt.mips`*
//! - `ptw`*
//!
//! ## `x86`/`x86_64`
//!
//! OS independent and `no_std`-friendly
Expand Down Expand Up @@ -107,15 +127,25 @@
#[doc(hidden)]
pub mod aarch64;

#[cfg(not(miri))]
#[cfg(target_arch = "loongarch64")]
#[doc(hidden)]
pub mod loongarch64;

#[cfg(not(miri))]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
mod x86;

#[cfg(miri)]
mod miri;

#[cfg(not(any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")))]
compile_error!("This crate works only on `aarch64`, `x86`, and `x86-64` targets.");
#[cfg(not(any(
target_arch = "aarch64",
target_arch = "loongarch64",
target_arch = "x86",
target_arch = "x86_64"
)))]
compile_error!("This crate works only on `aarch64`, `loongarch64`, `x86`, and `x86-64` targets.");

/// Create module with CPU feature detection code.
#[macro_export]
Expand Down
Loading

0 comments on commit b078e66

Please sign in to comment.