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
This commit is contained in:
parent
a998d1031c
commit
9d8b66868a
@ -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 *);
|
||||
|
@ -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);
|
||||
|
@ -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_ */
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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 *);
|
||||
|
@ -295,3 +295,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);
|
||||
|
@ -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 *);
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user