|
18 | 18 | //////////////////////////////
|
19 | 19 | // Local functions prototypes
|
20 | 20 |
|
21 |
| -static void l_accum(acl_hash_sha1_context_t *c, const char *buf, size_t len); |
22 |
| -static void l_accum_block(acl_hash_sha1_context_t *c, const char *buf); |
| 21 | +static void l_accum(acl_hash_sha1_context_t *c, const unsigned char *buf, |
| 22 | + size_t len); |
| 23 | +static void l_accum_block(acl_hash_sha1_context_t *c, const unsigned char *buf); |
23 | 24 | static void l_close(acl_hash_sha1_context_t *c, char *digest_buf);
|
24 | 25 | static uint32_t l_leftrotate(uint32_t v, unsigned bits);
|
25 |
| -static uint32_t l_read_bigendian_i32(const char *buf); |
| 26 | +static uint32_t l_read_bigendian_i32(const unsigned char *buf); |
26 | 27 | static void l_write_bigendian_hex_i32(uint32_t v, char *buf);
|
27 | 28 |
|
28 | 29 | //////////////////////////////
|
@@ -53,7 +54,7 @@ int acl_hash_add(acl_hash_context_t *ctx, const void *buf, size_t len) {
|
53 | 54 | return 0;
|
54 | 55 | }
|
55 | 56 |
|
56 |
| - l_accum(&(ctx->alg.sha1), (char *)buf, len); |
| 57 | + l_accum(&(ctx->alg.sha1), (unsigned char *)buf, len); |
57 | 58 |
|
58 | 59 | return 1;
|
59 | 60 | }
|
@@ -87,7 +88,8 @@ int acl_hash_hexdigest(acl_hash_context_t *ctx, char *digest_buf,
|
87 | 88 | //////////////////////////////
|
88 | 89 | // Local functions
|
89 | 90 |
|
90 |
| -static void l_accum(acl_hash_sha1_context_t *c, const char *buf, size_t len) { |
| 91 | +static void l_accum(acl_hash_sha1_context_t *c, const unsigned char *buf, |
| 92 | + size_t len) { |
91 | 93 | size_t buf_idx = 0;
|
92 | 94 | size_t tail_idx = c->len & 63;
|
93 | 95 |
|
@@ -127,7 +129,8 @@ static void l_accum(acl_hash_sha1_context_t *c, const char *buf, size_t len) {
|
127 | 129 | }
|
128 | 130 | }
|
129 | 131 |
|
130 |
| -static void l_accum_block(acl_hash_sha1_context_t *ctx, const char *buf) { |
| 132 | +static void l_accum_block(acl_hash_sha1_context_t *ctx, |
| 133 | + const unsigned char *buf) { |
131 | 134 | unsigned i;
|
132 | 135 | uint32_t w[80];
|
133 | 136 | uint32_t a = ctx->h0;
|
@@ -180,7 +183,7 @@ static void l_accum_block(acl_hash_sha1_context_t *ctx, const char *buf) {
|
180 | 183 | }
|
181 | 184 |
|
182 | 185 | static void l_close(acl_hash_sha1_context_t *c, char *digest_buf) {
|
183 |
| - char extra[64]; |
| 186 | + unsigned char extra[64]; |
184 | 187 | unsigned i;
|
185 | 188 | unsigned raw_tail_len = (1 /* 1-byte */ + 8 /* length field */ + c->len) & 63;
|
186 | 189 | unsigned num_zero_fill_bytes = raw_tail_len > 0 ? (64 - raw_tail_len) : 0;
|
@@ -217,12 +220,12 @@ static uint32_t l_leftrotate(uint32_t v, unsigned bits) {
|
217 | 220 | return hi | lo;
|
218 | 221 | }
|
219 | 222 |
|
220 |
| -static uint32_t l_read_bigendian_i32(const char *buf) { |
| 223 | +static uint32_t l_read_bigendian_i32(const unsigned char *buf) { |
221 | 224 | // Need to cast to uchar so we don't sign extend when widening out to 32 bits.
|
222 |
| - uint32_t byte3 = (unsigned char)buf[0]; |
223 |
| - uint32_t byte2 = (unsigned char)buf[1]; |
224 |
| - uint32_t byte1 = (unsigned char)buf[2]; |
225 |
| - uint32_t byte0 = (unsigned char)buf[3]; |
| 225 | + uint32_t byte3 = buf[0]; |
| 226 | + uint32_t byte2 = buf[1]; |
| 227 | + uint32_t byte1 = buf[2]; |
| 228 | + uint32_t byte0 = buf[3]; |
226 | 229 | uint32_t result = (byte3 << 24) | (byte2 << 16) | (byte1 << 8) | (byte0);
|
227 | 230 | return result;
|
228 | 231 | }
|
|
0 commit comments