summaryrefslogtreecommitdiffstats
path: root/src/protocol_ec25519_fhmqvc.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-04-22 13:54:36 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-04-22 13:54:36 +0200
commit1bbef32baabfa9da3bb55754da06c0b05550aa46 (patch)
tree43f06a3c17e12a09e6dbdc60095470586a27b43d /src/protocol_ec25519_fhmqvc.c
parentf21a6e3cec1fcc9930f06d3d0b8714cd34718815 (diff)
downloadfastd-1bbef32baabfa9da3bb55754da06c0b05550aa46.tar
fastd-1bbef32baabfa9da3bb55754da06c0b05550aa46.zip
Add --show-key and --machine-readable options
Diffstat (limited to 'src/protocol_ec25519_fhmqvc.c')
-rw-r--r--src/protocol_ec25519_fhmqvc.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/protocol_ec25519_fhmqvc.c b/src/protocol_ec25519_fhmqvc.c
index 719482c..3cd25b8 100644
--- a/src/protocol_ec25519_fhmqvc.c
+++ b/src/protocol_ec25519_fhmqvc.c
@@ -696,7 +696,8 @@ static void protocol_generate_key(fastd_context *ctx) {
ecc_secret_key_256 secret_key;
ecc_public_key_256 public_key;
- pr_info(ctx, "Reading 32 bytes from /dev/random...");
+ if (!ctx->conf->machine_readable)
+ pr_info(ctx, "Reading 32 bytes from /dev/random...");
fastd_random_bytes(ctx, secret_key.s, 32, true);
ecc_25519_secret_sanitize(&secret_key, &secret_key);
@@ -705,8 +706,20 @@ static void protocol_generate_key(fastd_context *ctx) {
ecc_25519_scalarmult_base(&work, &secret_key);
ecc_25519_store(&public_key, &work);
- hexdump("Secret: ", secret_key.s);
- hexdump("Public: ", public_key.p);
+ if (ctx->conf->machine_readable) {
+ hexdump("", secret_key.s);
+ }
+ else {
+ hexdump("Secret: ", secret_key.s);
+ hexdump("Public: ", public_key.p);
+ }
+}
+
+static void protocol_show_key(fastd_context *ctx) {
+ if (ctx->conf->machine_readable)
+ hexdump("", ctx->conf->protocol_config->public_key.p);
+ else
+ hexdump("Public: ", ctx->conf->protocol_config->public_key.p);
}
@@ -725,4 +738,5 @@ const fastd_protocol fastd_protocol_ec25519_fhmqvc = {
.free_peer_state = protocol_free_peer_state,
.generate_key = protocol_generate_key,
+ .show_key = protocol_show_key,
};