IF[1]
PROGRAMS{noinst}=asn1_internal_test modes_internal_test x509_internal_test \
tls13encryptiontest wpackettest ctype_internal_test \
- rdrand_sanitytest property_test ideatest rsa_mp_test \
+ rdcpu_sanitytest property_test ideatest rsa_mp_test \
rsa_sp800_56b_test bn_internal_test ecdsatest rsa_test \
rc2test rc4test rc5test hmactest ffc_internal_test \
asn1_dsa_internal_test dsatest dsa_no_digest_size_test \
INCLUDE[rc4test]=../include ../apps/include
DEPEND[rc4test]=../libcrypto.a libtestutil.a
- SOURCE[rdrand_sanitytest]=rdrand_sanitytest.c
- INCLUDE[rdrand_sanitytest]=../include ../apps/include
- DEPEND[rdrand_sanitytest]=../libcrypto.a libtestutil.a
+ SOURCE[rdcpu_sanitytest]=rdcpu_sanitytest.c
+ INCLUDE[rdcpu_sanitytest]=../include ../apps/include ../crypto
+ DEPEND[rdcpu_sanitytest]=../libcrypto.a libtestutil.a
SOURCE[rsa_sp800_56b_test]=rsa_sp800_56b_test.c
INCLUDE[rsa_sp800_56b_test]=.. ../include ../crypto/rsa ../apps/include
#if (defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
defined(__x86_64) || defined(__x86_64__) || \
defined(_M_AMD64) || defined (_M_X64)) && defined(OPENSSL_CPUID_OBJ)
-
+# define IS_X_86 1
size_t OPENSSL_ia32_rdrand_bytes(unsigned char *buf, size_t len);
size_t OPENSSL_ia32_rdseed_bytes(unsigned char *buf, size_t len);
+#else
+# define IS_X_86 0
+#endif
+
+#if defined(__aarch64__)
+# define IS_AARCH_64 1
+# include "arm_arch.h"
+
+size_t OPENSSL_rndr_bytes(unsigned char *buf, size_t len);
+size_t OPENSSL_rndrrs_bytes(unsigned char *buf, size_t len);
+#else
+# define IS_AARCH_64 0
+#endif
+#if (IS_X_86 || IS_AARCH_64)
static int sanity_check_bytes(size_t (*rng)(unsigned char *, size_t),
int rounds, int min_failures, int max_retries, int max_zero_words)
{
end:
return testresult;
}
+#endif
+#if IS_X_86
static int sanity_check_rdrand_bytes(void)
{
return sanity_check_bytes(OPENSSL_ia32_rdrand_bytes, 1000, 0, 10, 10);
*/
return sanity_check_bytes(OPENSSL_ia32_rdseed_bytes, 1000, 1, 10000, 10);
}
+#elif IS_AARCH_64
+static int sanity_check_rndr_bytes(void)
+{
+ return sanity_check_bytes(OPENSSL_rndr_bytes, 1000, 0, 10, 10);
+}
+
+static int sanity_check_rndrrs_bytes(void)
+{
+ return sanity_check_bytes(OPENSSL_rndrrs_bytes, 1000, 0, 10000, 10);
+}
+#endif
int setup_tests(void)
{
+#if (IS_X_86 || IS_AARCH_64)
OPENSSL_cpuid_setup();
+# if IS_X_86
int have_rdseed = (OPENSSL_ia32cap_P[2] & (1 << 18)) != 0;
int have_rdrand = (OPENSSL_ia32cap_P[1] & (1 << (62 - 32))) != 0;
if (have_rdseed) {
ADD_TEST(sanity_check_rdseed_bytes);
}
+# elif IS_AARCH_64
+ int have_rndr_rndrrs = (OPENSSL_armcap_P & (1 << 8)) != 0;
- return 1;
-}
-
-
-#else
+ if (have_rndr_rndrrs) {
+ ADD_TEST(sanity_check_rndr_bytes);
+ ADD_TEST(sanity_check_rndrrs_bytes);
+ }
+# endif
+#endif
-int setup_tests(void)
-{
return 1;
}
-
-#endif
use OpenSSL::Test::Simple;
use OpenSSL::Test::Utils;
-setup("test_rdrand_sanity");
+setup("test_rdcpu_sanity");
# We also need static builds to be enabled even on linux
plan skip_all => "This test is unsupported if static builds are not enabled"
if disabled("static");
-simple_test("test_rdrand_sanity", "rdrand_sanitytest");
+simple_test("test_rdcpu_sanity", "rdcpu_sanitytest");