00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <agnix/agnix.h>
00016 #include <agnix/init.h>
00017 #include <agnix/memory.h>
00018 #include <agnix/crypt.h>
00019 #include <agnix/console.h>
00020
00021 #define MOD_NAME "CRYPT: "
00022
00023 struct crypt_algo_s *crypt_algo[MAX_CRYPT_ALGO];
00024
00025 static int crypt_algo_nr = 0;
00026
00027 int get_free_crypt_algo(void)
00028 {
00029 return crypt_algo_nr++;
00030 }
00031
00032 int put_free_crypt_algo(int cryptd)
00033 {
00034 return 0;
00035 }
00036
00037 int register_crypt_algo(struct crypt_algo_s *algo)
00038 {
00039 int crypt_algo_d;
00040 int ret;
00041
00042 crypt_algo_d = get_free_crypt_algo();
00043
00044 if (crypt_algo_d < 0)
00045 return -1;
00046
00047 crypt_algo[crypt_algo_d] = algo;
00048 printk(MOD_NAME "registering %s crypt algorithm ... ", algo->algo_name);
00049
00050 if (algo->init) {
00051 ret = algo->init();
00052
00053 if (ret < 0) {
00054 printk("failed\n");
00055 return -1;
00056 }
00057 }
00058 printk("ok\n");
00059
00060 return crypt_algo_d;
00061 }
00062
00063 int unregister_crypt_algo(int cryptd)
00064 {
00065 put_free_crypt_algo(cryptd);
00066
00067 return 0;
00068 }
00069
00070 int __init crypt_init(void)
00071 {
00072 memset(crypt_algo, 0, MAX_CRYPT_ALGO * 4);
00073
00074 DES_init();
00075
00076
00077
00078 return 0;
00079 }