aboutsummaryrefslogtreecommitdiff
path: root/src/namecache
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2020-10-14 19:47:32 +0200
committerMartin Schanzenbach <mschanzenbach@posteo.de>2020-10-15 12:11:18 +0200
commit96c802b46be51e5c45f34e2de823f787d26c2929 (patch)
tree457ccfd8f9a61563af86318739c4a8f964a57025 /src/namecache
parentc14e3a2769ff0f15fdbb32797e37e43ce2344fa3 (diff)
downloadgnunet-96c802b46be51e5c45f34e2de823f787d26c2929.tar.gz
gnunet-96c802b46be51e5c45f34e2de823f787d26c2929.zip
- towards crypto agility; wip
Diffstat (limited to 'src/namecache')
-rw-r--r--src/namecache/gnunet-namecache.c4
-rw-r--r--src/namecache/namecache.h4
-rw-r--r--src/namecache/plugin_namecache_flat.c6
-rw-r--r--src/namecache/plugin_namecache_postgres.c6
-rw-r--r--src/namecache/plugin_namecache_sqlite.c6
-rw-r--r--src/namecache/test_namecache_api_cache_block.c20
6 files changed, 18 insertions, 28 deletions
diff --git a/src/namecache/gnunet-namecache.c b/src/namecache/gnunet-namecache.c
index 2e3c733e6..19f2a5766 100644
--- a/src/namecache/gnunet-namecache.c
+++ b/src/namecache/gnunet-namecache.c
@@ -51,7 +51,7 @@ static char *name;
51/** 51/**
52 * Public key of the zone to look in. 52 * Public key of the zone to look in.
53 */ 53 */
54static struct GNUNET_CRYPTO_EcdsaPublicKey pubkey; 54static struct GNUNET_IDENTITY_PublicKey pubkey;
55 55
56/** 56/**
57 * Public key of the zone to look in, in ASCII. 57 * Public key of the zone to look in, in ASCII.
@@ -177,7 +177,7 @@ run (void *cls,
177 } 177 }
178 178
179 if (GNUNET_OK != 179 if (GNUNET_OK !=
180 GNUNET_CRYPTO_ecdsa_public_key_from_string (pkey, strlen (pkey), &pubkey)) 180 GNUNET_IDENTITY_public_key_from_string (pkey, &pubkey))
181 { 181 {
182 fprintf (stderr, _ ("Invalid public key for zone `%s'\n"), pkey); 182 fprintf (stderr, _ ("Invalid public key for zone `%s'\n"), pkey);
183 GNUNET_SCHEDULER_shutdown (); 183 GNUNET_SCHEDULER_shutdown ();
diff --git a/src/namecache/namecache.h b/src/namecache/namecache.h
index 1657662c2..43c8cf85f 100644
--- a/src/namecache/namecache.h
+++ b/src/namecache/namecache.h
@@ -92,7 +92,7 @@ struct LookupBlockResponseMessage
92 /** 92 /**
93 * Derived public key. 93 * Derived public key.
94 */ 94 */
95 struct GNUNET_CRYPTO_EcdsaPublicKey derived_key; 95 struct GNUNET_IDENTITY_PublicKey derived_key;
96 96
97 /* follwed by encrypted block data */ 97 /* follwed by encrypted block data */
98}; 98};
@@ -121,7 +121,7 @@ struct BlockCacheMessage
121 /** 121 /**
122 * Derived public key. 122 * Derived public key.
123 */ 123 */
124 struct GNUNET_CRYPTO_EcdsaPublicKey derived_key; 124 struct GNUNET_IDENTITY_PublicKey derived_key;
125 125
126 /* follwed by encrypted block data */ 126 /* follwed by encrypted block data */
127}; 127};
diff --git a/src/namecache/plugin_namecache_flat.c b/src/namecache/plugin_namecache_flat.c
index 24f4f2570..1775561e1 100644
--- a/src/namecache/plugin_namecache_flat.c
+++ b/src/namecache/plugin_namecache_flat.c
@@ -208,7 +208,7 @@ store_and_free_entries (void *cls,
208 size_t block_size; 208 size_t block_size;
209 209
210 block_size = ntohl (entry->block->purpose.size) 210 block_size = ntohl (entry->block->purpose.size)
211 + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey) 211 + sizeof(struct GNUNET_IDENTITY_PublicKey)
212 + sizeof(struct GNUNET_CRYPTO_EcdsaSignature); 212 + sizeof(struct GNUNET_CRYPTO_EcdsaSignature);
213 213
214 GNUNET_STRINGS_base64_encode ((char *) entry->block, 214 GNUNET_STRINGS_base64_encode ((char *) entry->block,
@@ -320,10 +320,10 @@ namecache_cache_block (void *cls,
320 320
321 namecache_expire_blocks (plugin); 321 namecache_expire_blocks (plugin);
322 GNUNET_CRYPTO_hash (&block->derived_key, 322 GNUNET_CRYPTO_hash (&block->derived_key,
323 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey), 323 sizeof(struct GNUNET_IDENTITY_PublicKey),
324 &query); 324 &query);
325 block_size = ntohl (block->purpose.size) 325 block_size = ntohl (block->purpose.size)
326 + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey) 326 + sizeof(struct GNUNET_IDENTITY_PublicKey)
327 + sizeof(struct GNUNET_CRYPTO_EcdsaSignature); 327 + sizeof(struct GNUNET_CRYPTO_EcdsaSignature);
328 if (block_size > 64 * 65536) 328 if (block_size > 64 * 65536)
329 { 329 {
diff --git a/src/namecache/plugin_namecache_postgres.c b/src/namecache/plugin_namecache_postgres.c
index 654a3ae81..3c8fc4555 100644
--- a/src/namecache/plugin_namecache_postgres.c
+++ b/src/namecache/plugin_namecache_postgres.c
@@ -183,7 +183,7 @@ namecache_postgres_cache_block (void *cls,
183 struct Plugin *plugin = cls; 183 struct Plugin *plugin = cls;
184 struct GNUNET_HashCode query; 184 struct GNUNET_HashCode query;
185 size_t block_size = ntohl (block->purpose.size) 185 size_t block_size = ntohl (block->purpose.size)
186 + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey) 186 + sizeof(struct GNUNET_IDENTITY_PublicKey)
187 + sizeof(struct GNUNET_CRYPTO_EcdsaSignature); 187 + sizeof(struct GNUNET_CRYPTO_EcdsaSignature);
188 struct GNUNET_PQ_QueryParam params[] = { 188 struct GNUNET_PQ_QueryParam params[] = {
189 GNUNET_PQ_query_param_auto_from_type (&query), 189 GNUNET_PQ_query_param_auto_from_type (&query),
@@ -195,7 +195,7 @@ namecache_postgres_cache_block (void *cls,
195 195
196 namecache_postgres_expire_blocks (plugin); 196 namecache_postgres_expire_blocks (plugin);
197 GNUNET_CRYPTO_hash (&block->derived_key, 197 GNUNET_CRYPTO_hash (&block->derived_key,
198 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey), 198 sizeof(struct GNUNET_IDENTITY_PublicKey),
199 &query); 199 &query);
200 if (block_size > 64 * 65536) 200 if (block_size > 64 * 65536)
201 { 201 {
@@ -265,7 +265,7 @@ namecache_postgres_lookup_block (void *cls,
265 } 265 }
266 if ((bsize < sizeof(*block)) || 266 if ((bsize < sizeof(*block)) ||
267 (bsize != ntohl (block->purpose.size) 267 (bsize != ntohl (block->purpose.size)
268 + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey) 268 + sizeof(struct GNUNET_IDENTITY_PublicKey)
269 + sizeof(struct GNUNET_CRYPTO_EcdsaSignature))) 269 + sizeof(struct GNUNET_CRYPTO_EcdsaSignature)))
270 { 270 {
271 GNUNET_break (0); 271 GNUNET_break (0);
diff --git a/src/namecache/plugin_namecache_sqlite.c b/src/namecache/plugin_namecache_sqlite.c
index c9d79ba2d..33970631b 100644
--- a/src/namecache/plugin_namecache_sqlite.c
+++ b/src/namecache/plugin_namecache_sqlite.c
@@ -333,7 +333,7 @@ namecache_sqlite_cache_block (void *cls,
333 struct GNUNET_HashCode query; 333 struct GNUNET_HashCode query;
334 struct GNUNET_TIME_Absolute expiration; 334 struct GNUNET_TIME_Absolute expiration;
335 size_t block_size = ntohl (block->purpose.size) 335 size_t block_size = ntohl (block->purpose.size)
336 + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey) 336 + sizeof(struct GNUNET_IDENTITY_PublicKey)
337 + sizeof(struct GNUNET_CRYPTO_EcdsaSignature); 337 + sizeof(struct GNUNET_CRYPTO_EcdsaSignature);
338 struct GNUNET_SQ_QueryParam del_params[] = { 338 struct GNUNET_SQ_QueryParam del_params[] = {
339 GNUNET_SQ_query_param_auto_from_type (&query), 339 GNUNET_SQ_query_param_auto_from_type (&query),
@@ -357,7 +357,7 @@ namecache_sqlite_cache_block (void *cls,
357 namecache_sqlite_expire_blocks (plugin); 357 namecache_sqlite_expire_blocks (plugin);
358 } 358 }
359 GNUNET_CRYPTO_hash (&block->derived_key, 359 GNUNET_CRYPTO_hash (&block->derived_key,
360 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey), 360 sizeof(block->derived_key),
361 &query); 361 &query);
362 expiration = GNUNET_TIME_absolute_ntoh (block->expiration_time); 362 expiration = GNUNET_TIME_absolute_ntoh (block->expiration_time);
363 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 363 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -500,7 +500,7 @@ namecache_sqlite_lookup_block (void *cls,
500 } 500 }
501 else if ((block_size < sizeof(struct GNUNET_GNSRECORD_Block)) || 501 else if ((block_size < sizeof(struct GNUNET_GNSRECORD_Block)) ||
502 (ntohl (block->purpose.size) 502 (ntohl (block->purpose.size)
503 + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey) 503 + sizeof(struct GNUNET_IDENTITY_PublicKey)
504 + sizeof(struct GNUNET_CRYPTO_EcdsaSignature) != block_size)) 504 + sizeof(struct GNUNET_CRYPTO_EcdsaSignature) != block_size))
505 { 505 {
506 GNUNET_break (0); 506 GNUNET_break (0);
diff --git a/src/namecache/test_namecache_api_cache_block.c b/src/namecache/test_namecache_api_cache_block.c
index 12b72d93b..310c4de42 100644
--- a/src/namecache/test_namecache_api_cache_block.c
+++ b/src/namecache/test_namecache_api_cache_block.c
@@ -39,9 +39,9 @@ static struct GNUNET_NAMECACHE_Handle *nsh;
39 39
40static struct GNUNET_SCHEDULER_Task *endbadly_task; 40static struct GNUNET_SCHEDULER_Task *endbadly_task;
41 41
42static struct GNUNET_CRYPTO_EcdsaPrivateKey privkey; 42static struct GNUNET_IDENTITY_PrivateKey privkey;
43 43
44static struct GNUNET_CRYPTO_EcdsaPublicKey pubkey; 44static struct GNUNET_IDENTITY_PublicKey pubkey;
45 45
46static int res; 46static int res;
47 47
@@ -172,23 +172,13 @@ run (void *cls,
172{ 172{
173 struct GNUNET_GNSRECORD_Data rd; 173 struct GNUNET_GNSRECORD_Data rd;
174 struct GNUNET_GNSRECORD_Block *block; 174 struct GNUNET_GNSRECORD_Block *block;
175 char *hostkey_file;
176 const char *name = "dummy.dummy.gnunet"; 175 const char *name = "dummy.dummy.gnunet";
177 176
178 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 177 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
179 &endbadly, NULL); 178 &endbadly, NULL);
180 GNUNET_asprintf (&hostkey_file, 179 privkey.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY);
181 "zonefiles%s%s", 180 GNUNET_CRYPTO_ecdsa_key_create (&privkey.ecdsa_key);
182 DIR_SEPARATOR_STR, 181 GNUNET_IDENTITY_key_get_public (&privkey, &pubkey);
183 "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
184 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n",
185 hostkey_file);
186 GNUNET_assert (GNUNET_SYSERR !=
187 GNUNET_CRYPTO_ecdsa_key_from_file (hostkey_file,
188 GNUNET_YES,
189 &privkey));
190 GNUNET_free (hostkey_file);
191 GNUNET_CRYPTO_ecdsa_key_get_public (&privkey, &pubkey);
192 182
193 183
194 rd.expiration_time = GNUNET_TIME_absolute_get ().abs_value_us + 10000000000; 184 rd.expiration_time = GNUNET_TIME_absolute_get ().abs_value_us + 10000000000;