diff options
author | Florian Dold <florian.dold@gmail.com> | 2013-12-10 11:14:22 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2013-12-10 11:14:22 +0000 |
commit | f3a98e004caf91688887a01b5fe2ad3f11813238 (patch) | |
tree | 74fc500c7771e38e6cc2f71d18953cdf210a5f9f /src/util/gnunet-ecc.c | |
parent | 119237806b48c9220abc1b96b860bb8f7af03417 (diff) | |
download | gnunet-f3a98e004caf91688887a01b5fe2ad3f11813238.tar.gz gnunet-f3a98e004caf91688887a01b5fe2ad3f11813238.zip |
- key generation for secretsharing
- gnunet-ecc -E also prints hex
Diffstat (limited to 'src/util/gnunet-ecc.c')
-rw-r--r-- | src/util/gnunet-ecc.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/util/gnunet-ecc.c b/src/util/gnunet-ecc.c index d4e0f2387..4af9f084d 100644 --- a/src/util/gnunet-ecc.c +++ b/src/util/gnunet-ecc.c | |||
@@ -113,6 +113,19 @@ create_keys (const char *fn) | |||
113 | 113 | ||
114 | 114 | ||
115 | static void | 115 | static void |
116 | print_hex (char *msg, void *buf, size_t size) | ||
117 | { | ||
118 | size_t i; | ||
119 | printf ("%s: ", msg); | ||
120 | for (i = 0; i < size; i++) | ||
121 | { | ||
122 | printf ("%02hhx", ((char *)buf)[i]); | ||
123 | } | ||
124 | printf ("\n"); | ||
125 | } | ||
126 | |||
127 | |||
128 | static void | ||
116 | print_examples_ecdh () | 129 | print_examples_ecdh () |
117 | { | 130 | { |
118 | struct GNUNET_CRYPTO_EcdhePrivateKey *dh_priv1; | 131 | struct GNUNET_CRYPTO_EcdhePrivateKey *dh_priv1; |
@@ -132,14 +145,18 @@ print_examples_ecdh () | |||
132 | GNUNET_assert (NULL != GNUNET_STRINGS_data_to_string (dh_priv1, 32, buf, 128)); | 145 | GNUNET_assert (NULL != GNUNET_STRINGS_data_to_string (dh_priv1, 32, buf, 128)); |
133 | printf ("ECDHE key 1:\n"); | 146 | printf ("ECDHE key 1:\n"); |
134 | printf ("private: %s\n", buf); | 147 | printf ("private: %s\n", buf); |
148 | print_hex ("private(hex)", dh_priv1, sizeof *dh_priv1); | ||
135 | GNUNET_assert (NULL != GNUNET_STRINGS_data_to_string (dh_pub1, 32, buf, 128)); | 149 | GNUNET_assert (NULL != GNUNET_STRINGS_data_to_string (dh_pub1, 32, buf, 128)); |
136 | printf ("public: %s\n", buf); | 150 | printf ("public: %s\n", buf); |
151 | print_hex ("public(hex)", dh_pub1, sizeof *dh_pub1); | ||
137 | 152 | ||
138 | GNUNET_assert (NULL != GNUNET_STRINGS_data_to_string (dh_priv2, 32, buf, 128)); | 153 | GNUNET_assert (NULL != GNUNET_STRINGS_data_to_string (dh_priv2, 32, buf, 128)); |
139 | printf ("ECDHE key 2:\n"); | 154 | printf ("ECDHE key 2:\n"); |
140 | printf ("private: %s\n", buf); | 155 | printf ("private: %s\n", buf); |
156 | print_hex ("private(hex)", dh_priv2, sizeof *dh_priv2); | ||
141 | GNUNET_assert (NULL != GNUNET_STRINGS_data_to_string (dh_pub2, 32, buf, 128)); | 157 | GNUNET_assert (NULL != GNUNET_STRINGS_data_to_string (dh_pub2, 32, buf, 128)); |
142 | printf ("public: %s\n", buf); | 158 | printf ("public: %s\n", buf); |
159 | print_hex ("public(hex)", dh_pub2, sizeof *dh_pub2); | ||
143 | 160 | ||
144 | GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_ecc_ecdh (dh_priv1, dh_pub2, &hash)); | 161 | GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_ecc_ecdh (dh_priv1, dh_pub2, &hash)); |
145 | GNUNET_assert (NULL != GNUNET_STRINGS_data_to_string (&hash, 64, buf, 128)); | 162 | GNUNET_assert (NULL != GNUNET_STRINGS_data_to_string (&hash, 64, buf, 128)); |