crypto.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Slitheen - a decoy routing system for censorship resistance
  3. * Copyright (C) 2017 Cecylia Bocovich (cbocovic@uwaterloo.ca)
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, version 3.
  8. *
  9. * This program 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
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. * Additional permission under GNU GPL version 3 section 7
  18. *
  19. * If you modify this Program, or any covered work, by linking or combining
  20. * it with the OpenSSL library (or a modified version of that library),
  21. * containing parts covered by the terms of [name of library's license],
  22. * the licensors of this Program grant you additional permission to convey
  23. * the resulting work. {Corresponding Source for a non-source form of such
  24. * a combination shall include the source code for the parts of the OpenSSL
  25. * library used as well as that of the covered work.}
  26. */
  27. #ifndef _CRYPTO_H_
  28. #define _CRYPTO_H_
  29. #include <stdint.h>
  30. #include <openssl/evp.h>
  31. # define n2s(c,s) ((s=(((unsigned int)(c[0]))<< 8)| \
  32. (((unsigned int)(c[1])) )),c+=2)
  33. int PRF(uint8_t *secret, int32_t secret_len,
  34. uint8_t *seed1, int32_t seed1_len,
  35. uint8_t *seed2, int32_t seed2_len,
  36. uint8_t *seed3, int32_t seed3_len,
  37. uint8_t *seed4, int32_t seed4_len,
  38. uint8_t *output, int32_t output_len);
  39. int peek_header(uint8_t *data);
  40. int super_decrypt(uint8_t *data);
  41. int generate_super_keys(uint8_t *secret);
  42. typedef struct super_data_st {
  43. uint8_t *header_key;
  44. uint8_t *body_key;
  45. EVP_MD_CTX *body_mac_ctx;
  46. } super_data;
  47. #define PRE_MASTER_LEN 256
  48. #endif /* _CRYPTO_H_ */