35 |
|
|
36 |
lt_dlclose(td->algorithm_handle); |
lt_dlclose(td->algorithm_handle); |
37 |
lt_dlclose(td->mode_handle); |
lt_dlclose(td->mode_handle); |
38 |
lt_dlexit(); |
if (lt_dlexit() != 0) { |
39 |
|
return MCRYPT_UNKNOWN_ERROR; |
40 |
|
} |
41 |
|
|
42 |
td->algorithm_handle = NULL; |
td->algorithm_handle = NULL; |
43 |
td->mode_handle = NULL; |
td->mode_handle = NULL; |
144 |
return MCRYPT_FAILED; |
return MCRYPT_FAILED; |
145 |
} |
} |
146 |
|
|
|
/* LTDL_SET_PRELOADED_SYMBOLS(); */ |
|
|
|
|
147 |
td->algorithm_handle = mcrypt_dlopen(a_directory, m_directory, algorithm); |
td->algorithm_handle = mcrypt_dlopen(a_directory, m_directory, algorithm); |
148 |
if (td->algorithm_handle == NULL) { |
if (td->algorithm_handle == NULL) { |
149 |
err=lt_dlerror(); |
err=lt_dlerror(); |
187 |
int (*_mcrypt_get_size) (void); |
int (*_mcrypt_get_size) (void); |
188 |
|
|
189 |
const char *error; |
const char *error; |
|
void *s; |
|
190 |
|
|
191 |
s = td->algorithm_handle; |
_mcrypt_get_size = lt_dlsym(td->algorithm_handle, "_mcrypt_get_size"); |
192 |
_mcrypt_get_size = lt_dlsym(s, "_mcrypt_get_size"); |
if (_mcrypt_get_size == NULL) { |
193 |
if ((error = lt_dlerror())) { |
error = lt_dlerror(); |
194 |
if (error!=NULL) fputs(error, stderr); |
if (error!=NULL) fputs(error, stderr); |
195 |
fputs("\n", stderr); |
fputs("\n", stderr); |
196 |
return MCRYPT_UNKNOWN_ERROR; |
return MCRYPT_UNKNOWN_ERROR; |
204 |
int (*_mcrypt_get_size) (void); |
int (*_mcrypt_get_size) (void); |
205 |
|
|
206 |
const char *error; |
const char *error; |
|
void *s; |
|
207 |
|
|
208 |
s = td->mode_handle; |
_mcrypt_get_size = lt_dlsym(td->mode_handle, "_mcrypt_mode_get_size"); |
209 |
_mcrypt_get_size = lt_dlsym(s, "_mcrypt_mode_get_size"); |
if (_mcrypt_get_size == NULL) { |
210 |
if ((error = lt_dlerror())) { |
error = lt_dlerror(); |
211 |
if (error!=NULL) fputs(error, stderr); |
if (error!=NULL) fputs(error, stderr); |
212 |
fputs("\n", stderr); |
fputs("\n", stderr); |
213 |
return MCRYPT_UNKNOWN_ERROR; |
return MCRYPT_UNKNOWN_ERROR; |
221 |
int (*__mcrypt_set_key_stream) (void *, void *, int, void *, int); |
int (*__mcrypt_set_key_stream) (void *, void *, int, void *, int); |
222 |
int (*__mcrypt_set_key_block) (void *, void *, int); |
int (*__mcrypt_set_key_block) (void *, void *, int); |
223 |
const char *error; |
const char *error; |
|
void *s; |
|
224 |
|
|
|
s = td->algorithm_handle; |
|
225 |
if (mcrypt_enc_is_block_algorithm(td) == 0) { |
if (mcrypt_enc_is_block_algorithm(td) == 0) { |
226 |
/* stream */ |
/* stream */ |
227 |
__mcrypt_set_key_stream = lt_dlsym(s, "_mcrypt_set_key"); |
__mcrypt_set_key_stream = lt_dlsym(td->algorithm_handle, "_mcrypt_set_key"); |
228 |
if ((error = lt_dlerror())) { |
if (__mcrypt_set_key_stream == NULL) { |
229 |
|
error = lt_dlerror(); |
230 |
if (error!=NULL) fputs(error, stderr); |
if (error!=NULL) fputs(error, stderr); |
231 |
fputs("\n", stderr); |
fputs("\n", stderr); |
232 |
return -2; |
return -2; |
233 |
} |
} |
234 |
return __mcrypt_set_key_stream(a, b, c, d, e); |
return __mcrypt_set_key_stream(a, b, c, d, e); |
235 |
} else { |
} else { |
236 |
__mcrypt_set_key_block = lt_dlsym(s, "_mcrypt_set_key"); |
__mcrypt_set_key_block = lt_dlsym(td->algorithm_handle, "_mcrypt_set_key"); |
237 |
if ((error = lt_dlerror())) { |
if (__mcrypt_set_key_block == NULL) { |
238 |
|
error = lt_dlerror(); |
239 |
if (error!=NULL) fputs(error, stderr); |
if (error!=NULL) fputs(error, stderr); |
240 |
fputs("\n", stderr); |
fputs("\n", stderr); |
241 |
return -2; |
return -2; |
249 |
{ |
{ |
250 |
int (*__mcrypt_set_state) (void *, void *, int); |
int (*__mcrypt_set_state) (void *, void *, int); |
251 |
const char *error; |
const char *error; |
|
void *s; |
|
252 |
|
|
253 |
s = td->mode_handle; |
__mcrypt_set_state = lt_dlsym(td->mode_handle, "_mcrypt_set_state"); |
254 |
|
if (__mcrypt_set_state==NULL) { |
255 |
__mcrypt_set_state = lt_dlsym(s, "_mcrypt_set_state"); |
error = lt_dlerror(); |
|
if ((error = lt_dlerror())) { |
|
256 |
if (error!=NULL) fputs(error, stderr); |
if (error!=NULL) fputs(error, stderr); |
257 |
fputs("\n", stderr); |
fputs("\n", stderr); |
258 |
return MCRYPT_UNKNOWN_ERROR; |
return MCRYPT_UNKNOWN_ERROR; |
273 |
int mcrypt_get_algo_iv_size(MCRYPT td) |
int mcrypt_get_algo_iv_size(MCRYPT td) |
274 |
{ |
{ |
275 |
int (*_mcrypt_get_algo_iv_size) (void); |
int (*_mcrypt_get_algo_iv_size) (void); |
|
void *s; |
|
|
|
|
|
s = td->algorithm_handle; |
|
276 |
|
|
277 |
_mcrypt_get_algo_iv_size = lt_dlsym(s, "_mcrypt_get_algo_iv_size"); |
_mcrypt_get_algo_iv_size = lt_dlsym(td->algorithm_handle, "_mcrypt_get_algo_iv_size"); |
278 |
return _mcrypt_get_algo_iv_size(); |
return _mcrypt_get_algo_iv_size(); |
279 |
} |
} |
280 |
|
|
292 |
int mcrypt_enc_get_key_size(MCRYPT td) |
int mcrypt_enc_get_key_size(MCRYPT td) |
293 |
{ |
{ |
294 |
int (*_mcrypt_get_key_size) (void); |
int (*_mcrypt_get_key_size) (void); |
|
void *s; |
|
295 |
|
|
296 |
s = td->algorithm_handle; |
_mcrypt_get_key_size = lt_dlsym(td->algorithm_handle, "_mcrypt_get_key_size"); |
|
|
|
|
_mcrypt_get_key_size = lt_dlsym(s, "_mcrypt_get_key_size"); |
|
297 |
return _mcrypt_get_key_size(); |
return _mcrypt_get_key_size(); |
298 |
} |
} |
299 |
|
|
301 |
int *mcrypt_enc_get_supported_key_sizes(MCRYPT td, int *len) |
int *mcrypt_enc_get_supported_key_sizes(MCRYPT td, int *len) |
302 |
{ |
{ |
303 |
int *(*_mcrypt_get_key_sizes) (int *); |
int *(*_mcrypt_get_key_sizes) (int *); |
|
void *s; |
|
304 |
int *size; |
int *size; |
305 |
|
|
|
s = td->algorithm_handle; |
|
|
|
|
306 |
_mcrypt_get_key_sizes = |
_mcrypt_get_key_sizes = |
307 |
lt_dlsym(s, "_mcrypt_get_supported_key_sizes"); |
lt_dlsym(td->algorithm_handle, "_mcrypt_get_supported_key_sizes"); |
308 |
size = _mcrypt_get_key_sizes(len); |
size = _mcrypt_get_key_sizes(len); |
309 |
|
|
310 |
return size; |
return size; |
314 |
int mcrypt_enc_is_block_algorithm(MCRYPT td) |
int mcrypt_enc_is_block_algorithm(MCRYPT td) |
315 |
{ |
{ |
316 |
int (*_is_block_algorithm) (void); |
int (*_is_block_algorithm) (void); |
|
void *s; |
|
317 |
|
|
318 |
s = td->algorithm_handle; |
_is_block_algorithm = lt_dlsym(td->algorithm_handle, "_is_block_algorithm"); |
|
|
|
|
_is_block_algorithm = lt_dlsym(s, "_is_block_algorithm"); |
|
319 |
return _is_block_algorithm(); |
return _is_block_algorithm(); |
320 |
} |
} |
321 |
|
|
323 |
char *mcrypt_enc_get_algorithms_name(MCRYPT td) |
char *mcrypt_enc_get_algorithms_name(MCRYPT td) |
324 |
{ |
{ |
325 |
char *(*_mcrypt_get_algorithms_name) (void); |
char *(*_mcrypt_get_algorithms_name) (void); |
|
void *s; |
|
|
|
|
|
s = td->algorithm_handle; |
|
326 |
|
|
327 |
_mcrypt_get_algorithms_name = |
_mcrypt_get_algorithms_name = |
328 |
lt_dlsym(s, "_mcrypt_get_algorithms_name"); |
lt_dlsym(td->algorithm_handle, "_mcrypt_get_algorithms_name"); |
329 |
return _mcrypt_get_algorithms_name(); |
return _mcrypt_get_algorithms_name(); |
330 |
} |
} |
331 |
|
|
333 |
int init_mcrypt(MCRYPT td, void *buf, void *a, int b, void *c) |
int init_mcrypt(MCRYPT td, void *buf, void *a, int b, void *c) |
334 |
{ |
{ |
335 |
int (*_init_mcrypt) (void *, void *, int, void *, int); |
int (*_init_mcrypt) (void *, void *, int, void *, int); |
|
void *s; |
|
336 |
|
|
337 |
s = td->mode_handle; |
_init_mcrypt = lt_dlsym(td->mode_handle, "_init_mcrypt"); |
|
_init_mcrypt = lt_dlsym(s, "_init_mcrypt"); |
|
338 |
return _init_mcrypt(buf, a, b, c, mcrypt_enc_get_block_size(td)); |
return _init_mcrypt(buf, a, b, c, mcrypt_enc_get_block_size(td)); |
339 |
} |
} |
340 |
|
|
342 |
int end_mcrypt(MCRYPT td, void *buf) |
int end_mcrypt(MCRYPT td, void *buf) |
343 |
{ |
{ |
344 |
int (*_end_mcrypt) (void *); |
int (*_end_mcrypt) (void *); |
|
void *s; |
|
345 |
|
|
346 |
s = td->mode_handle; |
_end_mcrypt = lt_dlsym(td->mode_handle, "_end_mcrypt"); |
|
_end_mcrypt = lt_dlsym(s, "_end_mcrypt"); |
|
347 |
return _end_mcrypt(buf); |
return _end_mcrypt(buf); |
348 |
} |
} |
349 |
|
|
371 |
char *mcrypt_enc_get_modes_name(MCRYPT td) |
char *mcrypt_enc_get_modes_name(MCRYPT td) |
372 |
{ |
{ |
373 |
char *(*_mcrypt_get_modes_name) (void); |
char *(*_mcrypt_get_modes_name) (void); |
|
void *s; |
|
374 |
|
|
375 |
s = td->mode_handle; |
_mcrypt_get_modes_name = lt_dlsym(td->mode_handle, "_mcrypt_get_modes_name"); |
|
|
|
|
_mcrypt_get_modes_name = lt_dlsym(s, "_mcrypt_get_modes_name"); |
|
376 |
return _mcrypt_get_modes_name(); |
return _mcrypt_get_modes_name(); |
377 |
} |
} |
378 |
|
|
380 |
int mcrypt_enc_is_block_mode(MCRYPT td) |
int mcrypt_enc_is_block_mode(MCRYPT td) |
381 |
{ |
{ |
382 |
int (*_is_block_mode) (void); |
int (*_is_block_mode) (void); |
|
void *s; |
|
|
|
|
|
s = td->mode_handle; |
|
383 |
|
|
384 |
_is_block_mode = lt_dlsym(s, "_is_block_mode"); |
_is_block_mode = lt_dlsym(td->mode_handle, "_is_block_mode"); |
385 |
return _is_block_mode(); |
return _is_block_mode(); |
386 |
} |
} |
387 |
|
|
389 |
int mcrypt_enc_mode_has_iv(MCRYPT td) |
int mcrypt_enc_mode_has_iv(MCRYPT td) |
390 |
{ |
{ |
391 |
int (*_has_iv) (void); |
int (*_has_iv) (void); |
|
void *s; |
|
392 |
|
|
393 |
s = td->mode_handle; |
_has_iv = lt_dlsym(td->mode_handle, "_has_iv"); |
|
|
|
|
_has_iv = lt_dlsym(s, "_has_iv"); |
|
394 |
return _has_iv(); |
return _has_iv(); |
395 |
} |
} |
396 |
|
|
398 |
int mcrypt_enc_is_block_algorithm_mode(MCRYPT td) |
int mcrypt_enc_is_block_algorithm_mode(MCRYPT td) |
399 |
{ |
{ |
400 |
int (*_is_a_block_mode) (void); |
int (*_is_a_block_mode) (void); |
|
void *s; |
|
|
|
|
|
s = td->mode_handle; |
|
401 |
|
|
402 |
_is_a_block_mode = lt_dlsym(s, "_is_block_algorithm_mode"); |
_is_a_block_mode = lt_dlsym(td->mode_handle, "_is_block_algorithm_mode"); |
403 |
return _is_a_block_mode(); |
return _is_a_block_mode(); |
404 |
} |
} |
405 |
|
|
407 |
int mcrypt_enc_self_test(MCRYPT td) |
int mcrypt_enc_self_test(MCRYPT td) |
408 |
{ |
{ |
409 |
int (*_self_test) (void); |
int (*_self_test) (void); |
|
void *s; |
|
410 |
|
|
411 |
s = td->algorithm_handle; |
_self_test = lt_dlsym(td->algorithm_handle, "_mcrypt_self_test"); |
|
|
|
|
_self_test = lt_dlsym(s, "_mcrypt_self_test"); |
|
412 |
|
|
413 |
return _self_test(); |
return _self_test(); |
414 |
} |
} |
421 |
int (*_self_test) (void); |
int (*_self_test) (void); |
422 |
const char* error; |
const char* error; |
423 |
|
|
|
|
|
424 |
if (lt_dlinit() != 0) { |
if (lt_dlinit() != 0) { |
425 |
return MCRYPT_UNKNOWN_ERROR; |
return MCRYPT_UNKNOWN_ERROR; |
426 |
} |
} |
|
/* LTDL_SET_PRELOADED_SYMBOLS(); */ |
|
427 |
|
|
428 |
_handle = mcrypt_dlopen(a_directory, NULL, algorithm); |
_handle = mcrypt_dlopen(a_directory, NULL, algorithm); |
429 |
|
|
431 |
error=lt_dlerror(); |
error=lt_dlerror(); |
432 |
if (error!=NULL) fputs( error, stderr); |
if (error!=NULL) fputs( error, stderr); |
433 |
fputs("\n", stderr); |
fputs("\n", stderr); |
434 |
|
lt_dlexit(); |
435 |
return MCRYPT_UNKNOWN_ERROR; |
return MCRYPT_UNKNOWN_ERROR; |
436 |
} |
} |
437 |
|
|
440 |
i = _self_test(); |
i = _self_test(); |
441 |
|
|
442 |
lt_dlclose(_handle); |
lt_dlclose(_handle); |
443 |
lt_dlexit(); |
if (lt_dlexit() != 0) { |
444 |
|
return MCRYPT_UNKNOWN_ERROR; |
445 |
|
} |
446 |
|
|
447 |
return i; |
return i; |
448 |
} |
} |
449 |
|
|
458 |
if (lt_dlinit() != 0) { |
if (lt_dlinit() != 0) { |
459 |
return MCRYPT_UNKNOWN_ERROR; |
return MCRYPT_UNKNOWN_ERROR; |
460 |
} |
} |
|
/* LTDL_SET_PRELOADED_SYMBOLS(); */ |
|
461 |
|
|
462 |
_handle = mcrypt_dlopen(a_directory, NULL, algorithm); |
_handle = mcrypt_dlopen(a_directory, NULL, algorithm); |
463 |
if (!_handle) { |
if (!_handle) { |
472 |
i = _version(); |
i = _version(); |
473 |
|
|
474 |
lt_dlclose(_handle); |
lt_dlclose(_handle); |
475 |
lt_dlexit(); |
if (lt_dlexit() != 0) { |
476 |
|
return MCRYPT_UNKNOWN_ERROR; |
477 |
|
} |
478 |
|
|
479 |
return i; |
return i; |
480 |
} |
} |
490 |
if (lt_dlinit() != 0) { |
if (lt_dlinit() != 0) { |
491 |
return MCRYPT_UNKNOWN_ERROR; |
return MCRYPT_UNKNOWN_ERROR; |
492 |
} |
} |
|
/* LTDL_SET_PRELOADED_SYMBOLS(); */ |
|
493 |
|
|
494 |
_handle = mcrypt_dlopen(m_directory, NULL, mode); |
_handle = mcrypt_dlopen(m_directory, NULL, mode); |
495 |
if (!_handle) { |
if (!_handle) { |
504 |
i = _version(); |
i = _version(); |
505 |
|
|
506 |
lt_dlclose(_handle); |
lt_dlclose(_handle); |
507 |
lt_dlexit(); |
if (lt_dlexit() != 0) { |
508 |
|
return MCRYPT_UNKNOWN_ERROR; |
509 |
|
} |
510 |
|
|
511 |
return i; |
return i; |
512 |
} |
} |
522 |
if (lt_dlinit() != 0) { |
if (lt_dlinit() != 0) { |
523 |
return MCRYPT_UNKNOWN_ERROR; |
return MCRYPT_UNKNOWN_ERROR; |
524 |
} |
} |
|
/* LTDL_SET_PRELOADED_SYMBOLS(); */ |
|
525 |
|
|
526 |
_handle = mcrypt_dlopen(a_directory, NULL, algorithm); |
_handle = mcrypt_dlopen(a_directory, NULL, algorithm); |
527 |
|
|
537 |
i = _is_block_algorithm(); |
i = _is_block_algorithm(); |
538 |
|
|
539 |
lt_dlclose(_handle); |
lt_dlclose(_handle); |
540 |
lt_dlexit(); |
if (lt_dlexit() != 0) { |
541 |
|
return MCRYPT_UNKNOWN_ERROR; |
542 |
|
} |
543 |
|
|
544 |
return i; |
return i; |
545 |
} |
} |
555 |
if (lt_dlinit() != 0) { |
if (lt_dlinit() != 0) { |
556 |
return MCRYPT_UNKNOWN_ERROR; |
return MCRYPT_UNKNOWN_ERROR; |
557 |
} |
} |
|
/* LTDL_SET_PRELOADED_SYMBOLS(); */ |
|
558 |
|
|
559 |
_handle = mcrypt_dlopen(m_directory, NULL, mode); |
_handle = mcrypt_dlopen(m_directory, NULL, mode); |
560 |
if (!_handle) { |
if (!_handle) { |
569 |
i = _is_a_block_mode(); |
i = _is_a_block_mode(); |
570 |
|
|
571 |
lt_dlclose(_handle); |
lt_dlclose(_handle); |
572 |
lt_dlexit(); |
if (lt_dlexit() != 0) { |
573 |
|
return MCRYPT_UNKNOWN_ERROR; |
574 |
|
} |
575 |
|
|
576 |
return i; |
return i; |
577 |
} |
} |
587 |
if (lt_dlinit() != 0) { |
if (lt_dlinit() != 0) { |
588 |
return MCRYPT_UNKNOWN_ERROR; |
return MCRYPT_UNKNOWN_ERROR; |
589 |
} |
} |
|
/* LTDL_SET_PRELOADED_SYMBOLS(); */ |
|
590 |
|
|
591 |
_handle = mcrypt_dlopen(m_directory, NULL, mode); |
_handle = mcrypt_dlopen(m_directory, NULL, mode); |
592 |
if (!_handle) { |
if (!_handle) { |
601 |
i = _is_block_mode(); |
i = _is_block_mode(); |
602 |
|
|
603 |
lt_dlclose(_handle); |
lt_dlclose(_handle); |
604 |
lt_dlexit(); |
if (lt_dlexit() != 0) { |
605 |
|
return MCRYPT_UNKNOWN_ERROR; |
606 |
|
} |
607 |
|
|
608 |
return i; |
return i; |
609 |
} |
} |
619 |
if (lt_dlinit() != 0) { |
if (lt_dlinit() != 0) { |
620 |
return MCRYPT_UNKNOWN_ERROR; |
return MCRYPT_UNKNOWN_ERROR; |
621 |
} |
} |
|
/* LTDL_SET_PRELOADED_SYMBOLS(); */ |
|
622 |
|
|
623 |
_handle = mcrypt_dlopen(a_directory, NULL, algorithm); |
_handle = mcrypt_dlopen(a_directory, NULL, algorithm); |
624 |
if (!_handle) { |
if (!_handle) { |
633 |
i = _get_block_size(); |
i = _get_block_size(); |
634 |
|
|
635 |
lt_dlclose(_handle); |
lt_dlclose(_handle); |
636 |
lt_dlexit(); |
if (lt_dlexit() != 0) { |
637 |
|
return MCRYPT_UNKNOWN_ERROR; |
638 |
|
} |
639 |
|
|
640 |
return i; |
return i; |
641 |
} |
} |
651 |
if (lt_dlinit() != 0) { |
if (lt_dlinit() != 0) { |
652 |
return MCRYPT_UNKNOWN_ERROR; |
return MCRYPT_UNKNOWN_ERROR; |
653 |
} |
} |
|
/* LTDL_SET_PRELOADED_SYMBOLS(); */ |
|
654 |
|
|
655 |
_handle = mcrypt_dlopen(a_directory, NULL, algorithm); |
_handle = mcrypt_dlopen(a_directory, NULL, algorithm); |
656 |
if (!_handle) { |
if (!_handle) { |
665 |
i = _get_key_size(); |
i = _get_key_size(); |
666 |
|
|
667 |
lt_dlclose(_handle); |
lt_dlclose(_handle); |
668 |
lt_dlexit(); |
if (lt_dlexit() != 0) { |
669 |
|
return MCRYPT_UNKNOWN_ERROR; |
670 |
|
} |
671 |
|
|
672 |
return i; |
return i; |
673 |
} |
} |
686 |
*len = 0; |
*len = 0; |
687 |
return NULL; |
return NULL; |
688 |
} |
} |
|
/* LTDL_SET_PRELOADED_SYMBOLS(); */ |
|
689 |
|
|
690 |
_handle = mcrypt_dlopen(a_directory, NULL, algorithm); |
_handle = mcrypt_dlopen(a_directory, NULL, algorithm); |
691 |
if (!_handle) { |
if (!_handle) { |
702 |
size = _mcrypt_get_key_sizes(len); |
size = _mcrypt_get_key_sizes(len); |
703 |
|
|
704 |
lt_dlclose(_handle); |
lt_dlclose(_handle); |
705 |
lt_dlexit(); |
if (lt_dlexit() != 0) { |
706 |
|
return NULL; |
707 |
|
} |
708 |
|
|
709 |
return size; |
return size; |
710 |
} |
} |