crypto.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef _CRYPTO_H_
  2. #define _CRYPTO_H_
  3. #include "flow.h"
  4. #include "ptwist.h"
  5. #define n2s(c,s) ((s=(((unsigned int)(c[0]))<< 8)| \
  6. (((unsigned int)(c[1])) )),c+=2)
  7. /* Curves */
  8. int extract_parameters(flow *f, uint8_t *hs);
  9. int encrypt(flow *f, uint8_t *input, uint8_t *output, int32_t len, int32_t incoming, int32_t type, int32_t enc, uint8_t re);
  10. int extract_server_random(flow *f, uint8_t *hs);
  11. int compute_master_secret(flow *f);
  12. int PRF(flow *f, uint8_t *secret, int32_t secret_len,
  13. uint8_t *seed1, int32_t seed1_len,
  14. uint8_t *seed2, int32_t seed2_len,
  15. uint8_t *seed3, int32_t seed3_len,
  16. uint8_t *seed4, int32_t seed4_len,
  17. uint8_t *output, int32_t output_len);
  18. int update_finish_hash(flow *f, uint8_t *hs);
  19. int verify_finish_hash(flow *f, uint8_t *p, int32_t incoming);
  20. int init_ciphers(flow *f);
  21. void generate_client_super_keys(uint8_t *secret, client *c);
  22. int super_encrypt(client *c, uint8_t *data, uint32_t len);
  23. void check_handshake(struct packet_info *info);
  24. int check_tag(byte key[16], const byte privkey[PTWIST_BYTES],
  25. const byte tag[PTWIST_TAG_BYTES], const byte *context,
  26. size_t context_len);
  27. #define PRE_MASTER_MAX_LEN BUFSIZ
  28. #define SLITHEEN_KEYGEN_CONST "SLITHEEN_KEYGEN"
  29. #define SLITHEEN_KEYGEN_CONST_SIZE 15
  30. #define SLITHEEN_FINISHED_INPUT_CONST "SLITHEEN_FINISH"
  31. #define SLITHEEN_FINISHED_INPUT_CONST_SIZE 15
  32. #define SLITHEEN_SUPER_SECRET_SIZE 16 //extracted from slitheen ID tag
  33. #define SLITHEEN_SUPER_CONST "SLITHEEN_SUPER_ENCRYPT"
  34. #define SLITHEEN_SUPER_CONST_SIZE 22
  35. #endif