diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-11-21 13:04:43 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-11-21 13:04:43 +0000 |
commit | 5d26d48cabb053e50519583e074292f3c86aecac (patch) | |
tree | 4b23ce6256f2f600c9aaa411981bb1b1373e7cc2 /usr.sbin/relayd/check_tcp.c | |
parent | 58a45bd3fc8545f2f426bf7208337a15505fabdb (diff) |
allow the http digest type to be either SHA1 or MD5 determined by the
digest string length; it is compatible to any existing SHA1-only
configurations.
ok pyr@ gilles@
Diffstat (limited to 'usr.sbin/relayd/check_tcp.c')
-rw-r--r-- | usr.sbin/relayd/check_tcp.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/usr.sbin/relayd/check_tcp.c b/usr.sbin/relayd/check_tcp.c index 6b054bf2d6f..fe9299d446e 100644 --- a/usr.sbin/relayd/check_tcp.c +++ b/usr.sbin/relayd/check_tcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: check_tcp.c,v 1.27 2007/11/19 15:20:18 reyk Exp $ */ +/* $OpenBSD: check_tcp.c,v 1.28 2007/11/21 13:04:42 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -33,6 +33,7 @@ #include <errno.h> #include <fnmatch.h> #include <sha1.h> +#include <md5.h> #include <openssl/ssl.h> @@ -353,7 +354,7 @@ check_http_digest(struct ctl_tcp_event *cte) { char *head; u_char *b; - char digest[(SHA1_DIGEST_LENGTH*2)+1]; + char digest[SHA1_DIGEST_STRING_LENGTH]; struct host *host; /* @@ -373,7 +374,15 @@ check_http_digest(struct ctl_tcp_event *cte) return (1); } head += strlen("\r\n\r\n"); - SHA1Data(head, strlen(head), digest); + + switch (cte->table->conf.digest_type) { + case DIGEST_SHA1: + SHA1Data(head, strlen(head), digest); + break; + case DIGEST_MD5: + MD5Data(head, strlen(head), digest); + break; + } if (strcmp(cte->table->conf.digest, digest)) { log_warnx("check_http_digest: %s failed " |