Skip to content

Commit c4a31a7

Browse files
committed
Apply #[target_feature(enable="avx2")]
1 parent 9ba0bab commit c4a31a7

File tree

3 files changed

+185
-179
lines changed

3 files changed

+185
-179
lines changed

poly1305/src/backend/avx2.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl State {
4545
/// Initialize Poly1305 [`State`] with the given key
4646
pub(crate) fn new(key: &Key) -> Self {
4747
// Prepare addition key and polynomial key.
48-
let (k, r1) = prepare_keys(key);
48+
let (k, r1) = unsafe { prepare_keys(key) };
4949

5050
// Precompute R^2.
5151
let r2 = (r1 * r1).reduce();
@@ -68,7 +68,8 @@ impl State {
6868
}
6969

7070
/// Compute a Poly1305 block
71-
pub(crate) fn compute_block(&mut self, block: &Block, partial: bool) {
71+
#[target_feature(enable = "avx2")]
72+
pub(crate) unsafe fn compute_block(&mut self, block: &Block, partial: bool) {
7273
// We can cache a single partial block.
7374
if partial {
7475
assert!(self.partial_block.is_none());
@@ -101,7 +102,8 @@ impl State {
101102
}
102103

103104
/// Finalize output producing a [`Tag`]
104-
pub(crate) fn finalize(&mut self) -> Tag {
105+
#[target_feature(enable = "avx2")]
106+
pub(crate) unsafe fn finalize(&mut self) -> Tag {
105107
assert!(self.num_cached_blocks < 4);
106108
let mut data = &self.cached_blocks[..];
107109

0 commit comments

Comments
 (0)