summaryrefslogtreecommitdiff
path: root/fticks.c
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2011-04-04 16:21:20 +0200
committerLinus Nordberg <linus@nordu.net>2011-04-04 16:21:20 +0200
commit369aef553267ddee30b7560f247750c344797282 (patch)
treece8b0fe88a8f186c84ec99be8a15ae81da0999a5 /fticks.c
parent59e93add209b19fd1c29209930397a20a9d9c932 (diff)
Move configure_fticks to fticks.c.
Diffstat (limited to 'fticks.c')
-rw-r--r--fticks.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/fticks.c b/fticks.c
index 98022cd..c3b9c05 100644
--- a/fticks.c
+++ b/fticks.c
@@ -51,6 +51,75 @@ hash(const uint8_t *in,
}
}
+int
+fticks_configure(struct options *options,
+ uint8_t **reportingp,
+ uint8_t **macp,
+ uint8_t **keyp)
+{
+ int r = 0;
+ const char *reporting = (const char *) *reportingp;
+ const char *mac = (const char *) *macp;
+
+ if (reporting == NULL)
+ goto out;
+
+ if (strcasecmp(reporting, "None") == 0)
+ options->fticks_reporting = RSP_FTICKS_REPORTING_NONE;
+ else if (strcasecmp(reporting, "Basic") == 0)
+ options->fticks_reporting = RSP_FTICKS_REPORTING_BASIC;
+ else if (strcasecmp(reporting, "Full") == 0)
+ options->fticks_reporting = RSP_FTICKS_REPORTING_FULL;
+ else {
+ debugx(1, DBG_ERR, "config error: invalid FTicksReporting value: %s",
+ reporting);
+ r = 1;
+ goto out;
+ }
+
+ if (strcasecmp(mac, "Static") == 0)
+ options->fticks_mac = RSP_FTICKS_MAC_STATIC;
+ else if (strcasecmp(mac, "Original") == 0)
+ options->fticks_mac = RSP_FTICKS_MAC_ORIGINAL;
+ else if (strcasecmp(mac, "VendorHashed") == 0)
+ options->fticks_mac = RSP_FTICKS_MAC_VENDOR_HASHED;
+ else if (strcasecmp(mac, "VendorKeyHashed") == 0)
+ options->fticks_mac = RSP_FTICKS_MAC_VENDOR_KEY_HASHED;
+ else if (strcasecmp(mac, "FullyHashed") == 0)
+ options->fticks_mac = RSP_FTICKS_MAC_FULLY_HASHED;
+ else if (strcasecmp(mac, "FullyKeyHashed") == 0)
+ options->fticks_mac = RSP_FTICKS_MAC_FULLY_KEY_HASHED;
+ else {
+ debugx(1, DBG_ERR, "config error: invalid FTicksMAC value: %s", mac);
+ r = 1;
+ goto out;
+ }
+
+ if (*keyp == NULL
+ && (options->fticks_mac == RSP_FTICKS_MAC_VENDOR_KEY_HASHED
+ || options->fticks_mac == RSP_FTICKS_MAC_FULLY_KEY_HASHED)) {
+ debugx(1, DBG_ERR,
+ "config error: FTicksMAC %s requires an FTicksKey", mac);
+ options->fticks_mac = RSP_FTICKS_MAC_STATIC;
+ r = 1;
+ goto out;
+ }
+
+ if (*keyp != NULL)
+ options->fticks_key = *keyp;
+
+out:
+ if (*reportingp != NULL) {
+ free(*reportingp);
+ *reportingp = NULL;
+ }
+ if (*macp != NULL) {
+ free(*macp);
+ *macp = NULL;
+ }
+ return r;
+}
+
/** Hash the MAC in \a IN, keying with \a KEY if it's not NULL.
\a IN and \a KEY are NULL terminated strings.