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

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