Struct galois_2p8::field::GeneralField
source · [−]pub struct GeneralField { /* private fields */ }
Expand description
Implements field arithmetic compatible with all IrreducablePolynomial
s.
Recall that there are two strategies for optimizing field arithmetic in
GF(2^8)
: accessing direct multiplication and division tables, and
manipulating logarithms and exponentials. The latter method requires fewer
operations, but is only possible if the given IrreducablePolynomial
is
primitive.
This struct uses direct multiplication and division tables for its
operations, and is compatible with all IrreducablePolynomial
s,
including primitive ones. Operations are expected to be less performant
than those implemented by PrimitivePolynomialField
, with the exception
of vector operations, which may be accelerated in both using multiplication
and division tables. See the Field
documentation for more details
regarding vector operations.
Implementations
sourceimpl GeneralField
impl GeneralField
sourcepub fn new(poly: IrreducablePolynomial) -> Self
pub fn new(poly: IrreducablePolynomial) -> Self
Constructs a new GeneralField
with all tables initialized.
Trait Implementations
sourceimpl Field for GeneralField
impl Field for GeneralField
sourcefn polynomial(&self) -> IrreducablePolynomial
fn polynomial(&self) -> IrreducablePolynomial
Returns the polynomial modulo which all operations are performed.
sourcefn div(&self, src: u8, scale: u8) -> u8
fn div(&self, src: u8, scale: u8) -> u8
Returns the result of src / scale
in this field. Read more
sourcefn mult_two_pow(&self, scale: u8, x: u8) -> u8
fn mult_two_pow(&self, scale: u8, x: u8) -> u8
Returns the result of scale * 2^x
in this field.
sourceunsafe fn add_ptr_scaled_len(
&self,
dst: *mut u8,
src: *const u8,
scale: u8,
len: usize
)
unsafe fn add_ptr_scaled_len(
&self,
dst: *mut u8,
src: *const u8,
scale: u8,
len: usize
)
Adds scale * src[0..len]
into dst[0..len]
in place.
sourceunsafe fn mult_ptr_len(&self, dst: *mut u8, scale: u8, len: usize)
unsafe fn mult_ptr_len(&self, dst: *mut u8, scale: u8, len: usize)
Multiplies dst[0..len]
by scale
in place.
sourceunsafe fn div_ptr_len(&self, dst: *mut u8, scale: u8, len: usize)
unsafe fn div_ptr_len(&self, dst: *mut u8, scale: u8, len: usize)
Divides dst[0..len]
by scale
in place. Read more
sourceunsafe fn add_ptr_len(&self, dst: *mut u8, src: *const u8, len: usize)
unsafe fn add_ptr_len(&self, dst: *mut u8, src: *const u8, len: usize)
Adds src[0..len]
into dst[0..len]
.
sourcefn add_multiword(&self, dst: &mut [u8], src: &[u8])
fn add_multiword(&self, dst: &mut [u8], src: &[u8])
Adds src
into dst
in place, over the smallest common length. Read more
sourcefn add_multiword_len(&self, dst: &mut [u8], src: &[u8], len: usize)
fn add_multiword_len(&self, dst: &mut [u8], src: &[u8], len: usize)
Adds src[0..len]
into dst[0..len]
. Read more
sourcefn add_scaled_multiword(&self, dst: &mut [u8], src: &[u8], scale: u8)
fn add_scaled_multiword(&self, dst: &mut [u8], src: &[u8], scale: u8)
Adds src * scale
into dst
in place, over the smallest common length. Read more
sourcefn add_scaled_multiword_len(
&self,
dst: &mut [u8],
src: &[u8],
scale: u8,
len: usize
)
fn add_scaled_multiword_len(
&self,
dst: &mut [u8],
src: &[u8],
scale: u8,
len: usize
)
Adds src[0..len] * scale
into dst[0..len]
. Read more
sourceunsafe fn sub_ptr_len(&self, dst: *mut u8, src: *const u8, len: usize)
unsafe fn sub_ptr_len(&self, dst: *mut u8, src: *const u8, len: usize)
Subtracts src[0..len]
from dst[0..len]
in place.
sourceunsafe fn sub_ptr_scaled_len(
&self,
dst: *mut u8,
src: *const u8,
scale: u8,
len: usize
)
unsafe fn sub_ptr_scaled_len(
&self,
dst: *mut u8,
src: *const u8,
scale: u8,
len: usize
)
Subracts scale * src[0..len]
from dst[0..len]
in place.
sourcefn sub_multiword(&self, dst: &mut [u8], src: &[u8])
fn sub_multiword(&self, dst: &mut [u8], src: &[u8])
Subtracts src
from dst
in place, over the smallest common length. Read more
sourcefn sub_multiword_len(&self, dst: &mut [u8], src: &[u8], len: usize)
fn sub_multiword_len(&self, dst: &mut [u8], src: &[u8], len: usize)
Subtracts src[0..len]
from dst[0..len]
in place. Read more
sourcefn sub_scaled_multiword(&self, dst: &mut [u8], src: &[u8], scale: u8)
fn sub_scaled_multiword(&self, dst: &mut [u8], src: &[u8], scale: u8)
Subtracts scale * src
from dst
in place, over the smallest common length. Read more
impl Sync for GeneralField
Auto Trait Implementations
impl RefUnwindSafe for GeneralField
impl !Send for GeneralField
impl Unpin for GeneralField
impl UnwindSafe for GeneralField
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more