diff options
Diffstat (limited to 'src/gnsrecord/test_gnsrecord_crypto.c')
-rw-r--r-- | src/gnsrecord/test_gnsrecord_crypto.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/src/gnsrecord/test_gnsrecord_crypto.c b/src/gnsrecord/test_gnsrecord_crypto.c index d541f3076..9394f562d 100644 --- a/src/gnsrecord/test_gnsrecord_crypto.c +++ b/src/gnsrecord/test_gnsrecord_crypto.c | |||
@@ -92,29 +92,22 @@ rd_decrypt_cb (void *cls, | |||
92 | res = 0; | 92 | res = 0; |
93 | } | 93 | } |
94 | 94 | ||
95 | |||
96 | static void | 95 | static void |
97 | run (void *cls, | 96 | test_with_type (struct GNUNET_IDENTITY_PrivateKey *privkey) |
98 | char *const *args, | ||
99 | const char *cfgfile, | ||
100 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
101 | { | 97 | { |
102 | struct GNUNET_GNSRECORD_Block *block; | 98 | struct GNUNET_GNSRECORD_Block *block; |
103 | struct GNUNET_IDENTITY_PublicKey pubkey; | 99 | struct GNUNET_IDENTITY_PublicKey pubkey; |
104 | struct GNUNET_HashCode query_pub; | 100 | struct GNUNET_HashCode query_pub; |
105 | struct GNUNET_HashCode query_priv; | 101 | struct GNUNET_HashCode query_priv; |
106 | struct GNUNET_TIME_Absolute expire = GNUNET_TIME_absolute_get (); | 102 | struct GNUNET_TIME_Absolute expire = GNUNET_TIME_absolute_get (); |
107 | struct GNUNET_IDENTITY_PrivateKey privkey; | ||
108 | 103 | ||
109 | 104 | ||
110 | privkey.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); | ||
111 | GNUNET_CRYPTO_ecdsa_key_create (&privkey.ecdsa_key); | ||
112 | /* get public key */ | 105 | /* get public key */ |
113 | GNUNET_IDENTITY_key_get_public (&privkey, | 106 | GNUNET_IDENTITY_key_get_public (privkey, |
114 | &pubkey); | 107 | &pubkey); |
115 | 108 | ||
116 | /* test query derivation */ | 109 | /* test query derivation */ |
117 | GNUNET_GNSRECORD_query_from_private_key (&privkey, | 110 | GNUNET_GNSRECORD_query_from_private_key (privkey, |
118 | "testlabel", | 111 | "testlabel", |
119 | &query_priv); | 112 | &query_priv); |
120 | GNUNET_GNSRECORD_query_from_public_key (&pubkey, | 113 | GNUNET_GNSRECORD_query_from_public_key (&pubkey, |
@@ -129,7 +122,7 @@ run (void *cls, | |||
129 | 122 | ||
130 | /* Create block */ | 123 | /* Create block */ |
131 | GNUNET_assert (NULL != (block = | 124 | GNUNET_assert (NULL != (block = |
132 | GNUNET_GNSRECORD_block_create (&privkey, | 125 | GNUNET_GNSRECORD_block_create (privkey, |
133 | expire, | 126 | expire, |
134 | s_name, | 127 | s_name, |
135 | s_rd, | 128 | s_rd, |
@@ -146,6 +139,27 @@ run (void *cls, | |||
146 | } | 139 | } |
147 | 140 | ||
148 | 141 | ||
142 | |||
143 | static void | ||
144 | run (void *cls, | ||
145 | char *const *args, | ||
146 | const char *cfgfile, | ||
147 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
148 | { | ||
149 | struct GNUNET_IDENTITY_PrivateKey privkey; | ||
150 | struct GNUNET_IDENTITY_PrivateKey privkey_ed; | ||
151 | |||
152 | |||
153 | privkey.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); | ||
154 | GNUNET_CRYPTO_ecdsa_key_create (&privkey.ecdsa_key); | ||
155 | test_with_type (&privkey); | ||
156 | |||
157 | privkey_ed.type = htonl (GNUNET_GNSRECORD_TYPE_EDKEY); | ||
158 | GNUNET_CRYPTO_eddsa_key_create (&privkey_ed.eddsa_key); | ||
159 | test_with_type(&privkey_ed); | ||
160 | } | ||
161 | |||
162 | |||
149 | int | 163 | int |
150 | main (int argc, char *argv[]) | 164 | main (int argc, char *argv[]) |
151 | { | 165 | { |