Remove the CRYPTO_is_*_capable_at_runtime indirection

I think this dates to when CRYPTO_is_*_capable were inline functions in
public headers, so they couldn't access OPENSSL_armcap_P directly. Now
they can.

Change-Id: Ic06fffa7f5056401118b62d690dfe6b21bc30f86
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/62345
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: Bob Beck <bbe@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
chromium-stable
David Benjamin 1 year ago committed by Boringssl LUCI CQ
parent 7ce5d41410
commit 5edba0bcc9
  1. 1
      crypto/CMakeLists.txt
  2. 36
      crypto/cpu_arm.c
  3. 22
      crypto/internal.h

@ -134,7 +134,6 @@ add_library(
cpu_aarch64_win.c
cpu_arm_freebsd.c
cpu_arm_linux.c
cpu_arm.c
cpu_intel.c
crypto.c
curve25519/curve25519.c

@ -1,36 +0,0 @@
/* Copyright (c) 2014, Google Inc.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
#include "internal.h"
#if (defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64)) && \
!defined(OPENSSL_STATIC_ARMCAP)
#include <openssl/arm_arch.h>
int CRYPTO_is_NEON_capable_at_runtime(void) {
return (OPENSSL_armcap_P & ARMV7_NEON) != 0;
}
int CRYPTO_is_ARMv8_AES_capable_at_runtime(void) {
return (OPENSSL_armcap_P & ARMV8_AES) != 0;
}
int CRYPTO_is_ARMv8_PMULL_capable_at_runtime(void) {
return (OPENSSL_armcap_P & ARMV8_PMULL) != 0;
}
#endif /* (defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64)) &&
!defined(OPENSSL_STATIC_ARMCAP) */

@ -109,6 +109,7 @@
#ifndef OPENSSL_HEADER_CRYPTO_INTERNAL_H
#define OPENSSL_HEADER_CRYPTO_INTERNAL_H
#include <openssl/arm_arch.h>
#include <openssl/crypto.h>
#include <openssl/ex_data.h>
#include <openssl/stack.h>
@ -1379,21 +1380,6 @@ extern uint32_t OPENSSL_armcap_P;
#endif
#endif
#if !defined(OPENSSL_STATIC_ARMCAP)
// CRYPTO_is_NEON_capable_at_runtime returns true if the current CPU has a NEON
// unit. Note that |OPENSSL_armcap_P| also exists and contains the same
// information in a form that's easier for assembly to use.
OPENSSL_EXPORT int CRYPTO_is_NEON_capable_at_runtime(void);
// CRYPTO_is_ARMv8_AES_capable_at_runtime returns true if the current CPU
// supports the ARMv8 AES instruction.
int CRYPTO_is_ARMv8_AES_capable_at_runtime(void);
// CRYPTO_is_ARMv8_PMULL_capable_at_runtime returns true if the current CPU
// supports the ARMv8 PMULL instruction.
int CRYPTO_is_ARMv8_PMULL_capable_at_runtime(void);
#endif // !OPENSSL_STATIC_ARMCAP
// CRYPTO_is_NEON_capable returns true if the current CPU has a NEON unit. If
// this is known statically, it is a constant inline function.
OPENSSL_INLINE int CRYPTO_is_NEON_capable(void) {
@ -1402,7 +1388,7 @@ OPENSSL_INLINE int CRYPTO_is_NEON_capable(void) {
#elif defined(OPENSSL_STATIC_ARMCAP)
return 0;
#else
return CRYPTO_is_NEON_capable_at_runtime();
return (OPENSSL_armcap_P & ARMV7_NEON) != 0;
#endif
}
@ -1412,7 +1398,7 @@ OPENSSL_INLINE int CRYPTO_is_ARMv8_AES_capable(void) {
#elif defined(OPENSSL_STATIC_ARMCAP)
return 0;
#else
return CRYPTO_is_ARMv8_AES_capable_at_runtime();
return (OPENSSL_armcap_P & ARMV8_AES) != 0;
#endif
}
@ -1422,7 +1408,7 @@ OPENSSL_INLINE int CRYPTO_is_ARMv8_PMULL_capable(void) {
#elif defined(OPENSSL_STATIC_ARMCAP)
return 0;
#else
return CRYPTO_is_ARMv8_PMULL_capable_at_runtime();
return (OPENSSL_armcap_P & ARMV8_PMULL) != 0;
#endif
}

Loading…
Cancel
Save