WIP FPC-III support
[linux/fpc-iii.git] / include / keys / rxrpc-type.h
blob333c0f49a9cd2a24650301f62bb3cfb6dce6397c
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /* RxRPC key type
4 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
6 */
8 #ifndef _KEYS_RXRPC_TYPE_H
9 #define _KEYS_RXRPC_TYPE_H
11 #include <linux/key.h>
14 * key type for AF_RXRPC keys
16 extern struct key_type key_type_rxrpc;
18 extern struct key *rxrpc_get_null_key(const char *);
21 * RxRPC key for Kerberos IV (type-2 security)
23 struct rxkad_key {
24 u32 vice_id;
25 u32 start; /* time at which ticket starts */
26 u32 expiry; /* time at which ticket expires */
27 u32 kvno; /* key version number */
28 u8 primary_flag; /* T if key for primary cell for this user */
29 u16 ticket_len; /* length of ticket[] */
30 u8 session_key[8]; /* DES session key */
31 u8 ticket[]; /* the encrypted ticket */
35 * list of tokens attached to an rxrpc key
37 struct rxrpc_key_token {
38 u16 security_index; /* RxRPC header security index */
39 bool no_leak_key; /* Don't copy the key to userspace */
40 struct rxrpc_key_token *next; /* the next token in the list */
41 union {
42 struct rxkad_key *kad;
47 * structure of raw payloads passed to add_key() or instantiate key
49 struct rxrpc_key_data_v1 {
50 u16 security_index;
51 u16 ticket_length;
52 u32 expiry; /* time_t */
53 u32 kvno;
54 u8 session_key[8];
55 u8 ticket[];
59 * AF_RXRPC key payload derived from XDR format
60 * - based on openafs-1.4.10/src/auth/afs_token.xg
62 #define AFSTOKEN_LENGTH_MAX 16384 /* max payload size */
63 #define AFSTOKEN_STRING_MAX 256 /* max small string length */
64 #define AFSTOKEN_DATA_MAX 64 /* max small data length */
65 #define AFSTOKEN_CELL_MAX 64 /* max cellname length */
66 #define AFSTOKEN_MAX 8 /* max tokens per payload */
67 #define AFSTOKEN_BDATALN_MAX 16384 /* max big data length */
68 #define AFSTOKEN_RK_TIX_MAX 12000 /* max RxKAD ticket size */
69 #define AFSTOKEN_GK_KEY_MAX 64 /* max GSSAPI key size */
70 #define AFSTOKEN_GK_TOKEN_MAX 16384 /* max GSSAPI token size */
73 * Truncate a time64_t to the range from 1970 to 2106 as in the network
74 * protocol.
76 static inline u32 rxrpc_time64_to_u32(time64_t time)
78 if (time < 0)
79 return 0;
81 if (time > UINT_MAX)
82 return UINT_MAX;
84 return (u32)time;
88 * Extend u32 back to time64_t using the same 1970-2106 range.
90 static inline time64_t rxrpc_u32_to_time64(u32 time)
92 return (time64_t)time;
95 #endif /* _KEYS_RXRPC_TYPE_H */