chiark / gitweb /
sigkey handling: define MAX_SIG_KEYS
[secnet.git] / secnet.h
index 7da7c2d5a9935a7cd6bbb8285c8921faa7506594..f7bb3e5685128c7fdf0290f93e1ac17bb824ebca 100644 (file)
--- a/secnet.h
+++ b/secnet.h
@@ -27,6 +27,8 @@
 #include <stdlib.h>
 #include <stdarg.h>
 #include <stdio.h>
+#include <stdint.h>
+#include <inttypes.h>
 #include <string.h>
 #include <assert.h>
 #include <fcntl.h>
@@ -47,6 +49,7 @@
 /* send at most this many copies; honour at most that many addresses */
 
 #define MAX_NAK_MSG 80
+#define MAX_SIG_KEYS 4
 
 struct hash_if;
 struct comm_if;
@@ -68,6 +71,22 @@ union iaddr {
 #endif
 };
 
+#define GRPIDSZ 4
+#define ALGIDSZ 1
+#define KEYIDSZ (GRPIDSZ+ALGIDSZ)
+  /* Changing these is complex: this is the group id plus algo id */
+  /* They are costructed by pubkeys.fl.pl.  Also hardcoded in _PR_ */
+struct sigkeyid { uint8_t b[KEYIDSZ]; };
+
+#define SIGKEYID_PR_FMT "%02x%02x%02x%02x%02x"
+#define SIGKEYID_PR_VAL(id) /* SIGKEYID_PR_VAL(const sigkeyid *id) */  \
+    ((id) == (const struct sigkeyid*)0, (id)->b[0]),                   \
+    (id)->b[1],(id)->b[2],(id)->b[3],(id)->b[4]
+static inline bool_t sigkeyid_equal(const struct sigkeyid *a,
+                                   const struct sigkeyid *b) {
+    return !memcmp(a->b, b->b, KEYIDSZ);
+}
+
 #define ASSERT(x) do { if (!(x)) { fatal("assertion failed line %d file " \
                                         __FILE__,__LINE__); } } while(0)