From 91c7c7416b4a18ac2b9e872c2a1a6391cf8b3dc8 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Mon, 31 May 1999 19:16:22 +0000 Subject: Incoming side of authentication done but untested. Right handling of filters in rip. --- proto/rip/auth.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'proto/rip/auth.c') diff --git a/proto/rip/auth.c b/proto/rip/auth.c index 2477448..dbfdf8b 100644 --- a/proto/rip/auth.c +++ b/proto/rip/auth.c @@ -19,6 +19,7 @@ #include "lib/resource.h" #include "lib/lists.h" #include "lib/timer.h" +#include "lib/md5.h" #include "rip.h" @@ -47,10 +48,28 @@ rip_incoming_authentication( struct proto *p, struct rip_block_auth *block, stru DBG( "md5 password" ); { struct password_item *head; + struct rip_md5_tail *tail; + + tail = (char *) packet + (block->packetlen - sizeof(struct rip_block_auth)); + head = P_CF->passwords; while (head) { - if (head->id == block->keyid) - /* Perform md5 + compare */; + if (head->id == block->keyid) { + struct MD5Context ctxt; + int i; + char md5sum_packet[16]; + char md5sum_computed[16]; + + memcpy(md5sum_packet, tail->md5, i); + password_strncpy(tail->md5, head->password, 16); + + MD5Init(&ctxt); + MD5Update(&ctxt, packet, block->packetlen ); + MD5Final(md5sum_computed, &ctxt); + + if (memcmp(md5sum_packet, md5sum_computed, 16)) + return 1; + } head = head->next; } return 1; @@ -72,7 +91,7 @@ rip_outgoing_authentication( struct proto *p, struct rip_block_auth *block, stru log( L_ERR "no passwords set and password authentication requested\n" ); return; } - strncpy( (char *) (&block->packetlen), P_CF->passwords->password, 16); + password_strncpy( (char *) (&block->packetlen), P_CF->passwords->password, 16); return; } } -- cgit v1.2.3