knet_keygen_SOURCES = keygen.c
+knet_keygen_CPPFLAGS = -I$(top_srcdir)/libknet
+
install-exec-local:
$(INSTALL) -d -m 0700 $(DESTDIR)/$(DEFAULT_CONFIG_DIR)
$(INSTALL) -d $(DESTDIR)/$(DEFAULT_CONFIG_DIR)/cryptokeys.d
#include <sys/stat.h>
#include <fcntl.h>
+#include <libknet.h>
+
static char *output_file = NULL;
-static ssize_t keylen = 4096;
+static ssize_t keylen = KNET_MAX_KEY_LEN;
static void print_usage(void)
{
case 's':
keylen = atoi(optarg);
- if ((keylen < 1024) || (keylen > 4096)) {
- fprintf(stderr, "Error: Key size should be a value between 1024 and 4096 (default) included\n");
+ if ((keylen < KNET_MIN_KEY_LEN) || (keylen > KNET_MAX_KEY_LEN)) {
+ fprintf(stderr, "Error: Key size should be a value between %u and %u (default) included\n",
+ KNET_MIN_KEY_LEN, KNET_MAX_KEY_LEN);
return -1;
}
break;
(strncmp("none", knet_iface->hash_method, 4))) {
int fd = -1;
char keyfile[PATH_MAX];
- unsigned char private_key[4096];
+ unsigned char private_key[KNET_MAX_KEY_LEN];
struct stat sb;
memset(keyfile, 0, PATH_MAX);
}
knet_handle_cfg.private_key_len = (unsigned int)sb.st_size;
- if ((knet_handle_cfg.private_key_len < 1024) ||
- (knet_handle_cfg.private_key_len > 4096)) {
- knet_vty_write(vty, "Error: Key %s is %u long. Must be 1024 <= key_len <= 4096%s",
- keyfile, knet_handle_cfg.private_key_len, telnet_newline);
+ if ((knet_handle_cfg.private_key_len < KNET_MIN_KEY_LEN) ||
+ (knet_handle_cfg.private_key_len > KNET_MAX_KEY_LEN)) {
+ knet_vty_write(vty, "Error: Key %s is %u long. Must be %u <= key_len <= %u%s",
+ keyfile, knet_handle_cfg.private_key_len,
+ KNET_MIN_KEY_LEN, KNET_MAX_KEY_LEN, telnet_newline);
goto key_error;
}
#define KNET_FRAME_PONG 0x82
#define KNET_FRAME_PMSK 0x80 /* ping/pong packet mask */
+#define KNET_MIN_KEY_LEN 1024
+#define KNET_MAX_KEY_LEN 4096
+
struct knet_handle_cfg {
int fd;
uint16_t node_id;
if ((knet_h->crypto_instance->crypto_cipher_type > 0) ||
(knet_h->crypto_instance->crypto_hash_type > 0)) {
if ((!knet_h->crypto_instance->private_key) ||
- (knet_h->crypto_instance->private_key_len < 1024)) {
+ (knet_h->crypto_instance->private_key_len < KNET_MIN_KEY_LEN) ||
+ (knet_h->crypto_instance->private_key_len > KNET_MAX_KEY_LEN)) {
goto out_err;
}
}
#include "libknet.h"
-static unsigned char crypto_key[4096];
+static unsigned char crypto_key[KNET_MAX_KEY_LEN];
static int knet_sock[2];
static knet_handle_t knet_h;
static struct knet_handle_cfg knet_handle_cfg;