rspamd_cryptobox_test_instr (gint instr)
{
void (*old_handler) (int);
+ guint32 rd;
#if defined(__GNUC__)
ok = 1;
__asm__ volatile ("vpaddq %ymm0, %ymm0, %ymm0");\
break;
#endif
+ case CPUID_RDRAND:
+ /* Use byte code here for compatibility */
+ __asm__ volatile (".byte 0x0f,0xc7,0xf0; setc %1"
+ : "=a" (rd), "=qm" (ok)
+ :
+ : "edx"
+ );
+ break;
default:
break;
}
cpu_config |= CPUID_SSE41;
}
}
+ if ((cpu[2] & ((gint)1 << 30))) {
+ if (rspamd_cryptobox_test_instr (CPUID_RDRAND)) {
+ cpu_config |= CPUID_RDRAND;
+ }
+ }
if (nid > 7) {
rspamd_cryptobox_cpuid (cpu, 7);
case CPUID_AVX2:
rspamd_printf_gstring (buf, "avx2, ");
break;
+ case CPUID_RDRAND:
+ rspamd_printf_gstring (buf, "rdrand, ");
+ break;
}
}
}
ctx->cpu_extensions = buf->str;
g_string_free (buf, FALSE);
+ ctx->cpu_config = cpu_config;
ctx->chacha20_impl = chacha_load ();
ctx->poly1305_impl = poly1305_load ();
#define rspamd_cryptobox_HASHKEYBYTES 64
#define rspamd_cryptobox_HASHSTATEBYTES 256
+#define CPUID_AVX2 0x1
+#define CPUID_AVX 0x2
+#define CPUID_SSE2 0x4
+#define CPUID_SSE3 0x8
+#define CPUID_SSSE3 0x10
+#define CPUID_SSE41 0x20
+#define CPUID_RDRAND 0x40
+
typedef guchar rspamd_pk_t[rspamd_cryptobox_MAX_PKBYTES];
typedef guchar rspamd_sk_t[rspamd_cryptobox_MAX_SKBYTES];
typedef guchar rspamd_sig_t[rspamd_cryptobox_MAX_MACBYTES];
const gchar *poly1305_impl;
const gchar *siphash_impl;
const gchar *blake2_impl;
+ unsigned long cpu_config;
};
/**
#cmakedefine HAVE_SLASHMACRO 1
#cmakedefine HAVE_DOLLARMACRO 1
-#define CPUID_AVX2 0x1
-#define CPUID_AVX 0x2
-#define CPUID_SSE2 0x4
-#define CPUID_SSE3 0x8
-#define CPUID_SSSE3 0x10
-#define CPUID_SSE41 0x20
-
#endif
\ No newline at end of file
struct rspamd_external_libs_ctx *ctx;
ctx = g_slice_alloc0 (sizeof (*ctx));
- rspamd_cryptobox_init ();
+ ctx->crypto_ctx = rspamd_cryptobox_init ();
ottery_init (NULL);
#ifdef HAVE_LOCALE_H
struct mime_part;
struct rspamd_dns_resolver;
struct rspamd_task;
+struct rspamd_cryptobox_library_ctx;
/**
* Server statistics
struct rspamd_external_libs_ctx {
magic_t libmagic;
void **local_addrs;
+ struct rspamd_cryptobox_library_ctx *crypto_ctx;
ref_entry_t ref;
};