aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_crypto_lib.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-03-04 13:51:40 +0000
committerChristian Grothoff <christian@grothoff.org>2012-03-04 13:51:40 +0000
commit6a9425ddc6fa5de32bb97f05b46ab47c01106f80 (patch)
tree79211ae367b020cc79b103dab23b5e9d7c99688c /src/include/gnunet_crypto_lib.h
parent5c130e7d8357711b3646a39813670885c0891633 (diff)
downloadgnunet-6a9425ddc6fa5de32bb97f05b46ab47c01106f80.tar.gz
gnunet-6a9425ddc6fa5de32bb97f05b46ab47c01106f80.zip
LRN: adding generic functions for conversion of binary data to ascii and back: GNUNET_CRYPTO_string_to_data and GNUNET_CRYPTO_data_to_string
Diffstat (limited to 'src/include/gnunet_crypto_lib.h')
-rw-r--r--src/include/gnunet_crypto_lib.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index 3d2c946b0..640df8b0b 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -916,6 +916,39 @@ GNUNET_CRYPTO_rsa_verify (uint32_t purpose,
916void 916void
917GNUNET_CRYPTO_random_disable_entropy_gathering (void); 917GNUNET_CRYPTO_random_disable_entropy_gathering (void);
918 918
919/**
920 * Convert binary data to ASCII encoding. The ASCII encoding is rather
921 * GNUnet specific. It was chosen such that it only uses characters
922 * in [0-9A-V], can be produced without complex arithmetics and uses a
923 * small number of characters. The GNUnet encoding uses 103 characters.
924 * Does not append 0-terminator, but returns a pointer to the place where
925 * it should be placed, if needed.
926 *
927 * @param data data to encode
928 * @param size size of data (in bytes)
929 * @param out buffer to fill
930 * @param out_size size of the buffer. Must be large enough to hold
931 * ((size*8) + (((size*8) % 5) > 0 ? 5 - ((size*8) % 5) : 0)) / 5
932 * @return pointer to the next byte in 'out' or NULL on error.
933 */
934char *
935GNUNET_CRYPTO_data_to_string (unsigned char *data, size_t size,
936 char *out, size_t out_size);
937
938/**
939 * Convert ASCII encoding back to data
940 * out_size must match exactly the size of the data before it was encoded.
941 *
942 * @param enc the encoding
943 * @param enclen number of characters in 'enc' (without 0-terminator, which can be missing)
944 * @param out location where to store the decoded data
945 * @param out_size sizeof the output buffer
946 * @return GNUNET_OK on success, GNUNET_SYSERR if result has the wrong encoding
947 */
948int
949GNUNET_CRYPTO_string_to_data (const char *enc, size_t enclen,
950 unsigned char *out, size_t out_size);
951
919#if 0 /* keep Emacsens' auto-indent happy */ 952#if 0 /* keep Emacsens' auto-indent happy */
920{ 953{
921#endif 954#endif