]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Move sha1.[ch] to crypt.[ch] and make crypto API independent of sha1.
authorAndre Noll <maan@systemlinux.org>
Mon, 28 Feb 2011 23:28:27 +0000 (00:28 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 27 Mar 2011 14:43:11 +0000 (16:43 +0200)
This patch moves all public functions related to sha1 to crypt.c. This
allows to remove sha1.c, sha1.h and hash.h. It also removes the
HASH_TYPE define and avoids the word "sha1" in the public API and
its callers. The former sha1_hash() is now called hash_function().

12 files changed:
afs.h
aft.c
client_common.c
command.c
configure.ac
crypt.c
crypt.h
error.h
hash.h [deleted file]
server.c
sha1.c [deleted file]
sha1.h [deleted file]

diff --git a/afs.h b/afs.h
index 7a93183e40ec4795ca60ed95a412956109f49a68..f54aa87ccbc3c2ad0a3ab44b054f22a6560aaa85 100644 (file)
--- a/afs.h
+++ b/afs.h
@@ -7,7 +7,6 @@
 /** \file afs.h Exported symbols of the audio file selector. */
 
 #include <regex.h>
 /** \file afs.h Exported symbols of the audio file selector. */
 
 #include <regex.h>
-#include "hash.h"
 
 /** Audio file selector data stored in the audio file table. */
 struct afs_info {
 
 /** Audio file selector data stored in the audio file table. */
 struct afs_info {
@@ -119,8 +118,8 @@ struct ls_data {
        char *path;
        /** The score value (if -a was given). */
        long score;
        char *path;
        /** The score value (if -a was given). */
        long score;
-       /** The sha1 hash of audio file. */
-       HASH_TYPE *hash;
+       /** The hash value of audio file data. */
+       unsigned char *hash;
 };
 
 /** Data about the current audio file, passed from afs to server. */
 };
 
 /** Data about the current audio file, passed from afs to server. */
diff --git a/aft.c b/aft.c
index 9911b7fbadd7e3d58a25ceedd79ec0e1ce419f31..bcfe7e7d070198784875824c1902520c73028cc5 100644 (file)
--- a/aft.c
+++ b/aft.c
@@ -238,7 +238,7 @@ enum audio_file_table_columns {
  */
 static int aft_hash_compare(const struct osl_object *obj1, const struct osl_object *obj2)
 {
  */
 static int aft_hash_compare(const struct osl_object *obj1, const struct osl_object *obj2)
 {
-       return hash_compare((HASH_TYPE *)obj1->data, (HASH_TYPE *)obj2->data);
+       return hash_compare((unsigned char *)obj1->data, (unsigned char *)obj2->data);
 }
 
 static struct osl_column_description aft_cols[] = {
 }
 
 static struct osl_column_description aft_cols[] = {
@@ -485,7 +485,7 @@ int aft_get_row_of_path(const char *path, struct osl_row **row)
  *
  * \return Standard.
  */
  *
  * \return Standard.
  */
-static int aft_get_row_of_hash(HASH_TYPE *hash, struct osl_row **row)
+static int aft_get_row_of_hash(unsigned char *hash, struct osl_row **row)
 {
        const struct osl_object obj = {.data = hash, .size = HASH_SIZE};
        return osl(osl_get_row(audio_file_table, AFTCOL_HASH, &obj, row));
 {
        const struct osl_object obj = {.data = hash, .size = HASH_SIZE};
        return osl(osl_get_row(audio_file_table, AFTCOL_HASH, &obj, row));
@@ -605,7 +605,7 @@ static int get_hash_object_of_aft_row(const struct osl_row *row,
  * \return The return value of the underlying call to
  * get_hash_object_of_aft_row().
  */
  * \return The return value of the underlying call to
  * get_hash_object_of_aft_row().
  */
-static int get_hash_of_row(const struct osl_row *row, HASH_TYPE **hash)
+static int get_hash_of_row(const struct osl_row *row, unsigned char **hash)
 {
        struct osl_object obj;
        int ret = get_hash_object_of_aft_row(row, &obj);
 {
        struct osl_object obj;
        int ret = get_hash_object_of_aft_row(row, &obj);
@@ -1026,7 +1026,7 @@ out:
 
 static int make_status_items(struct audio_file_data *afd,
                struct afs_info *afsi, char *path, long score,
 
 static int make_status_items(struct audio_file_data *afd,
                struct afs_info *afsi, char *path, long score,
-               HASH_TYPE *hash)
+               unsigned char *hash)
 {
        struct ls_data d = {
                .afhi = afd->afhi,
 {
        struct ls_data d = {
                .afhi = afd->afhi,
@@ -1079,7 +1079,7 @@ static int make_status_items(struct audio_file_data *afd,
 int open_and_update_audio_file(struct osl_row *aft_row, long score,
        struct audio_file_data *afd)
 {
 int open_and_update_audio_file(struct osl_row *aft_row, long score,
        struct audio_file_data *afd)
 {
-       HASH_TYPE *aft_hash, file_hash[HASH_SIZE];
+       unsigned char *aft_hash, file_hash[HASH_SIZE];
        struct osl_object afsi_obj;
        struct afs_info old_afsi, new_afsi;
        int ret = get_hash_of_row(aft_row, &aft_hash);
        struct osl_object afsi_obj;
        struct afs_info old_afsi, new_afsi;
        int ret = get_hash_of_row(aft_row, &aft_hash);
@@ -1526,7 +1526,7 @@ int audio_file_loop(void *private_data, osl_rbtree_loop_func *func)
                func));
 }
 
                func));
 }
 
-static struct osl_row *find_hash_sister(HASH_TYPE *hash)
+static struct osl_row *find_hash_sister(unsigned char *hash)
 {
        const struct osl_object obj = {.data = hash, .size = HASH_SIZE};
        struct osl_row *row;
 {
        const struct osl_object obj = {.data = hash, .size = HASH_SIZE};
        struct osl_row *row;
@@ -1558,7 +1558,7 @@ enum com_add_buffer_offsets {
  * It's OK to call this with afhi == NULL. In this case, the audio format
  * handler info won't be stored in the buffer.
  */
  * It's OK to call this with afhi == NULL. In this case, the audio format
  * handler info won't be stored in the buffer.
  */
-static void save_add_callback_buffer(HASH_TYPE *hash, const char *path,
+static void save_add_callback_buffer(unsigned char *hash, const char *path,
                struct afh_info *afhi, uint32_t flags,
                uint8_t audio_format_num, struct osl_object *obj)
 {
                struct afh_info *afhi, uint32_t flags,
                uint8_t audio_format_num, struct osl_object *obj)
 {
@@ -1661,7 +1661,7 @@ static void com_add_callback(int fd, const struct osl_object *query)
        struct osl_row *pb, *aft_row;
        struct osl_row *hs;
        struct osl_object objs[NUM_AFT_COLUMNS];
        struct osl_row *pb, *aft_row;
        struct osl_row *hs;
        struct osl_object objs[NUM_AFT_COLUMNS];
-       HASH_TYPE *hash;
+       unsigned char *hash;
        char asc[2 * HASH_SIZE + 1];
        int ret;
        char afsi_buf[AFSI_SIZE];
        char asc[2 * HASH_SIZE + 1];
        int ret;
        char afsi_buf[AFSI_SIZE];
@@ -1671,7 +1671,7 @@ static void com_add_callback(int fd, const struct osl_object *query)
                .max_size_handler = pass_buffer_as_shm, .private_data = &fd};
        uint16_t afhi_offset, chunks_offset;
 
                .max_size_handler = pass_buffer_as_shm, .private_data = &fd};
        uint16_t afhi_offset, chunks_offset;
 
-       hash = (HASH_TYPE *)buf + CAB_HASH_OFFSET;
+       hash = (unsigned char *)buf + CAB_HASH_OFFSET;
        hash_to_asc(hash, asc);;
        objs[AFTCOL_HASH].data = buf + CAB_HASH_OFFSET;
        objs[AFTCOL_HASH].size = HASH_SIZE;
        hash_to_asc(hash, asc);;
        objs[AFTCOL_HASH].data = buf + CAB_HASH_OFFSET;
        objs[AFTCOL_HASH].size = HASH_SIZE;
@@ -1736,7 +1736,7 @@ static void com_add_callback(int fd, const struct osl_object *query)
        objs[AFTCOL_CHUNKS].size = query->size - chunks_offset;
        if (pb && !hs) { /* update pb's hash */
                char old_asc[2 * HASH_SIZE + 1];
        objs[AFTCOL_CHUNKS].size = query->size - chunks_offset;
        if (pb && !hs) { /* update pb's hash */
                char old_asc[2 * HASH_SIZE + 1];
-               HASH_TYPE *old_hash;
+               unsigned char *old_hash;
                ret = get_hash_of_row(pb, &old_hash);
                if (ret < 0)
                        goto out;
                ret = get_hash_of_row(pb, &old_hash);
                if (ret < 0)
                        goto out;
@@ -1813,7 +1813,7 @@ static void path_brother_callback(int fd, const struct osl_object *query)
 
 static void hash_sister_callback(int fd, const struct osl_object *query)
 {
 
 static void hash_sister_callback(int fd, const struct osl_object *query)
 {
-       HASH_TYPE *hash = query->data;
+       unsigned char *hash = query->data;
        struct osl_row *hash_sister;
 
        hash_sister = find_hash_sister(hash);
        struct osl_row *hash_sister;
 
        hash_sister = find_hash_sister(hash);
@@ -1837,7 +1837,7 @@ static int add_one_audio_file(const char *path, void *private_data)
        struct afh_info afhi, *afhi_ptr = NULL;
        struct osl_row *pb = NULL, *hs = NULL; /* path brother/hash sister */
        struct osl_object map, obj = {.data = NULL}, query;
        struct afh_info afhi, *afhi_ptr = NULL;
        struct osl_row *pb = NULL, *hs = NULL; /* path brother/hash sister */
        struct osl_object map, obj = {.data = NULL}, query;
-       HASH_TYPE hash[HASH_SIZE];
+       unsigned char hash[HASH_SIZE];
 
        ret = guess_audio_format(path);
        if (ret < 0 && !(pad->flags & ADD_FLAG_ALL))
 
        ret = guess_audio_format(path);
        if (ret < 0 && !(pad->flags & ADD_FLAG_ALL))
index b5d34ed7b7d3d7a6cf8ee6f95eafa3facc776834..c7ea3b4cb0dde32a36c1a50ebdb72658b9ec47e2 100644 (file)
@@ -21,7 +21,6 @@
 #include "string.h"
 #include "client.cmdline.h"
 #include "client.h"
 #include "string.h"
 #include "client.cmdline.h"
 #include "client.h"
-#include "hash.h"
 #include "buffer_tree.h"
 
 /** The size of the receiving buffer. */
 #include "buffer_tree.h"
 
 /** The size of the receiving buffer. */
@@ -182,7 +181,7 @@ static void client_post_select(struct sched *s, struct task *t)
                /* decrypted challenge/session key buffer */
                unsigned char crypt_buf[1024];
                /* the SHA1 of the decrypted challenge */
                /* decrypted challenge/session key buffer */
                unsigned char crypt_buf[1024];
                /* the SHA1 of the decrypted challenge */
-               unsigned char challenge_sha1[HASH_SIZE];
+               unsigned char challenge_hash[HASH_SIZE];
 
                ret = client_recv_buffer(ct, &s->rfds, buf, sizeof(buf), &n);
                if (ret < 0 || n == 0)
 
                ret = client_recv_buffer(ct, &s->rfds, buf, sizeof(buf), &n);
                if (ret < 0 || n == 0)
@@ -192,13 +191,13 @@ static void client_post_select(struct sched *s, struct task *t)
                        (unsigned char *)buf, n);
                if (ret < 0)
                        goto out;
                        (unsigned char *)buf, n);
                if (ret < 0)
                        goto out;
-               sha1_hash((char *)crypt_buf, CHALLENGE_SIZE, challenge_sha1);
+               hash_function((char *)crypt_buf, CHALLENGE_SIZE, challenge_hash);
                ct->scc.send = sc_new(crypt_buf + CHALLENGE_SIZE, SESSION_KEY_LEN);
                ct->scc.recv = sc_new(crypt_buf + CHALLENGE_SIZE + SESSION_KEY_LEN,
                        SESSION_KEY_LEN);
                ct->scc.send = sc_new(crypt_buf + CHALLENGE_SIZE, SESSION_KEY_LEN);
                ct->scc.recv = sc_new(crypt_buf + CHALLENGE_SIZE + SESSION_KEY_LEN,
                        SESSION_KEY_LEN);
-               hash_to_asc(challenge_sha1, buf);
+               hash_to_asc(challenge_hash, buf);
                PARA_INFO_LOG("--> %s\n", buf);
                PARA_INFO_LOG("--> %s\n", buf);
-               ret = send_bin_buffer(ct->scc.fd, (char *)challenge_sha1,
+               ret = send_bin_buffer(ct->scc.fd, (char *)challenge_hash,
                        HASH_SIZE);
                if (ret < 0)
                        goto out;
                        HASH_SIZE);
                if (ret < 0)
                        goto out;
index ece87e168a7e42b406526a9638ef5bf7126cd45c..22a71444bf2c694bb76edc26705521d6930e19f0 100644 (file)
--- a/command.c
+++ b/command.c
@@ -730,7 +730,7 @@ __noreturn void handle_connect(int fd, const char *peername)
        int ret, argc;
        char buf[4096];
        unsigned char rand_buf[CHALLENGE_SIZE + 2 * SESSION_KEY_LEN];
        int ret, argc;
        char buf[4096];
        unsigned char rand_buf[CHALLENGE_SIZE + 2 * SESSION_KEY_LEN];
-       unsigned char challenge_sha1[HASH_SIZE];
+       unsigned char challenge_hash[HASH_SIZE];
        struct user *u;
        struct server_command *cmd = NULL;
        char **argv = NULL;
        struct user *u;
        struct server_command *cmd = NULL;
        char **argv = NULL;
@@ -795,14 +795,14 @@ __noreturn void handle_connect(int fd, const char *peername)
        if (!u)
                goto net_err;
        /*
        if (!u)
                goto net_err;
        /*
-        * The correct response is the sha1 of the first CHALLENGE_SIZE bytes
+        * The correct response is the hash of the first CHALLENGE_SIZE bytes
         * of the random data.
         */
        ret = -E_BAD_AUTH;
        if (numbytes != HASH_SIZE)
                goto net_err;
         * of the random data.
         */
        ret = -E_BAD_AUTH;
        if (numbytes != HASH_SIZE)
                goto net_err;
-       sha1_hash((char *)rand_buf, CHALLENGE_SIZE, challenge_sha1);
-       if (memcmp(challenge_sha1, buf, HASH_SIZE))
+       hash_function((char *)rand_buf, CHALLENGE_SIZE, challenge_hash);
+       if (memcmp(challenge_hash, buf, HASH_SIZE))
                goto net_err;
        /* auth successful */
        alarm(0);
                goto net_err;
        /* auth successful */
        alarm(0);
index e8b2118cdede3d2a1ebabbe751cbaf2b2b741cec..48f2958f21b8f76c8a58142bf480e8e759d6cdc5 100644 (file)
@@ -87,7 +87,7 @@ AC_DEFUN([add_cmdline],[$(for i in $@; do printf "${i}.cmdline "; done)])
 all_errlist_objs="server mp3_afh afh_common vss command net string signal time
 daemon stat crypt http_send close_on_fork ipc acl afh fade amp_filter
 dccp_send fd user_list chunk_queue afs aft mood score attribute blob ringbuffer
 all_errlist_objs="server mp3_afh afh_common vss command net string signal time
 daemon stat crypt http_send close_on_fork ipc acl afh fade amp_filter
 dccp_send fd user_list chunk_queue afs aft mood score attribute blob ringbuffer
-playlist sha1 sched audiod grab_client filter_common wav_filter compress_filter
+playlist sched audiod grab_client filter_common wav_filter compress_filter
 http_recv dccp_recv recv_common write_common file_write audiod_command
 client_common recv stdout filter stdin audioc write client exec send_common ggo
 udp_recv udp_send color fec fecdec_filter prebuffer_filter mm
 http_recv dccp_recv recv_common write_common file_write audiod_command
 client_common recv stdout filter stdin audioc write client exec send_common ggo
 udp_recv udp_send color fec fecdec_filter prebuffer_filter mm
@@ -118,7 +118,7 @@ audiod_cmdline_objs="add_cmdline(audiod compress_filter http_recv dccp_recv file
 audiod_errlist_objs="audiod signal string daemon stat net
        time grab_client filter_common wav_filter compress_filter amp_filter http_recv dccp_recv
        recv_common fd sched write_common file_write audiod_command crypt fecdec_filter
 audiod_errlist_objs="audiod signal string daemon stat net
        time grab_client filter_common wav_filter compress_filter amp_filter http_recv dccp_recv
        recv_common fd sched write_common file_write audiod_command crypt fecdec_filter
-       client_common ggo udp_recv color fec prebuffer_filter sha1 audiod_command_list
+       client_common ggo udp_recv color fec prebuffer_filter audiod_command_list
        bitstream imdct wma_common wmadec_filter buffer_tree"
 audiod_ldflags="-lm"
 audiod_audio_formats="wma"
        bitstream imdct wma_common wmadec_filter buffer_tree"
 audiod_ldflags="-lm"
 audiod_audio_formats="wma"
@@ -131,7 +131,7 @@ server_cmdline_objs="add_cmdline(server)"
 server_errlist_objs="server afh_common mp3_afh vss command net string signal
        time daemon crypt http_send close_on_fork mm
        ipc dccp_send fd user_list chunk_queue afs aft mood score attribute
 server_errlist_objs="server afh_common mp3_afh vss command net string signal
        time daemon crypt http_send close_on_fork mm
        ipc dccp_send fd user_list chunk_queue afs aft mood score attribute
-       blob playlist sha1 sched acl send_common udp_send color fec
+       blob playlist sched acl send_common udp_send color fec
        server_command_list afs_command_list wma_afh wma_common"
 server_ldflags=""
 server_audio_formats="mp3 wma"
        server_command_list afs_command_list wma_afh wma_common"
 server_ldflags=""
 server_audio_formats="mp3 wma"
@@ -145,7 +145,7 @@ default_writer="FILE_WRITE"
 
 client_cmdline_objs="add_cmdline(client)"
 client_errlist_objs="client net string crypt fd sched stdin stdout time
 
 client_cmdline_objs="add_cmdline(client)"
 client_errlist_objs="client net string crypt fd sched stdin stdout time
-       client_common sha1 buffer_tree"
+       client_common buffer_tree"
 client_ldflags=""
 
 gui_cmdline_objs="add_cmdline(gui)"
 client_ldflags=""
 
 gui_cmdline_objs="add_cmdline(gui)"
diff --git a/crypt.c b/crypt.c
index 99804470783c04e3758e8800f87f083c4e54f623..f3bfed3be755ccce6ba9ec1d89c40934babedc35 100644 (file)
--- a/crypt.c
+++ b/crypt.c
@@ -14,6 +14,7 @@
 #include <openssl/err.h>
 #include <openssl/rc4.h>
 #include <openssl/pem.h>
 #include <openssl/err.h>
 #include <openssl/rc4.h>
 #include <openssl/pem.h>
+#include <openssl/sha.h>
 
 #include "para.h"
 #include "error.h"
 
 #include "para.h"
 #include "error.h"
@@ -364,3 +365,22 @@ int sc_recv_buffer(struct stream_cipher_context *scc, char *buf, size_t size)
                *buf = '\0';
        return n;
 }
                *buf = '\0';
        return n;
 }
+
+/**
+ * Compute the hash of the given input data.
+ *
+ * \param data Pointer to the data to compute the hash value from.
+ * \param len The length of \a data in bytes.
+ * \param hash Result pointer.
+ *
+ * \a hash must point to an area at least \p HASH_SIZE bytes large.
+ *
+ * \sa sha(3), openssl(1).
+ * */
+void hash_function(const char *data, unsigned long len, unsigned char *hash)
+{
+       SHA_CTX c;
+       SHA1_Init(&c);
+       SHA1_Update(&c, data, len);
+       SHA1_Final(hash, &c);
+}
diff --git a/crypt.h b/crypt.h
index 0e0695e574ecbfcb6dd4c5491fa2f499329a8d14..21abe41f68cd8c5b335cc133b5c6f3050869c4ee 100644 (file)
--- a/crypt.h
+++ b/crypt.h
@@ -60,3 +60,52 @@ int sc_recv_buffer(struct stream_cipher_context *scc, char *buf, size_t size);
 #define LOAD_PRIVATE_KEY 1
 #define CHALLENGE_SIZE 64
 /** \endcond **/
 #define LOAD_PRIVATE_KEY 1
 #define CHALLENGE_SIZE 64
 /** \endcond **/
+
+/** Size of the hash value in bytes. */
+#define HASH_SIZE 20
+
+void hash_function(const char *data, unsigned long len, unsigned char *hash);
+
+/**
+ * Compare two hashes.
+ *
+ * \param h1 Pointer to the first hash value.
+ * \param h2 Pointer to the second hash value.
+ *
+ * \return 1, -1, or zero, depending on whether \a h1 is greater than,
+ * less than or equal to h2, respectively.
+ */
+_static_inline_ int hash_compare(unsigned char *h1, unsigned char *h2)
+{
+       int i;
+
+       for (i = 0; i < HASH_SIZE; i++) {
+               if (h1[i] < h2[i])
+                       return -1;
+               if (h1[i] > h2[i])
+                       return 1;
+       }
+       return 0;
+}
+
+/**
+ * Convert a hash value to ascii format.
+ *
+ * \param hash the hash value.
+ * \param asc Result pointer.
+ *
+ * \a asc must point to an area of at least 2 * \p HASH_SIZE + 1 bytes which
+ * will be filled by the function with the ascii representation of the hash
+ * value given by \a hash, and a terminating \p NULL byte.
+ */
+_static_inline_ void hash_to_asc(unsigned char *hash, char *asc)
+{
+       int i;
+       const char hexchar[] = "0123456789abcdef";
+
+       for (i = 0; i < HASH_SIZE; i++) {
+               asc[2 * i] = hexchar[hash[i] >> 4];
+               asc[2 * i + 1] = hexchar[hash[i] & 0xf];
+       }
+       asc[2 * HASH_SIZE] = '\0';
+}
diff --git a/error.h b/error.h
index de5dacf298667a9ccaf5708f921ddabcc8baf95b..564f1339dd9b51e4d0c4fc034c65d2aa6a7c6187 100644 (file)
--- a/error.h
+++ b/error.h
@@ -19,7 +19,6 @@ DEFINE_ERRLIST_OBJECT_ENUM;
 #define GUI_ERRORS
 #define RINGBUFFER_ERRORS
 #define SCORE_ERRORS
 #define GUI_ERRORS
 #define RINGBUFFER_ERRORS
 #define SCORE_ERRORS
-#define SHA1_ERRORS
 #define RBTREE_ERRORS
 #define RECV_ERRORS
 #define IPC_ERRORS
 #define RBTREE_ERRORS
 #define RECV_ERRORS
 #define IPC_ERRORS
diff --git a/hash.h b/hash.h
deleted file mode 100644 (file)
index 6dfddbe..0000000
--- a/hash.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2007-2011 Andre Noll <maan@systemlinux.org>
- *
- * Licensed under the GPL v2. For licencing details see COPYING.
- */
-
-/** \file hash.h Inline functions for hash values. */
-
-/** hash arrays are always unsigned char. */
-#define HASH_TYPE unsigned char
-
-#include "sha1.h"
-/** We use openssl's sha1 implementation. */
-#define hash_function sha1_hash
-
-/**
- * Compare two hashes.
- *
- * \param h1 Pointer to the first hash value.
- * \param h2 Pointer to the second hash value.
- *
- * \return 1, -1, or zero, depending on whether \a h1 is greater than,
- * less than or equal to h2, respectively.
- */
-_static_inline_ int hash_compare(HASH_TYPE *h1, HASH_TYPE *h2)
-{
-       int i;
-
-       for (i = 0; i < HASH_SIZE; i++) {
-               if (h1[i] < h2[i])
-                       return -1;
-               if (h1[i] > h2[i])
-                       return 1;
-       }
-       return 0;
-}
-
-/**
- * Convert a hash value to ascii format.
- *
- * \param hash the hash value.
- * \param asc Result pointer.
- *
- * \a asc must point to an area of at least 2 * \p HASH_SIZE + 1 bytes which
- * will be filled by the function with the ascii representation of the hash
- * value given by \a hash, and a terminating \p NULL byte.
- */
-_static_inline_ void hash_to_asc(HASH_TYPE *hash, char *asc)
-{
-       int i;
-       const char hexchar[] = "0123456789abcdef";
-
-       for (i = 0; i < HASH_SIZE; i++) {
-               asc[2 * i] = hexchar[hash[i] >> 4];
-               asc[2 * i + 1] = hexchar[hash[i] & 0xf];
-       }
-       asc[2 * HASH_SIZE] = '\0';
-}
index 0f2967b3317e13f5272964fca46f136d44774bfa..9f237ad7f3d7e10dee527dce33f4b1ac0da30410 100644 (file)
--- a/server.c
+++ b/server.c
@@ -57,8 +57,7 @@
  *
  *     - Doubly linked lists: \ref list.h,
  *     - Ring buffer: \ref ringbuffer.c, \ref ringbuffer.h,
  *
  *     - Doubly linked lists: \ref list.h,
  *     - Ring buffer: \ref ringbuffer.c, \ref ringbuffer.h,
- *     - Hashing: \ref hash.h, \ref sha1.h, \ref sha1.c,
- *     - Crypto: \ref crypt.c.
+ *     - Crypto: \ref crypt.c, \ref crypt.h.
  *     - Forward error correction: \ref fec.c.
  */
 
  *     - Forward error correction: \ref fec.c.
  */
 
diff --git a/sha1.c b/sha1.c
deleted file mode 100644 (file)
index b0e955e..0000000
--- a/sha1.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2007-2011 Andre Noll <maan@systemlinux.org>
- *
- * Licensed under the GPL v2. For licencing details see COPYING.
- */
-
-/** \file sha1.c Secure Hash Algorithm, provided by openssl. */
-
-#include "para.h"
-#include <openssl/sha.h>
-
-/**
- * Compute the sha1 hash.
- *
- * \param data Pointer to the data to compute the hash value from.
- * \param len The length of \a data in bytes.
- * \param sha1 Result pointer.
- *
- * \a sha1 must point to an area at least 20 bytes large.
- *
- * \sa sha(3), openssl(1).
- * */
-void sha1_hash(const char *data, unsigned long len, unsigned char *sha1)
-{
-       SHA_CTX c;
-       SHA1_Init(&c);
-       SHA1_Update(&c, data, len);
-       SHA1_Final(sha1, &c);
-}
diff --git a/sha1.h b/sha1.h
deleted file mode 100644 (file)
index 4d21733..0000000
--- a/sha1.h
+++ /dev/null
@@ -1,5 +0,0 @@
-/** \file sha1.h Secure Hash Algorithm prototype */
-
-/** Size of the hash value in bytes. */
-#define HASH_SIZE 20
-void sha1_hash(const char *data, unsigned long len, unsigned char *sha1);