#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
+#include <stdint.h>
+#include <inttypes.h>
#include <string.h>
#include <assert.h>
#include <fcntl.h>
/* 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;
#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 SERIALSZ 4
+typedef uint32_t serialt;
+static inline int serial_cmp(serialt a, serialt b) {
+ if (a==b) return 0;
+ if (!a) return -1;
+ if (!b) return +1;
+ return b-a <= (serialt)0x7fffffffUL ? +1 : -1;
+}
+
#define ASSERT(x) do { if (!(x)) { fatal("assertion failed line %d file " \
__FILE__,__LINE__); } } while(0)
/* SIGPUBKEY interface */
typedef void sig_sethash_fn(void *st, struct hash_if *hash);
+typedef void sig_dispose_fn(void *st);
+
typedef bool_t sig_unpick_fn(void *sst, struct buffer_if *msg,
struct alg_msg_data *sig);
typedef bool_t sig_checksig_fn(void *st, uint8_t *data, int32_t datalen,
const struct alg_msg_data *sig);
struct sigpubkey_if {
void *st;
- sig_sethash_fn *sethash; /* must be called before check, if non-0 */
+ sig_sethash_fn *sethash; /* must be called before use, if non-0 */
sig_unpick_fn *unpick;
sig_checksig_fn *check;
+ const struct hash_if *hash;
+ sig_dispose_fn *dispose;
};
/* SIGPRIVKEY interface */
struct buffer_if *msg);
struct sigprivkey_if {
void *st;
- sig_sethash_fn *sethash; /* must be called before sign, if non-0 */
+ sig_sethash_fn *sethash; /* must be called before use, if non-0 */
sig_makesig_fn *sign;
+ const struct hash_if *hash;
+ sig_dispose_fn *dispose;
};
/* COMM interface */