Mercurial > hg > nginx
comparison src/core/ngx_md5.c @ 3941:ce1ba4a312d7
fix building by MSVC
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 18 Jul 2011 15:00:05 +0000 |
parents | 38e6f45c5e3d |
children | 21167183825d |
comparison
equal
deleted
inserted
replaced
3940:22f3e9197096 | 3941:ce1ba4a312d7 |
---|---|
34 void | 34 void |
35 ngx_md5_update(ngx_md5_t *ctx, const void *data, size_t size) | 35 ngx_md5_update(ngx_md5_t *ctx, const void *data, size_t size) |
36 { | 36 { |
37 size_t used, free; | 37 size_t used, free; |
38 | 38 |
39 used = ctx->bytes & 0x3f; | 39 used = (size_t) (ctx->bytes & 0x3f); |
40 ctx->bytes += size; | 40 ctx->bytes += size; |
41 | 41 |
42 if (used) { | 42 if (used) { |
43 free = 64 - used; | 43 free = 64 - used; |
44 | 44 |
64 void | 64 void |
65 ngx_md5_final(u_char result[16], ngx_md5_t *ctx) | 65 ngx_md5_final(u_char result[16], ngx_md5_t *ctx) |
66 { | 66 { |
67 size_t used, free; | 67 size_t used, free; |
68 | 68 |
69 used = ctx->bytes & 0x3f; | 69 used = (size_t) (ctx->bytes & 0x3f); |
70 | 70 |
71 ctx->buffer[used++] = 0x80; | 71 ctx->buffer[used++] = 0x80; |
72 | 72 |
73 free = 64 - used; | 73 free = 64 - used; |
74 | 74 |
80 } | 80 } |
81 | 81 |
82 ngx_memzero(&ctx->buffer[used], free - 8); | 82 ngx_memzero(&ctx->buffer[used], free - 8); |
83 | 83 |
84 ctx->bytes <<= 3; | 84 ctx->bytes <<= 3; |
85 ctx->buffer[56] = ctx->bytes; | 85 ctx->buffer[56] = (u_char) ctx->bytes; |
86 ctx->buffer[57] = ctx->bytes >> 8; | 86 ctx->buffer[57] = (u_char) (ctx->bytes >> 8); |
87 ctx->buffer[58] = ctx->bytes >> 16; | 87 ctx->buffer[58] = (u_char) (ctx->bytes >> 16); |
88 ctx->buffer[59] = ctx->bytes >> 24; | 88 ctx->buffer[59] = (u_char) (ctx->bytes >> 24); |
89 ctx->buffer[60] = ctx->bytes >> 32; | 89 ctx->buffer[60] = (u_char) (ctx->bytes >> 32); |
90 ctx->buffer[61] = ctx->bytes >> 40; | 90 ctx->buffer[61] = (u_char) (ctx->bytes >> 40); |
91 ctx->buffer[62] = ctx->bytes >> 48; | 91 ctx->buffer[62] = (u_char) (ctx->bytes >> 48); |
92 ctx->buffer[63] = ctx->bytes >> 56; | 92 ctx->buffer[63] = (u_char) (ctx->bytes >> 56); |
93 | 93 |
94 (void) ngx_md5_body(ctx, ctx->buffer, 64); | 94 (void) ngx_md5_body(ctx, ctx->buffer, 64); |
95 | 95 |
96 result[0] = ctx->a; | 96 result[0] = (u_char) ctx->a; |
97 result[1] = ctx->a >> 8; | 97 result[1] = (u_char) (ctx->a >> 8); |
98 result[2] = ctx->a >> 16; | 98 result[2] = (u_char) (ctx->a >> 16); |
99 result[3] = ctx->a >> 24; | 99 result[3] = (u_char) (ctx->a >> 24); |
100 result[4] = ctx->b; | 100 result[4] = (u_char) ctx->b; |
101 result[5] = ctx->b >> 8; | 101 result[5] = (u_char) (ctx->b >> 8); |
102 result[6] = ctx->b >> 16; | 102 result[6] = (u_char) (ctx->b >> 16); |
103 result[7] = ctx->b >> 24; | 103 result[7] = (u_char) (ctx->b >> 24); |
104 result[8] = ctx->c; | 104 result[8] = (u_char) ctx->c; |
105 result[9] = ctx->c >> 8; | 105 result[9] = (u_char) (ctx->c >> 8); |
106 result[10] = ctx->c >> 16; | 106 result[10] = (u_char) (ctx->c >> 16); |
107 result[11] = ctx->c >> 24; | 107 result[11] = (u_char) (ctx->c >> 24); |
108 result[12] = ctx->d; | 108 result[12] = (u_char) ctx->d; |
109 result[13] = ctx->d >> 8; | 109 result[13] = (u_char) (ctx->d >> 8); |
110 result[14] = ctx->d >> 16; | 110 result[14] = (u_char) (ctx->d >> 16); |
111 result[15] = ctx->d >> 24; | 111 result[15] = (u_char) (ctx->d >> 24); |
112 | 112 |
113 ngx_memzero(ctx, sizeof(*ctx)); | 113 ngx_memzero(ctx, sizeof(*ctx)); |
114 } | 114 } |
115 | 115 |
116 | 116 |