Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions belt-kwp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ 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.0 (UNRELEASED)
### Added
- Optional `zeroize` support ([#88])

### Removed
- `std` and `alloc` crate features ([#87])
- Implementation of `Copy` for `BeltKwp` ([#88])

[#87]: https://github.com/RustCrypto/key-wraps/pull/87
[#88]: https://github.com/RustCrypto/key-wraps/pull/88

## 0.1.1 (2026-05-27)
### Changed
Expand Down
4 changes: 4 additions & 0 deletions belt-kwp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ rust-version = "1.85"

[dependencies]
belt-block = "0.2"
zeroize = { version = "1.8", optional = true, default-features = false }

[dev-dependencies]
hex-literal = "1"

[features]
zeroize = ["dep:zeroize", "belt-block/zeroize"]

[package.metadata.docs.rs]
all-features = true
15 changes: 14 additions & 1 deletion belt-kwp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub type WrappedKey<N> = Array<u8, Sum<N, IvLen>>;
pub const IV_LEN: usize = IvLen::USIZE;

/// BelT Key Wrap instance as defined in STB 34.101.34-2020.
#[derive(Clone, Copy, PartialEq)]
#[derive(Clone, PartialEq)]
pub struct BeltKwp {
key: [u32; 8],
}
Expand Down Expand Up @@ -206,6 +206,19 @@ impl KeySizeUser for BeltKwp {
}
}

impl Drop for BeltKwp {
fn drop(&mut self) {
#[cfg(feature = "zeroize")]
{
use zeroize::Zeroize;
self.key.zeroize();
}
}
}

#[cfg(feature = "zeroize")]
impl zeroize::ZeroizeOnDrop for BeltKwp {}

/// Errors emitted from the wrap and unwrap operations.
#[derive(Debug)]
pub enum Error {
Expand Down
Loading