@@ -176,23 +176,29 @@ impl Key {
176
176
} ;
177
177
178
178
match detect_implementation ( cpu_features) {
179
- #[ cfg( any(
180
- target_arch = "aarch64" ,
181
- target_arch = "arm" ,
182
- target_arch = "x86_64" ,
183
- target_arch = "x86"
179
+ #[ cfg( all(
180
+ perlasm,
181
+ any(
182
+ target_arch = "aarch64" ,
183
+ target_arch = "arm" ,
184
+ target_arch = "x86_64" ,
185
+ target_arch = "x86"
186
+ )
184
187
) ) ]
185
188
// SAFETY: `aes_hw_set_encrypt_key` satisfies the `set_encrypt_key!`
186
189
// contract for these target architectures.
187
190
Implementation :: HWAES => unsafe {
188
191
set_encrypt_key ! ( aes_hw_set_encrypt_key, bytes, & mut key, cpu_features) ?;
189
192
} ,
190
193
191
- #[ cfg( any(
192
- target_arch = "aarch64" ,
193
- target_arch = "arm" ,
194
- target_arch = "x86_64" ,
195
- target_arch = "x86"
194
+ #[ cfg( all(
195
+ perlasm,
196
+ any(
197
+ target_arch = "aarch64" ,
198
+ target_arch = "arm" ,
199
+ target_arch = "x86_64" ,
200
+ target_arch = "x86"
201
+ )
196
202
) ) ]
197
203
// SAFETY: `vpaes_set_encrypt_key` satisfies the `set_encrypt_key!`
198
204
// contract for these target architectures.
@@ -213,19 +219,25 @@ impl Key {
213
219
#[ inline]
214
220
pub fn encrypt_block ( & self , a : Block , cpu_features : cpu:: Features ) -> Block {
215
221
match detect_implementation ( cpu_features) {
216
- #[ cfg( any(
217
- target_arch = "aarch64" ,
218
- target_arch = "arm" ,
219
- target_arch = "x86_64" ,
220
- target_arch = "x86"
222
+ #[ cfg( all(
223
+ perlasm,
224
+ any(
225
+ target_arch = "aarch64" ,
226
+ target_arch = "arm" ,
227
+ target_arch = "x86_64" ,
228
+ target_arch = "x86"
229
+ )
221
230
) ) ]
222
231
Implementation :: HWAES => encrypt_block ! ( aes_hw_encrypt, a, self ) ,
223
232
224
- #[ cfg( any(
225
- target_arch = "aarch64" ,
226
- target_arch = "arm" ,
227
- target_arch = "x86_64" ,
228
- target_arch = "x86"
233
+ #[ cfg( all(
234
+ perlasm,
235
+ any(
236
+ target_arch = "aarch64" ,
237
+ target_arch = "arm" ,
238
+ target_arch = "x86_64" ,
239
+ target_arch = "x86"
240
+ )
229
241
) ) ]
230
242
Implementation :: VPAES_BSAES => encrypt_block ! ( vpaes_encrypt, a, self ) ,
231
243
@@ -248,11 +260,14 @@ impl Key {
248
260
cpu_features : cpu:: Features ,
249
261
) {
250
262
match detect_implementation ( cpu_features) {
251
- #[ cfg( any(
252
- target_arch = "aarch64" ,
253
- target_arch = "arm" ,
254
- target_arch = "x86_64" ,
255
- target_arch = "x86"
263
+ #[ cfg( all(
264
+ perlasm,
265
+ any(
266
+ target_arch = "aarch64" ,
267
+ target_arch = "arm" ,
268
+ target_arch = "x86_64" ,
269
+ target_arch = "x86"
270
+ )
256
271
) ) ]
257
272
// SAFETY:
258
273
// * self.inner was initialized with `aes_hw_set_encrypt_key` above,
@@ -270,7 +285,10 @@ impl Key {
270
285
)
271
286
} ,
272
287
273
- #[ cfg( any( target_arch = "aarch64" , target_arch = "arm" , target_arch = "x86_64" ) ) ]
288
+ #[ cfg( all(
289
+ perlasm,
290
+ any( target_arch = "aarch64" , target_arch = "arm" , target_arch = "x86_64" )
291
+ ) ) ]
274
292
Implementation :: VPAES_BSAES => {
275
293
#[ cfg( target_arch = "arm" ) ]
276
294
let in_out = {
@@ -357,7 +375,7 @@ impl Key {
357
375
[ b0, b1, b2, b3, b4]
358
376
}
359
377
360
- #[ cfg( any( target_arch = "x86_64" , target_arch = "aarch64" ) ) ]
378
+ #[ cfg( all ( perlasm , any( target_arch = "x86_64" , target_arch = "aarch64" ) ) ) ]
361
379
#[ must_use]
362
380
pub fn is_aes_hw ( & self , cpu_features : cpu:: Features ) -> bool {
363
381
matches ! ( detect_implementation( cpu_features) , Implementation :: HWAES )
@@ -436,20 +454,26 @@ pub(super) const ZERO_BLOCK: Block = [0u8; BLOCK_LEN];
436
454
#[ derive( Clone , Copy ) ]
437
455
#[ allow( clippy:: upper_case_acronyms) ]
438
456
pub enum Implementation {
439
- #[ cfg( any(
440
- target_arch = "aarch64" ,
441
- target_arch = "arm" ,
442
- target_arch = "x86_64" ,
443
- target_arch = "x86"
457
+ #[ cfg( all(
458
+ perlasm,
459
+ any(
460
+ target_arch = "aarch64" ,
461
+ target_arch = "arm" ,
462
+ target_arch = "x86_64" ,
463
+ target_arch = "x86"
464
+ )
444
465
) ) ]
445
466
HWAES ,
446
467
447
468
// On "arm" only, this indicates that the bsaes implementation may be used.
448
- #[ cfg( any(
449
- target_arch = "aarch64" ,
450
- target_arch = "arm" ,
451
- target_arch = "x86_64" ,
452
- target_arch = "x86"
469
+ #[ cfg( all(
470
+ perlasm,
471
+ any(
472
+ target_arch = "aarch64" ,
473
+ target_arch = "arm" ,
474
+ target_arch = "x86_64" ,
475
+ target_arch = "x86"
476
+ )
453
477
) ) ]
454
478
VPAES_BSAES ,
455
479
@@ -458,36 +482,39 @@ pub enum Implementation {
458
482
459
483
fn detect_implementation ( cpu_features : cpu:: Features ) -> Implementation {
460
484
// `cpu_features` is only used for specific platforms.
461
- #[ cfg( not( any(
462
- target_arch = "aarch64" ,
463
- target_arch = "arm" ,
464
- target_arch = "x86_64" ,
465
- target_arch = "x86"
485
+ #[ cfg( not( all(
486
+ perlasm,
487
+ any(
488
+ target_arch = "aarch64" ,
489
+ target_arch = "arm" ,
490
+ target_arch = "x86_64" ,
491
+ target_arch = "x86"
492
+ )
466
493
) ) ) ]
467
494
let _cpu_features = cpu_features;
468
495
469
- #[ cfg( any( target_arch = "aarch64" , target_arch = "arm" ) ) ]
496
+ #[ cfg( all ( perlasm , any( target_arch = "aarch64" , target_arch = "arm" ) ) ) ]
470
497
{
471
498
if cpu:: arm:: AES . available ( cpu_features) {
472
499
return Implementation :: HWAES ;
473
500
}
474
501
}
475
502
476
- #[ cfg( any( target_arch = "x86_64" , target_arch = "x86" ) ) ]
503
+ #[ cfg( all ( perlasm , any( target_arch = "x86_64" , target_arch = "x86" ) ) ) ]
477
504
{
478
505
if cpu:: intel:: AES . available ( cpu_features) {
479
506
return Implementation :: HWAES ;
480
507
}
481
508
}
482
509
483
- #[ cfg( any( target_arch = "x86_64" , target_arch = "x86" ) ) ]
510
+ #[ cfg( all ( perlasm , any( target_arch = "x86_64" , target_arch = "x86" ) ) ) ]
484
511
{
485
512
if cpu:: intel:: SSSE3 . available ( cpu_features) {
486
513
return Implementation :: VPAES_BSAES ;
487
514
}
488
515
}
489
516
490
- #[ cfg( any( target_arch = "aarch64" , target_arch = "arm" ) ) ]
517
+ #[ cfg( all ( perlasm , any( target_arch = "aarch64" , target_arch = "arm" ) ) ) ]
491
518
{
492
519
if cpu:: arm:: NEON . available ( cpu_features) {
493
520
return Implementation :: VPAES_BSAES ;
0 commit comments