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); |
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, "/"); |
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 |
|
|
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 |
|
|
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 |
} |
} |
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 |
} |
} |
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 |
} |
} |
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 |
} |
} |
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 |
} |
} |
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 |
} |
} |
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 |
} |
} |
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) { |
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 |
} |
} |
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; |
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 |
} |
} |
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; |
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 |
} |
} |
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 |
} |
} |
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 |
} |
} |
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; |
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 |
} |
} |
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; |
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 |
} |
} |
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; |
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 |
} |
} |
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; |
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 |
} |
} |
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; |
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; |