1 /* $OpenBSD: auth-options.h,v 1.31 2021/07/23 03:57:20 djm Exp $ */
4 * Copyright (c) 2018 Damien Miller <djm@mindrot.org>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #ifndef AUTH_OPTIONS_H
20 #define AUTH_OPTIONS_H
25 /* Maximum number of permitopen/permitlisten directives to accept */
26 #define SSH_AUTHOPT_PERMIT_MAX 4096
28 /* Maximum number of environment directives to accept */
29 #define SSH_AUTHOPT_ENV_MAX 1024
32 * sshauthopt represents key options parsed from authorized_keys or
33 * from certificate extensions/options.
37 int permit_port_forwarding_flag
;
38 int permit_agent_forwarding_flag
;
39 int permit_x11_forwarding_flag
;
43 /* "restrict" keyword was invoked */
46 /* key/principal expiry date */
47 uint64_t valid_before
;
49 /* Certificate-related options */
51 char *cert_principals
;
56 /* Custom environment */
60 /* Permitted port forwardings */
64 /* Permitted listens (remote forwarding) */
69 * Permitted host/addresses (comma-separated)
70 * Caller must check source address matches both lists (if present).
72 char *required_from_host_cert
;
73 char *required_from_host_keys
;
75 /* Key requires user presence asserted */
76 int no_require_user_presence
;
77 /* Key requires user verification (e.g. PIN) */
81 struct sshauthopt
*sshauthopt_new(void);
82 struct sshauthopt
*sshauthopt_new_with_keys_defaults(void);
83 void sshauthopt_free(struct sshauthopt
*opts
);
84 struct sshauthopt
*sshauthopt_copy(const struct sshauthopt
*orig
);
85 int sshauthopt_serialise(const struct sshauthopt
*opts
, struct sshbuf
*m
, int);
86 int sshauthopt_deserialise(struct sshbuf
*m
, struct sshauthopt
**opts
);
89 * Parse authorized_keys options. Returns an options structure on success
90 * or NULL on failure. Will set errstr on failure.
92 struct sshauthopt
*sshauthopt_parse(const char *s
, const char **errstr
);
95 * Parse certification options to a struct sshauthopt.
96 * Returns options on success or NULL on failure.
98 struct sshauthopt
*sshauthopt_from_cert(struct sshkey
*k
);
103 struct sshauthopt
*sshauthopt_merge(const struct sshauthopt
*primary
,
104 const struct sshauthopt
*additional
, const char **errstrp
);