insecure.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /* Null security operations.
  3. *
  4. * Copyright (C) 2016 Red Hat, Inc. All Rights Reserved.
  5. * Written by David Howells ([email protected])
  6. */
  7. #include <net/af_rxrpc.h>
  8. #include "ar-internal.h"
  9. static int none_init_connection_security(struct rxrpc_connection *conn,
  10. struct rxrpc_key_token *token)
  11. {
  12. return 0;
  13. }
  14. /*
  15. * Work out how much data we can put in an unsecured packet.
  16. */
  17. static int none_how_much_data(struct rxrpc_call *call, size_t remain,
  18. size_t *_buf_size, size_t *_data_size, size_t *_offset)
  19. {
  20. *_buf_size = *_data_size = min_t(size_t, remain, RXRPC_JUMBO_DATALEN);
  21. *_offset = 0;
  22. return 0;
  23. }
  24. static int none_secure_packet(struct rxrpc_call *call, struct sk_buff *skb,
  25. size_t data_size)
  26. {
  27. return 0;
  28. }
  29. static int none_verify_packet(struct rxrpc_call *call, struct sk_buff *skb,
  30. unsigned int offset, unsigned int len,
  31. rxrpc_seq_t seq, u16 expected_cksum)
  32. {
  33. return 0;
  34. }
  35. static void none_free_call_crypto(struct rxrpc_call *call)
  36. {
  37. }
  38. static void none_locate_data(struct rxrpc_call *call, struct sk_buff *skb,
  39. unsigned int *_offset, unsigned int *_len)
  40. {
  41. }
  42. static int none_respond_to_challenge(struct rxrpc_connection *conn,
  43. struct sk_buff *skb,
  44. u32 *_abort_code)
  45. {
  46. struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
  47. trace_rxrpc_rx_eproto(NULL, sp->hdr.serial,
  48. tracepoint_string("chall_none"));
  49. return -EPROTO;
  50. }
  51. static int none_verify_response(struct rxrpc_connection *conn,
  52. struct sk_buff *skb,
  53. u32 *_abort_code)
  54. {
  55. struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
  56. trace_rxrpc_rx_eproto(NULL, sp->hdr.serial,
  57. tracepoint_string("resp_none"));
  58. return -EPROTO;
  59. }
  60. static void none_clear(struct rxrpc_connection *conn)
  61. {
  62. }
  63. static int none_init(void)
  64. {
  65. return 0;
  66. }
  67. static void none_exit(void)
  68. {
  69. }
  70. /*
  71. * RxRPC Kerberos-based security
  72. */
  73. const struct rxrpc_security rxrpc_no_security = {
  74. .name = "none",
  75. .security_index = RXRPC_SECURITY_NONE,
  76. .init = none_init,
  77. .exit = none_exit,
  78. .init_connection_security = none_init_connection_security,
  79. .free_call_crypto = none_free_call_crypto,
  80. .how_much_data = none_how_much_data,
  81. .secure_packet = none_secure_packet,
  82. .verify_packet = none_verify_packet,
  83. .locate_data = none_locate_data,
  84. .respond_to_challenge = none_respond_to_challenge,
  85. .verify_response = none_verify_response,
  86. .clear = none_clear,
  87. };