"Fossies" - the Fresh Open Source Software Archive

Member "libmcrypt-2.5.8/modules/modes/stream.c" (15 Jan 2003, 2776 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 "stream.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (C) 1998,1999,2000,2001 Nikos Mavroyanopoulos
    3  * 
    4  * This library is free software; you can redistribute it and/or modify it 
    5  * under the terms of the GNU Library General Public License as published 
    6  * by the Free Software Foundation; either version 2 of the License, or 
    7  * (at your option) any later version.
    8  *
    9  * This library is distributed in the hope that it will be useful,
   10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   12  * Library General Public License for more details.
   13  *
   14  * You should have received a copy of the GNU Library General Public
   15  * License along with this library; if not, write to the
   16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   17  * Boston, MA 02111-1307, USA.
   18  */
   19 
   20 #include <libdefs.h>
   21 #include <mcrypt_modules.h>
   22 
   23 #define _init_mcrypt stream_LTX__init_mcrypt
   24 #define _mcrypt_set_state stream_LTX__mcrypt_set_state
   25 #define _mcrypt_get_state stream_LTX__mcrypt_get_state
   26 #define _end_mcrypt stream_LTX__end_mcrypt
   27 #define _mcrypt stream_LTX__mcrypt
   28 #define _mdecrypt stream_LTX__mdecrypt
   29 #define _has_iv stream_LTX__has_iv
   30 #define _is_block_mode stream_LTX__is_block_mode
   31 #define _is_block_algorithm_mode stream_LTX__is_block_algorithm_mode
   32 #define _mcrypt_get_modes_name stream_LTX__mcrypt_get_modes_name
   33 #define _mcrypt_mode_get_size stream_LTX__mcrypt_mode_get_size
   34 #define _mcrypt_mode_version stream_LTX__mcrypt_mode_version
   35 
   36 /* STREAM MODE */
   37 
   38 int _init_mcrypt( void* ign, void *key, int lenofkey, void *IV, int size) { return 0; }
   39 
   40 int _mcrypt_set_state( void* buf, void *IV, int size) { return -1; }
   41 int _mcrypt_get_state( void* buf, void *IV, int *size) { return -1; }
   42 
   43 int _end_mcrypt(void* ign) {return 0;}
   44 
   45 int _mcrypt( void* ign, void *plaintext, int len, int blocksize, void* akey, void (*func)(void*,void*, int), void (*func2)(void*,void*, int))
   46 {
   47     void (*_mcrypt_stream_encrypt) (void *, void *, int);
   48 
   49     _mcrypt_stream_encrypt = func;
   50 
   51     _mcrypt_stream_encrypt(akey, plaintext, len);
   52     return 0;
   53 }
   54 
   55 
   56 
   57 int _mdecrypt( void* ign, void *ciphertext, int len, int blocksize, void* akey, void (*func)(void*,void*, int), void (*func2)(void*,void*, int))
   58 {
   59     void (*_mcrypt_stream_decrypt) (void *, void *, int);
   60 
   61     _mcrypt_stream_decrypt = func2;
   62 
   63     _mcrypt_stream_decrypt(akey, ciphertext, len);
   64     return 0;
   65 }
   66 
   67 int _has_iv() { return 1; }
   68 int _is_block_mode() { return 0; }
   69 int _is_block_algorithm_mode() { return 0; }
   70 const char *_mcrypt_get_modes_name() { return "STREAM";}
   71 int _mcrypt_mode_get_size () {return 0;}
   72 
   73 word32 _mcrypt_mode_version() {
   74     return 20010801;
   75 }
   76 
   77 #ifdef WIN32
   78 # ifdef USE_LTDL
   79 WIN32DLL_DEFINE int main (void)
   80 {
   81        /* empty main function to avoid linker error (see cygwin FAQ) */
   82 }
   83 # endif
   84 #endif