Commit 1f2e6307 authored by Niels Möller's avatar Niels Möller

* Constness improvements.

Rev: src/symmetric/include/md5.h:1.3
Rev: src/symmetric/include/sha.h:1.3
Rev: src/symmetric/md5.c:1.4
Rev: src/symmetric/sha.c:1.4
parent 31cda956
......@@ -17,7 +17,7 @@ struct md5_ctx {
};
void md5_init(struct md5_ctx *ctx);
void md5_update(struct md5_ctx *ctx, UINT8 *buffer, UINT32 len);
void md5_update(struct md5_ctx *ctx, const UINT8 *buffer, UINT32 len);
void md5_final(struct md5_ctx *ctx);
void md5_digest(struct md5_ctx *ctx, UINT8 *s);
void md5_copy(struct md5_ctx *dest, struct md5_ctx *src);
......@@ -20,7 +20,7 @@ struct sha_ctx {
};
void sha_init(struct sha_ctx *ctx);
void sha_update(struct sha_ctx *ctx, UINT8 *buffer, UINT32 len);
void sha_update(struct sha_ctx *ctx, const UINT8 *buffer, UINT32 len);
void sha_final(struct sha_ctx *ctx);
void sha_digest(struct sha_ctx *ctx, UINT8 *s);
void sha_copy(struct sha_ctx *dest, struct sha_ctx *src);
......@@ -135,12 +135,13 @@ static void md5_transform(struct md5_ctx *ctx, UINT32 *data)
#endif
/* Note that MD5 uses little endian byteorder */
#define STRING2INT(s) ((((((EXTRACT_UCHAR(s+3) << 8) \
| EXTRACT_UCHAR(s+2)) << 8) \
| EXTRACT_UCHAR(s+1)) << 8) \
| EXTRACT_UCHAR(s))
#define STRING2INT(s) ((((((EXTRACT_UCHAR(s+3) << 8) \
| EXTRACT_UCHAR(s+2)) << 8) \
| EXTRACT_UCHAR(s+1)) << 8) \
| EXTRACT_UCHAR(s))
static void md5_block(struct md5_ctx *ctx, UINT8 *block)
static void
md5_block(struct md5_ctx *ctx, const UINT8 *block)
{
UINT32 data[MD5_DATALEN];
int i;
......@@ -156,9 +157,10 @@ static void md5_block(struct md5_ctx *ctx, UINT8 *block)
md5_transform(ctx, data);
}
void md5_update(struct md5_ctx *ctx,
UINT8 *buffer,
UINT32 len)
void
md5_update(struct md5_ctx *ctx,
const UINT8 *buffer,
UINT32 len)
{
if (ctx->index)
{ /* Try to fill partial block */
......@@ -230,7 +232,8 @@ void md5_final(struct md5_ctx *ctx)
md5_transform(ctx, data);
}
void md5_digest(struct md5_ctx *ctx, UINT8 *s)
void
md5_digest(struct md5_ctx *ctx, UINT8 *s)
{
int i;
......
......@@ -267,7 +267,8 @@ UINT32 STRING2INT(UINT8 *s)
}
#endif
static void sha_block(struct sha_ctx *ctx, UINT8 *block)
static void
sha_block(struct sha_ctx *ctx, const UINT8 *block)
{
UINT32 data[SHA_DATALEN];
int i;
......@@ -283,7 +284,9 @@ static void sha_block(struct sha_ctx *ctx, UINT8 *block)
sha_transform(ctx, data);
}
void sha_update(struct sha_ctx *ctx, UINT8 *buffer, UINT32 len)
void
sha_update(struct sha_ctx *ctx,
const UINT8 *buffer, UINT32 len)
{
if (ctx->index)
{ /* Try to fill partial block */
......@@ -316,7 +319,8 @@ void sha_update(struct sha_ctx *ctx, UINT8 *buffer, UINT32 len)
/* Final wrapup - pad to SHA_DATASIZE-byte boundary with the bit pattern
1 0* (64-bit count of bits processed, MSB-first) */
void sha_final(struct sha_ctx *ctx)
void
sha_final(struct sha_ctx *ctx)
{
UINT32 data[SHA_DATALEN];
int i;
......@@ -354,7 +358,8 @@ void sha_final(struct sha_ctx *ctx)
sha_transform(ctx, data);
}
void sha_digest(struct sha_ctx *ctx, UINT8 *s)
void
sha_digest(struct sha_ctx *ctx, UINT8 *s)
{
int i;
......
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