diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2014-01-01 11:32:54 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2014-01-04 16:10:13 +0100 |
commit | 517f200c16643f5dd29027b798ffb795e7c3b5c0 (patch) | |
tree | 02b6b127076b21ea8a5be8bc631c6309459b9870 /src/pjctl.c | |
parent | cdcfca35b16be9ad95a31f6321fba2632cc9c34d (diff) | |
download | pjctl-517f200c16643f5dd29027b798ffb795e7c3b5c0.tar.gz pjctl-517f200c16643f5dd29027b798ffb795e7c3b5c0.tar.bz2 pjctl-517f200c16643f5dd29027b798ffb795e7c3b5c0.zip |
Use md5 from gnulib
Diffstat (limited to 'src/pjctl.c')
-rw-r--r-- | src/pjctl.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/src/pjctl.c b/src/pjctl.c index 0a04556..3c2ab96 100644 --- a/src/pjctl.c +++ b/src/pjctl.c @@ -33,10 +33,8 @@ #include <unistd.h> #include <netdb.h> -#ifndef NO_CRYPTO -#include <openssl/md5.h> -#endif #include "param.h" +#include "ext/gnulib/md5.h" enum pjlink_packet_offsets { PJLINK_HEADER = 0, @@ -78,10 +76,8 @@ struct pjctl { int fd; char *password; -#ifndef NO_CRYPTO int need_hash; char hash[32+1]; /* 0-terminated hex as ascii encoded 16 byte hash */ -#endif }; #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) @@ -138,17 +134,16 @@ handle_pjlink_error(char *param) return 0; } -#ifndef NO_CRYPTO static void init_hash(struct pjctl *pjctl, const char *salt) { - unsigned char md[MD5_DIGEST_LENGTH]; - MD5_CTX md5; + unsigned char md[MD5_DIGEST_SIZE]; + struct md5_ctx ctx; - MD5_Init(&md5); - MD5_Update(&md5, salt, strlen(salt)); - MD5_Update(&md5, pjctl->password, strlen(pjctl->password)); - MD5_Final(md, &md5); + md5_init_ctx(&ctx); + md5_process_bytes(salt, strlen(salt), &ctx); + md5_process_bytes(pjctl->password, strlen(pjctl->password), &ctx); + md5_finish_ctx(&ctx, md); snprintf(pjctl->hash, sizeof(pjctl->hash), "%02x%02x%02x%02x%02x%02x%02x%02x" @@ -159,7 +154,6 @@ init_hash(struct pjctl *pjctl, const char *salt) md[12], md[13], md[14], md[15]); pjctl->need_hash = 1; } -#endif static int send_next_cmd(struct pjctl *pjctl) @@ -179,7 +173,6 @@ send_next_cmd(struct pjctl *pjctl) memset(&msg, 0, sizeof msg); msg.msg_iov = iov; -#ifndef NO_CRYPTO if (pjctl->need_hash) { pjctl->state = PJCTL_AWAIT_RESPONSE_OR_AUTH_ERR; @@ -187,7 +180,6 @@ send_next_cmd(struct pjctl *pjctl) iov[msg.msg_iovlen].iov_len = 32; msg.msg_iovlen++; } -#endif cmd = pjctl->queue.prev; iov[msg.msg_iovlen].iov_base = cmd->command; @@ -206,7 +198,6 @@ static int handle_setup(struct pjctl *pjctl, char *data, int len) { switch (data[PJLINK_PARAMETER]) { -#ifndef NO_CRYPTO case '1': if (pjctl->password == NULL) { fprintf(stderr, @@ -217,7 +208,6 @@ handle_setup(struct pjctl *pjctl, char *data, int len) goto err; init_hash(pjctl, &data[PJLINK_PARAMETER+2]); break; -#endif case '0': /* No authentication */ break; |