@@ -70,15 +70,33 @@ use universal_hash::{
70
70
NewUniversalHash , UniversalHash ,
71
71
} ;
72
72
73
+ #[ cfg( all(
74
+ any( target_arch = "x86" , target_arch = "x86_64" ) ,
75
+ not( feature = "force-soft" )
76
+ ) ) ]
77
+ mod autodetect;
78
+
73
79
mod backend;
74
80
75
81
#[ cfg( all(
76
82
any( target_arch = "x86" , target_arch = "x86_64" ) ,
77
- target_feature = "avx2" ,
83
+ not ( feature = "force-soft" ) ,
78
84
any( fuzzing, test)
79
85
) ) ]
80
86
mod fuzz;
81
87
88
+ #[ cfg( all(
89
+ any( target_arch = "x86" , target_arch = "x86_64" ) ,
90
+ not( feature = "force-soft" )
91
+ ) ) ]
92
+ use crate :: autodetect:: State ;
93
+
94
+ #[ cfg( not( all(
95
+ any( target_arch = "x86" , target_arch = "x86_64" ) ,
96
+ not( feature = "force-soft" )
97
+ ) ) ) ]
98
+ use crate :: backend:: soft:: State ;
99
+
82
100
/// Size of a Poly1305 key
83
101
pub const KEY_SIZE : usize = 32 ;
84
102
@@ -102,7 +120,7 @@ pub type Tag = universal_hash::Output<Poly1305>;
102
120
/// For this reason it doesn't impl the `crypto_mac::Mac` trait.
103
121
#[ derive( Clone ) ]
104
122
pub struct Poly1305 {
105
- state : backend :: State ,
123
+ state : State ,
106
124
}
107
125
108
126
impl NewUniversalHash for Poly1305 {
@@ -111,7 +129,7 @@ impl NewUniversalHash for Poly1305 {
111
129
/// Initialize Poly1305 with the given key
112
130
fn new ( key : & Key ) -> Poly1305 {
113
131
Poly1305 {
114
- state : backend :: State :: new ( key) ,
132
+ state : State :: new ( key) ,
115
133
}
116
134
}
117
135
}
@@ -158,7 +176,7 @@ impl Poly1305 {
158
176
159
177
#[ cfg( all(
160
178
any( target_arch = "x86" , target_arch = "x86_64" ) ,
161
- target_feature = "avx2" ,
179
+ not ( feature = "force-soft" ) ,
162
180
any( fuzzing, test)
163
181
) ) ]
164
182
pub use crate :: fuzz:: fuzz_avx2;
0 commit comments