Skip to content

Commit ce3c9a7

Browse files
authored
dbl: seal the Dbl trait and tweak docs (#1198)
1 parent 8c5ddd4 commit ce3c9a7

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

dbl/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
### Changed
99
- Migrated from `generic-array` to `hybrid-array` ([#944])
1010
- Edition changed to 2024 and MSRV bumped to 1.85 ([#1149])
11+
- Seal the `Dbl` trait ([#1198])
1112

1213
[#944]: https://github.com/RustCrypto/utils/pull/944
1314
[#1149]: https://github.com/RustCrypto/utils/pull/1149
15+
[#1198]: https://github.com/RustCrypto/utils/pull/1198

dbl/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ name = "dbl"
33
version = "0.4.0-rc.2"
44
authors = ["RustCrypto Developers"]
55
license = "MIT OR Apache-2.0"
6-
description = "Double operation in Galois Field GF(2^128) as used by e.g. CMAC/PMAC"
76
documentation = "https://docs.rs/dbl"
87
repository = "https://github.com/RustCrypto/utils"
98
keywords = ["crypto", "dbl", "gf", "galois"]
109
edition = "2024"
1110
rust-version = "1.85"
1211
readme = "README.md"
12+
description = """Double operation in Galois Field `GF(2^128)` using the lexicographically first
13+
polynomial among the irreducible degree `n` polynomials having a minimum number of coefficients."""
1314

1415
[dependencies]
1516
hybrid-array = "0.3"

dbl/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [RustCrypto]: GF(2^128) "dbl" operation
1+
# [RustCrypto]: Double operation in `GF(2^n)`
22

33
[![crate][crate-image]][crate-link]
44
[![Docs][docs-image]][docs-link]
@@ -7,10 +7,9 @@
77
![Rust Version][rustc-image]
88
[![Project Chat][chat-image]][chat-link]
99

10-
Double operation in Galois Field GF(2^128) as used by e.g. CMAC/PMAC.
11-
12-
Also known as "multiply-by-x", the operation is performed in the finite field
13-
represented using the primitive polynomial x^128 + x^7 + x^2 + x + 1.
10+
Double operation (a.k.a. "multiply-by-x") in Galois Field `GF(2^n)` using
11+
the lexicographically first polynomial among the irreducible degree `n` polynomials
12+
having a minimum number of coefficients.
1413

1514
## License
1615

dbl/src/lib.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@ const C64: u64 = 0b1_1011;
1313
const C128: u64 = 0b1000_0111;
1414
const C256: u64 = 0b100_0010_0101;
1515

16-
/// Double and inverse double over GF(2^n).
16+
mod sealed {
17+
pub trait Sealed {}
18+
}
19+
20+
/// Double and inverse double over `GF(2^n)` with the lexicographically first polynomial
21+
/// among the irreducible degree `n` polynomials having a minimum number of coefficients.
1722
///
18-
/// This trait is implemented for 64, 128 and 256 bit block sizes. Big-endian
19-
/// order is used.
20-
pub trait Dbl {
23+
/// This trait is implemented using big-endian byte order for 64, 128 and 256 bit block sizes.
24+
pub trait Dbl: sealed::Sealed {
2125
/// Double block. (alternatively: multiply block by x)
2226
///
2327
/// If most significant bit of the block equals to zero will return
@@ -59,6 +63,8 @@ impl Dbl for Array<u8, U8> {
5963
}
6064
}
6165

66+
impl sealed::Sealed for Array<u8, U8> {}
67+
6268
impl Dbl for Array<u8, U16> {
6369
#[inline]
6470
fn dbl(self) -> Self {
@@ -104,6 +110,8 @@ impl Dbl for Array<u8, U16> {
104110
}
105111
}
106112

113+
impl sealed::Sealed for Array<u8, U16> {}
114+
107115
impl Dbl for Array<u8, U32> {
108116
#[inline]
109117
fn dbl(self) -> Self {
@@ -169,3 +177,5 @@ impl Dbl for Array<u8, U32> {
169177
res
170178
}
171179
}
180+
181+
impl sealed::Sealed for Array<u8, U32> {}

0 commit comments

Comments
 (0)