You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
885 B

  1. #ifndef _ENCRYPT_H
  2. #define _ENCRYPT_H
  3. #include "config.h"
  4. #include <sys/socket.h>
  5. #include <string.h>
  6. #include <stdlib.h>
  7. #include <stdio.h>
  8. #ifdef HAVE_STDINT_H
  9. #include <stdint.h>
  10. #elif HAVE_INTTYPES_H
  11. #include <inttypes.h>
  12. #endif
  13. #include "md5.h"
  14. #include "rc4.h"
  15. #define BUF_SIZE 4096
  16. #define TABLE 0
  17. #define RC4 1
  18. struct {
  19. int method;
  20. union {
  21. struct {
  22. uint8_t *encrypt_table;
  23. uint8_t *decrypt_table;
  24. uint32_t salt;
  25. uint64_t key;
  26. } table;
  27. struct {
  28. uint8_t *key;
  29. int key_len;
  30. } rc4;
  31. } ctx;
  32. } enc_conf;
  33. void encrypt_ctx(char *buf, int len, struct rc4_state *ctx);
  34. void decrypt_ctx(char *buf, int len, struct rc4_state *ctx);
  35. void enc_ctx_init(struct rc4_state *ctx, int enc);
  36. void enc_conf_init(const char *pass, const char *method);
  37. #endif // _ENCRYPT_H