libshared: move md5 to BPrivate namespace

Otherwise it clashes with the implementation in OpenSSL which uses the
same names but now has a different ABI.

Change-Id: I5cb3ff97d7b28de978cdcbd8a06f25f65fb53784
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2854
Reviewed-by: Kyle Ambroff-Kao <kyle@ambroffkao.com>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
Adrien Destugues 2020-05-31 11:53:58 +02:00 committed by Adrien Destugues
parent 6307201bac
commit 6b0e92ebd4
4 changed files with 12 additions and 9 deletions

View File

@ -25,9 +25,7 @@
#ifndef _MD5_H
#define _MD5_H
#ifdef __cplusplus
extern "C" {
#endif
namespace BPrivate {
/* Any 32-bit or wider unsigned integer data type will do */
typedef unsigned int MD5_u32plus;
@ -43,8 +41,8 @@ extern void MD5_Init(MD5_CTX *ctx);
extern void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size);
extern void MD5_Final(unsigned char *result, MD5_CTX *ctx);
#ifdef __cplusplus
};
#endif
using namespace BPrivate;
#endif

View File

@ -21,13 +21,13 @@
#define PRINT(x)
#endif
extern "C" {
#ifdef OPENSSL_ENABLED
extern "C" {
#include <openssl/md5.h>
};
#else
#include "md5.h"
#endif
};
#ifndef MD5_DIGEST_LENGTH
#define MD5_DIGEST_LENGTH 16

View File

@ -50,7 +50,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
Json.cpp
Keymap.cpp
LongAndDragTrackingFilter.cpp
md5.c
md5.cpp
MessageBuilder.cpp
NaturalCompare.cpp
PromptWindow.cpp

View File

@ -85,6 +85,9 @@
(ctx->block[(n)])
#endif
namespace BPrivate {
/*
* This processes one or more 64-byte data blocks, but does NOT update
* the bit counters. There are no alignment requirements.
@ -95,7 +98,7 @@ static const void *body(MD5_CTX *ctx, const void *data, unsigned long size)
MD5_u32plus a, b, c, d;
MD5_u32plus saved_a, saved_b, saved_c, saved_d;
ptr = data;
ptr = (const unsigned char*)data;
a = ctx->a;
b = ctx->b;
@ -291,3 +294,5 @@ void MD5_Final(unsigned char *result, MD5_CTX *ctx)
memset(ctx, 0, sizeof(*ctx));
}
};