|
9 | 9 | #include <ngx_config.h> |
10 | 10 | #include <ngx_core.h> |
11 | 11 | #include <ngx_http.h> |
| 12 | +#include <ngx_md5.h> |
| 13 | +#include <ngx_sha1.h> |
12 | 14 | #include <nginx.h> |
13 | 15 |
|
14 | | -#if (NGX_HAVE_OPENSSL_MD5_H) |
15 | | -#include <openssl/md5.h> |
16 | | -#else |
17 | | -#include <md5.h> |
18 | | -#endif |
19 | | - |
20 | | -#if (NGX_HAVE_OPENSSL_SHA1_H) |
21 | | -#include <openssl/sha.h> |
22 | | -#else |
23 | | -#include <sha.h> |
24 | | -#endif |
25 | | - |
26 | | - |
27 | | -#if (NGX_OPENSSL_MD5) |
28 | | -#define MD5Init MD5_Init |
29 | | -#define MD5Update MD5_Update |
30 | | -#define MD5Final MD5_Final |
31 | | -#endif |
32 | | - |
33 | 16 | #define MULTIPART_FORM_DATA_STRING "multipart/form-data" |
34 | 17 | #define BOUNDARY_STRING "boundary=" |
35 | 18 | #define CONTENT_DISPOSITION_STRING "Content-Disposition:" |
@@ -152,13 +135,15 @@ typedef struct { |
152 | 135 | unsigned int crc32:1; |
153 | 136 | } ngx_http_upload_loc_conf_t; |
154 | 137 |
|
| 138 | +#define MD5_DIGEST_LENGTH 16 |
155 | 139 | typedef struct ngx_http_upload_md5_ctx_s { |
156 | | - MD5_CTX md5; |
| 140 | + ngx_md5_t md5; |
157 | 141 | u_char md5_digest[MD5_DIGEST_LENGTH * 2]; |
158 | 142 | } ngx_http_upload_md5_ctx_t; |
159 | 143 |
|
| 144 | +#define SHA_DIGEST_LENGTH 20 |
160 | 145 | typedef struct ngx_http_upload_sha1_ctx_s { |
161 | | - SHA_CTX sha1; |
| 146 | + ngx_sha1_t sha1; |
162 | 147 | u_char sha1_digest[SHA_DIGEST_LENGTH * 2]; |
163 | 148 | } ngx_http_upload_sha1_ctx_t; |
164 | 149 |
|
@@ -1855,10 +1840,10 @@ static ngx_int_t ngx_http_upload_start_handler(ngx_http_upload_ctx_t *u) { /* {{ |
1855 | 1840 | } |
1856 | 1841 |
|
1857 | 1842 | if(u->md5_ctx != NULL) |
1858 | | - MD5Init(&u->md5_ctx->md5); |
| 1843 | + ngx_md5_init(&u->md5_ctx->md5); |
1859 | 1844 |
|
1860 | 1845 | if(u->sha1_ctx != NULL) |
1861 | | - SHA1_Init(&u->sha1_ctx->sha1); |
| 1846 | + ngx_sha1_init(&u->sha1_ctx->sha1); |
1862 | 1847 |
|
1863 | 1848 | if(u->calculate_crc32) |
1864 | 1849 | ngx_crc32_init(u->crc32); |
@@ -1945,10 +1930,10 @@ static void ngx_http_upload_finish_handler(ngx_http_upload_ctx_t *u) { /* {{{ */ |
1945 | 1930 | ngx_close_file(u->output_file.fd); |
1946 | 1931 |
|
1947 | 1932 | if(u->md5_ctx) |
1948 | | - MD5Final(u->md5_ctx->md5_digest, &u->md5_ctx->md5); |
| 1933 | + ngx_md5_final(u->md5_ctx->md5_digest, &u->md5_ctx->md5); |
1949 | 1934 |
|
1950 | 1935 | if(u->sha1_ctx) |
1951 | | - SHA1_Final(u->sha1_ctx->sha1_digest, &u->sha1_ctx->sha1); |
| 1936 | + ngx_sha1_final(u->sha1_ctx->sha1_digest, &u->sha1_ctx->sha1); |
1952 | 1937 |
|
1953 | 1938 | if(u->calculate_crc32) |
1954 | 1939 | ngx_crc32_final(u->crc32); |
@@ -2107,10 +2092,10 @@ static ngx_int_t ngx_http_upload_flush_output_buffer(ngx_http_upload_ctx_t *u, u |
2107 | 2092 | } |
2108 | 2093 |
|
2109 | 2094 | if(u->md5_ctx) |
2110 | | - MD5Update(&u->md5_ctx->md5, buf, len); |
| 2095 | + ngx_md5_update(&u->md5_ctx->md5, buf, len); |
2111 | 2096 |
|
2112 | 2097 | if(u->sha1_ctx) |
2113 | | - SHA1_Update(&u->sha1_ctx->sha1, buf, len); |
| 2098 | + ngx_sha1_update(&u->sha1_ctx->sha1, buf, len); |
2114 | 2099 |
|
2115 | 2100 | if(u->calculate_crc32) |
2116 | 2101 | ngx_crc32_update(&u->crc32, buf, len); |
@@ -4018,4 +4003,3 @@ ngx_upload_cleanup_handler(void *data) |
4018 | 4003 | } |
4019 | 4004 | } |
4020 | 4005 | } /* }}} */ |
4021 | | - |
0 commit comments