diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2007-12-12 17:09:50 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2007-12-12 17:09:50 +0000 |
| commit | 4341d7949eaf333bba5e0c49ac85af1492974292 (patch) | |
| tree | 6b75a378c7de73a2f936f505918486716648ef12 | |
| parent | 2bf343514358360df1bae483526b3855c3b2fcf9 (diff) | |
| download | nginx-4341d7949eaf333bba5e0c49ac85af1492974292.tar.gz nginx-4341d7949eaf333bba5e0c49ac85af1492974292.tar.bz2 | |
r1573, r1574, r1575 merge:
ngx_md5.h and ngx_sha1.h
| -rw-r--r-- | auto/sources | 2 | ||||
| -rw-r--r-- | src/core/ngx_md5.h | 40 | ||||
| -rw-r--r-- | src/core/ngx_sha1.h | 30 | ||||
| -rw-r--r-- | src/mysql/ngx_mysql.c | 31 |
4 files changed, 85 insertions, 18 deletions
diff --git a/auto/sources b/auto/sources index 957608c02..b4f2fb890 100644 --- a/auto/sources +++ b/auto/sources @@ -21,6 +21,8 @@ CORE_DEPS="src/core/nginx.h \ src/core/ngx_file.h \ src/core/ngx_crc.h \ src/core/ngx_crc32.h \ + src/core/ngx_md5.h \ + src/core/ngx_sha1.h \ src/core/ngx_rbtree.h \ src/core/ngx_radix_tree.h \ src/core/ngx_slab.h \ diff --git a/src/core/ngx_md5.h b/src/core/ngx_md5.h new file mode 100644 index 000000000..eeba97e86 --- /dev/null +++ b/src/core/ngx_md5.h @@ -0,0 +1,40 @@ + +/* + * Copyright (C) Igor Sysoev + */ + + +#ifndef _NGX_MD5_H_INCLUDED_ +#define _NGX_MD5_H_INCLUDED_ + + +#include <ngx_config.h> +#include <ngx_core.h> + + +#if (NGX_HAVE_OPENSSL_MD5_H) +#include <openssl/md5.h> +#else +#include <md5.h> +#endif + + +typedef MD5_CTX ngx_md5_t; + + +#if (NGX_OPENSSL_MD5) + +#define ngx_md5_init MD5_Init +#define ngx_md5_update MD5_Update +#define ngx_md5_final MD5_Final + +#else + +#define ngx_md5_init MD5Init +#define ngx_md5_update MD5Update +#define ngx_md5_final MD5Final + +#endif + + +#endif /* _NGX_MD5_H_INCLUDED_ */ diff --git a/src/core/ngx_sha1.h b/src/core/ngx_sha1.h new file mode 100644 index 000000000..78f52c5ce --- /dev/null +++ b/src/core/ngx_sha1.h @@ -0,0 +1,30 @@ + +/* + * Copyright (C) Igor Sysoev + */ + + +#ifndef _NGX_SHA1_H_INCLUDED_ +#define _NGX_SHA1_H_INCLUDED_ + + +#include <ngx_config.h> +#include <ngx_core.h> + + +#if (NGX_HAVE_OPENSSL_SHA1_H) +#include <openssl/sha.h> +#else +#include <sha.h> +#endif + + +typedef SHA_CTX ngx_sha1_t; + + +#define ngx_sha1_init SHA1_Init +#define ngx_sha1_update SHA1_Update +#define ngx_sha1_final SHA1_Final + + +#endif /* _NGX_SHA1_H_INCLUDED_ */ diff --git a/src/mysql/ngx_mysql.c b/src/mysql/ngx_mysql.c index 2c1980d1b..fd98f2b30 100644 --- a/src/mysql/ngx_mysql.c +++ b/src/mysql/ngx_mysql.c @@ -12,12 +12,7 @@ #include <ngx_event.h> #include <ngx_event_connect.h> #include <ngx_mysql.h> - -#if (NGX_HAVE_OPENSSL_SHA1_H) -#include <openssl/sha.h> -#else -#include <sha.h> -#endif +#include <ngx_sha1.h> #define NGX_MYSQL_LONG_PASSWORD 0x0001 @@ -142,7 +137,7 @@ ngx_mysql_read_server_greeting(ngx_event_t *rev) ngx_mysql_greeting1_pkt_t *gr1; ngx_mysql_greeting2_pkt_t *gr2; ngx_mysql_auth_pkt_t *auth; - SHA_CTX sha; + ngx_sha1_t sha; u_char hash1[20], hash2[20]; c = rev->data; @@ -241,19 +236,19 @@ ngx_mysql_read_server_greeting(ngx_event_t *rev) *p++ = (u_char) 20; - SHA1_Init(&sha); - SHA1_Update(&sha, m->passwd->data, m->passwd->len); - SHA1_Final(hash1, &sha); + ngx_sha1_init(&sha); + ngx_sha1_update(&sha, m->passwd->data, m->passwd->len); + ngx_sha1_final(hash1, &sha); - SHA1_Init(&sha); - SHA1_Update(&sha, hash1, 20); - SHA1_Final(hash2, &sha); + ngx_sha1_init(&sha); + ngx_sha1_update(&sha, hash1, 20); + ngx_sha1_final(hash2, &sha); - SHA1_Init(&sha); - SHA1_Update(&sha, gr2->salt1, 8); - SHA1_Update(&sha, gr2->salt2, 12); - SHA1_Update(&sha, hash2, 20); - SHA1_Final(hash2, &sha); + ngx_sha1_init(&sha); + ngx_sha1_update(&sha, gr2->salt1, 8); + ngx_sha1_update(&sha, gr2->salt2, 12); + ngx_sha1_update(&sha, hash2, 20); + ngx_sha1_final(hash2, &sha); for (i = 0; i < 20; i++) { *p++ = (u_char) (hash1[i] ^ hash2[i]); |
