/[mcrypt]/libmcrypt/lib/mcrypt_modules.c
ViewVC logotype

Diff of /libmcrypt/lib/mcrypt_modules.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by nmav, Sun Sep 17 22:10:39 2000 UTC revision 1.4 by nmav, Mon Sep 18 09:42:54 2000 UTC
# Line 52  void *mcrypt_dlopen_ext ( const char *fi Line 52  void *mcrypt_dlopen_ext ( const char *fi
52          void *ret;          void *ret;
53          char full_path[1054];          char full_path[1054];
54    
55            if (strlen(filename)>sizeof(full_path)) return;
56    
57            strcpy(full_path, filename);
58          ret = dlopen(full_path, RTLD_LAZY);          ret = dlopen(full_path, RTLD_LAZY);
59    
60          if (ret==NULL) {          if (ret==NULL) {
61                  strcat(full_path, ".so");                  strcat(full_path, ".so");
62                  ret = dlopen(full_path, RTLD_LAZY);                  ret = dlopen(full_path, RTLD_LAZY);
# Line 88  void *mcrypt_dlopen ( const char* a_dire Line 92  void *mcrypt_dlopen ( const char* a_dire
92    
93  #else  #else
94          char full_path[1050];          char full_path[1050];
95            
96          if (a_directory!=NULL) {          if (a_directory!=NULL) {
97                  strncpy(full_path, a_directory, 512);                  strncpy(full_path, a_directory, 512);
98                  strcat(full_path, "/");                  strcat(full_path, "/");
# Line 103  void *mcrypt_dlopen ( const char* a_dire Line 107  void *mcrypt_dlopen ( const char* a_dire
107                          ret = mcrypt_dlopen_ext(full_path);                          ret = mcrypt_dlopen_ext(full_path);
108                  }                  }
109          }          }
110            if (ret==NULL) {
111                    if (LIBDIR!=NULL) {
112                            strncpy(full_path, LIBDIR, 512);
113                            strcat(full_path, "/");
114                            strncat( full_path, filename, 510);
115                            ret = mcrypt_dlopen_ext(full_path);
116                    }
117            }
118          return ret;          return ret;
119  #endif  #endif
120    
# Line 112  MCRYPT mcrypt_module_open(char *algorith Line 124  MCRYPT mcrypt_module_open(char *algorith
124                            char *a_directory, char *mode, char *m_directory)                            char *a_directory, char *mode, char *m_directory)
125  {  {
126          MCRYPT td;          MCRYPT td;
127            char* err;
128                    
129          td = calloc(1, sizeof(CRYPT_STREAM));          td = calloc(1, sizeof(CRYPT_STREAM));
130    
# Line 123  MCRYPT mcrypt_module_open(char *algorith Line 136  MCRYPT mcrypt_module_open(char *algorith
136    
137          td->algorithm_handle = mcrypt_dlopen(a_directory, m_directory, algorithm);          td->algorithm_handle = mcrypt_dlopen(a_directory, m_directory, algorithm);
138          if (td->algorithm_handle == NULL) {          if (td->algorithm_handle == NULL) {
139                  fputs(lt_dlerror(), stderr);                  err=lt_dlerror();
140                    if (err!=NULL) fputs( err, stderr);
141                  fputs("\n", stderr);                  fputs("\n", stderr);
142                  return MCRYPT_FAILED;                  return MCRYPT_FAILED;
143          }          }
# Line 131  MCRYPT mcrypt_module_open(char *algorith Line 145  MCRYPT mcrypt_module_open(char *algorith
145          td->mode_handle = mcrypt_dlopen(a_directory, m_directory, mode);          td->mode_handle = mcrypt_dlopen(a_directory, m_directory, mode);
146    
147          if (td->mode_handle == NULL) {          if (td->mode_handle == NULL) {
148                  fputs(lt_dlerror(), stderr);                  err=lt_dlerror();
149                  fputs("\n", stderr);                  if (err!=NULL) fputs( err, stderr);
150                  lt_dlclose(td->algorithm_handle);                  lt_dlclose(td->algorithm_handle);
151                  return MCRYPT_FAILED;                  return MCRYPT_FAILED;
152          }          }
# Line 167  int mcrypt_get_size(MCRYPT td) Line 181  int mcrypt_get_size(MCRYPT td)
181          s = td->algorithm_handle;          s = td->algorithm_handle;
182          _mcrypt_get_size = lt_dlsym(s, "_mcrypt_get_size");          _mcrypt_get_size = lt_dlsym(s, "_mcrypt_get_size");
183          if ((error = lt_dlerror())) {          if ((error = lt_dlerror())) {
184                  fputs(error, stderr);                  if (error!=NULL) fputs(error, stderr);
185                  fputs("\n", stderr);                  fputs("\n", stderr);
186                  return MCRYPT_UNKNOWN_ERROR;                  return MCRYPT_UNKNOWN_ERROR;
187          }          }
# Line 184  int mcrypt_mode_get_size(MCRYPT td) Line 198  int mcrypt_mode_get_size(MCRYPT td)
198          s = td->mode_handle;          s = td->mode_handle;
199          _mcrypt_get_size = lt_dlsym(s, "_mcrypt_mode_get_size");          _mcrypt_get_size = lt_dlsym(s, "_mcrypt_mode_get_size");
200          if ((error = lt_dlerror())) {          if ((error = lt_dlerror())) {
201                  fputs(error, stderr);                  if (error!=NULL) fputs(error, stderr);
202                  fputs("\n", stderr);                  fputs("\n", stderr);
203                  return MCRYPT_UNKNOWN_ERROR;                  return MCRYPT_UNKNOWN_ERROR;
204          }          }
# Line 203  void mcrypt_set_key(MCRYPT td, void *a, Line 217  void mcrypt_set_key(MCRYPT td, void *a,
217                  /* stream */                  /* stream */
218                  __mcrypt_set_key_stream = lt_dlsym(s, "_mcrypt_set_key");                  __mcrypt_set_key_stream = lt_dlsym(s, "_mcrypt_set_key");
219                  if ((error = lt_dlerror())) {                  if ((error = lt_dlerror())) {
220                          fputs(error, stderr);                          if (error!=NULL) fputs(error, stderr);
221                          fputs("\n", stderr);                          fputs("\n", stderr);
222                          return;                          return;
223                  }                  }
# Line 211  void mcrypt_set_key(MCRYPT td, void *a, Line 225  void mcrypt_set_key(MCRYPT td, void *a,
225          } else {          } else {
226                  __mcrypt_set_key_block = lt_dlsym(s, "_mcrypt_set_key");                  __mcrypt_set_key_block = lt_dlsym(s, "_mcrypt_set_key");
227                  if ((error = lt_dlerror())) {                  if ((error = lt_dlerror())) {
228                          fputs(error, stderr);                          if (error!=NULL) fputs(error, stderr);
229                          fputs("\n", stderr);                          fputs("\n", stderr);
230                          return;                          return;
231                  }                  }
# Line 229  int mcrypt_enc_set_state(MCRYPT td, void Line 243  int mcrypt_enc_set_state(MCRYPT td, void
243    
244          __mcrypt_set_state = lt_dlsym(s, "_mcrypt_set_state");          __mcrypt_set_state = lt_dlsym(s, "_mcrypt_set_state");
245          if ((error = lt_dlerror())) {          if ((error = lt_dlerror())) {
246                  fputs(error, stderr);                  if (error!=NULL) fputs(error, stderr);
247                  fputs("\n", stderr);                  fputs("\n", stderr);
248                  return MCRYPT_UNKNOWN_ERROR;                  return MCRYPT_UNKNOWN_ERROR;
249          }          }
# Line 464  int mcrypt_module_self_test(char *algori Line 478  int mcrypt_module_self_test(char *algori
478          int i;          int i;
479          lt_dlhandle *_handle;          lt_dlhandle *_handle;
480          int (*_self_test) (void);          int (*_self_test) (void);
481            char* error;
482    
483    
484          if (lt_dlinit() != 0) {          if (lt_dlinit() != 0) {
# Line 475  int mcrypt_module_self_test(char *algori Line 489  int mcrypt_module_self_test(char *algori
489          _handle = mcrypt_dlopen(a_directory, NULL, algorithm);          _handle = mcrypt_dlopen(a_directory, NULL, algorithm);
490    
491          if (!_handle) {          if (!_handle) {
492                  fputs(lt_dlerror(), stderr);                  error=lt_dlerror();
493                    if (error!=NULL) fputs( error, stderr);
494                  fputs("\n", stderr);                  fputs("\n", stderr);
495                  return MCRYPT_UNKNOWN_ERROR;                  return MCRYPT_UNKNOWN_ERROR;
496          }          }
# Line 494  int mcrypt_module_algorithm_version(char Line 509  int mcrypt_module_algorithm_version(char
509          int i;          int i;
510          lt_dlhandle _handle;          lt_dlhandle _handle;
511          int (*_version) (void);          int (*_version) (void);
512            char* error;
513    
514          if (lt_dlinit() != 0) {          if (lt_dlinit() != 0) {
515                  return MCRYPT_UNKNOWN_ERROR;                  return MCRYPT_UNKNOWN_ERROR;
# Line 502  int mcrypt_module_algorithm_version(char Line 518  int mcrypt_module_algorithm_version(char
518    
519          _handle = mcrypt_dlopen(a_directory, NULL, algorithm);          _handle = mcrypt_dlopen(a_directory, NULL, algorithm);
520          if (!_handle) {          if (!_handle) {
521                  fputs(lt_dlerror(), stderr);                  error=lt_dlerror();
522                    if (error!=NULL) fputs( error, stderr);
523                  fputs("\n", stderr);                  fputs("\n", stderr);
524                  return MCRYPT_UNKNOWN_ERROR;                  return MCRYPT_UNKNOWN_ERROR;
525          }          }
# Line 522  int mcrypt_module_mode_version(char *mod Line 539  int mcrypt_module_mode_version(char *mod
539          int i;          int i;
540          lt_dlhandle *_handle;          lt_dlhandle *_handle;
541          int (*_version) (void);          int (*_version) (void);
542            char* error;
543    
544          if (lt_dlinit() != 0) {          if (lt_dlinit() != 0) {
545                  return MCRYPT_UNKNOWN_ERROR;                  return MCRYPT_UNKNOWN_ERROR;
# Line 530  int mcrypt_module_mode_version(char *mod Line 548  int mcrypt_module_mode_version(char *mod
548    
549          _handle = mcrypt_dlopen(m_directory, NULL, mode);          _handle = mcrypt_dlopen(m_directory, NULL, mode);
550          if (!_handle) {          if (!_handle) {
551                  fputs(lt_dlerror(), stderr);                  error=lt_dlerror();
552                    if(error!=NULL) fputs(error, stderr);
553                  fputs("\n", stderr);                  fputs("\n", stderr);
554                  return MCRYPT_UNKNOWN_ERROR;                  return MCRYPT_UNKNOWN_ERROR;
555          }          }
# Line 551  int mcrypt_module_is_block_algorithm(cha Line 570  int mcrypt_module_is_block_algorithm(cha
570          int i;          int i;
571          lt_dlhandle _handle;          lt_dlhandle _handle;
572          int (*_is_block_algorithm) (void);          int (*_is_block_algorithm) (void);
573            char* error;
574            
575          if (lt_dlinit() != 0) {          if (lt_dlinit() != 0) {
576                  return MCRYPT_UNKNOWN_ERROR;                  return MCRYPT_UNKNOWN_ERROR;
577          }          }
# Line 560  int mcrypt_module_is_block_algorithm(cha Line 580  int mcrypt_module_is_block_algorithm(cha
580          _handle = mcrypt_dlopen(a_directory, NULL, algorithm);          _handle = mcrypt_dlopen(a_directory, NULL, algorithm);
581                    
582          if (!_handle) {          if (!_handle) {
583                  fputs(lt_dlerror(), stderr);                  error=lt_dlerror();
584                    if(error!=NULL) fputs( error, stderr);
585                  fputs("\n", stderr);                  fputs("\n", stderr);
586                  return MCRYPT_UNKNOWN_ERROR;                  return MCRYPT_UNKNOWN_ERROR;
587          }          }
# Line 581  int mcrypt_module_is_block_algorithm_mod Line 602  int mcrypt_module_is_block_algorithm_mod
602          int i;          int i;
603          lt_dlhandle *_handle;          lt_dlhandle *_handle;
604          int (*_is_a_block_mode) (void);          int (*_is_a_block_mode) (void);
605            char* error;
606    
607          if (lt_dlinit() != 0) {          if (lt_dlinit() != 0) {
608                  return MCRYPT_UNKNOWN_ERROR;                  return MCRYPT_UNKNOWN_ERROR;
# Line 589  int mcrypt_module_is_block_algorithm_mod Line 611  int mcrypt_module_is_block_algorithm_mod
611    
612          _handle = mcrypt_dlopen(m_directory, NULL, mode);          _handle = mcrypt_dlopen(m_directory, NULL, mode);
613          if (!_handle) {          if (!_handle) {
614                  fputs(lt_dlerror(), stderr);                  error=lt_dlerror();
615                    if(error!=NULL) fputs( error, stderr);
616                  fputs("\n", stderr);                  fputs("\n", stderr);
617                  return MCRYPT_UNKNOWN_ERROR;                  return MCRYPT_UNKNOWN_ERROR;
618          }          }
# Line 610  int mcrypt_module_is_block_mode(char *mo Line 633  int mcrypt_module_is_block_mode(char *mo
633          int i;          int i;
634          lt_dlhandle *_handle;          lt_dlhandle *_handle;
635          int (*_is_block_mode) (void);          int (*_is_block_mode) (void);
636            char* error;
637    
638          if (lt_dlinit() != 0) {          if (lt_dlinit() != 0) {
639                  return MCRYPT_UNKNOWN_ERROR;                  return MCRYPT_UNKNOWN_ERROR;
# Line 619  int mcrypt_module_is_block_mode(char *mo Line 642  int mcrypt_module_is_block_mode(char *mo
642    
643          _handle = mcrypt_dlopen(m_directory, NULL, mode);          _handle = mcrypt_dlopen(m_directory, NULL, mode);
644          if (!_handle) {          if (!_handle) {
645                  fputs(lt_dlerror(), stderr);                  error=lt_dlerror();
646                    if(error!=NULL) fputs( error, stderr);
647                  fputs("\n", stderr);                  fputs("\n", stderr);
648                  return MCRYPT_UNKNOWN_ERROR;                  return MCRYPT_UNKNOWN_ERROR;
649          }          }
# Line 639  int mcrypt_module_get_algo_block_size(ch Line 663  int mcrypt_module_get_algo_block_size(ch
663          int i;          int i;
664          lt_dlhandle _handle;          lt_dlhandle _handle;
665          int (*_get_block_size) (void);          int (*_get_block_size) (void);
666            char* error;
667    
668          if (lt_dlinit() != 0) {          if (lt_dlinit() != 0) {
669                  return MCRYPT_UNKNOWN_ERROR;                  return MCRYPT_UNKNOWN_ERROR;
# Line 647  int mcrypt_module_get_algo_block_size(ch Line 672  int mcrypt_module_get_algo_block_size(ch
672    
673          _handle = mcrypt_dlopen(a_directory, NULL, algorithm);          _handle = mcrypt_dlopen(a_directory, NULL, algorithm);
674          if (!_handle) {          if (!_handle) {
675                  fputs(lt_dlerror(), stderr);                  error=lt_dlerror();
676                    if(error!=NULL) fputs( error, stderr);
677                  fputs("\n", stderr);                  fputs("\n", stderr);
678                  return MCRYPT_UNKNOWN_ERROR;                  return MCRYPT_UNKNOWN_ERROR;
679          }          }
# Line 667  int mcrypt_module_get_algo_key_size(char Line 693  int mcrypt_module_get_algo_key_size(char
693          int i;          int i;
694          lt_dlhandle _handle;          lt_dlhandle _handle;
695          int (*_get_key_size) (void);          int (*_get_key_size) (void);
696            char* error;
697    
698          if (lt_dlinit() != 0) {          if (lt_dlinit() != 0) {
699                  return MCRYPT_UNKNOWN_ERROR;                  return MCRYPT_UNKNOWN_ERROR;
# Line 675  int mcrypt_module_get_algo_key_size(char Line 702  int mcrypt_module_get_algo_key_size(char
702    
703          _handle = mcrypt_dlopen(a_directory, NULL, algorithm);          _handle = mcrypt_dlopen(a_directory, NULL, algorithm);
704          if (!_handle) {          if (!_handle) {
705                  fputs(lt_dlerror(), stderr);                  error=lt_dlerror();
706                    if(error!=NULL) fputs( error, stderr);
707                  fputs("\n", stderr);                  fputs("\n", stderr);
708                  return MCRYPT_UNKNOWN_ERROR;                  return MCRYPT_UNKNOWN_ERROR;
709          }          }
# Line 698  int *mcrypt_module_get_algo_supported_ke Line 726  int *mcrypt_module_get_algo_supported_ke
726          lt_dlhandle _handle;          lt_dlhandle _handle;
727          int *(*_mcrypt_get_key_sizes) (int *);          int *(*_mcrypt_get_key_sizes) (int *);
728          int *size;          int *size;
729            char* error;
730    
731          if (lt_dlinit() != 0) {          if (lt_dlinit() != 0) {
732                  *len = 0;                  *len = 0;
# Line 707  int *mcrypt_module_get_algo_supported_ke Line 736  int *mcrypt_module_get_algo_supported_ke
736    
737          _handle = mcrypt_dlopen(a_directory, NULL, algorithm);          _handle = mcrypt_dlopen(a_directory, NULL, algorithm);
738          if (!_handle) {          if (!_handle) {
739                  fputs(lt_dlerror(), stderr);                  error=lt_dlerror();
740                    if(error!=NULL) fputs( error, stderr);
741                  fputs("\n", stderr);                  fputs("\n", stderr);
742                  *len = 0;                  *len = 0;
743                  return NULL;                  return NULL;

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26