aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/des
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2001-03-02 10:38:19 +0000
committerRichard Levitte <levitte@openssl.org>2001-03-02 10:38:19 +0000
commit62dc5aad063f50fa75fdae66c4247c925d4b3c5d (patch)
treedcc37b462bcd4ab9ebf47781115d36a98e1d25cf /crypto/des
parent45ecfb19731d0190aecdddc911c710571c50bd67 (diff)
downloadopenssl-62dc5aad063f50fa75fdae66c4247c925d4b3c5d.tar.gz
Introduce the possibility to access global variables through
functions on platform were that's the best way to handle exporting global variables in shared libraries. To enable this functionality, one must configure with "EXPORT_VAR_AS_FN" or defined the C macro "OPENSSL_EXPORT_VAR_AS_FUNCTION" in crypto/opensslconf.h (the latter is normally done by Configure or something similar). To implement a global variable, use the macro OPENSSL_IMPLEMENT_GLOBAL in the source file (foo.c) like this: OPENSSL_IMPLEMENT_GLOBAL(int,foo)=1; OPENSSL_IMPLEMENT_GLOBAL(double,bar); To declare a global variable, use the macros OPENSSL_DECLARE_GLOBAL and OPENSSL_GLOBAL_REF in the header file (foo.h) like this: OPENSSL_DECLARE_GLOBAL(int,foo); #define foo OPENSSL_GLOBAL_REF(foo) OPENSSL_DECLARE_GLOBAL(double,bar); #define bar OPENSSL_GLOBAL_REF(bar) The #defines are very important, and therefore so is including the header file everywere where the defined globals are used. The macro OPENSSL_EXPORT_VAR_AS_FUNCTION also affects the definition of ASN.1 items, but that structure is a bt different. The largest change is in util/mkdef.pl which has been enhanced with better and easier to understand logic to choose which symbols should go into the Windows .def files as well as a number of fixes and code cleanup (among others, algorithm keywords are now sorted lexicographically to avoid constant rewrites).
Diffstat (limited to 'crypto/des')
-rw-r--r--crypto/des/des.h6
-rw-r--r--crypto/des/enc_read.c2
-rw-r--r--crypto/des/set_key.c2
3 files changed, 6 insertions, 4 deletions
diff --git a/crypto/des/des.h b/crypto/des/des.h
index 5fa6aef27b..dc627189b4 100644
--- a/crypto/des/des.h
+++ b/crypto/des/des.h
@@ -116,8 +116,10 @@ typedef struct des_ks_struct
#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
-OPENSSL_EXTERN int des_check_key; /* defaults to false */
-OPENSSL_EXTERN int des_rw_mode; /* defaults to DES_PCBC_MODE */
+OPENSSL_DECLARE_GLOBAL(int,des_check_key); /* defaults to false */
+#define des_check_key OPENSSL_GLOBAL_REF(des_check_key)
+OPENSSL_DECLARE_GLOBAL(int,des_rw_mode); /* defaults to DES_PCBC_MODE */
+#define des_rw_mode OPENSSL_GLOBAL_REF(des_rw_mode)
const char *des_options(void);
void des_ecb3_encrypt(const_des_cblock *input, des_cblock *output,
diff --git a/crypto/des/enc_read.c b/crypto/des/enc_read.c
index af2d9177d2..e8a5763abf 100644
--- a/crypto/des/enc_read.c
+++ b/crypto/des/enc_read.c
@@ -63,7 +63,7 @@
/* This has some uglies in it but it works - even over sockets. */
/*extern int errno;*/
-OPENSSL_GLOBAL int des_rw_mode=DES_PCBC_MODE;
+OPENSSL_IMPLEMENT_GLOBAL(int,des_rw_mode)=DES_PCBC_MODE;
/*
diff --git a/crypto/des/set_key.c b/crypto/des/set_key.c
index 6df3ba9a64..0dc79c9461 100644
--- a/crypto/des/set_key.c
+++ b/crypto/des/set_key.c
@@ -65,7 +65,7 @@
*/
#include "des_locl.h"
-OPENSSL_GLOBAL int des_check_key=0;
+OPENSSL_IMPLEMENT_GLOBAL(int,des_check_key); /* defaults to false */
static const unsigned char odd_parity[256]={
1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14,