[hash] mark update function buffer as const

This commit is contained in:
Vincent Hanquez 2015-04-18 12:20:38 +01:00
parent 5ea8614999
commit 488bc980aa
22 changed files with 27 additions and 27 deletions

View File

@ -73,7 +73,7 @@ static uint8_t *padding_table[] = {
UBYTES("\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10")
};
static void md2_do_chunk(struct md2_ctx *ctx, uint8_t *buf)
static void md2_do_chunk(struct md2_ctx *ctx, const uint8_t *buf)
{
uint8_t i, j, t;
uint8_t x[48];
@ -97,7 +97,7 @@ static void md2_do_chunk(struct md2_ctx *ctx, uint8_t *buf)
t = ctx->cksum[i] ^= S_table[buf[i] ^ t];
}
void cryptonite_md2_update(struct md2_ctx *ctx, uint8_t *data, uint32_t len)
void cryptonite_md2_update(struct md2_ctx *ctx, const uint8_t *data, uint32_t len)
{
uint32_t index, to_fill;

View File

@ -38,7 +38,7 @@ struct md2_ctx
#define MD2_CTX_SIZE sizeof(struct md2_ctx)
void cryptonite_md2_init(struct md2_ctx *ctx);
void cryptonite_md2_update(struct md2_ctx *ctx, uint8_t *data, uint32_t len);
void cryptonite_md2_update(struct md2_ctx *ctx, const uint8_t *data, uint32_t len);
void cryptonite_md2_finalize(struct md2_ctx *ctx, uint8_t *out);
#endif

View File

@ -113,7 +113,7 @@ static void md4_do_chunk(struct md4_ctx *ctx, uint32_t *buf)
ctx->h[0] += a; ctx->h[1] += b; ctx->h[2] += c; ctx->h[3] += d;
}
void cryptonite_md4_update(struct md4_ctx *ctx, uint8_t *data, uint32_t len)
void cryptonite_md4_update(struct md4_ctx *ctx, const uint8_t *data, uint32_t len)
{
uint32_t index, to_fill;

View File

@ -37,7 +37,7 @@ struct md4_ctx
#define MD4_CTX_SIZE sizeof(struct md4_ctx)
void cryptonite_md4_init(struct md4_ctx *ctx);
void cryptonite_md4_update(struct md4_ctx *ctx, uint8_t *data, uint32_t len);
void cryptonite_md4_update(struct md4_ctx *ctx, const uint8_t *data, uint32_t len);
void cryptonite_md4_finalize(struct md4_ctx *ctx, uint8_t *out);
#endif

View File

@ -126,7 +126,7 @@ static void md5_do_chunk(struct md5_ctx *ctx, uint32_t *buf)
ctx->h[0] += a; ctx->h[1] += b; ctx->h[2] += c; ctx->h[3] += d;
}
void cryptonite_md5_update(struct md5_ctx *ctx, uint8_t *data, uint32_t len)
void cryptonite_md5_update(struct md5_ctx *ctx, const uint8_t *data, uint32_t len)
{
uint32_t index, to_fill;

View File

@ -37,7 +37,7 @@ struct md5_ctx
#define MD5_CTX_SIZE sizeof(struct md5_ctx)
void cryptonite_md5_init(struct md5_ctx *ctx);
void cryptonite_md5_update(struct md5_ctx *ctx, uint8_t *data, uint32_t len);
void cryptonite_md5_update(struct md5_ctx *ctx, const uint8_t *data, uint32_t len);
void cryptonite_md5_finalize(struct md5_ctx *ctx, uint8_t *out);
#endif

View File

@ -249,7 +249,7 @@ static void ripemd160_do_chunk(struct ripemd160_ctx *ctx, uint32_t *buf)
ctx->h[0] = d2;
}
void cryptonite_ripemd160_update(struct ripemd160_ctx *ctx, uint8_t *data, uint32_t len)
void cryptonite_ripemd160_update(struct ripemd160_ctx *ctx, const uint8_t *data, uint32_t len)
{
uint32_t index, to_fill;

View File

@ -37,7 +37,7 @@ struct ripemd160_ctx
#define RIPEMD160_CTX_SIZE sizeof(struct ripemd160_ctx)
void cryptonite_ripemd160_init(struct ripemd160_ctx *ctx);
void cryptonite_ripemd160_update(struct ripemd160_ctx *ctx, uint8_t *data, uint32_t len);
void cryptonite_ripemd160_update(struct ripemd160_ctx *ctx, const uint8_t *data, uint32_t len);
void cryptonite_ripemd160_finalize(struct ripemd160_ctx *ctx, uint8_t *out);
#endif

View File

@ -155,7 +155,7 @@ static inline void sha1_do_chunk(struct sha1_ctx *ctx, uint32_t *buf)
ctx->h[4] += e;
}
void cryptonite_sha1_update(struct sha1_ctx *ctx, uint8_t *data, uint32_t len)
void cryptonite_sha1_update(struct sha1_ctx *ctx, const uint8_t *data, uint32_t len)
{
uint32_t index, to_fill;

View File

@ -37,7 +37,7 @@ struct sha1_ctx
#define SHA1_CTX_SIZE (sizeof(struct sha1_ctx))
void cryptonite_sha1_init(struct sha1_ctx *ctx);
void cryptonite_sha1_update(struct sha1_ctx *ctx, uint8_t *data, uint32_t len);
void cryptonite_sha1_update(struct sha1_ctx *ctx, const uint8_t *data, uint32_t len);
void cryptonite_sha1_finalize(struct sha1_ctx *ctx, uint8_t *out);
#endif

View File

@ -110,12 +110,12 @@ static void sha256_do_chunk(struct sha256_ctx *ctx, uint32_t buf[])
ctx->h[4] += e; ctx->h[5] += f; ctx->h[6] += g; ctx->h[7] += h;
}
void cryptonite_sha224_update(struct sha224_ctx *ctx, uint8_t *data, uint32_t len)
void cryptonite_sha224_update(struct sha224_ctx *ctx, const uint8_t *data, uint32_t len)
{
return cryptonite_sha256_update(ctx, data, len);
}
void cryptonite_sha256_update(struct sha256_ctx *ctx, uint8_t *data, uint32_t len)
void cryptonite_sha256_update(struct sha256_ctx *ctx, const uint8_t *data, uint32_t len)
{
uint32_t index, to_fill;

View File

@ -43,11 +43,11 @@ struct sha256_ctx
#define SHA256_CTX_SIZE sizeof(struct sha256_ctx)
void cryptonite_sha224_init(struct sha224_ctx *ctx);
void cryptonite_sha224_update(struct sha224_ctx *ctx, uint8_t *data, uint32_t len);
void cryptonite_sha224_update(struct sha224_ctx *ctx, const uint8_t *data, uint32_t len);
void cryptonite_sha224_finalize(struct sha224_ctx *ctx, uint8_t *out);
void cryptonite_sha256_init(struct sha256_ctx *ctx);
void cryptonite_sha256_update(struct sha256_ctx *ctx, uint8_t *data, uint32_t len);
void cryptonite_sha256_update(struct sha256_ctx *ctx, const uint8_t *data, uint32_t len);
void cryptonite_sha256_finalize(struct sha256_ctx *ctx, uint8_t *out);
#endif

View File

@ -104,7 +104,7 @@ void cryptonite_sha3_init(struct sha3_ctx *ctx, uint32_t hashlen)
ctx->bufsz = 200 - 2 * ctx->hashlen;
}
void cryptonite_sha3_update(struct sha3_ctx *ctx, uint8_t *data, uint32_t len)
void cryptonite_sha3_update(struct sha3_ctx *ctx, const uint8_t *data, uint32_t len)
{
uint32_t to_fill;

View File

@ -39,7 +39,7 @@ struct sha3_ctx
#define SHA3_CTX_SIZE sizeof(struct sha3_ctx)
void cryptonite_sha3_init(struct sha3_ctx *ctx, uint32_t hashlen);
void cryptonite_sha3_update(struct sha3_ctx *ctx, uint8_t *data, uint32_t len);
void cryptonite_sha3_update(struct sha3_ctx *ctx, const uint8_t *data, uint32_t len);
void cryptonite_sha3_finalize(struct sha3_ctx *ctx, uint8_t *out);
#endif

View File

@ -127,12 +127,12 @@ static void sha512_do_chunk(struct sha512_ctx *ctx, uint64_t *buf)
ctx->h[4] += e; ctx->h[5] += f; ctx->h[6] += g; ctx->h[7] += h;
}
void cryptonite_sha384_update(struct sha384_ctx *ctx, uint8_t *data, uint32_t len)
void cryptonite_sha384_update(struct sha384_ctx *ctx, const uint8_t *data, uint32_t len)
{
return cryptonite_sha512_update(ctx, data, len);
}
void cryptonite_sha512_update(struct sha512_ctx *ctx, uint8_t *data, uint32_t len)
void cryptonite_sha512_update(struct sha512_ctx *ctx, const uint8_t *data, uint32_t len)
{
unsigned int index, to_fill;

View File

@ -42,11 +42,11 @@ struct sha512_ctx
#define SHA512_CTX_SIZE sizeof(struct sha512_ctx)
void cryptonite_sha384_init(struct sha384_ctx *ctx);
void cryptonite_sha384_update(struct sha384_ctx *ctx, uint8_t *data, uint32_t len);
void cryptonite_sha384_update(struct sha384_ctx *ctx, const uint8_t *data, uint32_t len);
void cryptonite_sha384_finalize(struct sha384_ctx *ctx, uint8_t *out);
void cryptonite_sha512_init(struct sha512_ctx *ctx);
void cryptonite_sha512_update(struct sha512_ctx *ctx, uint8_t *data, uint32_t len);
void cryptonite_sha512_update(struct sha512_ctx *ctx, const uint8_t *data, uint32_t len);
void cryptonite_sha512_finalize(struct sha512_ctx *ctx, uint8_t *out);
void cryptonite_sha512_init_t(struct sha512_ctx *ctx, int t);

View File

@ -120,7 +120,7 @@ void cryptonite_skein256_init(struct skein256_ctx *ctx, uint32_t hashlen)
SET_TYPE(ctx, FLAG_FIRST | FLAG_TYPE(TYPE_MSG));
}
void cryptonite_skein256_update(struct skein256_ctx *ctx, uint8_t *data, uint32_t len)
void cryptonite_skein256_update(struct skein256_ctx *ctx, const uint8_t *data, uint32_t len)
{
uint32_t to_fill;

View File

@ -39,7 +39,7 @@ struct skein256_ctx
#define SKEIN256_CTX_SIZE sizeof(struct skein256_ctx)
void cryponite_skein256_init(struct skein256_ctx *ctx, uint32_t hashlen);
void cryponite_skein256_update(struct skein256_ctx *ctx, uint8_t *data, uint32_t len);
void cryponite_skein256_update(struct skein256_ctx *ctx, const uint8_t *data, uint32_t len);
void cryponite_skein256_finalize(struct skein256_ctx *ctx, uint8_t *out);
#endif

View File

@ -138,7 +138,7 @@ void cryptonite_skein512_init(struct skein512_ctx *ctx, uint32_t hashlen)
SET_TYPE(ctx, FLAG_FIRST | FLAG_TYPE(TYPE_MSG));
}
void cryptonite_skein512_update(struct skein512_ctx *ctx, uint8_t *data, uint32_t len)
void cryptonite_skein512_update(struct skein512_ctx *ctx, const uint8_t *data, uint32_t len)
{
uint32_t to_fill;

View File

@ -39,7 +39,7 @@ struct skein512_ctx
#define SKEIN512_CTX_SIZE sizeof(struct skein512_ctx)
void cryponite_skein512_init(struct skein512_ctx *ctx, uint32_t hashlen);
void cryponite_skein512_update(struct skein512_ctx *ctx, uint8_t *data, uint32_t len);
void cryponite_skein512_update(struct skein512_ctx *ctx, const uint8_t *data, uint32_t len);
void cryponite_skein512_finalize(struct skein512_ctx *ctx, uint8_t *out);
#endif

View File

@ -363,7 +363,7 @@ static inline void tiger_do_chunk(struct tiger_ctx *ctx, uint64_t *buf)
ctx->h[2] += c;
}
void cryptonite_tiger_update(struct tiger_ctx *ctx, uint8_t *data, uint32_t len)
void cryptonite_tiger_update(struct tiger_ctx *ctx, const uint8_t *data, uint32_t len)
{
uint32_t index, to_fill;

View File

@ -37,7 +37,7 @@ struct tiger_ctx
#define TIGER_CTX_SIZE (sizeof(struct tiger_ctx))
void cryptonite_tiger_init(struct tiger_ctx *ctx);
void cryptonite_tiger_update(struct tiger_ctx *ctx, uint8_t *data, uint32_t len);
void cryptonite_tiger_update(struct tiger_ctx *ctx, const uint8_t *data, uint32_t len);
void cryptonite_tiger_finalize(struct tiger_ctx *ctx, uint8_t *out);
#endif