Skip to content

Commit

Permalink
Update with ARMV8_HAVE_SHA3_AND_WORTH_USING
Browse files Browse the repository at this point in the history
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from #21398)
  • Loading branch information
sdlyyxy authored and paulidale committed Jul 21, 2023
1 parent 08e6eb2 commit ba9472c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion crypto/arm_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ extern unsigned int OPENSSL_armv8_rsa_neonized;
# define ARMV8_UNROLL8_EOR3 (1<<12)
# define ARMV8_SVE (1<<13)
# define ARMV8_SVE2 (1<<14)
# define ARMV8_WORTH_USING_SHA3 (1<<15)
# define ARMV8_HAVE_SHA3_AND_WORTH_USING (1<<15)

/*
* MIDR_EL1 system register
Expand Down
4 changes: 2 additions & 2 deletions crypto/armcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ void OPENSSL_cpuid_setup(void)
((strncmp(uarch, "Apple M1", 8) == 0) ||
(strncmp(uarch, "Apple M2", 8) == 0))) {
OPENSSL_armcap_P |= ARMV8_UNROLL8_EOR3;
OPENSSL_armcap_P |= ARMV8_WORTH_USING_SHA3;
OPENSSL_armcap_P |= ARMV8_HAVE_SHA3_AND_WORTH_USING;
}
}
}
Expand Down Expand Up @@ -433,7 +433,7 @@ void OPENSSL_cpuid_setup(void)
MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_AVALANCHE_MAX) ||
MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_BLIZZARD_MAX)) &&
(OPENSSL_armcap_P & ARMV8_SHA3))
OPENSSL_armcap_P |= ARMV8_WORTH_USING_SHA3;
OPENSSL_armcap_P |= ARMV8_HAVE_SHA3_AND_WORTH_USING;
# endif
}
#endif /* _WIN32, __ARM_MAX_ARCH__ >= 7 */
8 changes: 2 additions & 6 deletions providers/implementations/digests/sha3_prov.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,18 +271,14 @@ static PROV_SHA3_METHOD sha3_ARMSHA3_md =
armsha3_sha3_absorb,
generic_sha3_final
};
/* Users can switch back to the generic code by clearing either of the bits */
# define ARM_SHA3_CAPABLE \
((OPENSSL_armcap_P & ARMV8_SHA3) && \
(OPENSSL_armcap_P & ARMV8_WORTH_USING_SHA3))
# define SHA3_SET_MD(uname, typ) \
if (ARM_SHA3_CAPABLE) { \
if (OPENSSL_armcap_P & ARMV8_HAVE_SHA3_AND_WORTH_USING) { \
ctx->meth = sha3_ARMSHA3_md; \
} else { \
ctx->meth = sha3_generic_md; \
}
# define KMAC_SET_MD(bitlen) \
if (ARM_SHA3_CAPABLE) { \
if (OPENSSL_armcap_P & ARMV8_HAVE_SHA3_AND_WORTH_USING) { \
ctx->meth = sha3_ARMSHA3_md; \
} else { \
ctx->meth = sha3_generic_md; \
Expand Down

0 comments on commit ba9472c

Please sign in to comment.