1 #include <Rinternals.h>
2 #include <openssl/opensslconf.h>
3 #include <openssl/opensslv.h>
4 
5 #include <openssl/evp.h>
6 #ifdef EVP_PKEY_ED25519
7 #define HAS_ECX
8 #endif
9 
R_openssl_config()10 SEXP R_openssl_config() {
11   int has_ec = 1;
12   #ifdef OPENSSL_NO_EC
13   has_ec = 0;
14   #endif
15   int has_x25519 = 0;
16   #ifdef HAS_ECX
17   has_x25519 = 1;
18   #endif
19   int has_fips = 0;
20   #ifdef OPENSSL_FIPS
21   has_fips = 1;
22   #endif
23   SEXP res = PROTECT(allocVector(VECSXP, 4));
24   SET_VECTOR_ELT(res, 0, mkString(OPENSSL_VERSION_TEXT));
25   SET_VECTOR_ELT(res, 1, ScalarLogical(has_ec));
26   SET_VECTOR_ELT(res, 2, ScalarLogical(has_x25519));
27   SET_VECTOR_ELT(res, 3, ScalarLogical(has_fips));
28   UNPROTECT(1);
29   return res;
30 }
31