handshake.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Generic netlink HANDSHAKE service.
  4. *
  5. * Author: Chuck Lever <chuck.lever@oracle.com>
  6. *
  7. * Copyright (c) 2023, Oracle and/or its affiliates.
  8. */
  9. #ifndef _NET_HANDSHAKE_H
  10. #define _NET_HANDSHAKE_H
  11. enum {
  12. TLS_NO_KEYRING = 0,
  13. TLS_NO_PEERID = 0,
  14. TLS_NO_CERT = 0,
  15. TLS_NO_PRIVKEY = 0,
  16. };
  17. typedef void (*tls_done_func_t)(void *data, int status,
  18. key_serial_t peerid);
  19. struct tls_handshake_args {
  20. struct socket *ta_sock;
  21. tls_done_func_t ta_done;
  22. void *ta_data;
  23. const char *ta_peername;
  24. unsigned int ta_timeout_ms;
  25. key_serial_t ta_keyring;
  26. key_serial_t ta_my_cert;
  27. key_serial_t ta_my_privkey;
  28. unsigned int ta_num_peerids;
  29. key_serial_t ta_my_peerids[5];
  30. };
  31. int tls_client_hello_anon(const struct tls_handshake_args *args, gfp_t flags);
  32. int tls_client_hello_x509(const struct tls_handshake_args *args, gfp_t flags);
  33. int tls_client_hello_psk(const struct tls_handshake_args *args, gfp_t flags);
  34. int tls_server_hello_x509(const struct tls_handshake_args *args, gfp_t flags);
  35. int tls_server_hello_psk(const struct tls_handshake_args *args, gfp_t flags);
  36. bool tls_handshake_cancel(struct sock *sk);
  37. void tls_handshake_close(struct socket *sock);
  38. u8 tls_get_record_type(const struct sock *sk, const struct cmsghdr *msg);
  39. void tls_alert_recv(const struct sock *sk, const struct msghdr *msg,
  40. u8 *level, u8 *description);
  41. #endif /* _NET_HANDSHAKE_H */