diff --git a/crypto-common/CHANGELOG.md b/crypto-common/CHANGELOG.md index 662e027a6..030a547b7 100644 --- a/crypto-common/CHANGELOG.md +++ b/crypto-common/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Sealed `BlockSizes` trait implemented for types from `U1` to `U255` - `Generate` trait ([#2096]) +- `KeyExport` trait ([#2213]) ### Changed - `BlockUser::BlockSize` is now bounded by the `BlockSizes` trait @@ -20,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#1759]: https://github.com/RustCrypto/traits/pull/1759 [#2096]: https://github.com/RustCrypto/traits/pull/2096 +[#2213]: https://github.com/RustCrypto/traits/pull/2213 ## 0.1.7 (2025-11-12) ### Changed diff --git a/crypto-common/src/lib.rs b/crypto-common/src/lib.rs index d9919980d..164db413f 100644 --- a/crypto-common/src/lib.rs +++ b/crypto-common/src/lib.rs @@ -156,6 +156,12 @@ pub trait AlgorithmName { fn write_alg_name(f: &mut fmt::Formatter<'_>) -> fmt::Result; } +/// Serialize a key to a byte array. +pub trait KeyExport: KeySizeUser { + /// Serialize this key as a byte array. + fn to_bytes(&self) -> Key; +} + /// Types which can be initialized from a key. pub trait KeyInit: KeySizeUser + Sized { /// Create new value from fixed size key.