tortls.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Copyright 2003 Roger Dingledine */
  2. /* See LICENSE for licensing information */
  3. /* $Id$ */
  4. #ifndef _TORTLS_H
  5. #define _TORTLS_H
  6. #include "../common/crypto.h"
  7. typedef struct tor_tls_context_st tor_tls_context;
  8. typedef struct tor_tls_st tor_tls;
  9. #define TOR_TLS_ERROR -4
  10. #define TOR_TLS_CLOSE -3
  11. #define TOR_TLS_WANTREAD -2
  12. #define TOR_TLS_WANTWRITE -1
  13. #define TOR_TLS_DONE 0
  14. /* X509* tor_tls_write_certificate(char *certfile, crypto_pk_env_t *rsa, char *nickname); */
  15. int tor_tls_context_new(crypto_pk_env_t *rsa, int isServer,
  16. const char *nickname, unsigned int key_lifetime);
  17. tor_tls *tor_tls_new(int sock, int isServer);
  18. void tor_tls_free(tor_tls *tls);
  19. int tor_tls_peer_has_cert(tor_tls *tls);
  20. int tor_tls_get_peer_cert_nickname(tor_tls *tls, char *buf, int buflen);
  21. int tor_tls_verify(tor_tls *tls, crypto_pk_env_t *identity);
  22. int tor_tls_read(tor_tls *tls, char *cp, int len);
  23. int tor_tls_write(tor_tls *tls, char *cp, int n);
  24. int tor_tls_handshake(tor_tls *tls);
  25. int tor_tls_shutdown(tor_tls *tls);
  26. int tor_tls_get_pending_bytes(tor_tls *tls);
  27. unsigned long tor_tls_get_n_bytes_read(tor_tls *tls);
  28. unsigned long tor_tls_get_n_bytes_written(tor_tls *tls);
  29. #define assert_no_tls_errors() _assert_no_tls_errors(__FILE__,__LINE__);
  30. void _assert_no_tls_errors(const char *fname, int line);
  31. #endif
  32. /*
  33. Local Variables:
  34. mode:c
  35. indent-tabs-mode:nil
  36. c-basic-offset:2
  37. End:
  38. */