Skip to content

Commit 692b1b0

Browse files
committed
polyval: rename backend module => field_element
It's now the home of the `FieldElement` struct, and the backends are backends of our field element implementation. Additionally renames the following submodules of `field_element` named after their CPU instructions to the CPUs those instructions are for: - `clmul` => `x86` - `pmull` => `armv8`
1 parent 2d1f167 commit 692b1b0

File tree

9 files changed

+13
-12
lines changed

9 files changed

+13
-12
lines changed
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! POLYVAL backends
1+
//! POLYVAL field element implementation.
22
33
mod soft;
44

@@ -14,19 +14,19 @@ use zeroize::Zeroize;
1414
cfg_if! {
1515
if #[cfg(all(target_arch = "aarch64", not(polyval_backend = "soft")))] {
1616
mod autodetect;
17-
mod pmull;
17+
mod armv8;
1818
mod common;
19-
pub use crate::backend::autodetect::Polyval as PolyvalGeneric;
19+
pub use autodetect::Polyval as PolyvalGeneric;
2020
} else if #[cfg(all(
2121
any(target_arch = "x86_64", target_arch = "x86"),
2222
not(polyval_backend = "soft")
2323
))] {
2424
mod autodetect;
2525
mod clmul;
2626
mod common;
27-
pub use crate::backend::autodetect::Polyval as PolyvalGeneric;
27+
pub use autodetect::Polyval as PolyvalGeneric;
2828
} else {
29-
pub use crate::backend::soft::Polyval as PolyvalGeneric;
29+
pub use soft::Polyval as PolyvalGeneric;
3030
}
3131
}
3232

@@ -37,7 +37,8 @@ cfg_if! {
3737
///
3838
/// # Representation
3939
///
40-
/// The element is represented as 16-bytes in little-endian order.
40+
/// The element is represented as 16-bytes in little-endian order, using a `repr(C)` ABI and
41+
/// 16-byte alignment enforced with `align(16)`.
4142
///
4243
/// Arithmetic in POLYVAL's field has the following properties:
4344
/// - All arithmetic operations are performed modulo the polynomial above.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#![allow(unsafe_op_in_unsafe_fn)]
1717

1818
use super::FieldElement;
19-
use crate::{Block, Key, Tag, backend::common};
19+
use crate::{Block, Key, Tag, field_element::common};
2020
use core::{arch::aarch64::*, mem, ops::Mul};
2121
use universal_hash::{
2222
KeyInit, ParBlocks, Reset, UhfBackend,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Autodetection for CPU intrinsics, with fallback to the "soft" backend when
22
//! they are unavailable.
33
4-
use crate::{Key, Tag, backend::soft};
4+
use crate::{Key, Tag, field_element::soft};
55
use core::mem::ManuallyDrop;
66
use universal_hash::{
77
KeyInit, Reset, UhfClosure, UniversalHash,
@@ -12,7 +12,7 @@ use universal_hash::{
1212
};
1313

1414
#[cfg(target_arch = "aarch64")]
15-
use super::pmull as intrinsics;
15+
use super::armv8 as intrinsics;
1616

1717
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
1818
use super::clmul as intrinsics;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use core::arch::x86::*;
1010
use core::arch::x86_64::*;
1111

1212
use super::FieldElement;
13-
use crate::{Block, Key, Tag, backend::common};
13+
use crate::{Block, Key, Tag, field_element::common};
1414
use core::{ops::Mul, ptr};
1515
use universal_hash::{
1616
KeyInit, ParBlocks, Reset, UhfBackend,

polyval/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg"
77
)]
88

9-
mod backend;
9+
mod field_element;
1010
mod mulx;
1111

12-
pub use crate::{backend::PolyvalGeneric, mulx::mulx};
12+
pub use crate::{field_element::PolyvalGeneric, mulx::mulx};
1313
pub use universal_hash;
1414

1515
impl<const N: usize> core::fmt::Debug for PolyvalGeneric<N> {

0 commit comments

Comments
 (0)