aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-09-18 13:53:39 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-09-18 13:53:39 +0000
commit4e27ba9acbde9726ea29ccb4fbcc1afdfb80de8c (patch)
tree9b35525a2ba0b110391522f3cff7fe16265fe731 /src
parenta20d199156116af29256197c72ea9168fc78fc5f (diff)
downloadgnunet-4e27ba9acbde9726ea29ccb4fbcc1afdfb80de8c.tar.gz
gnunet-4e27ba9acbde9726ea29ccb4fbcc1afdfb80de8c.zip
-short hash output func
Diffstat (limited to 'src')
-rw-r--r--src/gns/gnunet-service-gns.c2
-rw-r--r--src/include/gnunet_common.h35
-rw-r--r--src/include/gnunet_crypto_lib.h11
-rw-r--r--src/util/common_logging.c37
4 files changed, 73 insertions, 12 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index d3f7ffabf..18bb26fe8 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -412,7 +412,7 @@ put_gns_record(void *cls,
412 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 412 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
413 _("Records for name `%s' in zone %s too large to fit into DHT"), 413 _("Records for name `%s' in zone %s too large to fit into DHT"),
414 name, 414 name,
415 GNUNET_h2s (&zhash) /* FIXME: write converter for short hash... */); 415 GNUNET_short_h2s (&zhash));
416 GNUNET_free(nrb); 416 GNUNET_free(nrb);
417 zone_update_taskid = GNUNET_SCHEDULER_add_now (&update_zone_dht_next, 417 zone_update_taskid = GNUNET_SCHEDULER_add_now (&update_zone_dht_next,
418 NULL); 418 NULL);
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index dae3d4945..60bf191c6 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -247,6 +247,16 @@ struct GNUNET_HashCode
247 247
248 248
249/** 249/**
250 * FIXME
251 * @brief 256-bit hashcode
252 **/
253struct GNUNET_CRYPTO_ShortHashCode
254{
255 uint32_t bits[256 / 8 / sizeof (uint32_t)]; /* = 8 */
256};
257
258
259/**
250 * The identity of the host (basically the SHA-512 hashcode of 260 * The identity of the host (basically the SHA-512 hashcode of
251 * it's public key). 261 * it's public key).
252 */ 262 */
@@ -438,6 +448,31 @@ GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls);
438 448
439 449
440/** 450/**
451 * Convert a short hash value to a string (for printing debug messages).
452 * This is one of the very few calls in the entire API that is
453 * NOT reentrant!
454 *
455 * @param hc the short hash code
456 * @return string
457 */
458const char *
459GNUNET_short_h2s (const struct GNUNET_CRYPTO_ShortHashCode * hc);
460
461
462/**
463 * Convert a short hash value to a string (for printing debug messages).
464 * This prints all 104 characters of a hashcode!
465 * This is one of the very few calls in the entire API that is
466 * NOT reentrant!
467 *
468 * @param hc the short hash code
469 * @return string
470 */
471const char *
472GNUNET_short_h2s_full (const struct GNUNET_CRYPTO_ShortHashCode * hc);
473
474
475/**
441 * Convert a hash value to a string (for printing debug messages). 476 * Convert a hash value to a string (for printing debug messages).
442 * This is one of the very few calls in the entire API that is 477 * This is one of the very few calls in the entire API that is
443 * NOT reentrant! 478 * NOT reentrant!
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index 710ef3179..57fcf8bc0 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -137,17 +137,6 @@ struct GNUNET_CRYPTO_HashAsciiEncoded
137}; 137};
138 138
139 139
140
141
142/**
143 * @brief 256-bit hashcode
144 */
145struct GNUNET_CRYPTO_ShortHashCode
146{
147 uint32_t bits[256 / 8 / sizeof (uint32_t)]; /* = 8 */
148};
149
150
151/** 140/**
152 * @brief 0-terminated ASCII encoding of a 'struct GNUNET_ShortHashCode'. 141 * @brief 0-terminated ASCII encoding of a 'struct GNUNET_ShortHashCode'.
153 */ 142 */
diff --git a/src/util/common_logging.c b/src/util/common_logging.c
index fbc0de50c..6161d0c6d 100644
--- a/src/util/common_logging.c
+++ b/src/util/common_logging.c
@@ -1012,6 +1012,43 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind)
1012 1012
1013 1013
1014/** 1014/**
1015 * Convert a short hash to a string (for printing debug messages).
1016 * This is one of the very few calls in the entire API that is
1017 * NOT reentrant!
1018 *
1019 * @param hc the short hash code
1020 * @return string form; will be overwritten by next call to GNUNET_h2s.
1021 */
1022const char *
1023GNUNET_short_h2s (const struct GNUNET_CRYPTO_ShortHashCode * hc)
1024{
1025 static struct GNUNET_CRYPTO_ShortHashAsciiEncoded ret;
1026
1027 GNUNET_CRYPTO_short_hash_to_enc (hc, &ret);
1028 ret.short_encoding[8] = '\0';
1029 return (const char *) ret.short_encoding;
1030}
1031
1032
1033/**
1034 * Convert a short hash to a string (for printing debug messages).
1035 * This is one of the very few calls in the entire API that is
1036 * NOT reentrant!
1037 *
1038 * @param hc the short hash code
1039 * @return string form; will be overwritten by next call to GNUNET_h2s_full.
1040 */
1041const char *
1042GNUNET_short_h2s_full (const struct GNUNET_CRYPTO_ShortHashCode * hc)
1043{
1044 static struct GNUNET_CRYPTO_ShortHashAsciiEncoded ret;
1045
1046 GNUNET_CRYPTO_short_hash_to_enc (hc, &ret);
1047 ret.short_encoding[sizeof (ret) - 1] = '\0';
1048 return (const char *) ret.short_encoding;
1049}
1050
1051/**
1015 * Convert a hash to a string (for printing debug messages). 1052 * Convert a hash to a string (for printing debug messages).
1016 * This is one of the very few calls in the entire API that is 1053 * This is one of the very few calls in the entire API that is
1017 * NOT reentrant! 1054 * NOT reentrant!