aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_uri.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-10 14:38:55 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-10 14:38:55 +0000
commit9351b1e9bdf2b067b6db06562c26ba658cff42b8 (patch)
tree68dc4ab447e7e8b6a20a706858cd36238c1c7c5f /src/fs/fs_uri.c
parent8beabcd96c0cf1e1873c0b5ff96e537f1beb0b34 (diff)
downloadgnunet-9351b1e9bdf2b067b6db06562c26ba658cff42b8.tar.gz
gnunet-9351b1e9bdf2b067b6db06562c26ba658cff42b8.zip
separating ECC crypto into functions/structs for ECDHE, ECDSA and EDDSA
Diffstat (limited to 'src/fs/fs_uri.c')
-rw-r--r--src/fs/fs_uri.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c
index e64fabeba..578fc6820 100644
--- a/src/fs/fs_uri.c
+++ b/src/fs/fs_uri.c
@@ -118,7 +118,7 @@ GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri,
118 case GNUNET_FS_URI_LOC: 118 case GNUNET_FS_URI_LOC:
119 GNUNET_CRYPTO_hash (&uri->data.loc.fi, 119 GNUNET_CRYPTO_hash (&uri->data.loc.fi,
120 sizeof (struct FileIdentifier) + 120 sizeof (struct FileIdentifier) +
121 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey), 121 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
122 key); 122 key);
123 break; 123 break;
124 default: 124 default:
@@ -357,7 +357,7 @@ static struct GNUNET_FS_Uri *
357uri_sks_parse (const char *s, char **emsg) 357uri_sks_parse (const char *s, char **emsg)
358{ 358{
359 struct GNUNET_FS_Uri *ret; 359 struct GNUNET_FS_Uri *ret;
360 struct GNUNET_CRYPTO_EccPublicSignKey ns; 360 struct GNUNET_CRYPTO_EcdsaPublicKey ns;
361 size_t pos; 361 size_t pos;
362 char *end; 362 char *end;
363 363
@@ -559,7 +559,7 @@ uri_loc_parse (const char *s, char **emsg)
559 unsigned long long exptime; 559 unsigned long long exptime;
560 unsigned long long flen; 560 unsigned long long flen;
561 struct GNUNET_TIME_Absolute et; 561 struct GNUNET_TIME_Absolute et;
562 struct GNUNET_CRYPTO_EccSignature sig; 562 struct GNUNET_CRYPTO_EddsaSignature sig;
563 struct LocUriAssembly ass; 563 struct LocUriAssembly ass;
564 int ret; 564 int ret;
565 size_t slen; 565 size_t slen;
@@ -604,7 +604,7 @@ uri_loc_parse (const char *s, char **emsg)
604 npos++; 604 npos++;
605 ret = 605 ret =
606 enc2bin (&s[npos], &ass.peer, 606 enc2bin (&s[npos], &ass.peer,
607 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey)); 607 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
608 if (ret == -1) 608 if (ret == -1)
609 { 609 {
610 *emsg = 610 *emsg =
@@ -617,7 +617,7 @@ uri_loc_parse (const char *s, char **emsg)
617 *emsg = GNUNET_strdup (_("SKS URI malformed (could not find signature)")); 617 *emsg = GNUNET_strdup (_("SKS URI malformed (could not find signature)"));
618 goto ERR; 618 goto ERR;
619 } 619 }
620 ret = enc2bin (&s[npos], &sig, sizeof (struct GNUNET_CRYPTO_EccSignature)); 620 ret = enc2bin (&s[npos], &sig, sizeof (struct GNUNET_CRYPTO_EcdsaSignature));
621 if (ret == -1) 621 if (ret == -1)
622 { 622 {
623 *emsg = GNUNET_strdup (_("SKS URI malformed (could not decode signature)")); 623 *emsg = GNUNET_strdup (_("SKS URI malformed (could not decode signature)"));
@@ -641,8 +641,8 @@ uri_loc_parse (const char *s, char **emsg)
641 et.abs_value_us = exptime * 1000LL * 1000LL; 641 et.abs_value_us = exptime * 1000LL * 1000LL;
642 ass.exptime = GNUNET_TIME_absolute_hton (et); 642 ass.exptime = GNUNET_TIME_absolute_hton (et);
643 if (GNUNET_OK != 643 if (GNUNET_OK !=
644 GNUNET_CRYPTO_ecc_verify (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT, 644 GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT,
645 &ass.purpose, &sig, &ass.peer.public_key)) 645 &ass.purpose, &sig, &ass.peer.public_key))
646 { 646 {
647 *emsg = 647 *emsg =
648 GNUNET_strdup (_("SKS URI malformed (signature failed validation)")); 648 GNUNET_strdup (_("SKS URI malformed (signature failed validation)"));
@@ -894,8 +894,8 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri,
894 struct GNUNET_TIME_Absolute expiration_time) 894 struct GNUNET_TIME_Absolute expiration_time)
895{ 895{
896 struct GNUNET_FS_Uri *uri; 896 struct GNUNET_FS_Uri *uri;
897 struct GNUNET_CRYPTO_EccPrivateKey *my_private_key; 897 struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key;
898 struct GNUNET_CRYPTO_EccPublicSignKey my_public_key; 898 struct GNUNET_CRYPTO_EddsaPublicKey my_public_key;
899 char *keyfile; 899 char *keyfile;
900 struct LocUriAssembly ass; 900 struct LocUriAssembly ass;
901 struct GNUNET_TIME_Absolute et; 901 struct GNUNET_TIME_Absolute et;
@@ -910,7 +910,7 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri,
910 _("Lacking key configuration settings.\n")); 910 _("Lacking key configuration settings.\n"));
911 return NULL; 911 return NULL;
912 } 912 }
913 if (NULL == (my_private_key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile))) 913 if (NULL == (my_private_key = GNUNET_CRYPTO_eddsa_key_create_from_file (keyfile)))
914 { 914 {
915 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 915 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
916 _("Could not access hostkey file `%s'.\n"), keyfile); 916 _("Could not access hostkey file `%s'.\n"), keyfile);
@@ -920,7 +920,7 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri,
920 GNUNET_free (keyfile); 920 GNUNET_free (keyfile);
921 /* we round expiration time to full seconds for SKS URIs */ 921 /* we round expiration time to full seconds for SKS URIs */
922 et.abs_value_us = (expiration_time.abs_value_us / 1000000LL) * 1000000LL; 922 et.abs_value_us = (expiration_time.abs_value_us / 1000000LL) * 1000000LL;
923 GNUNET_CRYPTO_ecc_key_get_public_for_signature (my_private_key, &my_public_key); 923 GNUNET_CRYPTO_eddsa_key_get_public (my_private_key, &my_public_key);
924 ass.purpose.size = htonl (sizeof (struct LocUriAssembly)); 924 ass.purpose.size = htonl (sizeof (struct LocUriAssembly));
925 ass.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT); 925 ass.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT);
926 ass.exptime = GNUNET_TIME_absolute_hton (et); 926 ass.exptime = GNUNET_TIME_absolute_hton (et);
@@ -932,8 +932,8 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri,
932 uri->data.loc.expirationTime = et; 932 uri->data.loc.expirationTime = et;
933 uri->data.loc.peer.public_key = my_public_key; 933 uri->data.loc.peer.public_key = my_public_key;
934 GNUNET_assert (GNUNET_OK == 934 GNUNET_assert (GNUNET_OK ==
935 GNUNET_CRYPTO_ecc_sign (my_private_key, &ass.purpose, 935 GNUNET_CRYPTO_eddsa_sign (my_private_key, &ass.purpose,
936 &uri->data.loc.contentSignature)); 936 &uri->data.loc.contentSignature));
937 GNUNET_free (my_private_key); 937 GNUNET_free (my_private_key);
938 return uri; 938 return uri;
939} 939}
@@ -947,7 +947,7 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri,
947 * @return an FS URI for the given namespace and identifier 947 * @return an FS URI for the given namespace and identifier
948 */ 948 */
949struct GNUNET_FS_Uri * 949struct GNUNET_FS_Uri *
950GNUNET_FS_uri_sks_create (const struct GNUNET_CRYPTO_EccPublicSignKey *ns, 950GNUNET_FS_uri_sks_create (const struct GNUNET_CRYPTO_EcdsaPublicKey *ns,
951 const char *id) 951 const char *id)
952{ 952{
953 struct GNUNET_FS_Uri *ns_uri; 953 struct GNUNET_FS_Uri *ns_uri;
@@ -1258,7 +1258,7 @@ GNUNET_FS_uri_test_equal (const struct GNUNET_FS_Uri *u1,
1258 case GNUNET_FS_URI_SKS: 1258 case GNUNET_FS_URI_SKS:
1259 if ((0 == 1259 if ((0 ==
1260 memcmp (&u1->data.sks.ns, &u2->data.sks.ns, 1260 memcmp (&u1->data.sks.ns, &u2->data.sks.ns,
1261 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey))) && 1261 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) &&
1262 (0 == strcmp (u1->data.sks.identifier, u2->data.sks.identifier))) 1262 (0 == strcmp (u1->data.sks.identifier, u2->data.sks.identifier)))
1263 1263
1264 return GNUNET_YES; 1264 return GNUNET_YES;
@@ -1285,7 +1285,7 @@ GNUNET_FS_uri_test_equal (const struct GNUNET_FS_Uri *u1,
1285 if (memcmp 1285 if (memcmp
1286 (&u1->data.loc, &u2->data.loc, 1286 (&u1->data.loc, &u2->data.loc,
1287 sizeof (struct FileIdentifier) + 1287 sizeof (struct FileIdentifier) +
1288 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey) + 1288 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) +
1289 sizeof (struct GNUNET_TIME_Absolute) + sizeof (unsigned short) + 1289 sizeof (struct GNUNET_TIME_Absolute) + sizeof (unsigned short) +
1290 sizeof (unsigned short)) != 0) 1290 sizeof (unsigned short)) != 0)
1291 return GNUNET_NO; 1291 return GNUNET_NO;
@@ -1319,7 +1319,7 @@ GNUNET_FS_uri_test_sks (const struct GNUNET_FS_Uri *uri)
1319 */ 1319 */
1320int 1320int
1321GNUNET_FS_uri_sks_get_namespace (const struct GNUNET_FS_Uri *uri, 1321GNUNET_FS_uri_sks_get_namespace (const struct GNUNET_FS_Uri *uri,
1322 struct GNUNET_CRYPTO_EccPublicSignKey *pseudonym) 1322 struct GNUNET_CRYPTO_EcdsaPublicKey *pseudonym)
1323{ 1323{
1324 if (!GNUNET_FS_uri_test_sks (uri)) 1324 if (!GNUNET_FS_uri_test_sks (uri))
1325 { 1325 {
@@ -1927,7 +1927,7 @@ uri_sks_to_string (const struct GNUNET_FS_Uri *uri)
1927 if (GNUNET_FS_URI_SKS != uri->type) 1927 if (GNUNET_FS_URI_SKS != uri->type)
1928 return NULL; 1928 return NULL;
1929 ret = GNUNET_STRINGS_data_to_string (&uri->data.sks.ns, 1929 ret = GNUNET_STRINGS_data_to_string (&uri->data.sks.ns,
1930 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey), 1930 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
1931 buf, 1931 buf,
1932 sizeof (buf)); 1932 sizeof (buf));
1933 GNUNET_assert (NULL != ret); 1933 GNUNET_assert (NULL != ret);
@@ -2032,10 +2032,10 @@ uri_loc_to_string (const struct GNUNET_FS_Uri *uri)
2032 GNUNET_CRYPTO_hash_to_enc (&uri->data.loc.fi.chk.query, &queryhash); 2032 GNUNET_CRYPTO_hash_to_enc (&uri->data.loc.fi.chk.query, &queryhash);
2033 peerId = 2033 peerId =
2034 bin2enc (&uri->data.loc.peer, 2034 bin2enc (&uri->data.loc.peer,
2035 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey)); 2035 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
2036 peerSig = 2036 peerSig =
2037 bin2enc (&uri->data.loc.contentSignature, 2037 bin2enc (&uri->data.loc.contentSignature,
2038 sizeof (struct GNUNET_CRYPTO_EccSignature)); 2038 sizeof (struct GNUNET_CRYPTO_EcdsaSignature));
2039 GNUNET_asprintf (&ret, 2039 GNUNET_asprintf (&ret,
2040 "%s%s%s.%s.%llu.%s.%s.%llu", GNUNET_FS_URI_PREFIX, 2040 "%s%s%s.%s.%llu.%s.%s.%llu", GNUNET_FS_URI_PREFIX,
2041 GNUNET_FS_URI_LOC_INFIX, (const char *) &keyhash, 2041 GNUNET_FS_URI_LOC_INFIX, (const char *) &keyhash,