Commit b83e5926 authored by Tom Lane's avatar Tom Lane

Replace bcopy by memmove for more portability.

parent 0ffe11ab
/* $PostgreSQL: pgsql/contrib/pgcrypto/md5.c,v 1.11 2004/05/07 00:24:57 tgl Exp $ */ /* $PostgreSQL: pgsql/contrib/pgcrypto/md5.c,v 1.12 2004/08/29 16:43:05 tgl Exp $ */
/* $KAME: md5.c,v 1.3 2000/02/22 14:01:17 itojun Exp $ */ /* $KAME: md5.c,v 1.3 2000/02/22 14:01:17 itojun Exp $ */
/* /*
...@@ -155,20 +155,18 @@ md5_loop(md5_ctxt * ctxt, const uint8 *input, unsigned len) ...@@ -155,20 +155,18 @@ md5_loop(md5_ctxt * ctxt, const uint8 *input, unsigned len)
if (len >= gap) if (len >= gap)
{ {
bcopy((void *) input, (void *) (ctxt->md5_buf + ctxt->md5_i), memmove(ctxt->md5_buf + ctxt->md5_i, input, gap);
gap);
md5_calc(ctxt->md5_buf, ctxt); md5_calc(ctxt->md5_buf, ctxt);
for (i = gap; i + MD5_BUFLEN <= len; i += MD5_BUFLEN) for (i = gap; i + MD5_BUFLEN <= len; i += MD5_BUFLEN)
md5_calc((uint8 *) (input + i), ctxt); md5_calc((uint8 *) (input + i), ctxt);
ctxt->md5_i = len - i; ctxt->md5_i = len - i;
bcopy((void *) (input + i), (void *) ctxt->md5_buf, ctxt->md5_i); memmove(ctxt->md5_buf, input + i, ctxt->md5_i);
} }
else else
{ {
bcopy((void *) input, (void *) (ctxt->md5_buf + ctxt->md5_i), memmove(ctxt->md5_buf + ctxt->md5_i, input, len);
len);
ctxt->md5_i += len; ctxt->md5_i += len;
} }
} }
...@@ -182,24 +180,21 @@ md5_pad(md5_ctxt * ctxt) ...@@ -182,24 +180,21 @@ md5_pad(md5_ctxt * ctxt)
gap = MD5_BUFLEN - ctxt->md5_i; gap = MD5_BUFLEN - ctxt->md5_i;
if (gap > 8) if (gap > 8)
{ {
bcopy((void *) md5_paddat, memmove(ctxt->md5_buf + ctxt->md5_i, md5_paddat,
(void *) (ctxt->md5_buf + ctxt->md5_i),
gap - sizeof(ctxt->md5_n)); gap - sizeof(ctxt->md5_n));
} }
else else
{ {
/* including gap == 8 */ /* including gap == 8 */
bcopy((void *) md5_paddat, (void *) (ctxt->md5_buf + ctxt->md5_i), memmove(ctxt->md5_buf + ctxt->md5_i, md5_paddat, gap);
gap);
md5_calc(ctxt->md5_buf, ctxt); md5_calc(ctxt->md5_buf, ctxt);
bcopy((void *) (md5_paddat + gap), memmove(ctxt->md5_buf, md5_paddat + gap,
(void *) ctxt->md5_buf,
MD5_BUFLEN - sizeof(ctxt->md5_n)); MD5_BUFLEN - sizeof(ctxt->md5_n));
} }
/* 8 byte word */ /* 8 byte word */
#if BYTE_ORDER == LITTLE_ENDIAN #if BYTE_ORDER == LITTLE_ENDIAN
bcopy(&ctxt->md5_n8[0], &ctxt->md5_buf[56], 8); memmove(&ctxt->md5_buf[56], &ctxt->md5_n8[0], 8);
#endif #endif
#if BYTE_ORDER == BIG_ENDIAN #if BYTE_ORDER == BIG_ENDIAN
ctxt->md5_buf[56] = ctxt->md5_n8[7]; ctxt->md5_buf[56] = ctxt->md5_n8[7];
...@@ -220,7 +215,7 @@ md5_result(uint8 *digest, md5_ctxt * ctxt) ...@@ -220,7 +215,7 @@ md5_result(uint8 *digest, md5_ctxt * ctxt)
{ {
/* 4 byte words */ /* 4 byte words */
#if BYTE_ORDER == LITTLE_ENDIAN #if BYTE_ORDER == LITTLE_ENDIAN
bcopy(&ctxt->md5_st8[0], digest, 16); memmove(digest, &ctxt->md5_st8[0], 16);
#endif #endif
#if BYTE_ORDER == BIG_ENDIAN #if BYTE_ORDER == BIG_ENDIAN
digest[0] = ctxt->md5_st8[3]; digest[0] = ctxt->md5_st8[3];
......
/* $PostgreSQL: pgsql/contrib/pgcrypto/sha1.c,v 1.13 2004/05/07 00:24:57 tgl Exp $ */ /* $PostgreSQL: pgsql/contrib/pgcrypto/sha1.c,v 1.14 2004/08/29 16:43:05 tgl Exp $ */
/* $KAME: sha1.c,v 1.3 2000/02/22 14:01:18 itojun Exp $ */ /* $KAME: sha1.c,v 1.3 2000/02/22 14:01:18 itojun Exp $ */
/* /*
...@@ -102,7 +102,7 @@ sha1_step(struct sha1_ctxt * ctxt) ...@@ -102,7 +102,7 @@ sha1_step(struct sha1_ctxt * ctxt)
#if BYTE_ORDER == LITTLE_ENDIAN #if BYTE_ORDER == LITTLE_ENDIAN
struct sha1_ctxt tctxt; struct sha1_ctxt tctxt;
bcopy(&ctxt->m.b8[0], &tctxt.m.b8[0], 64); memmove(&tctxt.m.b8[0], &ctxt->m.b8[0], 64);
ctxt->m.b8[0] = tctxt.m.b8[3]; ctxt->m.b8[0] = tctxt.m.b8[3];
ctxt->m.b8[1] = tctxt.m.b8[2]; ctxt->m.b8[1] = tctxt.m.b8[2];
ctxt->m.b8[2] = tctxt.m.b8[1]; ctxt->m.b8[2] = tctxt.m.b8[1];
...@@ -304,7 +304,7 @@ sha1_loop(struct sha1_ctxt * ctxt, const uint8 *input0, size_t len) ...@@ -304,7 +304,7 @@ sha1_loop(struct sha1_ctxt * ctxt, const uint8 *input0, size_t len)
gaplen = 64 - gapstart; gaplen = 64 - gapstart;
copysiz = (gaplen < len - off) ? gaplen : len - off; copysiz = (gaplen < len - off) ? gaplen : len - off;
bcopy(&input[off], &ctxt->m.b8[gapstart], copysiz); memmove(&ctxt->m.b8[gapstart], &input[off], copysiz);
COUNT += copysiz; COUNT += copysiz;
COUNT %= 64; COUNT %= 64;
ctxt->c.b64[0] += copysiz * 8; ctxt->c.b64[0] += copysiz * 8;
...@@ -322,7 +322,7 @@ sha1_result(struct sha1_ctxt * ctxt, uint8 *digest0) ...@@ -322,7 +322,7 @@ sha1_result(struct sha1_ctxt * ctxt, uint8 *digest0)
digest = (uint8 *) digest0; digest = (uint8 *) digest0;
sha1_pad(ctxt); sha1_pad(ctxt);
#if BYTE_ORDER == BIG_ENDIAN #if BYTE_ORDER == BIG_ENDIAN
bcopy(&ctxt->h.b8[0], digest, 20); memmove(digest, &ctxt->h.b8[0], 20);
#else #else
digest[0] = ctxt->h.b8[3]; digest[0] = ctxt->h.b8[3];
digest[1] = ctxt->h.b8[2]; digest[1] = ctxt->h.b8[2];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment