$OpenBSD: patch-src_secmem_c,v 1.2 2016/04/24 21:40:25 ajacoutot Exp $

Patch copied from gnupg/patches/patch-util_secmem_c

--- src/secmem.c.orig	Wed Mar 23 12:59:34 2016
+++ src/secmem.c	Sat Apr 23 08:36:27 2016
@@ -36,6 +36,9 @@
 #include <sys/capability.h>
 #endif
 #endif
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <uvm/uvm_swap_encrypt.h>
 
 #include "g10lib.h"
 #include "secmem.h"
@@ -231,8 +234,24 @@ mb_get_new (memblock_t *block, size_t size)
 static void
 print_warn (void)
 {
-  if (!no_warning)
-    log_info (_("Warning: using insecure memory!\n"));
+	int    mib[3], swapencrypt = 0;
+	size_t len;
+
+	mib[0] = CTL_VM;
+	mib[1] = VM_SWAPENCRYPT;
+	mib[2] = SWPENC_ENABLE;
+
+	len = sizeof(swapencrypt);
+
+	if (sysctl(mib, 3, &swapencrypt, &len, NULL, 0) == -1)
+		log_info("WARNING: Can't receive vm.swapencrypt.enable sysctl value\n");
+
+	if (!no_warning && !swapencrypt)
+	{
+		log_info("WARNING: Using insecure memory!\n");
+		log_info("Please enable swap encryption via"
+			 " 'sysctl vm.swapencrypt.enable=1'.\n");
+	}
 }
 
 /* Lock the memory pages into core and drop privileges.  */
