summaryrefslogtreecommitdiff
path: root/proto
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2016-10-25 17:04:17 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2016-11-02 16:23:53 +0100
commitde2a27e255b6ec834d11c005909b28a150c7c0db (patch)
tree9b6f61fa7f9d3cb05abf5e72b9fdb8d5ba9bdef7 /proto
parent7eec3988758cb4c19a0ab3bf90cab2a4914165be (diff)
Add generic message authentication interface
Add generic interface for generating and verifying MACs (message authentication codes). Replace multiple HMAC implementation with a generic one.
Diffstat (limited to 'proto')
-rw-r--r--proto/ospf/packet.c5
-rw-r--r--proto/rip/packets.c5
2 files changed, 6 insertions, 4 deletions
diff --git a/proto/ospf/packet.c b/proto/ospf/packet.c
index aa90aa51..a2fbd089 100644
--- a/proto/ospf/packet.c
+++ b/proto/ospf/packet.c
@@ -11,6 +11,7 @@
#include "ospf.h"
#include "nest/password.h"
#include "lib/md5.h"
+#include "lib/mac.h"
#include "lib/socket.h"
void
@@ -109,7 +110,7 @@ ospf_pkt_finalize(struct ospf_iface *ifa, struct ospf_packet *pkt)
char password[OSPF_AUTH_CRYPT_SIZE];
strncpy(password, passwd->password, sizeof(password));
- struct md5_context ctx;
+ struct hash_context ctx;
md5_init(&ctx);
md5_update(&ctx, (char *) pkt, plen);
md5_update(&ctx, password, OSPF_AUTH_CRYPT_SIZE);
@@ -180,7 +181,7 @@ ospf_pkt_checkauth(struct ospf_neighbor *n, struct ospf_iface *ifa, struct ospf_
memcpy(received, tail, OSPF_AUTH_CRYPT_SIZE);
strncpy(tail, pass->password, OSPF_AUTH_CRYPT_SIZE);
- struct md5_context ctx;
+ struct hash_context ctx;
md5_init(&ctx);
md5_update(&ctx, (byte *) pkt, plen + OSPF_AUTH_CRYPT_SIZE);
char *computed = md5_final(&ctx);
diff --git a/proto/rip/packets.c b/proto/rip/packets.c
index e026eaea..381b4771 100644
--- a/proto/rip/packets.c
+++ b/proto/rip/packets.c
@@ -11,6 +11,7 @@
#include "rip.h"
#include "lib/md5.h"
+#include "lib/mac.h"
#define RIP_CMD_REQUEST 1 /* want info */
@@ -241,7 +242,7 @@ rip_fill_authentication(struct rip_proto *p, struct rip_iface *ifa, struct rip_p
*plen += sizeof(struct rip_auth_tail) + RIP_MD5_LENGTH;
- struct md5_context ctx;
+ struct hash_context ctx;
md5_init(&ctx);
md5_update(&ctx, (byte *) pkt, *plen);
memcpy(tail->auth_data, md5_final(&ctx), RIP_MD5_LENGTH);
@@ -315,7 +316,7 @@ rip_check_authentication(struct rip_proto *p, struct rip_iface *ifa, struct rip_
memcpy(received, tail->auth_data, RIP_MD5_LENGTH);
strncpy(tail->auth_data, pass->password, RIP_MD5_LENGTH);
- struct md5_context ctx;
+ struct hash_context ctx;
md5_init(&ctx);
md5_update(&ctx, (byte *) pkt, *plen);
char *computed = md5_final(&ctx);