xref: /openbmc/linux/net/rxrpc/insecure.c (revision 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e)
1b4d0d230SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
2e0e4d82fSDavid Howells /* Null security operations.
3e0e4d82fSDavid Howells  *
4e0e4d82fSDavid Howells  * Copyright (C) 2016 Red Hat, Inc. All Rights Reserved.
5e0e4d82fSDavid Howells  * Written by David Howells (dhowells@redhat.com)
6e0e4d82fSDavid Howells  */
7e0e4d82fSDavid Howells 
8e0e4d82fSDavid Howells #include <net/af_rxrpc.h>
9e0e4d82fSDavid Howells #include "ar-internal.h"
10e0e4d82fSDavid Howells 
none_init_connection_security(struct rxrpc_connection * conn,struct rxrpc_key_token * token)1141057ebdSDavid Howells static int none_init_connection_security(struct rxrpc_connection *conn,
1241057ebdSDavid Howells 					 struct rxrpc_key_token *token)
13e0e4d82fSDavid Howells {
14e0e4d82fSDavid Howells 	return 0;
15e0e4d82fSDavid Howells }
16e0e4d82fSDavid Howells 
17d7d775b1SDavid Howells /*
18d7d775b1SDavid Howells  * Work out how much data we can put in an unsecured packet.
19d7d775b1SDavid Howells  */
none_how_much_data(struct rxrpc_call * call,size_t remain,size_t * _buf_size,size_t * _data_size,size_t * _offset)20d7d775b1SDavid Howells static int none_how_much_data(struct rxrpc_call *call, size_t remain,
21d7d775b1SDavid Howells 			       size_t *_buf_size, size_t *_data_size, size_t *_offset)
22d7d775b1SDavid Howells {
23d7d775b1SDavid Howells 	*_buf_size = *_data_size = min_t(size_t, remain, RXRPC_JUMBO_DATALEN);
24d7d775b1SDavid Howells 	*_offset = 0;
25d7d775b1SDavid Howells 	return 0;
26d7d775b1SDavid Howells }
27d7d775b1SDavid Howells 
none_secure_packet(struct rxrpc_call * call,struct rxrpc_txbuf * txb)28a4ea4c47SDavid Howells static int none_secure_packet(struct rxrpc_call *call, struct rxrpc_txbuf *txb)
29e0e4d82fSDavid Howells {
30e0e4d82fSDavid Howells 	return 0;
31e0e4d82fSDavid Howells }
32e0e4d82fSDavid Howells 
none_verify_packet(struct rxrpc_call * call,struct sk_buff * skb)33d4d02d8bSDavid Howells static int none_verify_packet(struct rxrpc_call *call, struct sk_buff *skb)
34e0e4d82fSDavid Howells {
35d4d02d8bSDavid Howells 	struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
36d4d02d8bSDavid Howells 
37d4d02d8bSDavid Howells 	sp->flags |= RXRPC_RX_VERIFIED;
38e0e4d82fSDavid Howells 	return 0;
39e0e4d82fSDavid Howells }
40e0e4d82fSDavid Howells 
none_free_call_crypto(struct rxrpc_call * call)411db88c53SDavid Howells static void none_free_call_crypto(struct rxrpc_call *call)
421db88c53SDavid Howells {
431db88c53SDavid Howells }
441db88c53SDavid Howells 
none_respond_to_challenge(struct rxrpc_connection * conn,struct sk_buff * skb)45e0e4d82fSDavid Howells static int none_respond_to_challenge(struct rxrpc_connection *conn,
46a00ce28bSDavid Howells 				     struct sk_buff *skb)
47e0e4d82fSDavid Howells {
48*57af281eSDavid Howells 	return rxrpc_abort_conn(conn, skb, RX_PROTOCOL_ERROR, -EPROTO,
49*57af281eSDavid Howells 				rxrpc_eproto_rxnull_challenge);
50e0e4d82fSDavid Howells }
51e0e4d82fSDavid Howells 
none_verify_response(struct rxrpc_connection * conn,struct sk_buff * skb)52e0e4d82fSDavid Howells static int none_verify_response(struct rxrpc_connection *conn,
53a00ce28bSDavid Howells 				struct sk_buff *skb)
54e0e4d82fSDavid Howells {
55*57af281eSDavid Howells 	return rxrpc_abort_conn(conn, skb, RX_PROTOCOL_ERROR, -EPROTO,
56*57af281eSDavid Howells 				rxrpc_eproto_rxnull_response);
57e0e4d82fSDavid Howells }
58e0e4d82fSDavid Howells 
none_clear(struct rxrpc_connection * conn)59e0e4d82fSDavid Howells static void none_clear(struct rxrpc_connection *conn)
60e0e4d82fSDavid Howells {
61e0e4d82fSDavid Howells }
62e0e4d82fSDavid Howells 
none_init(void)63e0e4d82fSDavid Howells static int none_init(void)
64e0e4d82fSDavid Howells {
65e0e4d82fSDavid Howells 	return 0;
66e0e4d82fSDavid Howells }
67e0e4d82fSDavid Howells 
none_exit(void)68e0e4d82fSDavid Howells static void none_exit(void)
69e0e4d82fSDavid Howells {
70e0e4d82fSDavid Howells }
71e0e4d82fSDavid Howells 
72e0e4d82fSDavid Howells /*
73e0e4d82fSDavid Howells  * RxRPC Kerberos-based security
74e0e4d82fSDavid Howells  */
75e0e4d82fSDavid Howells const struct rxrpc_security rxrpc_no_security = {
76e0e4d82fSDavid Howells 	.name				= "none",
77e0e4d82fSDavid Howells 	.security_index			= RXRPC_SECURITY_NONE,
78e0e4d82fSDavid Howells 	.init				= none_init,
79e0e4d82fSDavid Howells 	.exit				= none_exit,
80e0e4d82fSDavid Howells 	.init_connection_security	= none_init_connection_security,
811db88c53SDavid Howells 	.free_call_crypto		= none_free_call_crypto,
82d7d775b1SDavid Howells 	.how_much_data			= none_how_much_data,
83e0e4d82fSDavid Howells 	.secure_packet			= none_secure_packet,
84e0e4d82fSDavid Howells 	.verify_packet			= none_verify_packet,
85e0e4d82fSDavid Howells 	.respond_to_challenge		= none_respond_to_challenge,
86e0e4d82fSDavid Howells 	.verify_response		= none_verify_response,
87e0e4d82fSDavid Howells 	.clear				= none_clear,
88e0e4d82fSDavid Howells };
89