]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge branch 't/crypt_cleanups'
authorAndre Noll <maan@systemlinux.org>
Sat, 23 Apr 2011 13:54:59 +0000 (15:54 +0200)
committerAndre Noll <maan@systemlinux.org>
Sat, 23 Apr 2011 13:58:22 +0000 (15:58 +0200)
Conflicts:
Makefile.in

15 files changed:
1  2 
Makefile.in
NEWS
afh.c
audioc.c
audiod.c
client_common.c
command.c
configure.ac
error.h
fade.c
grab_client.c
gui.c
recv.c
server.c
write.c

diff --combined Makefile.in
index 8b33aaac0c9fe58bab3b20c61cee25476af90965,d7640b6c3782cfb577b0067230b7b8cc9565021a..8ecc1b8f6d606497aff2e9291e9b962d698cd28e
@@@ -15,15 -15,10 +15,15 @@@ build_date := $(shell date
  uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
  uname_rs := $(shell uname -rs)
  cc_version := $(shell $(CC) --version | head -n 1)
 -codename := deterministic entropy
 +codename := infinite rollback
 +
 +GIT_VERSION := $(shell ./GIT-VERSION-GEN git-version.h)
  
  DEBUG_CPPFLAGS += -Wno-sign-compare -g -Wunused -Wundef -W
  DEBUG_CPPFLAGS += -Wredundant-decls
 +DEBUG_CPPFLAGS += -Wall
 +DEBUG_CPPFLAGS += -Wformat-security
 +DEBUG_CPPFLAGS += -Wmissing-format-attribute
  # produces false positives
  # DEBUG_CPPFLAGS += -Wunreachable-code
  # DEBUG_CPPFLAGS += -Wwrite-strings
@@@ -43,24 -38,28 +43,23 @@@ ifeq ($(uname_s),Linux
        CPPFLAGS += -Wshadow
  endif
  CPPFLAGS += -Os
 -CPPFLAGS += -Wall
  CPPFLAGS += -Wuninitialized
  CPPFLAGS += -Wchar-subscripts
 -CPPFLAGS += -Wformat-security
  CPPFLAGS += -DBINDIR='"$(BINDIR)"'
  CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
  CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
  CPPFLAGS += -DCODENAME='"$(codename)"'
  CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
  CPPFLAGS += -Werror-implicit-function-declaration
 -CPPFLAGS += -Wmissing-format-attribute
  CPPFLAGS += -Wmissing-noreturn
  CPPFLAGS += -Wunused-macros
  CPPFLAGS += -Wbad-function-cast
  CPPFLAGS += -fno-strict-aliasing
  CPPFLAGS += -DMAIN_INPUT_FILE_IS_$(*F)
- CPPFLAGS += @SSL_CPPFLAGS@
 -CPPFLAGS += @ncurses_cppflags@
  CPPFLAGS += @arch_cppflags@
  CPPFLAGS += -I/usr/local/include
  CPPFLAGS += -I$(cmdline_dir)
  CPPFLAGS += @osl_cppflags@
 -CPPFLAGS += -DGIT_VERSION='"$(GIT_VERSION)"'
  
  man_pages := $(patsubst %, man/man1/%.1, @executables@)
  man_pages_in := $(patsubst %, web/%.man.in.html, @executables@)
@@@ -101,12 -100,18 +100,12 @@@ els
        Q =
  endif
  
 -.PHONY: dep all clean distclean maintainer-clean install man tarball\
 -      .FORCE-GIT-VERSION-FILE
 +.PHONY: dep all clean distclean maintainer-clean install man tarball
  all: dep @executables@ $(man_pages)
  dep: $(deps)
  man: $(man_pages)
  tarball: $(tarball)
  
 -GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
 -      @./GIT-VERSION-GEN GIT-VERSION-FILE
 --include GIT-VERSION-FILE
 -@executables@: GIT-VERSION-FILE
 -
  -include $(ggo_dir)/makefile
  
  %_command_list.c: %.cmd
@@@ -150,6 -155,9 +149,9 @@@ $(object_dir)
  $(man_dir):
        mkdir -p $@
  
+ $(object_dir)/crypt.o: crypt.c | $(object_dir)
+       @[ -z "$(Q)" ] || echo 'CC $<'
+       $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @openssl_cppflags@ $<
  $(object_dir)/spx_common.o: spx_common.c | $(object_dir)
        @[ -z "$(Q)" ] || echo 'CC $<'
        $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
@@@ -190,10 -198,6 +192,10 @@@ $(object_dir)/aac_afh.o: aac_afh.c | $(
        @[ -z "$(Q)" ] || echo 'CC $<'
        $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
  
 +$(object_dir)/gui%.o: gui%.c | $(object_dir)
 +      @[ -z "$(Q)" ] || echo 'CC $<'
 +      $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @curses_cppflags@ $<
 +
  $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
        @[ -z "$(Q)" ] || echo 'CC $<'
        $(Q) $(CC) -c $(CPPFLAGS) -Wno-unused-function -o $@ $<
@@@ -210,7 -214,6 +212,7 @@@ $(object_dir)/%.d: %.c | $(object_dir
        @[ -z "$(Q)" ] || echo 'DEP $<'
        $(Q) ./depend.sh $(object_dir) $(cmdline_dir) $(CPPFLAGS) $< > $@
  
 +
  recv_objs := $(addprefix $(object_dir)/, @recv_objs@)
  filter_objs := $(addprefix $(object_dir)/, @filter_objs@)
  client_objs := $(addprefix $(object_dir)/, @client_objs@)
@@@ -246,7 -249,7 +248,7 @@@ para_client: $(client_objs
  
  para_gui: $(gui_objs)
        @[ -z "$(Q)" ] || echo 'LD $@'
 -      $(Q) $(CC) $(LDFLAGS) -o $@ $(gui_objs) -lncurses
 +      $(Q) $(CC) $(LDFLAGS) -o $@ $(gui_objs) -lcurses
  
  para_audiod: audiod_command_list.c audiod_command_list.h $(audiod_objs)
        @[ -z "$(Q)" ] || echo 'LD $@'
@@@ -304,7 -307,7 +306,7 @@@ $(tarball): $(cmdline_generated
        git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
                | tar --delete $(tarball_delete) > $(tarball_pfx).tar
        mkdir -p $(tarball_pfx)/$(cmdline_dir)
 -      echo $(GIT_VERSION) > $(tarball_pfx)/VERSION
 +      ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
        cp -r $(autocrap) $(tarball_pfx)
        cp -r $(cmdline_generated) $(tarball_pfx)/$(cmdline_dir)
        tar rf $(tarball_pfx).tar $(tarball_pfx)/*
diff --combined NEWS
index c08197f522011aaceb409c542ad1ca6e75a160d0,23691951d23846cf238eafe1878af92fdd722930..3295738632ef423ca4b36f68f3bcdc533d873e38
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -1,15 -1,6 +1,16 @@@
 ------------------------------------------------
 -0.4.6 (to be announced) "deterministic entropy"
 ------------------------------------------------
 +-------------------------------------------
 +0.4.7 (to be announced) "infinite rollback"
 +-------------------------------------------
 +
 +      - configure: improved options for ogg/vorbis/speex.
 +      - The git version reported by --version always matches HEAD.
 +      - The autogen script detects the number of processors and
 +        runs a parallel make if possible.
++      - Major cleanup of the crypto API.
 +
 +------------------------------------------
 +0.4.6 (2011-03-31) "deterministic entropy"
 +------------------------------------------
  
  Lots of ogg/vorbis improvements, the new test suite, enhancements
  for para_gui and a fair amount of other bug fixes.
diff --combined afh.c
index 37d71224ba5631cc24f79c194810c20f9d9eb95e,53c721161378193c385f7706bca47dc8ad97d2f9..66c4d1ca0f41a9c0b09ff2f70bc3ce566007bca8
--- 1/afh.c
--- 2/afh.c
+++ b/afh.c
@@@ -7,7 -7,6 +7,6 @@@
  /** \file afh.c Paraslash's standalone audio format handler tool. */
  
  #include <regex.h>
- #include <dirent.h>
  #include <sys/time.h>
  
  #include "para.h"
@@@ -16,7 -15,6 +15,7 @@@
  #include "fd.h"
  #include "afh.h"
  #include "error.h"
 +#include "version.h"
  
  static struct afh_args_info conf;
  /** The list of all status items */
diff --combined audioc.c
index adcae715e28d29c48da934a16360dab8b5ecc476,c05bd14e105da209a88ae60ab1a7b9e208df8aa8..8c46b46f7d19864dbbd0c0074d399cb12ea696f2
+++ b/audioc.c
@@@ -8,7 -8,6 +8,6 @@@
  
  #include <regex.h>
  #include <sys/types.h>
- #include <dirent.h>
  
  #include "audioc.cmdline.h"
  #include "para.h"
@@@ -16,7 -15,6 +15,7 @@@
  #include "net.h"
  #include "string.h"
  #include "fd.h"
 +#include "version.h"
  
  INIT_AUDIOC_ERRLISTS;
  
diff --combined audiod.c
index 5bc22c816896d22b7c1269dc7ceb3fa234efd7b0,34a41620120dfb48887c0623a550799850b28019..9f664e178309c39e70a64d7ea55f6a29f0c5f6cf
+++ b/audiod.c
@@@ -7,9 -7,7 +7,7 @@@
  /** \file audiod.c the paraslash's audio daemon */
  #include <regex.h>
  #include <sys/types.h>
- #include <dirent.h>
  #include <signal.h>
- #include <openssl/rc4.h>
  #include <stdbool.h>
  
  #include "para.h"
@@@ -33,7 -31,6 +31,7 @@@
  #include "write.h"
  #include "write_common.h"
  #include "signal.h"
 +#include "version.h"
  
  /** define the array of error lists needed by para_audiod */
  INIT_AUDIOD_ERRLISTS;
diff --combined client_common.c
index 54bb9433e34cbd0a5bbfed50d07a7d536e0f8b65,33ad19546d2a6e8f5d072152f75e11fefbd6fb18..d3a9ede1f0e1d5b7238a387f0f3aa03650deed55
@@@ -8,8 -8,6 +8,6 @@@
  
  #include <regex.h>
  #include <sys/types.h>
- #include <dirent.h>
- #include <openssl/rc4.h>
  
  #include "para.h"
  #include "error.h"
  #include "sched.h"
  #include "client.cmdline.h"
  #include "crypt.h"
- #include "rc4.h"
  #include "net.h"
  #include "fd.h"
  #include "string.h"
  #include "client.cmdline.h"
  #include "client.h"
- #include "hash.h"
  #include "buffer_tree.h"
 +#include "version.h"
  
  /** The size of the receiving buffer. */
  #define CLIENT_BUFSIZE 4000
@@@ -41,8 -36,10 +37,10 @@@ void client_close(struct client_task *c
  {
        if (!ct)
                return;
-       if (ct->rc4c.fd >= 0)
-               close(ct->rc4c.fd);
+       if (ct->scc.fd >= 0)
+               close(ct->scc.fd);
+       sc_free(ct->scc.recv);
+       sc_free(ct->scc.send);
        free(ct->user);
        free(ct->config_file);
        free(ct->key_file);
@@@ -70,19 -67,19 +68,19 @@@ static void client_pre_select(struct sc
        struct client_task *ct = container_of(t, struct client_task, task);
        struct btr_node *btrn = ct->btrn;
  
-       if (ct->rc4c.fd < 0)
+       if (ct->scc.fd < 0)
                return;
        switch (ct->status) {
        case CL_CONNECTED:
        case CL_SENT_AUTH:
        case CL_SENT_CH_RESPONSE:
        case CL_SENT_COMMAND:
-               para_fd_set(ct->rc4c.fd, &s->rfds, &s->max_fileno);
+               para_fd_set(ct->scc.fd, &s->rfds, &s->max_fileno);
                return;
  
        case CL_RECEIVED_WELCOME:
        case CL_RECEIVED_PROCEED:
-               para_fd_set(ct->rc4c.fd, &s->wfds, &s->max_fileno);
+               para_fd_set(ct->scc.fd, &s->wfds, &s->max_fileno);
                return;
  
        case CL_RECEIVING:
@@@ -91,7 -88,7 +89,7 @@@
                        if (ret < 0)
                                sched_min_delay(s);
                        else
-                               para_fd_set(ct->rc4c.fd, &s->rfds,
+                               para_fd_set(ct->scc.fd, &s->rfds,
                                        &s->max_fileno);
                }
                return;
                        if (ret < 0)
                                sched_min_delay(s);
                        else
-                               para_fd_set(ct->rc4c.fd, &s->wfds,
+                               para_fd_set(ct->scc.fd, &s->wfds,
                                        &s->max_fileno);
                }
                return;
@@@ -114,12 -111,12 +112,12 @@@ static int client_recv_buffer(struct cl
        int ret;
  
        if (ct->status < CL_SENT_CH_RESPONSE)
-               return read_nonblock(ct->rc4c.fd, buf, sz, rfds, n);
+               return read_nonblock(ct->scc.fd, buf, sz, rfds, n);
  
        *n = 0;
-       ret = rc4_recv_buffer(&ct->rc4c, buf, sz);
+       ret = sc_recv_buffer(&ct->scc, buf, sz);
        /*
-        * rc4_recv_buffer is used with blocking fds elsewhere, so it
+        * sc_recv_buffer is used with blocking fds elsewhere, so it
         * does not use the nonblock-API. Therefore we need to
         * check for EOF and EAGAIN.
         */
@@@ -155,7 -152,7 +153,7 @@@ static void client_post_select(struct s
        char buf[CLIENT_BUFSIZE];
  
        t->error = 0;
-       if (ct->rc4c.fd < 0)
+       if (ct->scc.fd < 0)
                return;
        switch (ct->status) {
        case CL_CONNECTED: /* receive welcome message */
        case CL_RECEIVED_WELCOME: /* send auth command */
                sprintf(buf, AUTH_REQUEST_MSG "%s", ct->user);
                PARA_INFO_LOG("--> %s\n", buf);
-               if (!FD_ISSET(ct->rc4c.fd, &s->wfds))
+               if (!FD_ISSET(ct->scc.fd, &s->wfds))
                        return;
-               ret = send_buffer(ct->rc4c.fd, buf);
+               ret = send_buffer(ct->scc.fd, buf);
                if (ret < 0)
                        goto out;
                ct->status = CL_SENT_AUTH;
                return;
        case CL_SENT_AUTH:
                /*
-                * Receive challenge and rc4 keys, decrypt the challenge and
+                * Receive challenge and session keys, decrypt the challenge and
                 * send back the hash of the decrypted challenge.
                 */
                {
-               /* decrypted challenge/rc4 buffer */
+               /* 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)
                        goto out;
                PARA_INFO_LOG("<-- [challenge] (%zu bytes)\n", n);
-               ret = para_decrypt_buffer(ct->key_file, crypt_buf,
+               ret = priv_decrypt(ct->key_file, crypt_buf,
                        (unsigned char *)buf, n);
                if (ret < 0)
                        goto out;
-               sha1_hash((char *)crypt_buf, CHALLENGE_SIZE, challenge_sha1);
-               RC4_set_key(&ct->rc4c.send_key, RC4_KEY_LEN,
-                       crypt_buf + CHALLENGE_SIZE);
-               RC4_set_key(&ct->rc4c.recv_key, RC4_KEY_LEN,
-                       crypt_buf + CHALLENGE_SIZE + RC4_KEY_LEN);
-               hash_to_asc(challenge_sha1, buf);
+               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);
+               hash_to_asc(challenge_hash, buf);
                PARA_INFO_LOG("--> %s\n", buf);
-               ret = send_bin_buffer(ct->rc4c.fd, (char *)challenge_sha1,
+               ret = send_bin_buffer(ct->scc.fd, (char *)challenge_hash,
                        HASH_SIZE);
                if (ret < 0)
                        goto out;
                {
                int i;
                char *command = NULL;
-               if (!FD_ISSET(ct->rc4c.fd, &s->wfds))
+               if (!FD_ISSET(ct->scc.fd, &s->wfds))
                        return;
                for (i = 0; i < ct->conf.inputs_num; i++) {
                        char *tmp = command;
                }
                command = para_strcat(command, EOC_MSG "\n");
                PARA_DEBUG_LOG("--> %s\n", command);
-               ret = rc4_send_buffer(&ct->rc4c, command);
+               ret = sc_send_buffer(&ct->scc, command);
                free(command);
                if (ret < 0)
                        goto out;
                        goto out;
                if (ret == 0)
                        return;
-               if (!FD_ISSET(ct->rc4c.fd, &s->wfds))
+               if (!FD_ISSET(ct->scc.fd, &s->wfds))
                        return;
                sz = btr_next_buffer(btrn, &buf2);
-               ret = rc4_send_bin_buffer(&ct->rc4c, buf2, sz);
+               ret = sc_send_bin_buffer(&ct->scc, buf2, sz);
                if (ret < 0)
                        goto out;
                btr_consume(btrn, sz);
                 * The FD_ISSET() is not strictly necessary, but is allows us
                 * to skip the malloc below if there is nothing to read anyway.
                 */
-               if (!FD_ISSET(ct->rc4c.fd, &s->rfds))
+               if (!FD_ISSET(ct->scc.fd, &s->rfds))
                        return;
                buf2 = para_malloc(CLIENT_BUFSIZE);
                ret = client_recv_buffer(ct, &s->rfds, buf2, CLIENT_BUFSIZE, &n);
@@@ -316,14 -312,14 +313,14 @@@ static int client_connect(struct client
  {
        int ret;
  
-       ct->rc4c.fd = -1;
+       ct->scc.fd = -1;
        ret = para_connect_simple(IPPROTO_TCP, ct->conf.hostname_arg,
                                               ct->conf.server_port_arg);
        if (ret < 0)
                return ret;
-       ct->rc4c.fd = ret;
+       ct->scc.fd = ret;
        ct->status = CL_CONNECTED;
-       ret = mark_fd_nonblocking(ct->rc4c.fd);
+       ret = mark_fd_nonblocking(ct->scc.fd);
        if (ret < 0)
                goto err_out;
        ct->task.pre_select = client_pre_select;
        register_task(&ct->task);
        return 1;
  err_out:
-       close(ct->rc4c.fd);
-       ct->rc4c.fd = -1;
+       close(ct->scc.fd);
+       ct->scc.fd = -1;
        return ret;
  }
  
@@@ -364,7 -360,7 +361,7 @@@ int client_open(int argc, char *argv[]
        ct->btrn = btr_new_node(&(struct btr_node_description)
                EMBRACE(.name = "client", .parent = parent, .child = child));
        *ct_ptr = ct;
-       ct->rc4c.fd = -1;
+       ct->scc.fd = -1;
        ret = -E_CLIENT_SYNTAX;
        if (client_cmdline_parser(argc, argv, &ct->conf))
                goto out;
diff --combined command.c
index 24ddf7897d81e3b27c6f1777f975da49ca31ee52,1a090e49d71bb3d1ff3545236265f4c052bf83fe..d82bd5d71ca3ed6bf2fa40777c5a5b1231fd897f
+++ b/command.c
@@@ -10,8 -10,6 +10,6 @@@
  #include <signal.h>
  #include <sys/time.h>
  #include <sys/types.h>
- #include <dirent.h>
- #include <openssl/rc4.h>
  #include <osl.h>
  #include <stdbool.h>
  
@@@ -27,7 -25,6 +25,6 @@@
  #include "list.h"
  #include "send.h"
  #include "vss.h"
- #include "rc4.h"
  #include "net.h"
  #include "daemon.h"
  #include "fd.h"
@@@ -37,7 -34,6 +34,7 @@@
  #include "afs_command_list.h"
  #include "sched.h"
  #include "signal.h"
 +#include "version.h"
  
  /** Commands including options must be shorter than this. */
  #define MAX_COMMAND_LEN 32768
@@@ -45,7 -41,7 +42,7 @@@
  extern int mmd_mutex;
  extern struct misc_meta_data *mmd;
  extern struct sender senders[];
- int send_afs_status(struct rc4_context *rc4c, int parser_friendly);
+ int send_afs_status(struct stream_cipher_context *scc, int parser_friendly);
  
  const char *status_item_list[] = {STATUS_ITEM_ARRAY};
  
@@@ -190,7 -186,7 +187,7 @@@ static int check_sender_args(int argc, 
        return 1;
  }
  
- int com_sender(struct rc4_context *rc4c, int argc, char * const * argv)
+ int com_sender(struct stream_cipher_context *scc, int argc, char * const * argv)
  {
        int i, ret;
        char *msg = NULL;
                        free(msg);
                        msg = tmp;
                }
-               ret = rc4_send_buffer(rc4c, msg);
+               ret = sc_send_buffer(scc, msg);
                free(msg);
                return ret;
        }
                if (scd.sender_num < 0)
                        return ret;
                msg = senders[scd.sender_num].help();
-               ret = rc4_send_buffer(rc4c, msg);
+               ret = sc_send_buffer(scc, msg);
                free(msg);
                return ret;
        }
  }
  
  /* server info */
- int com_si(struct rc4_context *rc4c, int argc, __a_unused char * const * argv)
+ int com_si(struct stream_cipher_context *scc, int argc, __a_unused char * const * argv)
  {
        int i, ret;
        char *ut;
                free(info);
        }
        ut = uptime_str();
-       ret = rc4_send_va_buffer(rc4c, "version: " GIT_VERSION "\n"
+       ret = sc_send_va_buffer(scc, "version: " GIT_VERSION "\n"
                "up: %s\nplayed: %u\n"
                "server_pid: %d\n"
                "afs_pid: %d\n"
  }
  
  /* version */
- int com_version(struct rc4_context *rc4c, int argc, __a_unused char * const * argv)
+ int com_version(struct stream_cipher_context *scc, int argc, __a_unused char * const * argv)
  {
        if (argc != 1)
                return -E_COMMAND_SYNTAX;
-       return rc4_send_buffer(rc4c, VERSION_TEXT("server")
+       return sc_send_buffer(scc, VERSION_TEXT("server")
                "built: " BUILD_DATE "\n"
                UNAME_RS ", " CC_VERSION "\n"
        );
@@@ -347,7 -343,7 +344,7 @@@ static char *empty_status_items(int par
  #undef EMPTY_STATUS_ITEMS
  
  /* stat */
- int com_stat(struct rc4_context *rc4c, int argc, char * const * argv)
+ int com_stat(struct stream_cipher_context *scc, int argc, char * const * argv)
  {
        int i, ret;
        struct misc_meta_data tmp, *nmmd = &tmp;
        for (;;) {
                mmd_dup(nmmd);
                s = get_status(nmmd, parser_friendly);
-               ret = rc4_send_buffer(rc4c, s);
+               ret = sc_send_buffer(scc, s);
                free(s);
                if (ret < 0)
                        goto out;
                        static char *esi;
                        if (!esi)
                                esi = empty_status_items(parser_friendly);
-                       ret = rc4_send_buffer(rc4c, esi);
+                       ret = sc_send_buffer(scc, esi);
                        if (ret < 0)
                                goto out;
                } else
-                       send_afs_status(rc4c, parser_friendly);
+                       send_afs_status(scc, parser_friendly);
                ret = 1;
                if (num > 0 && !--num)
                        goto out;
@@@ -406,14 -402,14 +403,14 @@@ out
        return ret;
  }
  
- static int send_list_of_commands(struct rc4_context *rc4c, struct server_command *cmd,
+ static int send_list_of_commands(struct stream_cipher_context *scc, struct server_command *cmd,
                const char *handler)
  {
        int ret, i;
  
        for (i = 1; cmd->name; cmd++, i++) {
                char *perms = cmd_perms_itohuman(cmd->perms);
-               ret = rc4_send_va_buffer(rc4c, "%s\t%s\t%s\t%s\n", cmd->name,
+               ret = sc_send_va_buffer(scc, "%s\t%s\t%s\t%s\n", cmd->name,
                        handler,
                        perms,
                        cmd->description);
@@@ -446,7 -442,7 +443,7 @@@ static struct server_command *get_cmd_p
  }
  
  /* help */
- int com_help(struct rc4_context *rc4c, int argc, char * const * argv)
+ int com_help(struct stream_cipher_context *scc, int argc, char * const * argv)
  {
        struct server_command *cmd;
        char *perms, *handler;
  
        if (argc < 2) {
                /* no argument given, print list of commands */
-               if ((ret = send_list_of_commands(rc4c, server_cmds, "server")) < 0)
+               if ((ret = send_list_of_commands(scc, server_cmds, "server")) < 0)
                        return ret;
-               return send_list_of_commands(rc4c, afs_cmds, "afs");
+               return send_list_of_commands(scc, afs_cmds, "afs");
        }
        /* argument given for help */
        cmd = get_cmd_ptr(argv[1], &handler);
        if (!cmd)
                return -E_BAD_CMD;
        perms = cmd_perms_itohuman(cmd->perms);
-       ret = rc4_send_va_buffer(rc4c,
+       ret = sc_send_va_buffer(scc,
                "%s - %s\n\n"
                "handler: %s\n"
                "permissions: %s\n"
  }
  
  /* hup */
- int com_hup(__a_unused struct rc4_context *rc4c, int argc, __a_unused char * const * argv)
+ int com_hup(__a_unused struct stream_cipher_context *scc, int argc, __a_unused char * const * argv)
  {
        if (argc != 1)
                return -E_COMMAND_SYNTAX;
  }
  
  /* term */
- int com_term(__a_unused struct rc4_context *rc4c, int argc, __a_unused char * const * argv)
+ int com_term(__a_unused struct stream_cipher_context *scc, int argc, __a_unused char * const * argv)
  {
        if (argc != 1)
                return -E_COMMAND_SYNTAX;
        return 1;
  }
  
- int com_play(__a_unused struct rc4_context *rc4c, int argc, __a_unused char * const * argv)
+ int com_play(__a_unused struct stream_cipher_context *scc, int argc, __a_unused char * const * argv)
  {
        if (argc != 1)
                return -E_COMMAND_SYNTAX;
  }
  
  /* stop */
- int com_stop(__a_unused struct rc4_context *rc4c, int argc, __a_unused char * const * argv)
+ int com_stop(__a_unused struct stream_cipher_context *scc, int argc, __a_unused char * const * argv)
  {
        if (argc != 1)
                return -E_COMMAND_SYNTAX;
  }
  
  /* pause */
- int com_pause(__a_unused struct rc4_context *rc4c, int argc, __a_unused char * const * argv)
+ int com_pause(__a_unused struct stream_cipher_context *scc, int argc, __a_unused char * const * argv)
  {
        if (argc != 1)
                return -E_COMMAND_SYNTAX;
  }
  
  /* next */
- int com_next(__a_unused struct rc4_context *rc4c, int argc, __a_unused char * const * argv)
+ int com_next(__a_unused struct stream_cipher_context *scc, int argc, __a_unused char * const * argv)
  {
        if (argc != 1)
                return -E_COMMAND_SYNTAX;
  }
  
  /* nomore */
- int com_nomore(__a_unused struct rc4_context *rc4c, int argc, __a_unused char * const * argv)
+ int com_nomore(__a_unused struct stream_cipher_context *scc, int argc, __a_unused char * const * argv)
  {
        if (argc != 1)
                return -E_COMMAND_SYNTAX;
  }
  
  /* ff */
- int com_ff(__a_unused struct rc4_context *rc4c, int argc, char * const * argv)
+ int com_ff(__a_unused struct stream_cipher_context *scc, int argc, char * const * argv)
  {
        long promille;
        int ret, backwards = 0;
@@@ -603,7 -599,7 +600,7 @@@ out
  }
  
  /* jmp */
- int com_jmp(__a_unused struct rc4_context *rc4c, int argc, char * const * argv)
+ int com_jmp(__a_unused struct stream_cipher_context *scc, int argc, char * const * argv)
  {
        long unsigned int i;
        int ret;
@@@ -657,7 -653,7 +654,7 @@@ static struct server_command *parse_cmd
        return get_cmd_ptr(buf, NULL);
  }
  
- static int read_command(struct rc4_context *rc4c, char **result)
+ static int read_command(struct stream_cipher_context *scc, char **result)
  {
        int ret;
        char buf[4096];
                size_t numbytes;
                char *p;
  
-               ret = rc4_recv_buffer(rc4c, buf, sizeof(buf));
+               ret = sc_recv_buffer(scc, buf, sizeof(buf));
                if (ret < 0)
                        goto out;
                if (!ret)
@@@ -712,7 -708,7 +709,7 @@@ static void reset_signals(void
   * calls this function.
   *
   * An RSA-based challenge/response is used to authenticate
-  * the peer. It that authentication succeeds, a random RC4
+  * the peer. It that authentication succeeds, a random
   * session key is generated and sent back to the peer,
   * encrypted with its RSA public key.  From this point on,
   * all transfers are crypted with this session key.
   * which terminates the function if the connection was not
   * authenticated when the timeout expires.
   *
-  * \sa alarm(2), rc4(3), crypt.c, crypt.h
+  * \sa alarm(2), crypt.c, crypt.h
   */
  __noreturn void handle_connect(int fd, const char *peername)
  {
        int ret, argc;
        char buf[4096];
-       unsigned char rand_buf[CHALLENGE_SIZE + 2 * RC4_KEY_LEN];
-       unsigned char challenge_sha1[HASH_SIZE];
+       unsigned char rand_buf[CHALLENGE_SIZE + 2 * SESSION_KEY_LEN];
+       unsigned char challenge_hash[HASH_SIZE];
        struct user *u;
        struct server_command *cmd = NULL;
        char **argv = NULL;
        char *p, *command = NULL;
        size_t numbytes;
-       struct rc4_context rc4c = {.fd = fd};
+       struct stream_cipher_context scc = {.fd = fd};
  
        reset_signals();
        /* we need a blocking fd here as recv() might return EAGAIN otherwise. */
        u = lookup_user(p);
        if (u) {
                get_random_bytes_or_die(rand_buf, sizeof(rand_buf));
-               ret = para_encrypt_buffer(u->rsa, rand_buf, sizeof(rand_buf),
+               ret = pub_encrypt(u->pubkey, rand_buf, sizeof(rand_buf),
                        (unsigned char *)buf);
                if (ret < 0)
                        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;
-       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);
        PARA_INFO_LOG("good auth for %s\n", u->name);
-       /* init rc4 keys with the second part of the random buffer */
-       RC4_set_key(&rc4c.recv_key, RC4_KEY_LEN, rand_buf + CHALLENGE_SIZE);
-       RC4_set_key(&rc4c.send_key, RC4_KEY_LEN, rand_buf + CHALLENGE_SIZE
-               + RC4_KEY_LEN);
-       ret = rc4_send_buffer(&rc4c, PROCEED_MSG);
+       /* init stream cipher keys with the second part of the random buffer */
+       scc.recv = sc_new(rand_buf + CHALLENGE_SIZE, SESSION_KEY_LEN);
+       scc.send = sc_new(rand_buf + CHALLENGE_SIZE + SESSION_KEY_LEN, SESSION_KEY_LEN);
+       ret = sc_send_buffer(&scc, PROCEED_MSG);
        if (ret < 0)
                goto net_err;
-       ret = read_command(&rc4c, &command);
+       ret = read_command(&scc, &command);
        if (ret == -E_COMMAND_SYNTAX)
                goto err_out;
        if (ret < 0)
        argc = ret;
        PARA_NOTICE_LOG("calling com_%s() for %s@%s\n", cmd->name, u->name,
                        peername);
-       ret = cmd->handler(&rc4c, argc, argv);
+       ret = cmd->handler(&scc, argc, argv);
        free_argv(argv);
        mutex_lock(mmd_mutex);
        mmd->num_commands++;
        if (ret >= 0)
                goto out;
  err_out:
-       rc4_send_va_buffer(&rc4c, "%s\n", para_strerror(-ret));
+       sc_send_va_buffer(&scc, "%s\n", para_strerror(-ret));
  net_err:
        PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
  out:
        free(command);
+       sc_free(scc.recv);
+       sc_free(scc.send);
        mutex_lock(mmd_mutex);
        if (cmd && (cmd->perms & AFS_WRITE) && ret >= 0)
                mmd->events++;
diff --combined configure.ac
index e5a23438dbdcb989abe8d1f4556bc4f1bd689fa5,0201896321405d7ea009dc21be0d76ff1f3fb061..32381c6b1ceec6dfd2586a1f73c0cdd4804ce855
@@@ -87,7 -87,7 +87,7 @@@ AC_DEFUN([add_cmdline],[$(for i in $@; 
  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
@@@ -118,7 -118,7 +118,7 @@@ audiod_cmdline_objs="add_cmdline(audio
  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"
@@@ -131,7 -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
-       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"
@@@ -145,7 -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_common sha1 buffer_tree"
+       client_common buffer_tree"
  client_ldflags=""
  
  gui_cmdline_objs="add_cmdline(gui)"
  CPPFLAGS="$OLD_CPPFLAGS"
  LDFLAGS="$OLD_LDFLAGS"
  LIBS="$OLD_LIBS"
- ########################################################################### ssl
- dnl @synopsis CHECK_SSL
- dnl
- dnl based on the follwing macro from the autoconf archive
- dnl
- dnl @category InstalledPackages
- dnl @author Mark Ethan Trostler <trostler@juniper.net>
- dnl @version 2003-01-28
- dnl @license AllPermissive
- AC_DEFUN([CHECK_SSL],
- [
-       for ssldir in $1 /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
-               AC_MSG_CHECKING(for openssl in $ssldir)
-               if test -f "$ssldir/include/openssl/ssl.h"; then
-                       found_ssl="yes"
-                       AC_MSG_RESULT(yes)
-                       SSL_CFLAGS="-I$ssldir/include"
-                       SSL_CPPFLAGS="-I$ssldir/include"
-                       break
-               fi
-               AC_MSG_RESULT(no)
-       done
-       if test x_$found_ssl != x_yes; then
-               AC_MSG_ERROR(Cannot find ssl libraries)
-       else
-               SSL_LIBS="-lssl -lcrypto";
-               SSL_LDFLAGS="-L$ssldir/lib";
+ ###################################################################### openssl
+ OLD_CPPFLAGS="$CPPFLAGS"
+ OLD_LD_FLAGS="$LDFLAGS"
+ OLD_LIBS="$LIBS"
+ have_openssl="yes"
+ AC_ARG_WITH(openssl_headers, [AC_HELP_STRING(--with-openssl-headers=dir,
+       [look for openssl headers also in dir])])
+ if test -n "$with_openssl_headers"; then
+       openssl_cppflags="-I$with_openssl_headers"
+       CPPFLAGS="$CPPFLAGS $openssl_cppflags"
+ fi
+ AC_ARG_WITH(openssl_libs, [AC_HELP_STRING(--with-openssl-libs=dir,
+       [look for openssl libraries also in dir])])
+ if test -n "$with_openssl_libs"; then
+       openssl_libs="-L$with_openssl_libs"
+       LDFLAGS="$LDFLAGS $openssl_libs"
+ fi
+ AC_CHECK_HEADER(openssl/ssl.h, [], [have_openssl="no"])
+ AC_CHECK_LIB([crypto], [RAND_bytes], [], [have_openssl="no"])
+ if test "$have_openssl" = "no" -a -z "$with_openssl_headers$with_openssl_libs"; then
+       # try harder: openssl is sometimes installed in /usr/local/ssl
+       openssl_cppflags="-I/usr/local/ssl/include"
+       CPPFLAGS="$CPPFLAGS $openssl_cppflags"
+       openssl_libs="-L/usr/local/ssl/lib"
+       LDFLAGS="$LDFLAGS $openssl_libs"
+       # clear cache
+       unset ac_cv_header_openssl_ssl_h 2> /dev/null
+       unset ac_cv_lib_crypto_RAND_bytes 2> /dev/null
+       AC_CHECK_HEADER(openssl/ssl.h, [have_openssl="yes"], [])
+       if test "$have_openssl" = "yes"; then
+               AC_CHECK_LIB([crypto], [RAND_bytes], [], [have_openssl="no"])
        fi
-       AC_SUBST(SSL_CPPFLAGS)
- ])dnl
- AC_ARG_ENABLE(ssldir, [AS_HELP_STRING(--enable-ssldir=path,
-       [Search for openssl also in path.])])
- if test "$enable_ssldir" = "yes"; then enable_ssldir=""; fi
- CHECK_SSL($enable_ssldir)
- server_ldflags="$server_ldflags $SSL_LDFLAGS $SSL_LIBS"
- client_ldflags="$client_ldflags $SSL_LDFLAGS $SSL_LIBS"
- audiod_ldflags="$audiod_ldflags $SSL_LDFLAGS $SSL_LIBS"
+ fi
+ if test "$have_openssl" = "yes"; then
+       AC_DEFINE(HAVE_OPENSSL, 1, [define to 1 to turn on openssl support])
+       AC_SUBST(openssl_cppflags)
+       openssl_libs="$openssl_libs -lssl -lcrypto"
+       server_ldflags="$server_ldflags $openssl_libs"
+       client_ldflags="$client_ldflags $openssl_libs"
+       audiod_ldflags="$audiod_ldflags $openssl_libs"
+ else
+       AC_MSG_ERROR([openssl libraries not found])
+ fi
+ CPPFLAGS="$OLD_CPPFLAGS"
+ LDFLAGS="$OLD_LDFLAGS"
+ LIBS="$OLD_LIBS"
  ########################################################################### libsocket
  AC_CHECK_LIB([c], [socket],
        [socket_lib=],
@@@ -353,31 -359,31 +359,31 @@@ if test ${have_ucred} = yes; the
  fi
  
  ########################################################################### curses
 -have_ncurses="yes"
 +have_curses="yes"
  OLD_CPPFLAGS="$CPPFLAGS"
  OLD_LD_FLAGS="$LDFLAGS"
  OLD_LIBS="$LIBS"
 -AC_ARG_WITH(ncurses_headers, [AC_HELP_STRING(--with-ncurses-headers=dir,
 -      [look for ncurses.h also in dir])])
 -if test -n "$with_ncurses_headers"; then
 -      ncurses_cppflags="-I$with_ncurses_headers"
 -      CPPFLAGS="$CPPFLAGS $ncurses_cppflags"
 +AC_ARG_WITH(curses_headers, [AC_HELP_STRING(--with-curses-headers=dir,
 +      [look for curses.h also in dir])])
 +if test -n "$with_curses_headers"; then
 +      curses_cppflags="-I$with_curses_headers"
 +      CPPFLAGS="$CPPFLAGS $curses_cppflags"
  fi
 -AC_ARG_WITH(ncurses_libs, [AC_HELP_STRING(--with-ncurses-libs=dir,
 -      [look for libncurses also in dir])])
 -if test -n "$with_ncurses_libs"; then
 -      ncurses_libs="-L$with_ncurses_libs"
 -      LDFLAGS="$LDFLAGS $ncurses_libs"
 +AC_ARG_WITH(curses_libs, [AC_HELP_STRING(--with-curses-libs=dir,
 +      [look for libcurses also in dir])])
 +if test -n "$with_curses_libs"; then
 +      curses_libs="-L$with_curses_libs"
 +      LDFLAGS="$LDFLAGS $curses_libs"
  fi
  AC_CHECK_HEADER(curses.h, [], [
 -      have_ncurses="no"
 +      have_curses="no"
  ])
 -AC_CHECK_LIB([ncurses], [initscr], [], [
 -      have_ncurses="no"
 +AC_CHECK_LIB([curses], [initscr], [], [
 +      have_curses="no"
  ])
 -if test "$have_ncurses" = "yes"; then
 -      AC_SUBST(ncurses_cppflags)
 -      AC_DEFINE(HAVE_NCURSES, 1, [define to 1 to turn on ncurses support])
 +if test "$have_curses" = "yes"; then
 +      AC_SUBST(curses_cppflags)
 +      AC_DEFINE(HAVE_NCURSES, 1, [define to 1 to turn on curses support])
        extras="$extras gui"
        executables="$executables gui"
  else
@@@ -430,120 -436,86 +436,120 @@@ if test ${have_core_audio} = yes; the
  fi
  ########################################################### ogg/vorbis/speex
  have_ogg="yes"
 -have_vorbis="yes"
 -have_speex="yes"
  OLD_CPPFLAGS="$CPPFLAGS"
  OLD_LD_FLAGS="$LDFLAGS"
  OLD_LIBS="$LIBS"
 -AC_ARG_WITH(oggvorbis_headers, [AC_HELP_STRING(--with-oggvorbis-headers=dir,
 -      [look for ogg/vorbis/speex headers also in dir])])
 -if test -n "$with_oggvorbis_headers"; then
 -      ogg_cppflags="-I$with_oggvorbis_headers"
 +AC_ARG_WITH(ogg_headers, [AC_HELP_STRING(--with-ogg-headers=dir,
 +      [look for ogg headers also in dir])])
 +AC_ARG_WITH(ogg_libs, [AC_HELP_STRING(--with-ogg-libs=dir,
 +      [look for ogg libs also in dir])])
 +AC_ARG_WITH(vorbis_headers, [AC_HELP_STRING(--with-vorbis-headers=dir,
 +      [look for vorbis headers also in dir])])
 +AC_ARG_WITH(vorbis_libs, [AC_HELP_STRING(--with-vorbis-libs=dir,
 +      [look for vorbis libs also in dir])])
 +AC_ARG_WITH(speex_headers, [AC_HELP_STRING(--with-speex-headers=dir,
 +      [look for speex headers also in dir])])
 +AC_ARG_WITH(speex_libs, [AC_HELP_STRING(--with-speex-libs=dir,
 +      [look for speex libs also in dir])])
 +
 +if test -n "$with_ogg_headers"; then
 +      ogg_cppflags="-I$with_ogg_headers"
        CPPFLAGS="$CPPFLAGS $ogg_cppflags"
  fi
 -AC_ARG_WITH(oggvorbis_libs, [AC_HELP_STRING(--with-oggvorbis-libs=dir,
 -      [look for ogg/vorbis/speex libs also in dir])])
 -if test -n "$with_oggvorbis_libs"; then
 -      ogg_libs="-L$with_oggvorbis_libs"
 +if test -n "$with_ogg_libs"; then
 +      ogg_libs="-L$with_ogg_libs"
        LDFLAGS="$LDFLAGS $ogg_libs"
  fi
 -
 -AC_CHECK_LIB([ogg], [ogg_stream_init], [], [ have_ogg="no" ])
 -AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [ have_vorbis="no" ])
 -AC_CHECK_LIB([speex], [speex_decoder_init], [], [ have_speex="no" ])
  AC_CHECK_HEADERS([ogg/ogg.h], [], [ have_ogg="no"; ])
 -AC_CHECK_HEADERS([vorbis/codec.h], [], [ have_vorbis="no" ])
 -AC_CHECK_HEADERS([speex/speex.h], [], [ have_speex="no" ])
 +AC_CHECK_LIB([ogg], [ogg_stream_init], [], [ have_ogg="no" ])
 +
 +have_vorbis="yes"
 +have_speex="yes"
 +if test "$have_ogg" = "yes"; then
 +      # vorbis
 +      if test -n "$with_vorbis_headers"; then
 +              vorbis_cppflags="-I$with_vorbis_headers"
 +              CPPFLAGS="$CPPFLAGS $vorbis_cppflags"
 +      fi
 +      if test -n "$with_vorbis_libs"; then
 +              vorbis_libs="-L$with_vorbis_libs"
 +              LDFLAGS="$LDFLAGS $vorbis_libs"
 +      fi
 +      AC_CHECK_HEADERS([vorbis/codec.h], [], [ have_vorbis="no" ])
 +      AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [ have_vorbis="no" ])
 +
 +      # speex
 +      if test -n "$with_speex_headers"; then
 +              speex_cppflags="-I$with_speex_headers"
 +              CPPFLAGS="$CPPFLAGS $speex_cppflags"
 +      fi
 +      if test -n "$with_speex_libs"; then
 +              speex_libs="-L$with_speex_libs"
 +              LDFLAGS="$LDFLAGS $speex_libs"
 +      fi
 +      AC_CHECK_LIB([speex], [speex_decoder_init], [], [ have_speex="no" ])
 +      AC_CHECK_HEADERS([speex/speex.h], [], [ have_speex="no" ])
 +else
 +      have_vorbis="no"
 +      have_speex="no"
 +fi
 +
  msg="support in para_server/para_filter/para_afh"
 -if test "$have_ogg" = "yes" && { test "$have_vorbis" = "yes" || test "$have_speex" = "yes"; }; then
 +if test "$have_vorbis" = "yes" || test "$have_speex" = "yes"; then
        AC_SUBST(ogg_cppflags)
        ogg_libs="$ogg_libs -logg"
        if test "$OSTYPE" = "Darwin"; then
 -              ogg_libs="-Wl,-bind_at_load $ogg_libs $ogg_libs"
 +              ogg_libs="-Wl,-bind_at_load $ogg_libs"
        fi
        server_ldflags="$server_ldflags $ogg_libs"
        filter_ldflags="$filter_ldflags $ogg_libs"
        audiod_ldflags="$audiod_ldflags $ogg_libs"
 -      all_errlist_objs="$all_errlist_objs ogg_afh_common"
        afh_ldflags="$afh_ldflags $ogg_libs"
 +      all_errlist_objs="$all_errlist_objs ogg_afh_common"
        afh_errlist_objs="$afh_errlist_objs ogg_afh_common"
        server_errlist_objs="$server_errlist_objs ogg_afh_common"
 -      if test "$have_vorbis" = "yes"; then
 -              all_errlist_objs="$all_errlist_objs oggdec_filter ogg_afh"
 -              AC_DEFINE(HAVE_OGGVORBIS, 1, define to 1 to turn on ogg/vorbis support)
 -              filters="$filters oggdec"
 -              vorbis_libs="-lvorbis -lvorbisfile"
 -              server_ldflags="$server_ldflags $vorbis_libs"
 -              filter_ldflags="$filter_ldflags $vorbis_libs"
 -              audiod_ldflags="$audiod_ldflags $vorbis_libs"
 -              afh_ldflags="$afh_ldflags $vorbis_libs"
 -
 -              server_errlist_objs="$server_errlist_objs ogg_afh"
 -              filter_errlist_objs="$filter_errlist_objs oggdec_filter"
 -              audiod_errlist_objs="$audiod_errlist_objs oggdec_filter"
 -              afh_errlist_objs="$afh_errlist_objs ogg_afh"
 -
 -              audiod_audio_formats="$audiod_audio_formats ogg"
 -              server_audio_formats="$server_audio_formats ogg"
 -      else
 -              AC_MSG_WARN([no ogg/vorbis $msg])
 -      fi
 -      if test "$have_speex" = "yes"; then
 -              all_errlist_objs="$all_errlist_objs spxdec_filter spx_afh spx_common"
 -              AC_DEFINE(HAVE_SPEEX, 1, define to 1 to turn on ogg/speex support)
 -              filters="$filters spxdec"
 -              speex_libs="-lspeex"
 -              server_ldflags="$server_ldflags $speex_libs"
 -              filter_ldflags="$filter_ldflags $speex_libs"
 -              audiod_ldflags="$audiod_ldflags $speex_libs"
 -              afh_ldflags="$afh_ldflags $speex_libs"
 -
 -              server_errlist_objs="$server_errlist_objs spx_afh spx_common"
 -              filter_errlist_objs="$filter_errlist_objs spxdec_filter spx_common"
 -              audiod_errlist_objs="$audiod_errlist_objs spxdec_filter spx_common"
 -              afh_errlist_objs="$afh_errlist_objs spx_afh spx_common"
 -
 -              audiod_audio_formats="$audiod_audio_formats spx"
 -              server_audio_formats="$server_audio_formats spx"
 -      else
 -              AC_MSG_WARN([no ogg/speex $msg])
 -      fi
  else
 -      AC_MSG_WARN([no ogg/vorbis ogg/speex $msg])
 +      AC_MSG_WARN([vorbis/speex require ogg])
 +fi
 +if test "$have_vorbis" = "yes"; then
 +      all_errlist_objs="$all_errlist_objs oggdec_filter ogg_afh"
 +      AC_DEFINE(HAVE_OGGVORBIS, 1, define to 1 to turn on ogg/vorbis support)
 +      filters="$filters oggdec"
 +      vorbis_libs="-lvorbis -lvorbisfile"
 +      server_ldflags="$server_ldflags $vorbis_libs"
 +      filter_ldflags="$filter_ldflags $vorbis_libs"
 +      audiod_ldflags="$audiod_ldflags $vorbis_libs"
 +      afh_ldflags="$afh_ldflags $vorbis_libs"
 +
 +      server_errlist_objs="$server_errlist_objs ogg_afh"
 +      filter_errlist_objs="$filter_errlist_objs oggdec_filter"
 +      audiod_errlist_objs="$audiod_errlist_objs oggdec_filter"
 +      afh_errlist_objs="$afh_errlist_objs ogg_afh"
 +
 +      audiod_audio_formats="$audiod_audio_formats ogg"
 +      server_audio_formats="$server_audio_formats ogg"
 +else
 +      AC_MSG_WARN([no ogg/vorbis $msg])
 +fi
 +if test "$have_speex" = "yes"; then
 +      all_errlist_objs="$all_errlist_objs spxdec_filter spx_afh spx_common"
 +      AC_DEFINE(HAVE_SPEEX, 1, define to 1 to turn on ogg/speex support)
 +      filters="$filters spxdec"
 +      speex_libs="-lspeex"
 +      server_ldflags="$server_ldflags $speex_libs"
 +      filter_ldflags="$filter_ldflags $speex_libs"
 +      audiod_ldflags="$audiod_ldflags $speex_libs"
 +      afh_ldflags="$afh_ldflags $speex_libs"
 +
 +      server_errlist_objs="$server_errlist_objs spx_afh spx_common"
 +      filter_errlist_objs="$filter_errlist_objs spxdec_filter spx_common"
 +      audiod_errlist_objs="$audiod_errlist_objs spxdec_filter spx_common"
 +      afh_errlist_objs="$afh_errlist_objs spx_afh spx_common"
 +
 +      audiod_audio_formats="$audiod_audio_formats spx"
 +      server_audio_formats="$server_audio_formats spx"
 +else
 +      AC_MSG_WARN([no ogg/speex $msg])
  fi
  CPPFLAGS="$OLD_CPPFLAGS"
  LDFLAGS="$OLD_LDFLAGS"
diff --combined error.h
index fdd2d3b7b9b6b06f8e7ba0d6a457dc249c314b3e,564f1339dd9b51e4d0c4fc034c65d2aa6a7c6187..2e32c24044bd074cc9e311903adde6d85ac5a4c0
+++ b/error.h
@@@ -19,7 -19,6 +19,6 @@@ DEFINE_ERRLIST_OBJECT_ENUM
  #define GUI_ERRORS
  #define RINGBUFFER_ERRORS
  #define SCORE_ERRORS
- #define SHA1_ERRORS
  #define RBTREE_ERRORS
  #define RECV_ERRORS
  #define IPC_ERRORS
@@@ -273,6 -272,7 +272,6 @@@ extern const char **para_errlist[]
  
  #define AUDIOD_COMMAND_ERRORS \
        PARA_ERROR(CLIENT_WRITE, "client write error"), \
 -      PARA_ERROR(AUDIOD_SYNTAX, "syntax error"), \
        PARA_ERROR(UCRED_PERM, "permission denied"), \
        PARA_ERROR(INVALID_AUDIOD_CMD, "invalid command"), \
        PARA_ERROR(TOO_MANY_CLIENTS, "maximal number of stat clients exceeded"), \
  
  #define WRITE_ERRORS \
        PARA_ERROR(WRITE_SYNTAX, "para_write syntax error"), \
 -      PARA_ERROR(NO_WAV_HEADER, "wave header not found"), \
  
  
  #define ALSA_WRITE_ERRORS \
diff --combined fade.c
index 41b4a6d78e2b40d80cb24e31a5b0030c37db4584,e0ab967c68e012a5e788390e52e6aa4015077e2b..04ca923770ec069bda49d3a069fac795fd461ac1
--- 1/fade.c
--- 2/fade.c
+++ b/fade.c
@@@ -8,7 -8,6 +8,6 @@@
  
  #include <regex.h>
  #include <sys/types.h>
- #include <dirent.h>
  #include <sys/ioctl.h>
  #include <ctype.h>
  #include <stdlib.h> /* EXIT_SUCCESS */
@@@ -23,7 -22,6 +22,7 @@@
  #include "fd.h"
  #include "string.h"
  #include "error.h"
 +#include "version.h"
  
  INIT_FADE_ERRLISTS;
  static struct fade_args_info conf;
diff --combined grab_client.c
index a85e42a967817d6d767a6f9bf52b95c6146d5369,0d3b6036a924674866dbead443a2daaf273751b9..9109c2f8f6c5f1978eddd356ff7f8e979d73dd8a
@@@ -8,7 -8,6 +8,6 @@@
  
  #include <regex.h>
  #include <sys/types.h>
- #include <dirent.h>
  #include <stdbool.h>
  
  #include "para.h"
@@@ -62,9 -61,9 +61,9 @@@ struct grab_client 
  };
  
  /* Grab clients that are attached to a btr node. */
 -INITIALIZED_LIST_HEAD(active_grab_client_list);
 +static INITIALIZED_LIST_HEAD(active_grab_client_list);
  /* Grab clients that are not currently attached any btr node. */
 -INITIALIZED_LIST_HEAD(inactive_grab_client_list);
 +static INITIALIZED_LIST_HEAD(inactive_grab_client_list);
  
  static int gc_write(struct grab_client *gc, char *buf, size_t len)
  {
@@@ -131,12 -130,13 +130,12 @@@ static void gc_activate(struct grab_cli
        list_move(&gc->node, &active_grab_client_list);
        gc->btrn = btr_new_node(&(struct btr_node_description)
                EMBRACE(.name = name, .parent = parent));
 -      if (!gc->task.pre_select) {
 -              gc->task.pre_select = gc_pre_select;
 -              gc->task.post_select = gc_post_select;
 -              snprintf(gc->task.status, sizeof(gc->task.status) - 1, "%s", name);
 -              gc->task.status[sizeof(gc->task.status) - 1] = '\0';
 -              register_task(&gc->task);
 -      }
 +      gc->task.pre_select = gc_pre_select;
 +      gc->task.post_select = gc_post_select;
 +      snprintf(gc->task.status, sizeof(gc->task.status) - 1, "%s", name);
 +      gc->task.status[sizeof(gc->task.status) - 1] = '\0';
 +      gc->task.error = 0;
 +      register_task(&gc->task);
  }
  
  /**
@@@ -155,7 -155,7 +154,7 @@@ void activate_grab_clients(void
        struct grab_client *gc, *tmp;
  
        list_for_each_entry_safe(gc, tmp, &inactive_grab_client_list, node) {
 -              if (gc->task.error < 0) {
 +              if (gc->fd < 0) {
                        list_del(&gc->node);
                        free(gc);
                        continue;
@@@ -178,11 -178,11 +177,11 @@@ static int gc_close(struct grab_client 
                 * post_select().
                 */
                close(gc->fd);
 +              gc->fd = -1;
                free(gc->parent);
                free(gc->name);
                return 1;
        }
 -      gc_activate(gc);
        return 0;
  }
  
@@@ -209,8 -209,7 +208,8 @@@ static void gc_post_select(__a_unused s
                btr_consume(btrn, ret);
        return;
  err:
 -      t->error = gc_close(gc, ret)? ret : 0;
 +      gc_close(gc, ret);
 +      t->error = ret;
  }
  
  static int gc_check_args(int argc, char **argv, struct grab_client *gc)
diff --combined gui.c
index 578eeed0c96d502767a57b5cb80f0cad2c9cfc07,29089244c0439cfab0f779b217f672a3e24353c9..c8721565ae86502319be0ed2e6257454b876f841
--- 1/gui.c
--- 2/gui.c
+++ b/gui.c
@@@ -9,7 -9,6 +9,6 @@@
  #include <regex.h>
  #include <signal.h>
  #include <sys/types.h>
- #include <dirent.h>
  #include <curses.h>
  
  #include "gui.cmdline.h"
@@@ -22,7 -21,6 +21,7 @@@
  #include "list.h"
  #include "sched.h"
  #include "signal.h"
 +#include "version.h"
  
  /** define the array of error lists needed by para_gui */
  INIT_GUI_ERRLISTS;
@@@ -34,10 -32,10 +33,10 @@@ static int signal_pipe
  
  static struct win_data {
        WINDOW *win;
 -      NCURSES_SIZE_T begx;
 -      NCURSES_SIZE_T begy;
 -      NCURSES_SIZE_T cols;
 -      NCURSES_SIZE_T lines;
 +      size_t begx;
 +      size_t begy;
 +      size_t cols;
 +      size_t lines;
  } top, bot, sb, in, sep;
  
  #define RINGBUFFER_SIZE 512
diff --combined recv.c
index ae8a1f663b725cbed40f763e0105fd04d2d4dcc9,8e6d75b1c8b6fe3a1fa9d6865e9d3c71eb0e5843..52f457fc29b68e61ba017079511145f4e3120885
--- 1/recv.c
--- 2/recv.c
+++ b/recv.c
@@@ -8,7 -8,6 +8,6 @@@
  
  #include <regex.h>
  #include <sys/types.h>
- #include <dirent.h>
  #include <stdbool.h>
  
  #include "para.h"
@@@ -22,7 -21,6 +21,7 @@@
  #include "error.h"
  #include "stdout.h"
  #include "buffer_tree.h"
 +#include "version.h"
  
  /** The gengetopt args info struct. */
  static struct recv_args_info conf;
diff --combined server.c
index 4d54f74b63d47e52fee508a899bc3b8970d1e1b6,0ae888fa8557357838df38b0be1c9c8ae40cfaad..e8dddf5bc27a80238436811b7d2b46680cddb3d7
+++ b/server.c
   *
   *    - 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.
   */
  
  #include <signal.h>
- #include <dirent.h>
  #include <sys/time.h>
- #include <openssl/rc4.h>
  #include <regex.h>
  #include <osl.h>
  #include <stdbool.h>
@@@ -91,7 -88,6 +88,7 @@@
  #include "signal.h"
  #include "user_list.h"
  #include "color.h"
 +#include "version.h"
  
  /** Define the array of error lists needed by para_server. */
  INIT_SERVER_ERRLISTS;
diff --combined write.c
index 571dc4ed8e4c0d35e253f277205975d5eac8758c,8ddd51a9d4d8ef5b061159102f0b99390cc283d5..6b574414b6b13c227c98b008addd28f4b2302b33
+++ b/write.c
@@@ -8,7 -8,6 +8,6 @@@
  
  #include <regex.h>
  #include <sys/types.h>
- #include <dirent.h>
  #include <stdbool.h>
  
  #include "para.h"
@@@ -23,7 -22,6 +22,7 @@@
  #include "write_common.h"
  #include "fd.h"
  #include "error.h"
 +#include "version.h"
  
  INIT_WRITE_ERRLISTS;