"Fossies" - the Fresh Open Source Software Archive

Member "libmcrypt-2.5.8/include/mutils/mcrypt.h" (19 Feb 2007, 5260 Bytes) of package /linux/privat/old/libmcrypt-2.5.8.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "mcrypt.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (C) 1998,1999,2002 Nikos Mavroyanopoulos
    3  *
    4  * Encryption/decryption library. This library is free software;
    5  * you can redistribute it and/or modify it under the terms of the
    6  * GNU Library General Public License as published by the Free Software
    7  * Foundation; either version 2 of the License, or (at your option) any
    8  * later version.
    9  *
   10  * This library is distributed in the hope that it will be useful,
   11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   13  * Library General Public License for more details.
   14  *
   15  * You should have received a copy of the GNU Library General Public
   16  * License along with this library; if not, write to the
   17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   18  * Boston, MA 02111-1307, USA.
   19  */
   20 
   21 
   22 #define MCRYPT_API_VERSION 20021217
   23 
   24 #define LIBMCRYPT_VERSION "2.5.8"
   25 
   26 #ifdef __cplusplus
   27 extern "C" {
   28 #endif
   29 /* Definitions
   30  */
   31 #define MCRYPT_FAILED 0x0
   32 
   33 struct CRYPT_STREAM;
   34 typedef struct CRYPT_STREAM *MCRYPT;
   35 
   36 /* generic - high level functions. 
   37  */
   38     MCRYPT mcrypt_module_open(char *algorithm,
   39                   char *a_directory, char *mode,
   40                   char *m_directory);
   41     int mcrypt_module_close(MCRYPT td);
   42 
   43     /* returns 0 if the library has not been compiled with
   44      * dynamic module support.
   45      */
   46     int mcrypt_module_support_dynamic(void);
   47 
   48 /* returns thread descriptor */
   49 
   50     int mcrypt_generic_init(const MCRYPT td, void *key, int lenofkey,
   51                 void *IV);
   52     int mcrypt_generic_deinit(const MCRYPT td);
   53     int mcrypt_generic_end(const MCRYPT td);
   54     int mdecrypt_generic(MCRYPT td, void *plaintext, int len);
   55     int mcrypt_generic(MCRYPT td, void *plaintext, int len);
   56 
   57 /* extra functions */
   58 
   59     int mcrypt_enc_set_state(MCRYPT td, void *st, int size);
   60     int mcrypt_enc_get_state(MCRYPT td, void *st, int *size); /* only 
   61     * for block algorithms and certain modes like cbc
   62     * ncfb etc.
   63     */
   64     int (mcrypt_enc_self_test) (MCRYPT);
   65     int (mcrypt_enc_get_block_size) (MCRYPT);
   66     int (mcrypt_enc_get_iv_size) (MCRYPT);
   67     int (mcrypt_enc_get_key_size) (MCRYPT);
   68 
   69 /* If this is a block algorithm returns 1 
   70  */
   71     int (mcrypt_enc_is_block_algorithm) (MCRYPT);
   72 
   73 /* If the mode operates in blocks returns 1 
   74  */
   75     int (mcrypt_enc_is_block_mode) (MCRYPT);
   76 
   77 /* If the mode is for block algorithms it returns 1 
   78  */
   79     int (mcrypt_enc_is_block_algorithm_mode) (MCRYPT td);
   80     int mcrypt_enc_mode_has_iv(MCRYPT td);
   81 
   82 /* Return a const string containing the name of the algorithm/mode
   83  */
   84     char *(mcrypt_enc_get_algorithms_name) (MCRYPT td);
   85     char *(mcrypt_enc_get_modes_name) (MCRYPT td);
   86 
   87     int *mcrypt_enc_get_supported_key_sizes(MCRYPT td, int *len);
   88 
   89 
   90     char **mcrypt_list_algorithms(char *libdir, int *size);
   91     char **mcrypt_list_modes(char *libdir, int *size);
   92 
   93     /* Frees the memory allocated by the mcrypt_list_xxx() functions. 
   94      */
   95     void mcrypt_free_p(char **p, int size);
   96     void mcrypt_free(void *ptr);
   97 
   98     /* If mcrypt_xxx functions return an error code, and you supply this
   99      * to this function, it will print a human readable message
  100      */
  101     void mcrypt_perror(int err);
  102     const char* mcrypt_strerror(int err);
  103 
  104     /* Self test for the specified algorithm 
  105      */
  106     int mcrypt_module_self_test(char *algorithm, char *a_directory);
  107 
  108     int mcrypt_module_is_block_algorithm(char *algorithm,
  109                          char *a_directory);
  110     int mcrypt_module_is_block_algorithm_mode(char *mode,
  111                           char *m_directory);
  112     int mcrypt_module_is_block_mode(char *mode, char *m_directory);
  113 
  114     int mcrypt_module_get_algo_key_size(char *algorithm,
  115                         char *a_directory);
  116     int mcrypt_module_get_algo_block_size(char *algorithm,
  117                           char *a_directory);
  118 
  119     int *mcrypt_module_get_algo_supported_key_sizes(char *algorithm,
  120                             char *a_directory,
  121                             int *len);
  122 
  123     /* Checks the version of the specified module 
  124      */
  125     int mcrypt_module_algorithm_version(char *algorithm,
  126                         char *a_directory);
  127     int mcrypt_module_mode_version(char *mode, char *a_directory);
  128 
  129 
  130     /* for multithreaded applications: 
  131      */
  132     int mcrypt_mutex_register ( void (*mutex_lock)(void) , 
  133             void (*mutex_unlock)(void), 
  134             void (*set_error)(const char*), 
  135             const char* (*get_error)(void));
  136 
  137     const char *
  138         mcrypt_check_version( const char *);
  139 
  140     /* These definitions exist in order to ease the access to 
  141      * mcrypt_module_init().
  142      */
  143 
  144     /* Algorithms */
  145 #define MCRYPT_BLOWFISH     "blowfish"
  146 #define MCRYPT_DES      "des"
  147 #define MCRYPT_3DES         "tripledes"
  148 #define MCRYPT_3WAY         "threeway"
  149 #define MCRYPT_GOST         "gost"
  150 #define MCRYPT_SAFER_SK64   "safer-sk64"
  151 #define MCRYPT_SAFER_SK128  "safer-sk128"
  152 #define MCRYPT_CAST_128     "cast-128"
  153 #define MCRYPT_XTEA         "xtea"
  154 #define MCRYPT_RC2      "rc2"
  155 #define MCRYPT_TWOFISH      "twofish"
  156 #define MCRYPT_CAST_256     "cast-256"
  157 #define MCRYPT_SAFERPLUS    "saferplus"
  158 #define MCRYPT_LOKI97       "loki97"
  159 #define MCRYPT_SERPENT      "serpent"
  160 #define MCRYPT_RIJNDAEL_128     "rijndael-128"
  161 #define MCRYPT_RIJNDAEL_192     "rijndael-192"
  162 #define MCRYPT_RIJNDAEL_256     "rijndael-256"
  163 #define MCRYPT_ENIGMA       "enigma"
  164 #define MCRYPT_ARCFOUR      "arcfour"
  165 #define MCRYPT_WAKE     "wake"
  166 
  167     /* Modes */
  168 #define MCRYPT_CBC      "cbc"
  169 #define MCRYPT_ECB      "ecb"
  170 #define MCRYPT_CFB      "cfb"
  171 #define MCRYPT_OFB      "ofb"
  172 #define MCRYPT_nOFB     "nofb"
  173 #define MCRYPT_STREAM       "stream"
  174 
  175 #ifdef __cplusplus
  176 }
  177 #endif