Skip to content

Commit 5726c4a

Browse files
authored
Rename "armcrypto" implementations to "neon_aes" (#20)
The Arm 64-bit architecture contains a number of architecture extensions relevant to the AEGIS family of algorithms, however currently libaegis only checks and exposes FEAT_AES. In particular: * FEAT_SHA3 contains the Neon EOR3 and BCAX instructions which can be useful for e.g. combining pairs of exclusive-or instructions. * FEAT_SVE_AES provides SVE versions of the existing AESE and AESMC instructions. These can be beneficial on micro-architectures with longer vectors. * FEAT_SVE2 provides SVE2 versions of the EOR3 and BCAX instructions, mirroring the Neon versions but for SVE vectors. As a first step towards supporting these new extensions, rename the existing code to disambiguate away from "armcrypto" and instead refer to the exact "neon_aes" extension that the code depends on.
1 parent 77492f6 commit 5726c4a

27 files changed

+109
-109
lines changed

build.zig

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,44 +31,44 @@ pub fn build(b: *std.Build) void {
3131
const source_files = &.{
3232
"src/aegis128l/aegis128l_aesni.c",
3333
"src/aegis128l/aegis128l_altivec.c",
34-
"src/aegis128l/aegis128l_armcrypto.c",
34+
"src/aegis128l/aegis128l_neon_aes.c",
3535
"src/aegis128l/aegis128l_soft.c",
3636
"src/aegis128l/aegis128l.c",
3737

3838
"src/aegis128x2/aegis128x2_aesni.c",
3939
"src/aegis128x2/aegis128x2_altivec.c",
4040
"src/aegis128x2/aegis128x2_avx2.c",
41-
"src/aegis128x2/aegis128x2_armcrypto.c",
41+
"src/aegis128x2/aegis128x2_neon_aes.c",
4242
"src/aegis128x2/aegis128x2_soft.c",
4343
"src/aegis128x2/aegis128x2.c",
4444

4545
"src/aegis128x4/aegis128x4_aesni.c",
4646
"src/aegis128x4/aegis128x4_altivec.c",
4747
"src/aegis128x4/aegis128x4_avx2.c",
4848
"src/aegis128x4/aegis128x4_avx512.c",
49-
"src/aegis128x4/aegis128x4_armcrypto.c",
50-
"src/aegis128x4/aegis128x4_armcrypto.c",
49+
"src/aegis128x4/aegis128x4_neon_aes.c",
50+
"src/aegis128x4/aegis128x4_neon_aes.c",
5151
"src/aegis128x4/aegis128x4_soft.c",
5252
"src/aegis128x4/aegis128x4.c",
5353

5454
"src/aegis256/aegis256_aesni.c",
5555
"src/aegis256/aegis256_altivec.c",
56-
"src/aegis256/aegis256_armcrypto.c",
56+
"src/aegis256/aegis256_neon_aes.c",
5757
"src/aegis256/aegis256_soft.c",
5858
"src/aegis256/aegis256.c",
5959

6060
"src/aegis256x2/aegis256x2_aesni.c",
6161
"src/aegis256x2/aegis256x2_altivec.c",
6262
"src/aegis256x2/aegis256x2_avx2.c",
63-
"src/aegis256x2/aegis256x2_armcrypto.c",
63+
"src/aegis256x2/aegis256x2_neon_aes.c",
6464
"src/aegis256x2/aegis256x2_soft.c",
6565
"src/aegis256x2/aegis256x2.c",
6666

6767
"src/aegis256x4/aegis256x4_aesni.c",
6868
"src/aegis256x4/aegis256x4_altivec.c",
6969
"src/aegis256x4/aegis256x4_avx2.c",
7070
"src/aegis256x4/aegis256x4_avx512.c",
71-
"src/aegis256x4/aegis256x4_armcrypto.c",
71+
"src/aegis256x4/aegis256x4_neon_aes.c",
7272
"src/aegis256x4/aegis256x4_soft.c",
7373
"src/aegis256x4/aegis256x4.c",
7474

src/aegis128l/aegis128l.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
#include "aegis128l.h"
77
#include "aegis128l_aesni.h"
88
#include "aegis128l_altivec.h"
9-
#include "aegis128l_armcrypto.h"
9+
#include "aegis128l_neon_aes.h"
1010

1111
#ifndef HAS_HW_AES
1212
# include "aegis128l_soft.h"
1313
static const aegis128l_implementation *implementation = &aegis128l_soft_implementation;
1414
#else
1515
# if defined(__aarch64__) || defined(_M_ARM64)
16-
static const aegis128l_implementation *implementation = &aegis128l_armcrypto_implementation;
16+
static const aegis128l_implementation *implementation = &aegis128l_neon_aes_implementation;
1717
# elif defined(__x86_64__) || defined(__i386__)
1818
static const aegis128l_implementation *implementation = &aegis128l_aesni_implementation;
1919
# elif defined(__ALTIVEC__) && defined(__CRYPTO__)
@@ -232,8 +232,8 @@ aegis128l_pick_best_implementation(void)
232232
#endif
233233

234234
#if defined(__aarch64__) || defined(_M_ARM64)
235-
if (aegis_runtime_has_armcrypto()) {
236-
implementation = &aegis128l_armcrypto_implementation;
235+
if (aegis_runtime_has_neon_aes()) {
236+
implementation = &aegis128l_neon_aes_implementation;
237237
return 0;
238238
}
239239
#endif

src/aegis128l/aegis128l_armcrypto.h

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/aegis128l/aegis128l_armcrypto.c renamed to src/aegis128l/aegis128l_neon_aes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# include "../common/common.h"
77
# include "aegis128l.h"
8-
# include "aegis128l_armcrypto.h"
8+
# include "aegis128l_neon_aes.h"
99

1010
# ifndef __ARM_FEATURE_CRYPTO
1111
# define __ARM_FEATURE_CRYPTO 1
@@ -52,7 +52,7 @@ aegis128l_update(aes_block_t *const state, const aes_block_t d1, const aes_block
5252

5353
# include "aegis128l_common.h"
5454

55-
struct aegis128l_implementation aegis128l_armcrypto_implementation = {
55+
struct aegis128l_implementation aegis128l_neon_aes_implementation = {
5656
.encrypt_detached = encrypt_detached,
5757
.decrypt_detached = decrypt_detached,
5858
.encrypt_unauthenticated = encrypt_unauthenticated,

src/aegis128l/aegis128l_neon_aes.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef aegis128l_neon_aes_H
2+
#define aegis128l_neon_aes_H
3+
4+
#include "../common/common.h"
5+
#include "implementations.h"
6+
7+
extern struct aegis128l_implementation aegis128l_neon_aes_implementation;
8+
9+
#endif

src/aegis128x2/aegis128x2.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
#include "aegis128x2.h"
77
#include "aegis128x2_aesni.h"
88
#include "aegis128x2_altivec.h"
9-
#include "aegis128x2_armcrypto.h"
9+
#include "aegis128x2_neon_aes.h"
1010
#include "aegis128x2_avx2.h"
1111

1212
#ifndef HAS_HW_AES
1313
# include "aegis128x2_soft.h"
1414
static const aegis128x2_implementation *implementation = &aegis128x2_soft_implementation;
1515
#else
1616
# if defined(__aarch64__) || defined(_M_ARM64)
17-
static const aegis128x2_implementation *implementation = &aegis128x2_armcrypto_implementation;
17+
static const aegis128x2_implementation *implementation = &aegis128x2_neon_aes_implementation;
1818
# elif defined(__x86_64__) || defined(__i386__)
1919
static const aegis128x2_implementation *implementation = &aegis128x2_aesni_implementation;
2020
# elif defined(__ALTIVEC__) && defined(__CRYPTO__)
@@ -232,8 +232,8 @@ aegis128x2_pick_best_implementation(void)
232232
#endif
233233

234234
#if defined(__aarch64__) || defined(_M_ARM64)
235-
if (aegis_runtime_has_armcrypto()) {
236-
implementation = &aegis128x2_armcrypto_implementation;
235+
if (aegis_runtime_has_neon_aes()) {
236+
implementation = &aegis128x2_neon_aes_implementation;
237237
return 0;
238238
}
239239
#endif

src/aegis128x2/aegis128x2_armcrypto.h

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/aegis128x2/aegis128x2_armcrypto.c renamed to src/aegis128x2/aegis128x2_neon_aes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# include "../common/common.h"
77
# include "aegis128x2.h"
8-
# include "aegis128x2_armcrypto.h"
8+
# include "aegis128x2_neon_aes.h"
99

1010
# ifndef __ARM_FEATURE_CRYPTO
1111
# define __ARM_FEATURE_CRYPTO 1
@@ -86,7 +86,7 @@ aegis128x2_update(aes_block_t *const state, const aes_block_t d1, const aes_bloc
8686

8787
# include "aegis128x2_common.h"
8888

89-
struct aegis128x2_implementation aegis128x2_armcrypto_implementation = {
89+
struct aegis128x2_implementation aegis128x2_neon_aes_implementation = {
9090
.encrypt_detached = encrypt_detached,
9191
.decrypt_detached = decrypt_detached,
9292
.encrypt_unauthenticated = encrypt_unauthenticated,

src/aegis128x2/aegis128x2_neon_aes.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef aegis128x2_neon_aes_H
2+
#define aegis128x2_neon_aes_H
3+
4+
#include "../common/common.h"
5+
#include "implementations.h"
6+
7+
extern struct aegis128x2_implementation aegis128x2_neon_aes_implementation;
8+
9+
#endif

src/aegis128x4/aegis128x4.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "aegis128x4.h"
77
#include "aegis128x4_aesni.h"
88
#include "aegis128x4_altivec.h"
9-
#include "aegis128x4_armcrypto.h"
9+
#include "aegis128x4_neon_aes.h"
1010
#include "aegis128x4_avx2.h"
1111
#include "aegis128x4_avx512.h"
1212

@@ -15,7 +15,7 @@
1515
static const aegis128x4_implementation *implementation = &aegis128x4_soft_implementation;
1616
#else
1717
# if defined(__aarch64__) || defined(_M_ARM64)
18-
static const aegis128x4_implementation *implementation = &aegis128x4_armcrypto_implementation;
18+
static const aegis128x4_implementation *implementation = &aegis128x4_neon_aes_implementation;
1919
# elif defined(__x86_64__) || defined(__i386__)
2020
static const aegis128x4_implementation *implementation = &aegis128x4_aesni_implementation;
2121
# elif defined(__ALTIVEC__) && defined(__CRYPTO__)
@@ -233,8 +233,8 @@ aegis128x4_pick_best_implementation(void)
233233
#endif
234234

235235
#if defined(__aarch64__) || defined(_M_ARM64)
236-
if (aegis_runtime_has_armcrypto()) {
237-
implementation = &aegis128x4_armcrypto_implementation;
236+
if (aegis_runtime_has_neon_aes()) {
237+
implementation = &aegis128x4_neon_aes_implementation;
238238
return 0;
239239
}
240240
#endif

src/aegis128x4/aegis128x4_armcrypto.h

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/aegis128x4/aegis128x4_armcrypto.c renamed to src/aegis128x4/aegis128x4_neon_aes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# include "../common/common.h"
77
# include "aegis128x4.h"
8-
# include "aegis128x4_armcrypto.h"
8+
# include "aegis128x4_neon_aes.h"
99

1010
# ifndef __ARM_FEATURE_CRYPTO
1111
# define __ARM_FEATURE_CRYPTO 1
@@ -94,7 +94,7 @@ aegis128x4_update(aes_block_t *const state, const aes_block_t d1, const aes_bloc
9494

9595
# include "aegis128x4_common.h"
9696

97-
struct aegis128x4_implementation aegis128x4_armcrypto_implementation = {
97+
struct aegis128x4_implementation aegis128x4_neon_aes_implementation = {
9898
.encrypt_detached = encrypt_detached,
9999
.decrypt_detached = decrypt_detached,
100100
.encrypt_unauthenticated = encrypt_unauthenticated,

src/aegis128x4/aegis128x4_neon_aes.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef aegis128x4_neon_aes_H
2+
#define aegis128x4_neon_aes_H
3+
4+
#include "../common/common.h"
5+
#include "implementations.h"
6+
7+
extern struct aegis128x4_implementation aegis128x4_neon_aes_implementation;
8+
9+
#endif

src/aegis256/aegis256.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
#include "aegis256.h"
77
#include "aegis256_aesni.h"
88
#include "aegis256_altivec.h"
9-
#include "aegis256_armcrypto.h"
9+
#include "aegis256_neon_aes.h"
1010

1111
#ifndef HAS_HW_AES
1212
# include "aegis256_soft.h"
1313
static const aegis256_implementation *implementation = &aegis256_soft_implementation;
1414
#else
1515
# if defined(__aarch64__) || defined(_M_ARM64)
16-
static const aegis256_implementation *implementation = &aegis256_armcrypto_implementation;
16+
static const aegis256_implementation *implementation = &aegis256_neon_aes_implementation;
1717
# elif defined(__x86_64__) || defined(__i386__)
1818
static const aegis256_implementation *implementation = &aegis256_aesni_implementation;
1919
# elif defined(__ALTIVEC__) && defined(__CRYPTO__)
@@ -231,8 +231,8 @@ aegis256_pick_best_implementation(void)
231231
#endif
232232

233233
#if defined(__aarch64__) || defined(_M_ARM64)
234-
if (aegis_runtime_has_armcrypto()) {
235-
implementation = &aegis256_armcrypto_implementation;
234+
if (aegis_runtime_has_neon_aes()) {
235+
implementation = &aegis256_neon_aes_implementation;
236236
return 0;
237237
}
238238
#endif

src/aegis256/aegis256_armcrypto.h

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/aegis256/aegis256_armcrypto.c renamed to src/aegis256/aegis256_neon_aes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# include "../common/common.h"
77
# include "aegis256.h"
8-
# include "aegis256_armcrypto.h"
8+
# include "aegis256_neon_aes.h"
99

1010
# ifndef __ARM_FEATURE_CRYPTO
1111
# define __ARM_FEATURE_CRYPTO 1
@@ -50,7 +50,7 @@ aegis256_update(aes_block_t *const state, const aes_block_t d)
5050

5151
# include "aegis256_common.h"
5252

53-
struct aegis256_implementation aegis256_armcrypto_implementation = {
53+
struct aegis256_implementation aegis256_neon_aes_implementation = {
5454
.encrypt_detached = encrypt_detached,
5555
.decrypt_detached = decrypt_detached,
5656
.encrypt_unauthenticated = encrypt_unauthenticated,

src/aegis256/aegis256_neon_aes.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef aegis256_neon_aes_H
2+
#define aegis256_neon_aes_H
3+
4+
#include "../common/common.h"
5+
#include "implementations.h"
6+
7+
extern struct aegis256_implementation aegis256_neon_aes_implementation;
8+
9+
#endif

src/aegis256x2/aegis256x2.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
#include "aegis256x2.h"
77
#include "aegis256x2_aesni.h"
88
#include "aegis256x2_altivec.h"
9-
#include "aegis256x2_armcrypto.h"
9+
#include "aegis256x2_neon_aes.h"
1010
#include "aegis256x2_avx2.h"
1111

1212
#ifndef HAS_HW_AES
1313
# include "aegis256x2_soft.h"
1414
static const aegis256x2_implementation *implementation = &aegis256x2_soft_implementation;
1515
#else
1616
# if defined(__aarch64__) || defined(_M_ARM64)
17-
static const aegis256x2_implementation *implementation = &aegis256x2_armcrypto_implementation;
17+
static const aegis256x2_implementation *implementation = &aegis256x2_neon_aes_implementation;
1818
# elif defined(__x86_64__) || defined(__i386__)
1919
static const aegis256x2_implementation *implementation = &aegis256x2_aesni_implementation;
2020
# elif defined(__ALTIVEC__) && defined(__CRYPTO__)
@@ -232,8 +232,8 @@ aegis256x2_pick_best_implementation(void)
232232
#endif
233233

234234
#if defined(__aarch64__) || defined(_M_ARM64)
235-
if (aegis_runtime_has_armcrypto()) {
236-
implementation = &aegis256x2_armcrypto_implementation;
235+
if (aegis_runtime_has_neon_aes()) {
236+
implementation = &aegis256x2_neon_aes_implementation;
237237
return 0;
238238
}
239239
#endif

src/aegis256x2/aegis256x2_armcrypto.h

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/aegis256x2/aegis256x2_armcrypto.c renamed to src/aegis256x2/aegis256x2_neon_aes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# include "../common/common.h"
77
# include "aegis256x2.h"
8-
# include "aegis256x2_armcrypto.h"
8+
# include "aegis256x2_neon_aes.h"
99

1010
# ifndef __ARM_FEATURE_CRYPTO
1111
# define __ARM_FEATURE_CRYPTO 1
@@ -84,7 +84,7 @@ aegis256x2_update(aes_block_t *const state, const aes_block_t d)
8484

8585
# include "aegis256x2_common.h"
8686

87-
struct aegis256x2_implementation aegis256x2_armcrypto_implementation = {
87+
struct aegis256x2_implementation aegis256x2_neon_aes_implementation = {
8888
.encrypt_detached = encrypt_detached,
8989
.decrypt_detached = decrypt_detached,
9090
.encrypt_unauthenticated = encrypt_unauthenticated,

src/aegis256x2/aegis256x2_neon_aes.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef aegis256x2_neon_aes_H
2+
#define aegis256x2_neon_aes_H
3+
4+
#include "../common/common.h"
5+
#include "implementations.h"
6+
7+
extern struct aegis256x2_implementation aegis256x2_neon_aes_implementation;
8+
9+
#endif

0 commit comments

Comments
 (0)