"Das U-Boot" Source Tree

md5: Use typedef for MD5 context

Use of typedef is beneficial for porting with other crypto libs
without changing the API callers.
Secondly, it is for the code consistency with other digest libs.
SHA1, SHA256 and SHA512 are all using typedef for their context.

Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

authored by

Raymond Mao and committed by
Tom Rini
0fe031dd 329bb667

+14 -14
+4 -4
drivers/crypto/hash/hash_sw.c
··· 50 50 /* MD5 */ 51 51 static void hash_init_md5(void *ctx) 52 52 { 53 - MD5Init((struct MD5Context *)ctx); 53 + MD5Init((MD5Context *)ctx); 54 54 } 55 55 56 56 static void hash_update_md5(void *ctx, const void *ibuf, uint32_t ilen) 57 57 { 58 - MD5Update((struct MD5Context *)ctx, ibuf, ilen); 58 + MD5Update((MD5Context *)ctx, ibuf, ilen); 59 59 } 60 60 61 61 static void hash_finish_md5(void *ctx, void *obuf) 62 62 { 63 - MD5Final(obuf, (struct MD5Context *)ctx); 63 + MD5Final(obuf, (MD5Context *)ctx); 64 64 } 65 65 66 66 /* SHA1 */ ··· 158 158 .init = hash_init_md5, 159 159 .update = hash_update_md5, 160 160 .finish = hash_finish_md5, 161 - .ctx_alloc_sz = sizeof(struct MD5Context), 161 + .ctx_alloc_sz = sizeof(MD5Context), 162 162 }, 163 163 164 164 [HASH_ALGO_SHA1] = {
+5 -5
include/u-boot/md5.h
··· 10 10 11 11 #define MD5_SUM_LEN 16 12 12 13 - struct MD5Context { 13 + typedef struct MD5Context { 14 14 __u32 buf[4]; 15 15 __u32 bits[2]; 16 16 union { 17 17 unsigned char in[64]; 18 18 __u32 in32[16]; 19 19 }; 20 - }; 20 + } MD5Context; 21 21 22 - void MD5Init(struct MD5Context *ctx); 23 - void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len); 24 - void MD5Final(unsigned char digest[16], struct MD5Context *ctx); 22 + void MD5Init(MD5Context *ctx); 23 + void MD5Update(MD5Context *ctx, unsigned char const *buf, unsigned int len); 24 + void MD5Final(unsigned char digest[16], MD5Context *ctx); 25 25 26 26 /* 27 27 * Calculate and store in 'output' the MD5 digest of 'len' bytes at
+5 -5
lib/md5.c
··· 55 55 * initialization constants. 56 56 */ 57 57 void 58 - MD5Init(struct MD5Context *ctx) 58 + MD5Init(MD5Context *ctx) 59 59 { 60 60 ctx->buf[0] = 0x67452301; 61 61 ctx->buf[1] = 0xefcdab89; ··· 71 71 * of bytes. 72 72 */ 73 73 void 74 - MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) 74 + MD5Update(MD5Context *ctx, unsigned char const *buf, unsigned int len) 75 75 { 76 76 register __u32 t; 77 77 ··· 120 120 * 1 0* (64-bit count of bits processed, MSB-first) 121 121 */ 122 122 void 123 - MD5Final(unsigned char digest[16], struct MD5Context *ctx) 123 + MD5Final(unsigned char digest[16], MD5Context *ctx) 124 124 { 125 125 unsigned int count; 126 126 unsigned char *p; ··· 269 269 void 270 270 md5 (unsigned char *input, int len, unsigned char output[16]) 271 271 { 272 - struct MD5Context context; 272 + MD5Context context; 273 273 274 274 MD5Init(&context); 275 275 MD5Update(&context, input, len); ··· 286 286 md5_wd(const unsigned char *input, unsigned int len, unsigned char output[16], 287 287 unsigned int chunk_sz) 288 288 { 289 - struct MD5Context context; 289 + MD5Context context; 290 290 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG) 291 291 const unsigned char *end, *curr; 292 292 int chunk;