Blame view

include/keys/rxrpc-type.h 4.21 KB
2874c5fd2   Thomas Gleixner   treewide: Replace...
1
  /* SPDX-License-Identifier: GPL-2.0-or-later */
17926a793   David Howells   [AF_RXRPC]: Provi...
2
3
4
5
  /* RxRPC key type
   *
   * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
   * Written by David Howells (dhowells@redhat.com)
17926a793   David Howells   [AF_RXRPC]: Provi...
6
7
8
9
10
11
12
13
14
15
16
   */
  
  #ifndef _KEYS_RXRPC_TYPE_H
  #define _KEYS_RXRPC_TYPE_H
  
  #include <linux/key.h>
  
  /*
   * key type for AF_RXRPC keys
   */
  extern struct key_type key_type_rxrpc;
76181c134   David Howells   KEYS: Make reques...
17
  extern struct key *rxrpc_get_null_key(const char *);
339412841   David Howells   RxRPC: Allow key ...
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  /*
   * RxRPC key for Kerberos IV (type-2 security)
   */
  struct rxkad_key {
  	u32	vice_id;
  	u32	start;			/* time at which ticket starts */
  	u32	expiry;			/* time at which ticket expires */
  	u32	kvno;			/* key version number */
  	u8	primary_flag;		/* T if key for primary cell for this user */
  	u16	ticket_len;		/* length of ticket[] */
  	u8	session_key[8];		/* DES session key */
  	u8	ticket[0];		/* the encrypted ticket */
  };
  
  /*
99455153d   David Howells   RxRPC: Parse secu...
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
   * Kerberos 5 principal
   *	name/name/name@realm
   */
  struct krb5_principal {
  	u8	n_name_parts;		/* N of parts of the name part of the principal */
  	char	**name_parts;		/* parts of the name part of the principal */
  	char	*realm;			/* parts of the realm part of the principal */
  };
  
  /*
   * Kerberos 5 tagged data
   */
  struct krb5_tagged_data {
  	/* for tag value, see /usr/include/krb5/krb5.h
  	 * - KRB5_AUTHDATA_* for auth data
965475acc   David Howells   KEYS: Strip trail...
48
  	 * -
99455153d   David Howells   RxRPC: Parse secu...
49
  	 */
4e36a95e5   David Howells   RxRPC: Use uX/sX ...
50
51
  	s32		tag;
  	u32		data_len;
99455153d   David Howells   RxRPC: Parse secu...
52
53
54
55
56
57
58
  	u8		*data;
  };
  
  /*
   * RxRPC key for Kerberos V (type-5 security)
   */
  struct rxk5_key {
4e36a95e5   David Howells   RxRPC: Use uX/sX ...
59
60
61
62
63
  	u64			authtime;	/* time at which auth token generated */
  	u64			starttime;	/* time at which auth token starts */
  	u64			endtime;	/* time at which auth token expired */
  	u64			renew_till;	/* time to which auth token can be renewed */
  	s32			is_skey;	/* T if ticket is encrypted in another ticket's
99455153d   David Howells   RxRPC: Parse secu...
64
  						 * skey */
4e36a95e5   David Howells   RxRPC: Use uX/sX ...
65
  	s32			flags;		/* mask of TKT_FLG_* bits (krb5/krb5.h) */
99455153d   David Howells   RxRPC: Parse secu...
66
67
  	struct krb5_principal	client;		/* client principal name */
  	struct krb5_principal	server;		/* server principal name */
4e36a95e5   David Howells   RxRPC: Use uX/sX ...
68
69
  	u16			ticket_len;	/* length of ticket */
  	u16			ticket2_len;	/* length of second ticket */
99455153d   David Howells   RxRPC: Parse secu...
70
71
72
73
74
75
76
77
78
79
80
  	u8			n_authdata;	/* number of authorisation data elements */
  	u8			n_addresses;	/* number of addresses */
  	struct krb5_tagged_data	session;	/* session data; tag is enctype */
  	struct krb5_tagged_data *addresses;	/* addresses */
  	u8			*ticket;	/* krb5 ticket */
  	u8			*ticket2;	/* second krb5 ticket, if related to ticket (via
  						 * DUPLICATE-SKEY or ENC-TKT-IN-SKEY) */
  	struct krb5_tagged_data *authdata;	/* authorisation data */
  };
  
  /*
339412841   David Howells   RxRPC: Allow key ...
81
82
83
84
85
86
87
   * list of tokens attached to an rxrpc key
   */
  struct rxrpc_key_token {
  	u16	security_index;		/* RxRPC header security index */
  	struct rxrpc_key_token *next;	/* the next token in the list */
  	union {
  		struct rxkad_key *kad;
99455153d   David Howells   RxRPC: Parse secu...
88
  		struct rxk5_key *k5;
339412841   David Howells   RxRPC: Allow key ...
89
90
91
92
93
94
95
  	};
  };
  
  /*
   * structure of raw payloads passed to add_key() or instantiate key
   */
  struct rxrpc_key_data_v1 {
339412841   David Howells   RxRPC: Allow key ...
96
97
98
99
100
101
102
103
104
105
106
107
108
  	u16		security_index;
  	u16		ticket_length;
  	u32		expiry;			/* time_t */
  	u32		kvno;
  	u8		session_key[8];
  	u8		ticket[0];
  };
  
  /*
   * AF_RXRPC key payload derived from XDR format
   * - based on openafs-1.4.10/src/auth/afs_token.xg
   */
  #define AFSTOKEN_LENGTH_MAX		16384	/* max payload size */
99455153d   David Howells   RxRPC: Parse secu...
109
110
  #define AFSTOKEN_STRING_MAX		256	/* max small string length */
  #define AFSTOKEN_DATA_MAX		64	/* max small data length */
339412841   David Howells   RxRPC: Allow key ...
111
112
  #define AFSTOKEN_CELL_MAX		64	/* max cellname length */
  #define AFSTOKEN_MAX			8	/* max tokens per payload */
99455153d   David Howells   RxRPC: Parse secu...
113
  #define AFSTOKEN_BDATALN_MAX		16384	/* max big data length */
339412841   David Howells   RxRPC: Allow key ...
114
115
116
117
118
119
120
121
122
  #define AFSTOKEN_RK_TIX_MAX		12000	/* max RxKAD ticket size */
  #define AFSTOKEN_GK_KEY_MAX		64	/* max GSSAPI key size */
  #define AFSTOKEN_GK_TOKEN_MAX		16384	/* max GSSAPI token size */
  #define AFSTOKEN_K5_COMPONENTS_MAX	16	/* max K5 components */
  #define AFSTOKEN_K5_NAME_MAX		128	/* max K5 name length */
  #define AFSTOKEN_K5_REALM_MAX		64	/* max K5 realm name length */
  #define AFSTOKEN_K5_TIX_MAX		16384	/* max K5 ticket size */
  #define AFSTOKEN_K5_ADDRESSES_MAX	16	/* max K5 addresses */
  #define AFSTOKEN_K5_AUTHDATA_MAX	16	/* max K5 pieces of auth data */
10674a03c   Baolin Wang   net: rxrpc: Repla...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
  /*
   * Truncate a time64_t to the range from 1970 to 2106 as in the network
   * protocol.
   */
  static inline u32 rxrpc_time64_to_u32(time64_t time)
  {
  	if (time < 0)
  		return 0;
  
  	if (time > UINT_MAX)
  		return UINT_MAX;
  
  	return (u32)time;
  }
  
  /*
   * Extend u32 back to time64_t using the same 1970-2106 range.
   */
  static inline time64_t rxrpc_u32_to_time64(u32 time)
  {
  	return (time64_t)time;
  }
dd89db1df   Robert P. J. Day   KEYS: Fix the co...
145
  #endif /* _KEYS_RXRPC_TYPE_H */