summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Junghans <tobydox@veyon.io>2018-11-07 12:48:29 +0100
committerTobias Junghans <tobydox@veyon.io>2018-11-07 12:59:16 +0100
commit1a381cb7603f0ed3570facbad9fdf685d262a48c (patch)
tree71f61a09c5fef62ea8776e7c341cd0db1552ae10
parenta70d3b2710b8fec3d7f15ff12da1becaccfe12e8 (diff)
downloadlibtdevnc-1a381cb7603f0ed3570facbad9fdf685d262a48c.tar.gz
libtdevnc-1a381cb7603f0ed3570facbad9fdf685d262a48c.zip
common: d3des: use per-thread key register
When encrypting/decrypting from different threads this can race due to the global key register.
-rw-r--r--common/d3des.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/common/d3des.c b/common/d3des.c
index db999a5..12ccf62 100644
--- a/common/d3des.c
+++ b/common/d3des.c
@@ -28,12 +28,20 @@
#include "d3des.h"
+#if defined(__GNUC__)
+#define TLS __thread
+#elif defined(_MSC_VER)
+#define TLS __declspec(thread)
+#else
+#define TLS
+#endif
+
static void scrunch(unsigned char *, unsigned long *);
static void unscrun(unsigned long *, unsigned char *);
static void desfunc(unsigned long *, unsigned long *);
static void cookey(unsigned long *);
-static unsigned long KnL[32] = { 0L };
+static TLS unsigned long KnL[32] = { 0L };
/*
static unsigned long KnR[32] = { 0L };
static unsigned long Kn3[32] = { 0L };