nixio-tls.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef NIXIO_TLS_H_
  2. #define NIXIO_TLS_H_
  3. #include "nixio.h"
  4. #include <sys/types.h>
  5. #ifndef WITHOUT_OPENSSL
  6. #include <openssl/ssl.h>
  7. #include <openssl/md5.h>
  8. #include <openssl/sha.h>
  9. #endif
  10. #define NIXIO_TLS_CTX_META "nixio.tls.ctx"
  11. #define NIXIO_TLS_SOCK_META "nixio.tls.sock"
  12. typedef struct nixio_tls_socket {
  13. SSL *socket;
  14. #ifdef WITH_AXTLS
  15. char connected;
  16. size_t pbufsiz;
  17. char *pbufpos;
  18. char *pbuffer;
  19. #endif
  20. } nixio_tls_sock;
  21. #define NIXIO_CRYPTO_HASH_META "nixio.crypto.hash"
  22. #define NIXIO_DIGEST_SIZE 64
  23. #define NIXIO_CRYPTO_BLOCK_SIZE 64
  24. #define NIXIO_HASH_NONE 0
  25. #define NIXIO_HASH_MD5 0x01
  26. #define NIXIO_HASH_SHA1 0x02
  27. #define NIXIO_HMAC_BIT 0x40
  28. typedef int(*nixio_hash_initcb)(void *);
  29. typedef int(*nixio_hash_updatecb)(void *, const void *, unsigned long);
  30. typedef int(*nixio_hash_finalcb)(unsigned char *, void *);
  31. typedef struct nixio_hash_obj {
  32. uint type;
  33. unsigned char digest[NIXIO_DIGEST_SIZE];
  34. size_t digest_size;
  35. unsigned char key[NIXIO_CRYPTO_BLOCK_SIZE];
  36. size_t key_size;
  37. size_t block_size;
  38. void *ctx;
  39. nixio_hash_initcb init;
  40. nixio_hash_updatecb update;
  41. nixio_hash_finalcb final;
  42. } nixio_hash;
  43. #endif /* NIXIO_TLS_H_ */