Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Rewrite ARM feature detection. This removes the thread-unsafe SIGILL-based detection and the multi-consumer-hostile CRYPTO_set_NEON_capable API. (Changing OPENSSL_armcap_P after initialization is likely to cause problems.) The right way to detect ARM features on Linux is getauxval. On aarch64, we should be able to rely on this, so use it straight. Split this out into its own file. The #ifdefs in the old cpu-arm.c meant it shared all but no code with its arm counterpart anyway. Unfortunately, various versions of Android have different missing APIs, so, on arm, we need a series of workarounds. Previously, we used a SIGILL fallback based on OpenSSL's logic, but this is inherently not thread-safe. (SIGILL also does not tell us if the OS knows how to save and restore NEON state.) Instead, base the behavior on Android NDK's cpu-features library, what Chromium currently uses with CRYPTO_set_NEON_capable: - Android before API level 20 does not provide getauxval. Where missing, we can read from /proc/self/auxv. - On some versions of Android, /proc/self/auxv is also not readable, so use /proc/cpuinfo's Features line. - Linux only advertises optional features in /proc/cpuinfo. ARMv8 makes NEON mandatory, so /proc/cpuinfo can't be used without additional effort. Finally, we must blacklist a particular chip because the NEON unit is broken (https://crbug.com/341598). Unfortunately, this means CRYPTO_library_init now depends on /proc being available, which will require some care with Chromium's sandbox. The simplest solution is to just call CRYPTO_library_init before entering the sandbox. It's worth noting that Chromium's current EnsureOpenSSLInit function already depends on /proc/cpuinfo to detect the broken CPU, by way of base::CPU. android_getCpuFeatures also interally depends on it. We were already relying on both of those being stateful and primed prior to entering the sandbox. BUG=chromium:589200 Change-Id: Ic5d1c341aab5a614eb129d8aa5ada2809edd6af8 Reviewed-on: https://boringssl-review.googlesource.com/7506 Reviewed-by: David Benjamin <davidben@google.com>
pirms 8 gadiem
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* Copyright (c) 2014, Google Inc.
  2. *
  3. * Permission to use, copy, modify, and/or distribute this software for any
  4. * purpose with or without fee is hereby granted, provided that the above
  5. * copyright notice and this permission notice appear in all copies.
  6. *
  7. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  10. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  12. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  13. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
  14. #ifndef OPENSSL_HEADER_CRYPTO_H
  15. #define OPENSSL_HEADER_CRYPTO_H
  16. #include <openssl/base.h>
  17. /* Upstream OpenSSL defines |OPENSSL_malloc|, etc., in crypto.h rather than
  18. * mem.h. */
  19. #include <openssl/mem.h>
  20. /* Upstream OpenSSL defines |CRYPTO_LOCK|, etc., in crypto.h rather than
  21. * thread.h. */
  22. #include <openssl/thread.h>
  23. #if defined(__cplusplus)
  24. extern "C" {
  25. #endif
  26. /* crypto.h contains functions for initializing the crypto library. */
  27. /* CRYPTO_library_init initializes the crypto library. It must be called if the
  28. * library is built with BORINGSSL_NO_STATIC_INITIALIZER. Otherwise, it does
  29. * nothing and a static initializer is used instead. It is safe to call this
  30. * function multiple times and concurrently from multiple threads.
  31. *
  32. * On some ARM configurations, this function may require filesystem access and
  33. * should be called before entering a sandbox. */
  34. OPENSSL_EXPORT void CRYPTO_library_init(void);
  35. /* CRYPTO_is_confidential_build returns one if the linked version of BoringSSL
  36. * has been built with the BORINGSSL_CONFIDENTIAL define and zero otherwise.
  37. *
  38. * This is used by some consumers to identify whether they are using an
  39. * internal version of BoringSSL. */
  40. OPENSSL_EXPORT int CRYPTO_is_confidential_build(void);
  41. /* CRYPTO_has_asm returns one unless BoringSSL was built with OPENSSL_NO_ASM,
  42. * in which case it returns zero. */
  43. OPENSSL_EXPORT int CRYPTO_has_asm(void);
  44. /* Deprecated functions. */
  45. /* OPENSSL_VERSION_TEXT contains a string the identifies the version of
  46. * “OpenSSL”. node.js requires a version number in this text. */
  47. #define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2 (compatible; BoringSSL)"
  48. #define SSLEAY_VERSION 0
  49. /* SSLeay_version is a compatibility function that returns the string
  50. * "BoringSSL". */
  51. OPENSSL_EXPORT const char *SSLeay_version(int unused);
  52. /* SSLeay is a compatibility function that returns OPENSSL_VERSION_NUMBER from
  53. * base.h. */
  54. OPENSSL_EXPORT unsigned long SSLeay(void);
  55. /* CRYPTO_malloc_init returns one. */
  56. OPENSSL_EXPORT int CRYPTO_malloc_init(void);
  57. /* ENGINE_load_builtin_engines does nothing. */
  58. OPENSSL_EXPORT void ENGINE_load_builtin_engines(void);
  59. /* OPENSSL_load_builtin_modules does nothing. */
  60. OPENSSL_EXPORT void OPENSSL_load_builtin_modules(void);
  61. /* FIPS_mode returns zero. */
  62. OPENSSL_EXPORT int FIPS_mode(void);
  63. #if defined(__cplusplus)
  64. } /* extern C */
  65. #endif
  66. #endif /* OPENSSL_HEADER_CRYPTO_H */