tls.h 887 B

123456789101112131415161718192021222324
  1. /* Minimal TLS 1.3 client for ring-3 commands (see tls.c).
  2. *
  3. * TLS_CHACHA20_POLY1305_SHA256 + X25519 only. Certificates are NOT
  4. * verified (phase A): the leaf fingerprint is printed so a human can
  5. * compare it out of band. The TCP connection must already be up; the
  6. * caller owns the NIC. */
  7. #ifndef TLS_H
  8. #define TLS_H
  9. /* 0 on success (then tls_send/tls_recv may be used), -1 on failure. */
  10. int tls_connect(const char *sni);
  11. /* 0 on success; the payload is sent as one record (<= 1024 bytes). */
  12. int tls_send(const void *buf, unsigned int len);
  13. /* >0 bytes, 0 = peer closed (close_notify or TCP EOF), -1 = timeout,
  14. * -2 = reset/protocol error. Same shape as SYS_TCP_RECV. */
  15. int tls_recv(void *buf, unsigned int max, unsigned int timeout_ms);
  16. /* Best-effort close_notify (then the caller closes the TCP connection). */
  17. void tls_close(void);
  18. void tls_abandon(void);
  19. #endif