summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuiz Otavio O Souza <luiz@netgate.com>2015-09-15 15:50:00 -0500
committerLuiz Otavio O Souza <luiz@netgate.com>2015-10-20 12:03:24 -0500
commitfbbde3a0d1cef7642b2575e0b008ab41c519809c (patch)
treee19c9b385bef3548ddb16fd9b4d8f49238d1b99e
parente8001fd0fddc08dbe26cabe348f1adca96c271d8 (diff)
downloadFreeBSD-src-fbbde3a0d1cef7642b2575e0b008ab41c519809c.zip
FreeBSD-src-fbbde3a0d1cef7642b2575e0b008ab41c519809c.tar.gz
MFC r282726:
Ensure libmd symbols do not clash with libcrypto Add a prefix to all symbols in libmd to avoid incompatibilites with same-named, but not binary compatible, symbols from libcrypto. Also introduce Weak aliases to avoid the need to rebuild dependent binaries and a major version bump. PR: 199119 Differential Revision: D2216 Reviewed by: roberto, delphij MFC after: 2 weeks TAG: IPSEC-HEAD Issue: #4841
-rw-r--r--lib/libmd/md4.h12
-rw-r--r--lib/libmd/md4c.c9
-rw-r--r--lib/libmd/md5.h19
-rw-r--r--lib/libmd/md5c.c13
-rw-r--r--lib/libmd/mdXhl.c9
-rw-r--r--lib/libmd/ripemd.h15
-rw-r--r--lib/libmd/rmd160c.c13
-rw-r--r--lib/libmd/sha.h28
-rw-r--r--lib/libmd/sha1c.c25
-rw-r--r--lib/libmd/sha256.h14
-rw-r--r--lib/libmd/sha256c.c11
-rw-r--r--lib/libmd/sha512.h14
-rw-r--r--lib/libmd/sha512c.c11
-rw-r--r--lib/libmd/shadriver.c3
14 files changed, 195 insertions, 1 deletions
diff --git a/lib/libmd/md4.h b/lib/libmd/md4.h
index 4773513..efef98f 100644
--- a/lib/libmd/md4.h
+++ b/lib/libmd/md4.h
@@ -35,6 +35,18 @@ typedef struct MD4Context {
#include <sys/cdefs.h>
__BEGIN_DECLS
+
+/* Ensure libmd symbols do not clash with libcrypto */
+
+#define MD4Init _libmd_MD4Init
+#define MD4Update _libmd_MD4Update
+#define MD4Pad _libmd_MD4Pad
+#define MD4Final _libmd_MD4Final
+#define MD4End _libmd_MD4End
+#define MD4File _libmd_MD4File
+#define MD4FileChunk _libmd_MD4FileChunk
+#define MD4Data _libmd_MD4Data
+
void MD4Init(MD4_CTX *);
void MD4Update(MD4_CTX *, const void *, unsigned int);
void MD4Pad(MD4_CTX *);
diff --git a/lib/libmd/md4c.c b/lib/libmd/md4c.c
index 1211a98..2234c40 100644
--- a/lib/libmd/md4c.c
+++ b/lib/libmd/md4c.c
@@ -290,3 +290,12 @@ unsigned int len;
output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
(((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
}
+
+#undef MD4Init
+__weak_reference(_libmd_MD4Init, MD4Init);
+#undef MD4Update
+__weak_reference(_libmd_MD4Update, MD4Update);
+#undef MD4Pad
+__weak_reference(_libmd_MD4Pad, MD4Pad);
+#undef MD4Final
+__weak_reference(_libmd_MD4Final, MD4Final);
diff --git a/lib/libmd/md5.h b/lib/libmd/md5.h
index 803a88f..1d6ee6c 100644
--- a/lib/libmd/md5.h
+++ b/lib/libmd/md5.h
@@ -1,4 +1,23 @@
+/* $FreeBSD$ */
+
#ifndef _MD5_H_
#define _MD5_H_
+
+#ifndef _KERNEL
+
+/* Ensure libmd symbols do not clash with libcrypto */
+
+#define MD5Init _libmd_MD5Init
+#define MD5Update _libmd_MD5Update
+#define MD5Pad _libmd_MD5Pad
+#define MD5Final _libmd_MD5Final
+#define MD5Transform _libmd_MD5Transform
+#define MD5End _libmd_MD5End
+#define MD5File _libmd_MD5File
+#define MD5FileChunk _libmd_MD5FileChunk
+#define MD5Data _libmd_MD5Data
+
+#endif
+
#include <sys/md5.h>
#endif /* _MD5_H_ */
diff --git a/lib/libmd/md5c.c b/lib/libmd/md5c.c
index d097390..bfbb531 100644
--- a/lib/libmd/md5c.c
+++ b/lib/libmd/md5c.c
@@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$");
#include <machine/endian.h>
#include <sys/endian.h>
-#include <sys/md5.h>
+#include "md5.h"
static void MD5Transform(u_int32_t [4], const unsigned char [64]);
@@ -335,3 +335,14 @@ MD5Transform (state, block)
/* Zeroize sensitive information. */
memset ((void *)x, 0, sizeof (x));
}
+
+#undef MD5Init
+__weak_reference(_libmd_MD5Init, MD5Init);
+#undef MD5Update
+__weak_reference(_libmd_MD5Update, MD5Update);
+#undef MD5Pad
+__weak_reference(_libmd_MD5Pad, MD5Pad);
+#undef MD5Final
+__weak_reference(_libmd_MD5Final, MD5Final);
+#undef MD5Transform
+__weak_reference(_libmd_MD5Transform, MD5Transform);
diff --git a/lib/libmd/mdXhl.c b/lib/libmd/mdXhl.c
index 2954548..9db000d 100644
--- a/lib/libmd/mdXhl.c
+++ b/lib/libmd/mdXhl.c
@@ -96,3 +96,12 @@ MDXData (const void *data, unsigned int len, char *buf)
MDXUpdate(&ctx,data,len);
return (MDXEnd(&ctx, buf));
}
+
+#undef MDXEnd
+__weak_reference(_libmd_MDXEnd, MDXEnd);
+#undef MDXFile
+__weak_reference(_libmd_MDXFile, MDXFile);
+#undef MDXFileChunk
+__weak_reference(_libmd_MDXFileChunk, MDXFileChunk);
+#undef MDXData
+__weak_reference(_libmd_MDXData, MDXData);
diff --git a/lib/libmd/ripemd.h b/lib/libmd/ripemd.h
index 2ff35cc..1f8725a 100644
--- a/lib/libmd/ripemd.h
+++ b/lib/libmd/ripemd.h
@@ -81,6 +81,21 @@ typedef struct RIPEMD160state_st {
} RIPEMD160_CTX;
__BEGIN_DECLS
+
+/* Ensure libmd symbols do not clash with libcrypto */
+
+#define RIPEMD160_Init _libmd_RIPEMD160_Init
+#define RIPEMD160_Update _libmd_RIPEMD160_Update
+#define RIPEMD160_Final _libmd_RIPEMD160_Final
+#define RIPEMD160_End _libmd_RIPEMD160_End
+#define RIPEMD160_File _libmd_RIPEMD160_File
+#define RIPEMD160_FileChunk _libmd_RIPEMD160_FileChunk
+#define RIPEMD160_Data _libmd_RIPEMD160_Data
+
+#define RIPEMD160_Transform _libmd_RIPEMD160_Transform
+#define RMD160_version _libmd_RMD160_version
+#define ripemd160_block _libmd_ripemd160_block
+
void RIPEMD160_Init(RIPEMD160_CTX *c);
void RIPEMD160_Update(RIPEMD160_CTX *c, const void *data,
size_t len);
diff --git a/lib/libmd/rmd160c.c b/lib/libmd/rmd160c.c
index e01f1e0..a33126f 100644
--- a/lib/libmd/rmd160c.c
+++ b/lib/libmd/rmd160c.c
@@ -545,3 +545,16 @@ unsigned long *l;
}
}
#endif
+
+#undef RIPEMD160_Init
+__weak_reference(_libmd_RIPEMD160_Init, RIPEMD160_Init);
+#undef RIPEMD160_Update
+__weak_reference(_libmd_RIPEMD160_Update, RIPEMD160_Update);
+#undef RIPEMD160_Final
+__weak_reference(_libmd_RIPEMD160_Final, RIPEMD160_Final);
+#undef RIPEMD160_Transform
+__weak_reference(_libmd_RIPEMD160_Transform, RIPEMD160_Transform);
+#undef RMD160_version
+__weak_reference(_libmd_RMD160_version, RMD160_version);
+#undef ripemd160_block
+__weak_reference(_libmd_ripemd160_block, ripemd160_block);
diff --git a/lib/libmd/sha.h b/lib/libmd/sha.h
index 8a0b7c2..502f1ae 100644
--- a/lib/libmd/sha.h
+++ b/lib/libmd/sha.h
@@ -79,6 +79,33 @@ typedef struct SHAstate_st {
#define SHA1_CTX SHA_CTX
__BEGIN_DECLS
+
+/* Ensure libmd symbols do not clash with libcrypto */
+
+#define SHA_Init _libmd_SHA_Init
+#define SHA_Update _libmd_SHA_Update
+#define SHA_Final _libmd_SHA_Final
+#define SHA_End _libmd_SHA_End
+#define SHA_File _libmd_SHA_File
+#define SHA_FileChunk _libmd_SHA_FileChunk
+#define SHA_Data _libmd_SHA_Data
+
+#define SHA_Transform _libmd_SHA_Transform
+#define SHA_version _libmd_SHA_version
+#define sha_block _libmd_sha_block
+
+#define SHA1_Init _libmd_SHA1_Init
+#define SHA1_Update _libmd_SHA1_Update
+#define SHA1_Final _libmd_SHA1_Final
+#define SHA1_End _libmd_SHA1_End
+#define SHA1_File _libmd_SHA1_File
+#define SHA1_FileChunk _libmd_SHA1_FileChunk
+#define SHA1_Data _libmd_SHA1_Data
+
+#define SHA1_Transform _libmd_SHA1_Transform
+#define SHA1_version _libmd_SHA1_version
+#define sha1_block _libmd_sha1_block
+
void SHA_Init(SHA_CTX *c);
void SHA_Update(SHA_CTX *c, const void *data, size_t len);
void SHA_Final(unsigned char *md, SHA_CTX *c);
@@ -86,6 +113,7 @@ char *SHA_End(SHA_CTX *, char *);
char *SHA_File(const char *, char *);
char *SHA_FileChunk(const char *, char *, off_t, off_t);
char *SHA_Data(const void *, unsigned int, char *);
+
void SHA1_Init(SHA_CTX *c);
void SHA1_Update(SHA_CTX *c, const void *data, size_t len);
void SHA1_Final(unsigned char *md, SHA_CTX *c);
diff --git a/lib/libmd/sha1c.c b/lib/libmd/sha1c.c
index ba3278a..ea50622 100644
--- a/lib/libmd/sha1c.c
+++ b/lib/libmd/sha1c.c
@@ -488,3 +488,28 @@ SHA_CTX *c;
/* memset((char *)&c,0,sizeof(c));*/
}
+
+#undef SHA_Init
+__weak_reference(_libmd_SHA_Init, SHA_Init);
+#undef SHA_Update
+__weak_reference(_libmd_SHA_Update, SHA_Update);
+#undef SHA_Final
+__weak_reference(_libmd_SHA_Final, SHA_Final);
+#undef SHA_Transform
+__weak_reference(_libmd_SHA_Transform, SHA_Transform);
+#undef SHA_version
+__weak_reference(_libmd_SHA_version, SHA_version);
+#undef sha_block
+__weak_reference(_libmd_sha_block, sha_block);
+#undef SHA1_Init
+__weak_reference(_libmd_SHA1_Init, SHA1_Init);
+#undef SHA1_Update
+__weak_reference(_libmd_SHA1_Update, SHA1_Update);
+#undef SHA1_Final
+__weak_reference(_libmd_SHA1_Final, SHA1_Final);
+#undef SHA1_Transform
+__weak_reference(_libmd_SHA1_Transform, SHA1_Transform);
+#undef SHA1_version
+__weak_reference(_libmd_SHA1_version, SHA1_version);
+#undef sha1_block
+__weak_reference(_libmd_sha1_block, sha1_block);
diff --git a/lib/libmd/sha256.h b/lib/libmd/sha256.h
index ce51787..3419048 100644
--- a/lib/libmd/sha256.h
+++ b/lib/libmd/sha256.h
@@ -38,6 +38,20 @@ typedef struct SHA256Context {
} SHA256_CTX;
__BEGIN_DECLS
+
+/* Ensure libmd symbols do not clash with libcrypto */
+
+#define SHA256_Init _libmd_SHA256_Init
+#define SHA256_Update _libmd_SHA256_Update
+#define SHA256_Final _libmd_SHA256_Final
+#define SHA256_End _libmd_SHA256_End
+#define SHA256_File _libmd_SHA256_File
+#define SHA256_FileChunk _libmd_SHA256_FileChunk
+#define SHA256_Data _libmd_SHA256_Data
+
+#define SHA256_Transform _libmd_SHA256_Transform
+#define SHA256_version _libmd_SHA256_version
+
void SHA256_Init(SHA256_CTX *);
void SHA256_Update(SHA256_CTX *, const void *, size_t);
void SHA256_Final(unsigned char [32], SHA256_CTX *);
diff --git a/lib/libmd/sha256c.c b/lib/libmd/sha256c.c
index c95fd31..0c2fd1b 100644
--- a/lib/libmd/sha256c.c
+++ b/lib/libmd/sha256c.c
@@ -298,3 +298,14 @@ SHA256_Final(unsigned char digest[32], SHA256_CTX * ctx)
/* Clear the context state */
memset((void *)ctx, 0, sizeof(*ctx));
}
+
+#undef SHA256_Init
+__weak_reference(_libmd_SHA256_Init, SHA256_Init);
+#undef SHA256_Update
+__weak_reference(_libmd_SHA256_Update, SHA256_Update);
+#undef SHA256_Final
+__weak_reference(_libmd_SHA256_Final, SHA256_Final);
+#undef SHA256_Transform
+__weak_reference(_libmd_SHA256_Transform, SHA256_Transform);
+#undef SHA256_version
+__weak_reference(_libmd_SHA256_version, SHA256_version);
diff --git a/lib/libmd/sha512.h b/lib/libmd/sha512.h
index 8998f4c..101597e 100644
--- a/lib/libmd/sha512.h
+++ b/lib/libmd/sha512.h
@@ -38,6 +38,20 @@ typedef struct SHA512Context {
} SHA512_CTX;
__BEGIN_DECLS
+
+/* Ensure libmd symbols do not clash with libcrypto */
+
+#define SHA512_Init _libmd_SHA512_Init
+#define SHA512_Update _libmd_SHA512_Update
+#define SHA512_Final _libmd_SHA512_Final
+#define SHA512_End _libmd_SHA512_End
+#define SHA512_File _libmd_SHA512_File
+#define SHA512_FileChunk _libmd_SHA512_FileChunk
+#define SHA512_Data _libmd_SHA512_Data
+
+#define SHA512_Transform _libmd_SHA512_Transform
+#define SHA512_version _libmd_SHA512_version
+
void SHA512_Init(SHA512_CTX *);
void SHA512_Update(SHA512_CTX *, const void *, size_t);
void SHA512_Final(unsigned char [64], SHA512_CTX *);
diff --git a/lib/libmd/sha512c.c b/lib/libmd/sha512c.c
index c2a93be..5c2e200 100644
--- a/lib/libmd/sha512c.c
+++ b/lib/libmd/sha512c.c
@@ -318,3 +318,14 @@ SHA512_Final(unsigned char digest[64], SHA512_CTX * ctx)
/* Clear the context state */
memset((void *)ctx, 0, sizeof(*ctx));
}
+
+#undef SHA512_Init
+__weak_reference(_libmd_SHA512_Init, SHA512_Init);
+#undef SHA512_Update
+__weak_reference(_libmd_SHA512_Update, SHA512_Update);
+#undef SHA512_Final
+__weak_reference(_libmd_SHA512_Final, SHA512_Final);
+#undef SHA512_Transform
+__weak_reference(_libmd_SHA512_Transform, SHA512_Transform);
+#undef SHA512_version
+__weak_reference(_libmd_SHA512_version, SHA512_version);
diff --git a/lib/libmd/shadriver.c b/lib/libmd/shadriver.c
index adaf684..29a3cf0 100644
--- a/lib/libmd/shadriver.c
+++ b/lib/libmd/shadriver.c
@@ -31,10 +31,13 @@ __FBSDID("$FreeBSD$");
#endif
#if SHA == 1
+#undef SHA_Data
#define SHA_Data SHA1_Data
#elif SHA == 256
+#undef SHA_Data
#define SHA_Data SHA256_Data
#elif SHA == 512
+#undef SHA_Data
#define SHA_Data SHA512_Data
#endif
OpenPOWER on IntegriCloud