.. | .. |
---|
26 | 26 | #include <watchdog.h> |
---|
27 | 27 | #include <u-boot/sha1.h> |
---|
28 | 28 | |
---|
| 29 | +#include <linux/compiler.h> |
---|
| 30 | + |
---|
| 31 | +#ifdef USE_HOSTCC |
---|
| 32 | +#undef __weak |
---|
| 33 | +#define __weak |
---|
| 34 | +#undef __maybe_unused |
---|
| 35 | +#define __maybe_unused |
---|
| 36 | +#endif |
---|
| 37 | + |
---|
29 | 38 | const uint8_t sha1_der_prefix[SHA1_DER_LEN] = { |
---|
30 | 39 | 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, |
---|
31 | 40 | 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14 |
---|
.. | .. |
---|
66 | 75 | ctx->state[4] = 0xC3D2E1F0; |
---|
67 | 76 | } |
---|
68 | 77 | |
---|
69 | | -static void sha1_process(sha1_context *ctx, const unsigned char data[64]) |
---|
| 78 | +static void __maybe_unused sha1_process_one(sha1_context *ctx, const unsigned char data[64]) |
---|
70 | 79 | { |
---|
71 | 80 | unsigned long temp, W[16], A, B, C, D, E; |
---|
72 | 81 | |
---|
.. | .. |
---|
220 | 229 | ctx->state[4] += E; |
---|
221 | 230 | } |
---|
222 | 231 | |
---|
| 232 | +__weak void sha1_process(sha1_context *ctx, const unsigned char *data, |
---|
| 233 | + unsigned int blocks) |
---|
| 234 | +{ |
---|
| 235 | + if (!blocks) |
---|
| 236 | + return; |
---|
| 237 | + |
---|
| 238 | + while (blocks--) { |
---|
| 239 | + sha1_process_one(ctx, data); |
---|
| 240 | + data += 64; |
---|
| 241 | + } |
---|
| 242 | +} |
---|
| 243 | + |
---|
223 | 244 | /* |
---|
224 | 245 | * SHA-1 process buffer |
---|
225 | 246 | */ |
---|
.. | .. |
---|
243 | 264 | |
---|
244 | 265 | if (left && ilen >= fill) { |
---|
245 | 266 | memcpy ((void *) (ctx->buffer + left), (void *) input, fill); |
---|
246 | | - sha1_process (ctx, ctx->buffer); |
---|
| 267 | + sha1_process(ctx, ctx->buffer, 1); |
---|
247 | 268 | input += fill; |
---|
248 | 269 | ilen -= fill; |
---|
249 | 270 | left = 0; |
---|
250 | 271 | } |
---|
251 | 272 | |
---|
252 | | - while (ilen >= 64) { |
---|
253 | | - sha1_process (ctx, input); |
---|
254 | | - input += 64; |
---|
255 | | - ilen -= 64; |
---|
256 | | - } |
---|
| 273 | + sha1_process(ctx, input, ilen / 64); |
---|
| 274 | + input += ilen / 64 * 64; |
---|
| 275 | + ilen = ilen % 64; |
---|
257 | 276 | |
---|
258 | 277 | if (ilen > 0) { |
---|
259 | 278 | memcpy ((void *) (ctx->buffer + left), (void *) input, ilen); |
---|