Skip to content

Commit

Permalink
Validate or define ARM HWCAP2_XXX macros
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Feb 4, 2025
1 parent cc9c9f0 commit 4aaf4ad
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions crypto/fipsmodule/cpucap/cpu_arm_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,37 @@ extern "C" {
// The cpuinfo parser lives in a header file so it may be accessible from
// cross-platform fuzzers without adding code to those platforms normally.

#define HWCAP_NEON (1 << 12)
#if defined(HWCAP_NEON) && HWCAP_NEON != 4096
#error "HWCAP_NEON is defined but has wrong value (expected 4096)"
#elif !defined(HWCAP_NEON)
#define HWCAP_NEON 4096
#endif

// See /usr/include/asm/hwcap.h on an ARM installation for the source of
// these values.
#define HWCAP2_AES (1 << 0)
#define HWCAP2_PMULL (1 << 1)
#define HWCAP2_SHA1 (1 << 2)
#define HWCAP2_SHA2 (1 << 3)
#if defined(HWCAP2_AES) && HWCAP2_AES != 1
#error "HWCAP2_AES is defined but has wrong value (expected 1)"
#elif !defined(HWCAP2_AES)
#define HWCAP2_AES 1
#endif

#if defined(HWCAP2_PMULL) && HWCAP2_PMULL != 2
#error "HWCAP2_PMULL is defined but has wrong value (expected 2)"
#elif !defined(HWCAP2_PMULL)
#define HWCAP2_PMULL 2
#endif

#if defined(HWCAP2_SHA1) && HWCAP2_SHA1 != 4
#error "HWCAP2_SHA1 is defined but has wrong value (expected 4)"
#elif !defined(HWCAP2_SHA1)
#define HWCAP2_SHA1 4
#endif

#if defined(HWCAP2_SHA2) && HWCAP2_SHA2 != 8
#error "HWCAP2_SHA2 is defined but has wrong value (expected 8)"
#elif !defined(HWCAP2_SHA2)
#define HWCAP2_SHA2 8
#endif

typedef struct {
const char *data;
Expand Down

0 comments on commit 4aaf4ad

Please sign in to comment.