From 488bc980aa0125b1ef57fdef7f779b61ac1384a5 Mon Sep 17 00:00:00 2001 From: Vincent Hanquez Date: Sat, 18 Apr 2015 12:20:38 +0100 Subject: [PATCH] [hash] mark update function buffer as const --- cbits/cryptonite_md2.c | 4 ++-- cbits/cryptonite_md2.h | 2 +- cbits/cryptonite_md4.c | 2 +- cbits/cryptonite_md4.h | 2 +- cbits/cryptonite_md5.c | 2 +- cbits/cryptonite_md5.h | 2 +- cbits/cryptonite_ripemd.c | 2 +- cbits/cryptonite_ripemd.h | 2 +- cbits/cryptonite_sha1.c | 2 +- cbits/cryptonite_sha1.h | 2 +- cbits/cryptonite_sha256.c | 4 ++-- cbits/cryptonite_sha256.h | 4 ++-- cbits/cryptonite_sha3.c | 2 +- cbits/cryptonite_sha3.h | 2 +- cbits/cryptonite_sha512.c | 4 ++-- cbits/cryptonite_sha512.h | 4 ++-- cbits/cryptonite_skein256.c | 2 +- cbits/cryptonite_skein256.h | 2 +- cbits/cryptonite_skein512.c | 2 +- cbits/cryptonite_skein512.h | 2 +- cbits/cryptonite_tiger.c | 2 +- cbits/cryptonite_tiger.h | 2 +- 22 files changed, 27 insertions(+), 27 deletions(-) diff --git a/cbits/cryptonite_md2.c b/cbits/cryptonite_md2.c index 42bf546..9d6b1c8 100644 --- a/cbits/cryptonite_md2.c +++ b/cbits/cryptonite_md2.c @@ -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; diff --git a/cbits/cryptonite_md2.h b/cbits/cryptonite_md2.h index 37f19ce..7163b6b 100644 --- a/cbits/cryptonite_md2.h +++ b/cbits/cryptonite_md2.h @@ -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 diff --git a/cbits/cryptonite_md4.c b/cbits/cryptonite_md4.c index 14d4387..3cb87b1 100644 --- a/cbits/cryptonite_md4.c +++ b/cbits/cryptonite_md4.c @@ -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; diff --git a/cbits/cryptonite_md4.h b/cbits/cryptonite_md4.h index 4c6cd69..fcb7bac 100644 --- a/cbits/cryptonite_md4.h +++ b/cbits/cryptonite_md4.h @@ -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 diff --git a/cbits/cryptonite_md5.c b/cbits/cryptonite_md5.c index fe44f5e..4612a5e 100644 --- a/cbits/cryptonite_md5.c +++ b/cbits/cryptonite_md5.c @@ -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; diff --git a/cbits/cryptonite_md5.h b/cbits/cryptonite_md5.h index 7f7ca2c..7187f96 100644 --- a/cbits/cryptonite_md5.h +++ b/cbits/cryptonite_md5.h @@ -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 diff --git a/cbits/cryptonite_ripemd.c b/cbits/cryptonite_ripemd.c index 83d52ae..67fadb2 100644 --- a/cbits/cryptonite_ripemd.c +++ b/cbits/cryptonite_ripemd.c @@ -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; diff --git a/cbits/cryptonite_ripemd.h b/cbits/cryptonite_ripemd.h index 59b5363..8f84fb8 100644 --- a/cbits/cryptonite_ripemd.h +++ b/cbits/cryptonite_ripemd.h @@ -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 diff --git a/cbits/cryptonite_sha1.c b/cbits/cryptonite_sha1.c index 185b4df..33b6fa0 100644 --- a/cbits/cryptonite_sha1.c +++ b/cbits/cryptonite_sha1.c @@ -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; diff --git a/cbits/cryptonite_sha1.h b/cbits/cryptonite_sha1.h index fc32514..5457a7d 100644 --- a/cbits/cryptonite_sha1.h +++ b/cbits/cryptonite_sha1.h @@ -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 diff --git a/cbits/cryptonite_sha256.c b/cbits/cryptonite_sha256.c index f1a9cc1..b93d815 100644 --- a/cbits/cryptonite_sha256.c +++ b/cbits/cryptonite_sha256.c @@ -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; diff --git a/cbits/cryptonite_sha256.h b/cbits/cryptonite_sha256.h index 1d960a2..8a20ff6 100644 --- a/cbits/cryptonite_sha256.h +++ b/cbits/cryptonite_sha256.h @@ -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 diff --git a/cbits/cryptonite_sha3.c b/cbits/cryptonite_sha3.c index d824899..13bfea9 100644 --- a/cbits/cryptonite_sha3.c +++ b/cbits/cryptonite_sha3.c @@ -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; diff --git a/cbits/cryptonite_sha3.h b/cbits/cryptonite_sha3.h index b18d74f..3b46441 100644 --- a/cbits/cryptonite_sha3.h +++ b/cbits/cryptonite_sha3.h @@ -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 diff --git a/cbits/cryptonite_sha512.c b/cbits/cryptonite_sha512.c index b72f1d8..407dbd2 100644 --- a/cbits/cryptonite_sha512.c +++ b/cbits/cryptonite_sha512.c @@ -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; diff --git a/cbits/cryptonite_sha512.h b/cbits/cryptonite_sha512.h index a5c199f..431ad6b 100644 --- a/cbits/cryptonite_sha512.h +++ b/cbits/cryptonite_sha512.h @@ -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); diff --git a/cbits/cryptonite_skein256.c b/cbits/cryptonite_skein256.c index 42c8853..a2f6e07 100644 --- a/cbits/cryptonite_skein256.c +++ b/cbits/cryptonite_skein256.c @@ -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; diff --git a/cbits/cryptonite_skein256.h b/cbits/cryptonite_skein256.h index 1ba977d..eaaa037 100644 --- a/cbits/cryptonite_skein256.h +++ b/cbits/cryptonite_skein256.h @@ -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 diff --git a/cbits/cryptonite_skein512.c b/cbits/cryptonite_skein512.c index 3c84dca..5e38e51 100644 --- a/cbits/cryptonite_skein512.c +++ b/cbits/cryptonite_skein512.c @@ -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; diff --git a/cbits/cryptonite_skein512.h b/cbits/cryptonite_skein512.h index 7ec2866..069500c 100644 --- a/cbits/cryptonite_skein512.h +++ b/cbits/cryptonite_skein512.h @@ -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 diff --git a/cbits/cryptonite_tiger.c b/cbits/cryptonite_tiger.c index cc968a9..30538f1 100644 --- a/cbits/cryptonite_tiger.c +++ b/cbits/cryptonite_tiger.c @@ -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; diff --git a/cbits/cryptonite_tiger.h b/cbits/cryptonite_tiger.h index 06c7d62..a248023 100644 --- a/cbits/cryptonite_tiger.h +++ b/cbits/cryptonite_tiger.h @@ -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