Replace direct use of RC4 by stream cipher abstraction.
[paraslash.git] / user_list.c
index 525a47dfac7ce6705859836c67998cf3e9358107..9cde1f625e3d9fd8dc2c198dd9775db2a5b24879 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2006-2011 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -9,7 +9,6 @@
 #include <regex.h>
 #include <sys/types.h>
 #include <dirent.h>
-#include <openssl/rc4.h>
 
 #include "para.h"
 #include "error.h"
@@ -41,7 +40,7 @@ static void populate_user_list(char *user_list_file)
                /* keyword, name, key, perms */
                char w[255], n[255], k[255], p[255], tmp[4][255];
                struct user *u;
-               RSA *rsa;
+               struct asymmetric_key *pubkey;
 
                ret = para_fgets(line, sizeof(line), file_ptr);
                if (ret <= 0)
@@ -51,7 +50,7 @@ static void populate_user_list(char *user_list_file)
                if (strcmp(w, "user"))
                        continue;
                PARA_DEBUG_LOG("found entry for user %s\n", n);
-               ret = get_rsa_key(k, &rsa, LOAD_PUBLIC_KEY);
+               ret = get_asymmetric_key(k, LOAD_PUBLIC_KEY, &pubkey);
                if (ret < 0) {
                        PARA_NOTICE_LOG("skipping entry for user %s: %s\n", n,
                                para_strerror(-ret));
@@ -64,14 +63,14 @@ static void populate_user_list(char *user_list_file)
                 * which are too short. For details see RSA_public_encrypt(3).
                 */
                if (ret <= CHALLENGE_SIZE + 2 * RC4_KEY_LEN + 41) {
-                       PARA_WARNING_LOG("rsa key %s too short (%d)\n",
+                       PARA_WARNING_LOG("public key %s too short (%d)\n",
                                k, ret);
-                       rsa_free(rsa);
+                       free_asymmetric_key(pubkey);
                        continue;
                }
                u = para_malloc(sizeof(*u));
                u->name = para_strdup(n);
-               u->rsa = rsa;
+               u->pubkey = pubkey;
                u->perms = 0;
                num = sscanf(p, "%200[A-Z_],%200[A-Z_],%200[A-Z_],%200[A-Z_]",
                        tmp[0], tmp[1], tmp[2], tmp[3]);
@@ -117,7 +116,7 @@ void init_user_list(char *user_list_file)
                list_for_each_entry_safe(u, tmp, &user_list, node) {
                        list_del(&u->node);
                        free(u->name);
-                       rsa_free(u->rsa);
+                       free_asymmetric_key(u->pubkey);
                        free(u);
                }
        } else