Main Page | Directories | File List | Globals

crypt.c

Go to the documentation of this file.
00001 /*
00002  * kernel_libs/crypt/crypt.c
00003  *
00004  * Copyright (c) 2003-2004 Lukasz Dembinski <dembol@nasa.com.pl>
00005  * All Rights Reserved
00006  * 
00007  * Date:        2004/02
00008  * Author:      Lukasz Dembinski
00009  * Info:        crypt.c core file
00010  * Contact:     mailto: <dembol@nasa.com.pl>
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 /*  MD4_init(); */
00076 /*  MD5_init(); */
00077     
00078     return 0;
00079 }
Dokumentacje wygenerowano programem Doxygen 1.4.2 dla projektu Agnix