Skip to content

Commit

Permalink
Prefix non-static symbols with 'apr__' to avoid namespace conflicts.
Browse files Browse the repository at this point in the history
* random/unix/sha2.h, random/unix/sha2_glue.c, random/unix/sha2.c:
  Rename SHA256_Init, SHA256_Update, SHA256_Final, SHA256_Transform,
  SHA384_Init, SHA512_Init, SHA512_Final, SHA384_Final, SHA512_Update,
  SHA384_Update, and SHA512_Transform, , to apr__SHA256_Init,
  apr__SHA256_Update, apr__SHA256_Final, apr__SHA256_Transform,
  apr__SHA384_Init, apr__SHA512_Init, apr__SHA512_Final,
  apr__SHA384_Final, apr__SHA512_Update, apr__SHA384_Update, and
  apr__SHA512_Transform.


git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@354824 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Brian Fitzpatrick committed Dec 7, 2005
1 parent b3b0e3c commit 16557bf
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 45 deletions.
66 changes: 33 additions & 33 deletions random/unix/sha2.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ typedef apr_uint64_t sha2_word64; /* Exactly 8 bytes */
* only.
*/
void SHA512_Last(SHA512_CTX*);
void SHA256_Transform(SHA256_CTX*, const sha2_word32*);
void SHA512_Transform(SHA512_CTX*, const sha2_word64*);
void apr__SHA256_Transform(SHA256_CTX*, const sha2_word32*);
void apr__SHA512_Transform(SHA512_CTX*, const sha2_word64*);


/*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/
Expand Down Expand Up @@ -264,7 +264,7 @@ static const char *sha2_hex_digits = "0123456789abcdef";


/*** SHA-256: *********************************************************/
void SHA256_Init(SHA256_CTX* context) {
void apr__SHA256_Init(SHA256_CTX* context) {
if (context == (SHA256_CTX*)0) {
return;
}
Expand Down Expand Up @@ -310,7 +310,7 @@ void SHA256_Init(SHA256_CTX* context) {
(h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
j++

void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
void apr__SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
sha2_word32 a, b, c, d, e, f, g, h, s0, s1;
sha2_word32 T1, *W256;
int j;
Expand Down Expand Up @@ -368,7 +368,7 @@ void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {

#else /* SHA2_UNROLL_TRANSFORM */

void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
void apr__SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
sha2_word32 a, b, c, d, e, f, g, h, s0, s1;
sha2_word32 T1, T2, *W256;
int j;
Expand Down Expand Up @@ -448,7 +448,7 @@ void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {

#endif /* SHA2_UNROLL_TRANSFORM */

void SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) {
void apr__SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) {
unsigned int freespace, usedspace;

if (len == 0) {
Expand All @@ -471,7 +471,7 @@ void SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) {
context->bitcount += freespace << 3;
len -= freespace;
data += freespace;
SHA256_Transform(context, (sha2_word32*)context->buffer);
apr__SHA256_Transform(context, (sha2_word32*)context->buffer);
} else {
/* The buffer is not yet full */
MEMCPY_BCOPY(&context->buffer[usedspace], data, len);
Expand All @@ -483,7 +483,7 @@ void SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) {
}
while (len >= SHA256_BLOCK_LENGTH) {
/* Process as many complete blocks as we can */
SHA256_Transform(context, (sha2_word32*)data);
apr__SHA256_Transform(context, (sha2_word32*)data);
context->bitcount += SHA256_BLOCK_LENGTH << 3;
len -= SHA256_BLOCK_LENGTH;
data += SHA256_BLOCK_LENGTH;
Expand All @@ -497,7 +497,7 @@ void SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) {
usedspace = freespace = 0;
}

void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
void apr__SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
sha2_word32 *d = (sha2_word32*)digest;
unsigned int usedspace;

Expand All @@ -524,7 +524,7 @@ void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
MEMSET_BZERO(&context->buffer[usedspace], SHA256_BLOCK_LENGTH - usedspace);
}
/* Do second-to-last transform: */
SHA256_Transform(context, (sha2_word32*)context->buffer);
apr__SHA256_Transform(context, (sha2_word32*)context->buffer);

/* And set-up for the last transform: */
MEMSET_BZERO(context->buffer, SHA256_SHORT_BLOCK_LENGTH);
Expand All @@ -540,7 +540,7 @@ void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
*(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount;

/* Final transform: */
SHA256_Transform(context, (sha2_word32*)context->buffer);
apr__SHA256_Transform(context, (sha2_word32*)context->buffer);

#if !APR_IS_BIGENDIAN
{
Expand Down Expand Up @@ -569,7 +569,7 @@ char *SHA256_End(SHA256_CTX* context, char buffer[]) {
assert(context != (SHA256_CTX*)0);

if (buffer != (char*)0) {
SHA256_Final(digest, context);
apr__SHA256_Final(digest, context);

for (i = 0; i < SHA256_DIGEST_LENGTH; i++) {
*buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
Expand All @@ -587,14 +587,14 @@ char *SHA256_End(SHA256_CTX* context, char buffer[]) {
char* SHA256_Data(const sha2_byte* data, size_t len, char digest[SHA256_DIGEST_STRING_LENGTH]) {
SHA256_CTX context;

SHA256_Init(&context);
SHA256_Update(&context, data, len);
apr__SHA256_Init(&context);
apr__SHA256_Update(&context, data, len);
return SHA256_End(&context, digest);
}


/*** SHA-512: *********************************************************/
void SHA512_Init(SHA512_CTX* context) {
void apr__SHA512_Init(SHA512_CTX* context) {
if (context == (SHA512_CTX*)0) {
return;
}
Expand Down Expand Up @@ -639,7 +639,7 @@ void SHA512_Init(SHA512_CTX* context) {
(h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \
j++

void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
void apr__SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
sha2_word64 a, b, c, d, e, f, g, h, s0, s1;
sha2_word64 T1, *W512 = (sha2_word64*)context->buffer;
int j;
Expand Down Expand Up @@ -694,7 +694,7 @@ void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {

#else /* SHA2_UNROLL_TRANSFORM */

void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
void apr__SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
sha2_word64 a, b, c, d, e, f, g, h, s0, s1;
sha2_word64 T1, T2, *W512 = (sha2_word64*)context->buffer;
int j;
Expand Down Expand Up @@ -772,7 +772,7 @@ void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {

#endif /* SHA2_UNROLL_TRANSFORM */

void SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) {
void apr__SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) {
unsigned int freespace, usedspace;

if (len == 0) {
Expand All @@ -795,7 +795,7 @@ void SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) {
ADDINC128(context->bitcount, freespace << 3);
len -= freespace;
data += freespace;
SHA512_Transform(context, (sha2_word64*)context->buffer);
apr__SHA512_Transform(context, (sha2_word64*)context->buffer);
} else {
/* The buffer is not yet full */
MEMCPY_BCOPY(&context->buffer[usedspace], data, len);
Expand All @@ -807,7 +807,7 @@ void SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) {
}
while (len >= SHA512_BLOCK_LENGTH) {
/* Process as many complete blocks as we can */
SHA512_Transform(context, (sha2_word64*)data);
apr__SHA512_Transform(context, (sha2_word64*)data);
ADDINC128(context->bitcount, SHA512_BLOCK_LENGTH << 3);
len -= SHA512_BLOCK_LENGTH;
data += SHA512_BLOCK_LENGTH;
Expand Down Expand Up @@ -843,7 +843,7 @@ void SHA512_Last(SHA512_CTX* context) {
MEMSET_BZERO(&context->buffer[usedspace], SHA512_BLOCK_LENGTH - usedspace);
}
/* Do second-to-last transform: */
SHA512_Transform(context, (sha2_word64*)context->buffer);
apr__SHA512_Transform(context, (sha2_word64*)context->buffer);

/* And set-up for the last transform: */
MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH - 2);
Expand All @@ -860,10 +860,10 @@ void SHA512_Last(SHA512_CTX* context) {
*(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0];

/* Final transform: */
SHA512_Transform(context, (sha2_word64*)context->buffer);
apr__SHA512_Transform(context, (sha2_word64*)context->buffer);
}

void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
void apr__SHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
sha2_word64 *d = (sha2_word64*)digest;

/* Sanity check: */
Expand Down Expand Up @@ -900,7 +900,7 @@ char *SHA512_End(SHA512_CTX* context, char buffer[]) {
assert(context != (SHA512_CTX*)0);

if (buffer != (char*)0) {
SHA512_Final(digest, context);
apr__SHA512_Final(digest, context);

for (i = 0; i < SHA512_DIGEST_LENGTH; i++) {
*buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
Expand All @@ -918,14 +918,14 @@ char *SHA512_End(SHA512_CTX* context, char buffer[]) {
char* SHA512_Data(const sha2_byte* data, size_t len, char digest[SHA512_DIGEST_STRING_LENGTH]) {
SHA512_CTX context;

SHA512_Init(&context);
SHA512_Update(&context, data, len);
apr__SHA512_Init(&context);
apr__SHA512_Update(&context, data, len);
return SHA512_End(&context, digest);
}


/*** SHA-384: *********************************************************/
void SHA384_Init(SHA384_CTX* context) {
void apr__SHA384_Init(SHA384_CTX* context) {
if (context == (SHA384_CTX*)0) {
return;
}
Expand All @@ -934,11 +934,11 @@ void SHA384_Init(SHA384_CTX* context) {
context->bitcount[0] = context->bitcount[1] = 0;
}

void SHA384_Update(SHA384_CTX* context, const sha2_byte* data, size_t len) {
SHA512_Update((SHA512_CTX*)context, data, len);
void apr__SHA384_Update(SHA384_CTX* context, const sha2_byte* data, size_t len) {
apr__SHA512_Update((SHA512_CTX*)context, data, len);
}

void SHA384_Final(sha2_byte digest[], SHA384_CTX* context) {
void apr__SHA384_Final(sha2_byte digest[], SHA384_CTX* context) {
sha2_word64 *d = (sha2_word64*)digest;

/* Sanity check: */
Expand Down Expand Up @@ -975,7 +975,7 @@ char *SHA384_End(SHA384_CTX* context, char buffer[]) {
assert(context != (SHA384_CTX*)0);

if (buffer != (char*)0) {
SHA384_Final(digest, context);
apr__SHA384_Final(digest, context);

for (i = 0; i < SHA384_DIGEST_LENGTH; i++) {
*buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
Expand All @@ -993,8 +993,8 @@ char *SHA384_End(SHA384_CTX* context, char buffer[]) {
char* SHA384_Data(const sha2_byte* data, size_t len, char digest[SHA384_DIGEST_STRING_LENGTH]) {
SHA384_CTX context;

SHA384_Init(&context);
SHA384_Update(&context, data, len);
apr__SHA384_Init(&context);
apr__SHA384_Update(&context, data, len);
return SHA384_End(&context, digest);
}

18 changes: 9 additions & 9 deletions random/unix/sha2.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,23 @@ typedef SHA512_CTX SHA384_CTX;


/*** SHA-256/384/512 Function Prototypes ******************************/
void SHA256_Init(SHA256_CTX *);
void SHA256_Update(SHA256_CTX *, const apr_byte_t *, size_t);
void SHA256_Final(apr_byte_t [SHA256_DIGEST_LENGTH], SHA256_CTX *);
void apr__SHA256_Init(SHA256_CTX *);
void apr__SHA256_Update(SHA256_CTX *, const apr_byte_t *, size_t);
void apr__SHA256_Final(apr_byte_t [SHA256_DIGEST_LENGTH], SHA256_CTX *);
char* SHA256_End(SHA256_CTX *, char [SHA256_DIGEST_STRING_LENGTH]);
char* SHA256_Data(const apr_byte_t *, size_t,
char [SHA256_DIGEST_STRING_LENGTH]);

void SHA384_Init(SHA384_CTX *);
void SHA384_Update(SHA384_CTX *, const apr_byte_t *, size_t);
void SHA384_Final(apr_byte_t [SHA384_DIGEST_LENGTH], SHA384_CTX *);
void apr__SHA384_Init(SHA384_CTX *);
void apr__SHA384_Update(SHA384_CTX *, const apr_byte_t *, size_t);
void apr__SHA384_Final(apr_byte_t [SHA384_DIGEST_LENGTH], SHA384_CTX *);
char* SHA384_End(SHA384_CTX *, char [SHA384_DIGEST_STRING_LENGTH]);
char* SHA384_Data(const apr_byte_t *, size_t,
char [SHA384_DIGEST_STRING_LENGTH]);

void SHA512_Init(SHA512_CTX *);
void SHA512_Update(SHA512_CTX *, const apr_byte_t *, size_t);
void SHA512_Final(apr_byte_t [SHA512_DIGEST_LENGTH], SHA512_CTX *);
void apr__SHA512_Init(SHA512_CTX *);
void apr__SHA512_Update(SHA512_CTX *, const apr_byte_t *, size_t);
void apr__SHA512_Final(apr_byte_t [SHA512_DIGEST_LENGTH], SHA512_CTX *);
char* SHA512_End(SHA512_CTX *, char [SHA512_DIGEST_STRING_LENGTH]);
char* SHA512_Data(const apr_byte_t *, size_t,
char [SHA512_DIGEST_STRING_LENGTH]);
Expand Down
6 changes: 3 additions & 3 deletions random/unix/sha2_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

static void sha256_init(apr_crypto_hash_t *h)
{
SHA256_Init(h->data);
apr__SHA256_Init(h->data);
}

static void sha256_add(apr_crypto_hash_t *h,const void *data,
apr_size_t bytes)
{
SHA256_Update(h->data,data,bytes);
apr__SHA256_Update(h->data,data,bytes);
}

static void sha256_finish(apr_crypto_hash_t *h,unsigned char *result)
{
SHA256_Final(result,h->data);
apr__SHA256_Final(result,h->data);
}

APR_DECLARE(apr_crypto_hash_t *) apr_crypto_sha256_new(apr_pool_t *p)
Expand Down

0 comments on commit 16557bf

Please sign in to comment.