Skip to content

Commit 51f8e00

Browse files
committed
Adjust ARM and AltiVec variants of AEGIS
1 parent fe267c6 commit 51f8e00

File tree

16 files changed

+250
-201
lines changed

16 files changed

+250
-201
lines changed

src/aegis/aegis128l/aegis128l_altivec.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#ifdef __clang__
2323
# pragma clang attribute push(__attribute__((target("altivec,crypto"))), apply_to = function)
2424
#elif defined(__GNUC__)
25-
# pragma GCC target("+altivec+crypto")
25+
# pragma GCC target("altivec,crypto")
2626
#endif
2727

2828
#define AES_BLOCK_LENGTH 16
@@ -59,7 +59,7 @@ AEGIS_AES_BLOCK_LOAD(const uint8_t *a)
5959
static inline AEGIS_AES_BLOCK_T
6060
AEGIS_AES_BLOCK_LOAD_64x2(uint64_t a, uint64_t b)
6161
{
62-
return vec_revb(vec_insert(a, vec_promote((unsigned long long) b, 1), 0));
62+
return (AEGIS_AES_BLOCK_T) vec_revb(vec_insert(a, vec_promote((unsigned long long) b, 1), 0));
6363
}
6464

6565
static inline void
@@ -71,7 +71,7 @@ AEGIS_AES_BLOCK_STORE(uint8_t *a, const AEGIS_AES_BLOCK_T b)
7171
static inline AEGIS_AES_BLOCK_T
7272
AEGIS_AES_ENC(const AEGIS_AES_BLOCK_T a, const AEGIS_AES_BLOCK_T b)
7373
{
74-
return vec_cipher_be(a, b);
74+
return (AEGIS_AES_BLOCK_T) vec_cipher_be(a, b);
7575
}
7676

7777
static inline void

src/aegis/aegis128l/aegis128l_armcrypto.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
** SPDX-License-Identifier: MIT
66
*/
77

8-
#if defined(__aarch64__) || defined(_M_ARM64)
8+
#include "../common/aeshardware.h"
9+
10+
#if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NEON
911

1012
#include <errno.h>
1113
#include <stddef.h>
@@ -24,7 +26,11 @@
2426
# define __ARM_FEATURE_AES 1
2527
#endif
2628

29+
#ifdef USE_ARM64_NEON_H
30+
#include <arm64_neon.h>
31+
#else
2732
#include <arm_neon.h>
33+
#endif
2834

2935
#ifdef __clang__
3036
# pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), \

src/aegis/aegis128x2/aegis128x2_altivec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#ifdef __clang__
2323
# pragma clang attribute push(__attribute__((target("altivec,crypto"))), apply_to = function)
2424
#elif defined(__GNUC__)
25-
# pragma GCC target("+altivec+crypto")
25+
# pragma GCC target("altivec,crypto")
2626
#endif
2727

2828
#define AES_BLOCK_LENGTH 32
@@ -63,7 +63,7 @@ static inline AEGIS_AES_BLOCK_T
6363
AEGIS_AES_BLOCK_LOAD_64x2(uint64_t a, uint64_t b)
6464
{
6565
const vector unsigned char t =
66-
vec_revb(vec_insert(a, vec_promote((unsigned long long) (b), 1), 0));
66+
(vector unsigned char) vec_revb(vec_insert(a, vec_promote((unsigned long long) (b), 1), 0));
6767
return (AEGIS_AES_BLOCK_T) { t, t };
6868
}
6969
static inline void

src/aegis/aegis128x2/aegis128x2_armcrypto.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
** SPDX-License-Identifier: MIT
66
*/
77

8-
#if defined(__aarch64__) || defined(_M_ARM64)
8+
#include "../common/aeshardware.h"
9+
10+
#if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NEON
911

1012
#include <errno.h>
1113
#include <stddef.h>
@@ -24,7 +26,11 @@
2426
# define __ARM_FEATURE_AES 1
2527
#endif
2628

29+
#ifdef USE_ARM64_NEON_H
30+
#include <arm64_neon.h>
31+
#else
2732
#include <arm_neon.h>
33+
#endif
2834

2935
#ifdef __clang__
3036
# pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), \

src/aegis/aegis128x4/aegis128x4_altivec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#ifdef __clang__
2323
# pragma clang attribute push(__attribute__((target("altivec,crypto"))), apply_to = function)
2424
#elif defined(__GNUC__)
25-
# pragma GCC target("+altivec+crypto")
25+
# pragma GCC target("altivec,crypto")
2626
#endif
2727

2828
#define AES_BLOCK_LENGTH 64
@@ -68,7 +68,7 @@ static inline AEGIS_AES_BLOCK_T
6868
AEGIS_AES_BLOCK_LOAD_64x2(uint64_t a, uint64_t b)
6969
{
7070
const vector unsigned char t =
71-
vec_revb(vec_insert(a, vec_promote((unsigned long long) (b), 1), 0));
71+
(vector unsigned char) vec_revb(vec_insert(a, vec_promote((unsigned long long) (b), 1), 0));
7272
return (AEGIS_AES_BLOCK_T) { t, t, t, t };
7373
}
7474
static inline void

src/aegis/aegis128x4/aegis128x4_armcrypto.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
** SPDX-License-Identifier: MIT
66
*/
77

8-
#if defined(__aarch64__) || defined(_M_ARM64)
8+
#include "../common/aeshardware.h"
9+
10+
#if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NEON
911

1012
#include <errno.h>
1113
#include <stddef.h>
@@ -24,7 +26,11 @@
2426
# define __ARM_FEATURE_AES 1
2527
#endif
2628

29+
#ifdef USE_ARM64_NEON_H
30+
#include <arm64_neon.h>
31+
#else
2732
#include <arm_neon.h>
33+
#endif
2834

2935
#ifdef __clang__
3036
# pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), \

src/aegis/aegis256/aegis256_altivec.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#ifdef __clang__
2323
# pragma clang attribute push(__attribute__((target("altivec,crypto"))), apply_to = function)
2424
#elif defined(__GNUC__)
25-
# pragma GCC target("+altivec+crypto")
25+
# pragma GCC target("altivec,crypto")
2626
#endif
2727

2828
#define AES_BLOCK_LENGTH 16
@@ -59,7 +59,7 @@ AEGIS_AES_BLOCK_LOAD(const uint8_t *a)
5959
static inline AEGIS_AES_BLOCK_T
6060
AEGIS_AES_BLOCK_LOAD_64x2(uint64_t a, uint64_t b)
6161
{
62-
return vec_revb(vec_insert(a, vec_promote((unsigned long long) b, 1), 0));
62+
return (AEGIS_AES_BLOCK_T) vec_revb(vec_insert(a, vec_promote((unsigned long long) b, 1), 0));
6363
}
6464

6565
static inline void
@@ -71,7 +71,7 @@ AEGIS_AES_BLOCK_STORE(uint8_t *a, const AEGIS_AES_BLOCK_T b)
7171
static inline AEGIS_AES_BLOCK_T
7272
AEGIS_AES_ENC(const AEGIS_AES_BLOCK_T a, const AEGIS_AES_BLOCK_T b)
7373
{
74-
return vec_cipher_be(a, b);
74+
return (AEGIS_AES_BLOCK_T) vec_cipher_be(a, b);
7575
}
7676

7777
static inline void

src/aegis/aegis256/aegis256_armcrypto.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
** SPDX-License-Identifier: MIT
66
*/
77

8-
#if defined(__aarch64__) || defined(_M_ARM64)
8+
#include "../common/aeshardware.h"
9+
10+
#if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NEON
911

1012
#include <errno.h>
1113
#include <stddef.h>
@@ -24,7 +26,11 @@
2426
# define __ARM_FEATURE_AES 1
2527
#endif
2628

29+
#ifdef USE_ARM64_NEON_H
30+
#include <arm64_neon.h>
31+
#else
2732
#include <arm_neon.h>
33+
#endif
2834

2935
#ifdef __clang__
3036
# pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), \

src/aegis/aegis256x2/aegis256x2_altivec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#ifdef __clang__
2323
# pragma clang attribute push(__attribute__((target("altivec,crypto"))), apply_to = function)
2424
#elif defined(__GNUC__)
25-
# pragma GCC target("+altivec+crypto")
25+
# pragma GCC target("altivec,crypto")
2626
#endif
2727

2828
#define AES_BLOCK_LENGTH 32
@@ -63,7 +63,7 @@ static inline AEGIS_AES_BLOCK_T
6363
AEGIS_AES_BLOCK_LOAD_64x2(uint64_t a, uint64_t b)
6464
{
6565
const vector unsigned char t =
66-
vec_revb(vec_insert(a, vec_promote((unsigned long long) (b), 1), 0));
66+
(vector unsigned char) vec_revb(vec_insert(a, vec_promote((unsigned long long) (b), 1), 0));
6767
return (AEGIS_AES_BLOCK_T) { t, t };
6868
}
6969

src/aegis/aegis256x2/aegis256x2_armcrypto.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
** SPDX-License-Identifier: MIT
66
*/
77

8-
#if defined(__aarch64__) || defined(_M_ARM64)
8+
#include "../common/aeshardware.h"
9+
10+
#if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NEON
911

1012
#include <errno.h>
1113
#include <stddef.h>
@@ -24,7 +26,11 @@
2426
# define __ARM_FEATURE_AES 1
2527
#endif
2628

29+
#ifdef USE_ARM64_NEON_H
30+
#include <arm64_neon.h>
31+
#else
2732
#include <arm_neon.h>
33+
#endif
2834

2935
#ifdef __clang__
3036
# pragma clang attribute push(__attribute__((target("neon,crypto,aes"))), \

0 commit comments

Comments
 (0)