blob: a028b0bbe06f77c97f3d7276183947a8d99519fd [file] [log] [blame]
romanc1d2b092023-02-02 08:58:27 +01001/**
romane028ef92023-02-24 16:33:08 +01002 * @file server_config.h
romanc1d2b092023-02-02 08:58:27 +01003 * @author Roman Janota <janota@cesnet.cz>
4 * @brief libnetconf2 server configuration
5 *
6 * @copyright
roman3f9b65c2023-06-05 14:26:58 +02007 * Copyright (c) 2023 CESNET, z.s.p.o.
romanc1d2b092023-02-02 08:58:27 +01008 *
9 * This source code is licensed under BSD 3-Clause License (the "License").
10 * You may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * https://opensource.org/licenses/BSD-3-Clause
14 */
15
16#ifndef NC_CONFIG_SERVER_H_
17#define NC_CONFIG_SERVER_H_
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
roman3f9b65c2023-06-05 14:26:58 +020023#include <stdarg.h>
romanc1d2b092023-02-02 08:58:27 +010024#include <stdint.h>
25
roman3f9b65c2023-06-05 14:26:58 +020026#include <libyang/libyang.h>
27
romanc1d2b092023-02-02 08:58:27 +010028#include "session.h"
romanc1d2b092023-02-02 08:58:27 +010029
30/**
roman8ba6efa2023-07-12 15:27:52 +020031 * @defgroup server_config Server Configuration
32 * @ingroup server
33 *
34 * @brief Server-side configuration creation and application
35 * @{
36 */
37
38/**
roman35120972023-08-08 10:39:12 +020039 * @} Server Configuration
40 */
41
42/**
43 * @defgroup server_config_functions Server Configuration Functions
44 * @ingroup server_config
45 *
46 * @brief Server-side configuration functions
47 * @{
48 */
49
50/**
51 * @brief Implements all the required modules and their features in the context.
52 * Needs to be called before any other configuration functions.
53 *
54 * If ctx is :
55 * - NULL: a new context will be created and if the call is successful you have to free it,
56 * - non NULL: modules will simply be implemented.
57 *
58 * Implemented modules: ietf-netconf-server, ietf-x509-cert-to-name, ietf-crypto-types,
59 * ietf-tcp-common, ietf-ssh-common, iana-ssh-encryption-algs, iana-ssh-key-exchange-algs,
60 * iana-ssh-mac-algs, iana-ssh-public-key-algs, ietf-keystore, ietf-ssh-server, ietf-truststore,
61 * ietf-tls-server and libnetconf2-netconf-server.
62 *
63 * @param[in, out] ctx Optional context in which the modules will be implemented. Created if ctx is null.
64 * @return 0 on success, 1 on error.
65 */
66int nc_server_config_load_modules(struct ly_ctx **ctx);
67
68/**
romanf02273a2023-05-25 09:44:11 +020069 * @brief Configure server based on the given diff data.
romanc1d2b092023-02-02 08:58:27 +010070 *
romanf6f37a52023-05-25 14:27:51 +020071 * Expected data are a validated instance of a ietf-netconf-server YANG data.
romanc1d2b092023-02-02 08:58:27 +010072 * The data must be in the diff format and supported operations are: create, replace,
73 * delete and none. Context must already have implemented the required modules, see
roman0f5fa422023-08-07 09:03:24 +020074 * ::nc_server_config_load_modules().
romanc1d2b092023-02-02 08:58:27 +010075 *
romanf6f37a52023-05-25 14:27:51 +020076 * @param[in] diff ietf-netconf-server YANG diff data.
romanc1d2b092023-02-02 08:58:27 +010077 * @return 0 on success, 1 on error.
78 */
romanf6f37a52023-05-25 14:27:51 +020079int nc_server_config_setup_diff(const struct lyd_node *diff);
romanc1d2b092023-02-02 08:58:27 +010080
81/**
romanf02273a2023-05-25 09:44:11 +020082 * @brief Configure server based on the given data.
83 *
84 * Expected data is a validated instance of a ietf-netconf-server YANG data.
85 * Behaves as if all the nodes in data had the replace operation. That means that the current configuration will be deleted
86 * and just the given data will all be applied.
roman0f5fa422023-08-07 09:03:24 +020087 * The data must not contain any operation attribute, see ::nc_server_config_setup_diff() which works with diff.
88 * Context must already have implemented the required modules, see ::nc_server_config_load_modules().
romanf02273a2023-05-25 09:44:11 +020089 *
90 * @param[in] data ietf-netconf-server YANG data.
91 * @return 0 on success, 1 on error.
92 */
romanf6f37a52023-05-25 14:27:51 +020093int nc_server_config_setup_data(const struct lyd_node *data);
romanf02273a2023-05-25 09:44:11 +020094
95/**
roman35120972023-08-08 10:39:12 +020096 * @brief Configure server based on the given ietf-netconf-server YANG data from a file.
roman0f5fa422023-08-07 09:03:24 +020097 * Wrapper around ::nc_server_config_setup_data() hiding work with parsing the data.
romanc1d2b092023-02-02 08:58:27 +010098 *
99 * @param[in] ctx libyang context.
roman35120972023-08-08 10:39:12 +0200100 * @param[in] path Path to the file with ietf-netconf-server YANG data.
romanc1d2b092023-02-02 08:58:27 +0100101 * @return 0 on success, 1 on error.
102 */
103int nc_server_config_setup_path(const struct ly_ctx *ctx, const char *path);
104
roman2eab4742023-06-06 10:00:26 +0200105#ifdef NC_ENABLED_SSH_TLS
106
romanc1d2b092023-02-02 08:58:27 +0100107/**
roman35120972023-08-08 10:39:12 +0200108 * @brief Creates new YANG configuration data nodes for local-address and local-port.
roman9b1379c2023-03-31 10:11:10 +0200109 *
roman9b1379c2023-03-31 10:11:10 +0200110 * @param[in] ctx libyang context.
111 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman35120972023-08-08 10:39:12 +0200112 * If an endpoint with this identifier already exists, its contents might be changed.
roman3f9b65c2023-06-05 14:26:58 +0200113 * @param[in] transport Either SSH or TLS transport for the given endpoint.
114 * @param[in] address New listening address.
115 * @param[in] port New listening port.
roman9b1379c2023-03-31 10:11:10 +0200116 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
117 * Otherwise the new YANG data will be added to the previous data and may override it.
118 * @return 0 on success, non-zero otherwise.
roman45cec4e2023-02-17 10:21:39 +0100119 */
roman3f9b65c2023-06-05 14:26:58 +0200120int nc_server_config_new_address_port(const struct ly_ctx *ctx, const char *endpt_name, NC_TRANSPORT_IMPL transport,
roman142718b2023-06-29 09:15:29 +0200121 const char *address, uint16_t port, struct lyd_node **config);
roman3f9b65c2023-06-05 14:26:58 +0200122
roman8ba6efa2023-07-12 15:27:52 +0200123#endif /* NC_ENABLED_SSH_TLS */
124
125/**
romand0b78372023-09-14 10:06:03 +0200126 * @brief Creates new YANG data nodes for a UNIX socket.
127 *
128 * @param[in] ctx libyang context.
129 * @param[in] endpt_name Arbitrary identifier of the endpoint.
130 * If an endpoint with this identifier already exists, its contents might be changed.
131 * @param[in] path Path to the socket.
132 * @param[in] mode New mode, use -1 for default.
133 * @param[in] uid New uid, use -1 for default
134 * @param[in] gid New gid, use -1 for default
135 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
136 * Otherwise the new YANG data will be added to the previous data and may override it.
137 * @return 0 on success, non-zero otherwise.
138 */
139int nc_server_config_new_unix_socket(const struct ly_ctx *ctx, const char *endpt_name, const char *path,
140 mode_t mode, uid_t uid, gid_t gid, struct lyd_node **config);
141
142/**
roman8ba6efa2023-07-12 15:27:52 +0200143 * @brief Deletes an endpoint from the YANG data.
144 *
145 * @param[in] endpt_name Optional identifier of an endpoint to be deleted.
146 * If NULL, all of the endpoints will be deleted.
roman35120972023-08-08 10:39:12 +0200147 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200148 * @return 0 on success, non-zero otherwise.
149 */
150int nc_server_config_new_del_endpt(const char *endpt_name, struct lyd_node **config);
151
152#ifdef NC_ENABLED_SSH_TLS
153
154/**
155 * @brief Creates new YANG data nodes for an asymmetric key in the keystore.
156 *
157 * @param[in] ctx libyang context.
roman13145912023-08-17 15:36:54 +0200158 * @param[in] ti Transport in which the key pair will be used. Either SSH or TLS.
roman12c3d522023-07-26 13:39:30 +0200159 * @param[in] asym_key_name Identifier of the asymmetric key pair.
160 * This identifier is used to reference the key pair.
roman8ba6efa2023-07-12 15:27:52 +0200161 * @param[in] privkey_path Path to a private key file.
162 * @param[in] pubkey_path Optional path a public key file.
163 * If not supplied, it will be generated from the private key.
164 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
165 * Otherwise the new YANG data will be added to the previous data and may override it.
166 * @return 0 on success, non-zero otherwise.
167 */
roman13145912023-08-17 15:36:54 +0200168int nc_server_config_new_keystore_asym_key(const struct ly_ctx *ctx, NC_TRANSPORT_IMPL ti, const char *asym_key_name,
169 const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200170
171/**
172 * @brief Deletes a keystore's asymmetric key from the YANG data.
173 *
roman12c3d522023-07-26 13:39:30 +0200174 * @param[in] asym_key_name Optional identifier of the asymmetric key to be deleted.
roman8ba6efa2023-07-12 15:27:52 +0200175 * If NULL, all of the asymmetric keys in the keystore will be deleted.
176 * @param[in,out] config Configuration YANG data tree.
177 * @return 0 on success, non-zero otherwise.
178 */
roman12c3d522023-07-26 13:39:30 +0200179int nc_server_config_new_del_keystore_asym_key(const char *asym_key_name, struct lyd_node **config);
180
181/**
182 * @brief Creates new YANG data nodes for a certificate in the keystore.
183 *
184 * A certificate can not exist without its asymmetric key, so you must call ::nc_server_config_new_keystore_asym_key()
185 * either before or after calling this with the same identifier for the asymmetric key.
186 *
187 * An asymmetric key pair can have zero or more certificates associated with this key pair, however a certificate must
188 * have exactly one key pair it belongs to.
189 *
190 * @param[in] ctx libyang context.
191 * @param[in] asym_key_name Arbitrary identifier of the asymmetric key.
192 * If an asymmetric key pair with this name already exists, its contents will be changed.
193 * @param[in] cert_name Arbitrary identifier of the key pair's certificate.
194 * If a certificate with this name already exists, its contents will be changed.
195 * @param[in] cert_path Path to the PEM encoded certificate file.
196 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
197 * Otherwise the new YANG data will be added to the previous data and may override it.
198 * @return 0 on success, non-zero otherwise.
199 */
200int nc_server_config_new_keystore_cert(const struct ly_ctx *ctx, const char *asym_key_name, const char *cert_name,
201 const char *cert_path, struct lyd_node **config);
202
203/**
204 * @brief Deletes a keystore's certificate from the YANG data.
205 *
206 * @param[in] asym_key_name Identifier of an existing asymmetric key pair.
207 * @param[in] cert_name Optional identifier of a certificate to be deleted.
208 * If NULL, all of the certificates belonging to the asymmetric key pair will be deleted.
209 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
210 * Otherwise the new YANG data will be added to the previous data and may override it.
211 * @return 0 on success, non-zero otherwise.
212 */
213int nc_server_config_new_del_keystore_cert(const char *asym_key_name, const char *cert_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200214
215/**
216 * @brief Creates new YANG data nodes for a public key in the truststore.
217 *
218 * @param[in] ctx libyang context.
roman12c3d522023-07-26 13:39:30 +0200219 * @param[in] pub_bag_name Arbitrary identifier of the public key bag.
roman8ba6efa2023-07-12 15:27:52 +0200220 * This name is used to reference the public keys in the bag.
221 * If a public key bag with this name already exists, its contents will be changed.
222 * @param[in] pubkey_name Arbitrary identifier of the public key.
roman12c3d522023-07-26 13:39:30 +0200223 * If a public key with this name already exists in the given bag, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200224 * @param[in] pubkey_path Path to a file containing a public key.
225 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
226 * Otherwise the new YANG data will be added to the previous data and may override it.
227 * @return 0 on success, non-zero otherwise.
228 */
roman12c3d522023-07-26 13:39:30 +0200229int nc_server_config_new_truststore_pubkey(const struct ly_ctx *ctx, const char *pub_bag_name, const char *pubkey_name,
roman8ba6efa2023-07-12 15:27:52 +0200230 const char *pubkey_path, struct lyd_node **config);
231
232/**
233 * @brief Deletes a truststore's public key from the YANG data.
234 *
roman12c3d522023-07-26 13:39:30 +0200235 * @param[in] pub_bag_name Identifier of an existing public key bag.
roman8ba6efa2023-07-12 15:27:52 +0200236 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
237 * If NULL, all of the public keys in the given bag will be deleted.
238 * @param[in,out] config Configuration YANG data tree.
239 * @return 0 on success, non-zero otherwise.
240 */
roman12c3d522023-07-26 13:39:30 +0200241int nc_server_config_new_del_truststore_pubkey(const char *pub_bag_name, const char *pubkey_name, struct lyd_node **config);
242
243/**
244 * @brief Creates new YANG data nodes for a certificate in the truststore.
245 *
246 * @param[in] ctx libyang context.
247 * @param[in] cert_bag_name Arbitrary identifier of the certificate bag.
248 * This name is used to reference the certificates in the bag.
249 * If a certificate bag with this name already exists, its contents will be changed.
250 * @param[in] cert_name Arbitrary identifier of the certificate.
251 * If a certificate with this name already exists in the given bag, its contents will be changed.
252 * @param[in] cert_path Path to a file containing a PEM encoded certificate.
253 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
254 * Otherwise the new YANG data will be added to the previous data and may override it.
255 * @return 0 on success, non-zero otherwise.
256 */
257int nc_server_config_new_truststore_cert(const struct ly_ctx *ctx, const char *cert_bag_name, const char *cert_name,
258 const char *cert_path, struct lyd_node **config);
259
260/**
261 * @brief Deletes a truststore's certificate from the YANG data.
262 *
263 * @param[in] cert_bag_name Identifier of an existing certificate bag.
264 * @param[in] cert_name Optional identifier of a certificate to be deleted.
265 * If NULL, all of the certificates in the given bag will be deleted.
266 * @param[in,out] config Configuration YANG data tree.
267 * @return 0 on success, non-zero otherwise.
268 */
269int nc_server_config_new_del_truststore_cert(const char *cert_bag_name,
270 const char *cert_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200271
272/**
roman35120972023-08-08 10:39:12 +0200273 * @} Server Configuration Functions
roman8ba6efa2023-07-12 15:27:52 +0200274 */
275
276/**
277 * @defgroup server_config_ssh SSH Server Configuration
278 * @ingroup server_config
279 *
280 * @brief SSH server configuration creation and deletion
281 * @{
282 */
283
roman3f9b65c2023-06-05 14:26:58 +0200284/**
285 * @brief Creates new YANG configuration data nodes for a hostkey.
286 *
287 * @param[in] ctx libyang context.
288 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200289 * If an endpoint with this identifier already exists, its hostkey might be changed.
roman3f9b65c2023-06-05 14:26:58 +0200290 * @param[in] hostkey_name Arbitrary identifier of the hostkey.
roman142718b2023-06-29 09:15:29 +0200291 * If a hostkey with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200292 * @param[in] privkey_path Path to a file containing a private key.
293 * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
roman35120972023-08-08 10:39:12 +0200294 * @param[in] pubkey_path Optional path to a file containing a public key. If NULL, public key will be
roman3f9b65c2023-06-05 14:26:58 +0200295 * generated from the private key.
296 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
297 * Otherwise the new YANG data will be added to the previous data and may override it.
298 * @return 0 on success, non-zero otherwise.
299 */
roman8ba6efa2023-07-12 15:27:52 +0200300int nc_server_config_new_ssh_hostkey(const struct ly_ctx *ctx, const char *endpt_name, const char *hostkey_name,
301 const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
302
303/**
304 * @brief Deletes a hostkey from the YANG data.
305 *
306 * @param[in] ctx libyang context.
307 * @param[in] endpt_name Identifier of an existing endpoint.
308 * @param[in] hostkey_name Optional identifier of the hostkey to be deleted.
309 * If NULL, all of the hostkeys on this endpoint will be deleted.
310 * @param[in,out] config Configuration YANG data tree.
311 * @return 0 on success, non-zero otherwise.
312 */
313int nc_server_config_new_ssh_del_hostkey(const struct ly_ctx *ctx, const char *endpt_name,
314 const char *hostkey_name, struct lyd_node **config);
315
316/**
317 * @brief Creates new YANG data nodes for a reference to an asymmetric key located in the keystore.
318 *
319 * This asymmetric key pair will be used as the SSH hostkey.
320 *
321 * @param[in] ctx libyang context.
322 * @param[in] endpt_name Arbitrary identifier of an endpoint.
323 * If an endpoint with this identifier already exists, its contents will be changed.
324 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
325 * If an endpoint's hostkey with this identifier already exists, its contents will be changed.
326 * @param[in] keystore_reference Name of the asymmetric key pair to be referenced and used as a hostkey.
327 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
328 * Otherwise the new YANG data will be added to the previous data and may override it.
329 * @return 0 on success, non-zero otherwise.
330 */
roman67af8982023-08-08 10:56:04 +0200331int nc_server_config_new_ssh_keystore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *hostkey_name,
roman8ba6efa2023-07-12 15:27:52 +0200332 const char *keystore_reference, struct lyd_node **config);
333
334/**
335 * @brief Deletes a keystore reference from the YANG data.
336 *
337 * @param[in] endpt_name Identifier of an existing endpoint.
338 * @param[in] hostkey_name Identifier of an existing hostkey on the given endpoint.
339 * @param[in,out] config Configuration YANG data tree.
340 * @return 0 on success, non-zero otherwise.
341 */
roman67af8982023-08-08 10:56:04 +0200342int nc_server_config_new_ssh_del_keystore_ref(const char *endpt_name, const char *hostkey_name,
roman8ba6efa2023-07-12 15:27:52 +0200343 struct lyd_node **config);
344
345/**
roman68404fd2023-07-24 10:40:59 +0200346 * @brief Creates new YANG configuration data nodes for the maximum amount of failed SSH authentication attempts.
347 *
348 * @param[in] ctx libyang context.
349 * @param[in] endpt_name Arbitrary identifier of the endpoint.
350 * If an endpoint with this identifier already exists, its contents might be changed.
351 * @param[in] auth_attempts Maximum amount of failed SSH authentication attempts after which a
352 * client is disconnected. The default value is 3.
353 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
354 * Otherwise the new YANG data will be added to the previous data and may override it.
355 * @return 0 on success, non-zero otherwise.
356 */
357int nc_server_config_new_ssh_auth_attempts(const struct ly_ctx *ctx, const char *endpt_name, uint16_t auth_attempts,
358 struct lyd_node **config);
359
360/**
361 * @brief Creates new YANG configuration data nodes for an SSH authentication timeout.
362 *
363 * @param[in] ctx libyang context.
364 * @param[in] endpt_name Arbitrary identifier of the endpoint.
365 * If an endpoint with this identifier already exists, its contents might be changed.
366 * @param[in] auth_timeout Maximum amount of time in seconds after which the authentication is deemed
367 * unsuccessful. The default value is 10.
368 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
369 * Otherwise the new YANG data will be added to the previous data and may override it.
370 * @return 0 on success, non-zero otherwise.
371 */
372int nc_server_config_new_ssh_auth_timeout(const struct ly_ctx *ctx, const char *endpt_name, uint16_t auth_timeout,
373 struct lyd_node **config);
374
375/**
roman8ba6efa2023-07-12 15:27:52 +0200376 * @brief Creates new YANG configuration data nodes for an SSH user's public key authentication method.
377 *
378 * @param[in] ctx libyang context.
379 * @param[in] endpt_name Arbitrary identifier of the endpoint.
380 * If an endpoint with this identifier already exists, its user might be changed.
381 * @param[in] user_name Arbitrary identifier of the user.
382 * If an user with this identifier already exists, its contents will be changed.
383 * @param[in] pubkey_name Arbitrary identifier of the user's public key.
384 * If a public key with this identifier already exists for this user, its contents will be changed.
385 * @param[in] pubkey_path Path to a file containing the user's public key.
386 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
387 * Otherwise the new YANG data will be added to the previous data and may override it.
388 * @return 0 on success, non-zero otherwise.
389 */
390int nc_server_config_new_ssh_user_pubkey(const struct ly_ctx *ctx, const char *endpt_name,
391 const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config);
392
393/**
394 * @brief Deletes an SSH user's public key from the YANG data.
395 *
396 * @param[in] endpt_name Identifier of an existing endpoint.
397 * @param[in] user_name Identifier of an existing user on the given endpoint.
398 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
399 * If NULL, all of the users public keys will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200400 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200401 * @return 0 on success, non-zero otherwise.
402 */
403int nc_server_config_new_ssh_del_user_pubkey(const char *endpt_name, const char *user_name,
404 const char *pubkey_name, struct lyd_node **config);
405
406/**
407 * @brief Creates new YANG configuration data nodes for an SSH user's password authentication method.
408 *
409 * @param[in] ctx libyang context.
410 * @param[in] endpt_name Arbitrary identifier of the endpoint.
411 * If an endpoint with this identifier already exists, its user might be changed.
412 * @param[in] user_name Arbitrary identifier of the user.
413 * If an user with this identifier already exists, its contents will be changed.
roman35120972023-08-08 10:39:12 +0200414 * @param[in] password Clear-text password to be set for the user. It will be hashed.
roman8ba6efa2023-07-12 15:27:52 +0200415 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
416 * Otherwise the new YANG data will be added to the previous data and may override it.
417 * @return 0 on success, non-zero otherwise.
418 */
419int nc_server_config_new_ssh_user_password(const struct ly_ctx *ctx, const char *endpt_name,
420 const char *user_name, const char *password, struct lyd_node **config);
421
422/**
423 * @brief Deletes an SSH user's password from the YANG data.
424 *
425 * @param[in] endpt_name Identifier of an existing endpoint.
426 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200427 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200428 * @return 0 on success, non-zero otherwise.
429 */
430int nc_server_config_new_ssh_del_user_password(const char *endpt_name, const char *user_name,
431 struct lyd_node **config);
432
433/**
434 * @brief Creates new YANG configuration data nodes for an SSH user's none authentication method.
435 *
436 * @param[in] ctx libyang context.
437 * @param[in] endpt_name Arbitrary identifier of the endpoint.
438 * If an endpoint with this identifier already exists, its user might be changed.
439 * @param[in] user_name Arbitrary identifier of the user.
440 * If an user with this identifier already exists, its contents will be changed.
441 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
442 * Otherwise the new YANG data will be added to the previous data and may override it.
443 * @return 0 on success, non-zero otherwise.
444 */
445int nc_server_config_new_ssh_user_none(const struct ly_ctx *ctx, const char *endpt_name,
446 const char *user_name, struct lyd_node **config);
447
448/**
449 * @brief Deletes an SSH user's none authentication method from the YANG data.
450 *
451 * @param[in] endpt_name Identifier of an existing endpoint.
452 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200453 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200454 * @return 0 on success, non-zero otherwise.
455 */
456int nc_server_config_new_ssh_del_user_none(const char *endpt_name, const char *user_name,
457 struct lyd_node **config);
458
459/**
460 * @brief Creates new YANG configuration data nodes for an SSH user's keyboard interactive authentication method.
461 *
462 * @param[in] ctx libyang context.
463 * @param[in] endpt_name Arbitrary identifier of the endpoint.
464 * If an endpoint with this identifier already exists, its user might be changed.
465 * @param[in] user_name Arbitrary identifier of the user.
466 * If an user with this identifier already exists, its contents will be changed.
467 * @param[in] pam_config_name Name of the PAM configuration file.
roman0f5fa422023-08-07 09:03:24 +0200468 * @param[in] pam_config_dir Optional. The absolute path to the directory in which the configuration file
469 * with the name pam_config_name is located. A newer version (>= 1.4) of PAM library is required to be able to specify
roman8ba6efa2023-07-12 15:27:52 +0200470 * the path. If NULL is passed, then the PAM's system directories will be searched (usually /etc/pam.d/).
471 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
472 * Otherwise the new YANG data will be added to the previous data and may override it.
473 * @return 0 on success, non-zero otherwise.
474 */
475int nc_server_config_new_ssh_user_interactive(const struct ly_ctx *ctx, const char *endpt_name,
476 const char *user_name, const char *pam_config_name, const char *pam_config_dir, struct lyd_node **config);
477
478/**
479 * @brief Deletes an SSH user's keyboard interactive authentication from the YANG data.
480 *
481 * @param[in] endpt_name Identifier of an existing endpoint.
482 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200483 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200484 * @return 0 on success, non-zero otherwise.
485 */
486int nc_server_config_new_ssh_del_user_interactive(const char *endpt_name, const char *user_name,
487 struct lyd_node **config);
488
489/**
490 * @brief Deletes an SSH user from the YANG data.
491 *
492 * @param[in] endpt_name Identifier of an existing endpoint.
493 * @param[in] user_name Optional identifier of an user to be deleted.
494 * If NULL, all of the users on this endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200495 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200496 * @return 0 on success, non-zero otherwise.
497 */
498int nc_server_config_new_ssh_del_user(const char *endpt_name,
499 const char *user_name, struct lyd_node **config);
500
501/**
502 * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore.
503 *
504 * The public key's located in the bag will be used for client authentication.
505 *
506 * @param[in] ctx libyang context.
507 * @param[in] endpt_name Arbitrary identifier of an endpoint.
508 * If an endpoint with this identifier already exists, its contents will be changed.
509 * @param[in] user_name Arbitrary identifier of the endpoint's user.
510 * If an endpoint's user with this identifier already exists, its contents will be changed.
511 * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication.
Roytak9b32c0f2023-08-02 15:07:29 +0200512 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200513 * Otherwise the new YANG data will be added to the previous data and may override it.
514 * @return 0 on success, non-zero otherwise.
515 */
roman67af8982023-08-08 10:56:04 +0200516int nc_server_config_new_ssh_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200517 const char *truststore_reference, struct lyd_node **config);
518
519/**
520 * @brief Deletes a truststore reference from the YANG data.
521 *
522 * @param[in] endpt_name Identifier of an existing endpoint.
523 * @param[in] user_name Identifier of an user on the given endpoint whose truststore reference will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200524 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200525 * @return 0 on success, non-zero otherwise.
526 */
roman67af8982023-08-08 10:56:04 +0200527int nc_server_config_new_ssh_del_truststore_ref(const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200528 struct lyd_node **config);
529
530/**
531 * @brief Creates new YANG configuration data nodes, which will be a reference to another SSH endpoint's users.
532 *
533 * Whenever a client tries to connect to the referencing endpoint, all of its users will be tried first. If no match is
534 * found, the referenced endpoint's configured users will be tried.
535 *
536 * @param[in] ctx libyang context
537 * @param[in] endpt_name Arbitrary identifier of the endpoint.
538 * If an endpoint with this identifier already exists, its contents will be changed.
539 * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data
540 * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle.
541 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
542 * Otherwise the new YANG data will be added to the previous data and may override it.
543 * @return 0 on success, non-zero otherwise.
544 */
roman67af8982023-08-08 10:56:04 +0200545int nc_config_new_ssh_endpoint_user_ref(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200546 const char *referenced_endpt, struct lyd_node **config);
547
548/**
549 * @brief Deletes reference to another SSH endpoint's users from the YANG data.
550 *
551 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200552 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200553 * @return 0 on success, non-zero otherwise.
554 */
roman67af8982023-08-08 10:56:04 +0200555int nc_config_new_ssh_del_endpoint_user_ref(const char *endpt_name, struct lyd_node **config);
roman9b1379c2023-03-31 10:11:10 +0200556
557/**
558 * @brief Creates new YANG configuration data nodes for host-key algorithms replacing any previous ones.
559 *
560 * Supported algorithms are: ssh-ed25519, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521,
561 * rsa-sha2-512, rsa-sha2-256, ssh-rsa and ssh-dss.
562 *
563 * @param[in] ctx libyang context
564 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200565 * If an endpoint with this identifier already exists, its host-key algorithms will be replaced.
roman9b1379c2023-03-31 10:11:10 +0200566 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
567 * Otherwise the new YANG data will be added to the previous data and may override it.
568 * @param[in] alg_count Number of following algorithms.
569 * @param[in] ... String literals of host-key algorithms in a decreasing order of preference.
570 * @return 0 on success, non-zero otherwise.
571 */
roman466719d2023-05-05 16:14:37 +0200572int nc_server_config_new_ssh_host_key_algs(const struct ly_ctx *ctx, const char *endpt_name,
roman9b1379c2023-03-31 10:11:10 +0200573 struct lyd_node **config, int alg_count, ...);
574
575/**
roman8ba6efa2023-07-12 15:27:52 +0200576 * @brief Deletes a hostkey algorithm from the YANG data.
577 *
578 * @param[in] endpt_name Identifier of an existing endpoint.
579 * @param[in] alg Optional algorithm to be deleted.
580 * If NULL, all of the hostkey algorithms on this endpoint will be deleted.
roman35120972023-08-08 10:39:12 +0200581 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200582 * @return 0 on success, non-zero otherwise.
583 */
584int nc_server_config_new_ssh_del_host_key_alg(const char *endpt_name, const char *alg, struct lyd_node **config);
585
586/**
roman9b1379c2023-03-31 10:11:10 +0200587 * @brief Creates new YANG configuration data nodes for key exchange algorithms replacing any previous ones.
588 *
589 * Supported algorithms are: diffie-hellman-group-exchange-sha1, curve25519-sha256, ecdh-sha2-nistp256,
590 * ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group18-sha512, diffie-hellman-group16-sha512,
591 * diffie-hellman-group-exchange-sha256 and diffie-hellman-group14-sha256.
592 *
593 * @param[in] ctx libyang context
594 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200595 * If an endpoint with this identifier already exists, its key exchange algorithms will be replaced.
roman9b1379c2023-03-31 10:11:10 +0200596 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
597 * Otherwise the new YANG data will be added to the previous data and may override it.
598 * @param[in] alg_count Number of following algorithms.
599 * @param[in] ... String literals of key exchange algorithms in a decreasing order of preference.
600 * @return 0 on success, non-zero otherwise.
601 */
roman466719d2023-05-05 16:14:37 +0200602int nc_server_config_new_ssh_key_exchange_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config,
roman9b1379c2023-03-31 10:11:10 +0200603 int alg_count, ...);
604
605/**
roman8ba6efa2023-07-12 15:27:52 +0200606 * @brief Deletes a key exchange algorithm from the YANG data.
607 *
608 * @param[in] endpt_name Identifier of an existing endpoint.
609 * @param[in] alg Optional algorithm to be deleted.
610 * If NULL, all of the key exchange algorithms on this endpoint will be deleted.
roman35120972023-08-08 10:39:12 +0200611 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200612 * @return 0 on success, non-zero otherwise.
613 */
614int nc_server_config_new_ssh_del_key_exchange_alg(const char *endpt_name, const char *alg, struct lyd_node **config);
615
616/**
roman9b1379c2023-03-31 10:11:10 +0200617 * @brief Creates new YANG configuration data nodes for encryption algorithms replacing any previous ones.
618 *
619 * Supported algorithms are: aes256-ctr, aes192-ctr, aes128-ctr, aes256-cbc, aes192-cbc, aes128-cbc, blowfish-cbc
620 * triple-des-cbc and none.
621 *
622 * @param[in] ctx libyang context
623 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200624 * If an endpoint with this identifier already exists, its encryption algorithms will be replaced.
roman9b1379c2023-03-31 10:11:10 +0200625 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
626 * Otherwise the new YANG data will be added to the previous data and may override it.
627 * @param[in] alg_count Number of following algorithms.
628 * @param[in] ... String literals of encryption algorithms in a decreasing order of preference.
629 * @return 0 on success, non-zero otherwise.
630 */
roman466719d2023-05-05 16:14:37 +0200631int nc_server_config_new_ssh_encryption_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config,
roman9b1379c2023-03-31 10:11:10 +0200632 int alg_count, ...);
633
634/**
roman8ba6efa2023-07-12 15:27:52 +0200635 * @brief Deletes an encryption algorithm from the YANG data.
636 *
637 * @param[in] endpt_name Identifier of an existing endpoint.
638 * @param[in] alg Optional algorithm to be deleted.
639 * If NULL, all of the encryption algorithms on this endpoint will be deleted.
roman35120972023-08-08 10:39:12 +0200640 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200641 * @return 0 on success, non-zero otherwise.
642 */
643int nc_server_config_new_ssh_del_encryption_alg(const char *endpt_name, const char *alg, struct lyd_node **config);
644
645/**
roman9b1379c2023-03-31 10:11:10 +0200646 * @brief Creates new YANG configuration data nodes for mac algorithms replacing any previous ones.
647 *
648 * Supported algorithms are: hmac-sha2-256, hmac-sha2-512 and hmac-sha1.
649 *
650 * @param[in] ctx libyang context
651 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200652 * If an endpoint with this identifier already exists, its mac algorithms will be replaced.
roman9b1379c2023-03-31 10:11:10 +0200653 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
654 * Otherwise the new YANG data will be added to the previous data and may override it.
655 * @param[in] alg_count Number of following algorithms.
656 * @param[in] ... String literals of mac algorithms in a decreasing order of preference.
657 * @return 0 on success, non-zero otherwise.
658 */
roman466719d2023-05-05 16:14:37 +0200659int nc_server_config_new_ssh_mac_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config,
roman9b1379c2023-03-31 10:11:10 +0200660 int alg_count, ...);
661
662/**
roman8ba6efa2023-07-12 15:27:52 +0200663 * @brief Deletes a mac algorithm from the YANG data.
roman9b1379c2023-03-31 10:11:10 +0200664 *
roman8ba6efa2023-07-12 15:27:52 +0200665 * @param[in] endpt_name Identifier of an existing endpoint.
666 * @param[in] alg Optional algorithm to be deleted.
667 * If NULL, all of the mac algorithms on this endpoint will be deleted.
roman35120972023-08-08 10:39:12 +0200668 * @param[in,out] config Modified configuration YANG data tree.
roman9b1379c2023-03-31 10:11:10 +0200669 * @return 0 on success, non-zero otherwise.
670 */
roman8ba6efa2023-07-12 15:27:52 +0200671int nc_server_config_new_ssh_del_mac_alg(const char *endpt_name, const char *alg, struct lyd_node **config);
roman9b1379c2023-03-31 10:11:10 +0200672
673/**
roman35120972023-08-08 10:39:12 +0200674 * @} SSH Server Configuration
roman9b1379c2023-03-31 10:11:10 +0200675 */
roman9b1379c2023-03-31 10:11:10 +0200676
677/**
roman8ba6efa2023-07-12 15:27:52 +0200678 * @defgroup server_config_tls TLS Server Configuration
679 * @ingroup server_config
roman9b1379c2023-03-31 10:11:10 +0200680 *
roman8ba6efa2023-07-12 15:27:52 +0200681 * @brief TLS server configuration creation and deletion
682 * @{
roman9b1379c2023-03-31 10:11:10 +0200683 */
roman2e797ef2023-06-19 10:47:49 +0200684
685/**
roman3f9b65c2023-06-05 14:26:58 +0200686 * @brief Creates new YANG configuration data nodes for a server's certificate.
687 *
688 * @param[in] ctx libyang context.
689 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200690 * If an endpoint with this identifier already exists, its server certificate will be changed.
roman6c4efcd2023-08-08 10:18:44 +0200691 * @param[in] privkey_path Path to the server's PEM encoded private key file.
roman3f9b65c2023-06-05 14:26:58 +0200692 * @param[in] pubkey_path Optional path to the server's public key file. If not provided,
693 * it will be generated from the private key.
roman3f9b65c2023-06-05 14:26:58 +0200694 * @param[in] certificate_path Path to the server's certificate file.
695 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
696 * Otherwise the new YANG data will be added to the previous data and may override it.
697 * @return 0 on success, non-zero otherwise.
698 */
roman6c4efcd2023-08-08 10:18:44 +0200699int nc_server_config_new_tls_server_certificate(const struct ly_ctx *ctx, const char *endpt_name, const char *privkey_path,
700 const char *pubkey_path, const char *certificate_path, struct lyd_node **config);
roman3f9b65c2023-06-05 14:26:58 +0200701
702/**
roman8ba6efa2023-07-12 15:27:52 +0200703 * @brief Deletes the server's certificate from the YANG data.
704 *
705 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200706 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200707 * @return 0 on success, non-zero otherwise.
708 */
709int nc_server_config_new_tls_del_server_certificate(const char *endpt_name, struct lyd_node **config);
710
711/**
roman12c3d522023-07-26 13:39:30 +0200712 * @brief Creates new YANG configuration data nodes for a keystore reference to the TLS server's certificate.
713 *
714 * @param[in] ctx libyang context.
715 * @param[in] endpt_name Arbitrary identifier of the endpoint.
716 * If an endpoint with this identifier already exists, its contents will be changed.
717 * @param[in] asym_key_ref Name of the asymmetric key pair in the keystore to be referenced.
718 * @param[in] cert_ref Name of the certificate, which must belong to the given asymmetric key pair, to be referenced.
719 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
720 * Otherwise the new YANG data will be added to the previous data and may override it.
721 * @return 0 on success, non-zero otherwise.
722 */
roman67af8982023-08-08 10:56:04 +0200723int nc_server_config_new_tls_keystore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *asym_key_ref,
roman12c3d522023-07-26 13:39:30 +0200724 const char *cert_ref, struct lyd_node **config);
725
726/**
727 * @brief Deletes a TLS server certificate keystore reference from the YANG data.
728 *
729 * @param[in] endpt_name Identifier of an existing endpoint.
730 * @param[in,out] config Modified configuration YANG data tree.
731 * @return 0 on success, non-zero otherwise.
732 */
roman67af8982023-08-08 10:56:04 +0200733int nc_server_config_new_tls_del_keystore_ref(const char *endpt_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200734
735/**
roman3f9b65c2023-06-05 14:26:58 +0200736 * @brief Creates new YANG configuration data nodes for a client's (end-entity) certificate.
737 *
738 * @param[in] ctx libyang context.
739 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200740 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200741 * @param[in] cert_name Arbitrary identifier of the client's certificate.
roman35120972023-08-08 10:39:12 +0200742 * If a client certificate with this identifier already exists, it will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200743 * @param[in] cert_path Path to the client's certificate file.
744 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
745 * Otherwise the new YANG data will be added to the previous data and may override it.
746 * @return 0 on success, non-zero otherwise.
747 */
748int nc_server_config_new_tls_client_certificate(const struct ly_ctx *ctx, const char *endpt_name, const char *cert_name,
749 const char *cert_path, struct lyd_node **config);
750
751/**
roman8ba6efa2023-07-12 15:27:52 +0200752 * @brief Deletes a client (end-entity) certificate from the YANG data.
753 *
754 * @param[in] endpt_name Identifier of an existing endpoint.
755 * @param[in] cert_name Optional name of a certificate to be deleted.
756 * If NULL, all of the end-entity certificates on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200757 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200758 * @return 0 on success, non-zero otherwise.
759 */
760int nc_server_config_new_tls_del_client_certificate(const char *endpt_name, const char *cert_name, struct lyd_node **config);
761
762/**
roman12c3d522023-07-26 13:39:30 +0200763 * @brief Creates new YANG configuration data nodes for a truststore reference to a set of client (end-entity) certificates.
764 *
765 * @param[in] ctx libyang context.
766 * @param[in] endpt_name Arbitrary identifier of the endpoint.
767 * If an endpoint with this identifier already exists, its contents will be changed.
768 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
769 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
770 * Otherwise the new YANG data will be added to the previous data and may override it.
771 * @return 0 on success, non-zero otherwise.
772 */
773int nc_server_config_new_tls_client_cert_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name,
774 const char *cert_bag_ref, struct lyd_node **config);
775
776/**
777 * @brief Deletes a client (end-entity) certificates truststore reference from the YANG data.
778 *
779 * @param[in] endpt_name Identifier of an existing endpoint.
780 * @param[in,out] config Modified configuration YANG data tree.
781 * @return 0 on success, non-zero otherwise.
782 */
783int nc_server_config_new_tls_del_client_cert_truststore_ref(const char *endpt_name, struct lyd_node **config);
784
785/**
roman3f9b65c2023-06-05 14:26:58 +0200786 * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate.
787 *
788 * @param[in] ctx libyang context.
789 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200790 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200791 * @param[in] cert_name Arbitrary identifier of the certificate authority certificate.
roman35120972023-08-08 10:39:12 +0200792 * If a CA with this identifier already exists, it will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200793 * @param[in] cert_path Path to the CA certificate file.
794 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
795 * Otherwise the new YANG data will be added to the previous data and may override it.
796 * @return 0 on success, non-zero otherwise.
797 */
798int nc_server_config_new_tls_client_ca(const struct ly_ctx *ctx, const char *endpt_name, const char *cert_name,
799 const char *cert_path, struct lyd_node **config);
800
801/**
roman8ba6efa2023-07-12 15:27:52 +0200802 * @brief Deletes a client certificate authority (trust-anchor) certificate from the YANG data.
803 *
804 * @param[in] endpt_name Identifier of an existing endpoint.
805 * @param[in] cert_name Optional name of a certificate to be deleted.
806 * If NULL, all of the CA certificates on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200807 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200808 * @return 0 on success, non-zero otherwise.
809 */
810int nc_server_config_new_tls_del_client_ca(const char *endpt_name, const char *cert_name, struct lyd_node **config);
811
812/**
roman12c3d522023-07-26 13:39:30 +0200813 * @brief Creates new YANG configuration data nodes for a truststore reference to a set of client certificate authority (trust-anchor) certificates.
814 *
815 * @param[in] ctx libyang context.
816 * @param[in] endpt_name Arbitrary identifier of the endpoint.
817 * If an endpoint with this identifier already exists, its contents will be changed.
818 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
819 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
820 * Otherwise the new YANG data will be added to the previous data and may override it.
821 * @return 0 on success, non-zero otherwise.
822 */
823int nc_server_config_new_tls_client_ca_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name,
824 const char *cert_bag_ref, struct lyd_node **config);
825
826/**
827 * @brief Deletes a client certificate authority (trust-anchor) certificates truststore reference from the YANG data.
828 *
829 * @param[in] endpt_name Identifier of an existing endpoint.
830 * @param[in,out] config Modified configuration YANG data tree.
831 * @return 0 on success, non-zero otherwise.
832 */
833int nc_server_config_new_tls_del_client_ca_truststore_ref(const char *endpt_name, struct lyd_node **config);
834
835/**
Roytak76958912023-09-29 15:25:14 +0200836 * @brief Creates new YANG configuration data nodes, which will be a reference to another TLS endpoint's certificates.
837 *
838 * Whenever an user tries to connect to the referencing endpoint, all of its certificates will be tried first. If no match is
839 * found, the referenced endpoint's configured certificates will be tried. The same applies to cert-to-name entries.
840 *
841 * @param[in] ctx libyang context
842 * @param[in] endpt_name Arbitrary identifier of the endpoint.
843 * If an endpoint with this identifier already exists, its contents will be changed.
844 * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data
845 * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle.
846 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
847 * Otherwise the new YANG data will be added to the previous data and may override it.
848 * @return 0 on success, non-zero otherwise.
849 */
850int nc_config_new_tls_endpoint_client_ref(const struct ly_ctx *ctx, const char *endpt_name,
851 const char *referenced_endpt, struct lyd_node **config);
852
853/**
854 * @brief Deletes reference to another TLS endpoint's users from the YANG data.
855 *
856 * @param[in] endpt_name Identifier of an existing endpoint.
857 * @param[in,out] config Modified configuration YANG data tree.
858 * @return 0 on success, non-zero otherwise.
859 */
860int nc_config_new_tls_del_endpoint_client_ref(const char *endpt_name, struct lyd_node **config);
861
862/**
roman3f9b65c2023-06-05 14:26:58 +0200863 * @brief Creates new YANG configuration data nodes for a cert-to-name entry.
864 *
865 * @param[in] ctx libyang context.
866 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200867 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200868 * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier).
869 * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is
870 * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry.
871 * @param[in] map_type Mapping username to the certificate option.
872 * @param[in] name Username for this cert-to-name entry.
873 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
874 * Otherwise the new YANG data will be added to the previous data and may override it.
875 * @return 0 on success, non-zero otherwise.
876 */
877int nc_server_config_new_tls_ctn(const struct ly_ctx *ctx, const char *endpt_name, uint32_t id, const char *fingerprint,
878 NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config);
879
roman12644fe2023-06-08 11:06:42 +0200880/**
roman8ba6efa2023-07-12 15:27:52 +0200881 * @brief Deletes a cert-to-name entry from the YANG data.
882 *
883 * @param[in] endpt_name Identifier of an existing endpoint.
884 * @param[in] id Optional ID of the CTN entry.
885 * If 0, all of the cert-to-name entries on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200886 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200887 * @return 0 on success, non-zero otherwise.
888 */
889int nc_server_config_new_tls_del_ctn(const char *endpt_name, uint32_t id, struct lyd_node **config);
890
891/**
roman12644fe2023-06-08 11:06:42 +0200892 * @brief Creates new YANG configuration data nodes for a TLS version.
893 *
894 * @param[in] ctx libyang context.
895 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200896 * If an endpoint with this identifier already exists, its contents will be changed.
roman12644fe2023-06-08 11:06:42 +0200897 * @param[in] tls_version TLS version to be used. Call this multiple times to set
898 * the accepted versions of the TLS protocol and let the client and server negotiate
899 * the given version.
900 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
901 * Otherwise the new YANG data will be added to the previous data and may override it.
902 * @return 0 on success, non-zero otherwise.
903 */
904int nc_server_config_new_tls_version(const struct ly_ctx *ctx, const char *endpt_name,
905 NC_TLS_VERSION tls_version, struct lyd_node **config);
906
907/**
roman8ba6efa2023-07-12 15:27:52 +0200908 * @brief Deletes a TLS version from the YANG data.
909 *
910 * @param[in] endpt_name Identifier of an existing endpoint.
911 * @param[in] tls_version TLS version to be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200912 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200913 * @return 0 on success, non-zero otherwise.
914 */
915int nc_server_config_new_tls_del_version(const char *endpt_name, NC_TLS_VERSION tls_version, struct lyd_node **config);
916
917/**
roman12644fe2023-06-08 11:06:42 +0200918 * @brief Creates new YANG configuration data nodes for a TLS cipher.
919 *
920 * @param[in] ctx libyang context.
921 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200922 * If an endpoint with this identifier already exists, its contents will be changed.
roman12644fe2023-06-08 11:06:42 +0200923 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
924 * Otherwise the new YANG data will be added to the previous data and may override it.
roman35120972023-08-08 10:39:12 +0200925 * @param[in] cipher_count Number of following ciphers.
roman12644fe2023-06-08 11:06:42 +0200926 * @param[in] ... TLS ciphers. These ciphers MUST be in the format as listed in the
927 * iana-tls-cipher-suite-algs YANG model (lowercase and separated by dashes). Regardless
928 * of the TLS protocol version used, all of these ciphers will be tried and some of them
929 * might not be set (TLS handshake might fail then). For the list of supported ciphers see
930 * the OpenSSL documentation.
931 * @return 0 on success, non-zero otherwise.
932 */
933int nc_server_config_new_tls_ciphers(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config,
roman08f67f42023-06-08 13:51:54 +0200934 int cipher_count, ...);
roman12644fe2023-06-08 11:06:42 +0200935
romanfaecc582023-06-15 16:13:31 +0200936/**
roman8ba6efa2023-07-12 15:27:52 +0200937 * @brief Deletes a TLS cipher from the YANG data.
938 *
939 * @param[in] endpt_name Identifier of an existing endpoint.
940 * @param[in] cipher TLS cipher to be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200941 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200942 * @return 0 on success, non-zero otherwise.
943 */
944int nc_server_config_new_tls_del_cipher(const char *endpt_name, const char *cipher, struct lyd_node **config);
945
946/**
romanfaecc582023-06-15 16:13:31 +0200947 * @brief Creates new YANG configuration data nodes for a Certificate Revocation List via a local file.
948 *
949 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
950 * this function will remove any CRL YANG nodes created by the other two functions.
951 *
952 * @param[in] ctx libyang context.
953 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200954 * If an endpoint with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +0200955 * @param[in] crl_path Path to a DER/PEM encoded CRL file.
romanfaecc582023-06-15 16:13:31 +0200956 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
957 * Otherwise the new YANG data will be added to the previous data and may override it.
958 * @return 0 on success, non-zero otherwise.
959 */
roman9d5e5a52023-07-14 12:43:44 +0200960int nc_server_config_new_tls_crl_path(const struct ly_ctx *ctx, const char *endpt_name,
961 const char *crl_path, struct lyd_node **config);
romanfaecc582023-06-15 16:13:31 +0200962
963/**
964 * @brief Creates new YANG configuration data nodes for a Certificate Revocation List via an URL.
965 *
966 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
967 * this function will remove any CRL YANG nodes created by the other two functions.
968 *
969 * @param[in] ctx libyang context.
970 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200971 * If an endpoint with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +0200972 * @param[in] crl_url URL from which the CRL file will be downloaded. The file has to be in the DER or PEM format.
romanfaecc582023-06-15 16:13:31 +0200973 * The allowed protocols are all the protocols supported by CURL.
974 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
975 * Otherwise the new YANG data will be added to the previous data and may override it.
976 * @return 0 on success, non-zero otherwise.
977 */
roman9d5e5a52023-07-14 12:43:44 +0200978int nc_server_config_new_tls_crl_url(const struct ly_ctx *ctx, const char *endpt_name, const char *crl_url, struct lyd_node **config);
romanfaecc582023-06-15 16:13:31 +0200979
980/**
981 * @brief Creates new YANG configuration data nodes for a Certificate Revocation List via certificate extensions.
982 *
983 * The chain of configured Certificate Authorities will be examined. For each certificate in this chain all the
984 * CRLs from the URLs specified in their extension fields CRL Distribution Points will be downloaded and used.
roman9d5e5a52023-07-14 12:43:44 +0200985 *
romanfaecc582023-06-15 16:13:31 +0200986 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
987 * this function will remove any CRL YANG nodes created by the other two functions.
988 *
989 * @param[in] ctx libyang context.
990 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200991 * If an endpoint with this identifier already exists, its contents will be changed.
romanfaecc582023-06-15 16:13:31 +0200992 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
993 * Otherwise the new YANG data will be added to the previous data and may override it.
994 * @return 0 on success, non-zero otherwise.
995 */
996int nc_server_config_new_tls_crl_cert_ext(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config);
997
roman2e797ef2023-06-19 10:47:49 +0200998/**
roman8ba6efa2023-07-12 15:27:52 +0200999 * @brief Deletes all the CRL nodes from the YANG data.
1000 *
1001 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +02001002 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001003 * @return 0 on success, non-zero otherwise.
1004 */
1005int nc_server_config_new_tls_del_crl(const char *endpt_name, struct lyd_node **config);
1006
1007/**
roman35120972023-08-08 10:39:12 +02001008 * @} TLS Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001009 */
1010
1011/**
roman35120972023-08-08 10:39:12 +02001012 * @defgroup server_config_ch Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001013 * @ingroup server_config
1014 *
Roytak2161df62023-08-02 15:04:42 +02001015 * @brief Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +02001016 * @{
1017 */
1018
1019/**
roman35120972023-08-08 10:39:12 +02001020 * @} Call Home Server Configuration
1021 */
1022
1023/**
1024 * @defgroup server_config_ch_functions Call Home Server Configuration Functions
1025 * @ingroup server_config_ch
1026 *
1027 * @brief Call Home server configuration functions
1028 * @{
1029 */
1030
1031/**
Roytak2161df62023-08-02 15:04:42 +02001032 * @brief Creates new YANG configuration data nodes for a Call Home client's address and port.
roman142718b2023-06-29 09:15:29 +02001033 *
1034 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001035 * @param[in] client_name Arbitrary identifier of the Call Home client.
1036 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +02001037 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1038 * If the client's endpoint with this identifier already exists, its contents will be changed.
1039 * @param[in] transport Transport protocol to be used on this endpoint - either SSH or TLS.
1040 * @param[in] address Address to connect to.
1041 * @param[in] port Port to connect to.
1042 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1043 * Otherwise the new YANG data will be added to the previous data and may override it.
1044 * @return 0 on success, non-zero otherwise.
1045 */
roman8ba6efa2023-07-12 15:27:52 +02001046int nc_server_config_new_ch_address_port(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman5cbb6532023-06-22 12:53:17 +02001047 NC_TRANSPORT_IMPL transport, const char *address, const char *port, struct lyd_node **config);
1048
roman8ba6efa2023-07-12 15:27:52 +02001049#endif /* NC_ENABLED_SSH_TLS */
1050
1051/**
Roytak2161df62023-08-02 15:04:42 +02001052 * @brief Deletes a Call Home client from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001053 *
1054 * @param[in] client_name Optional identifier of a client to be deleted.
Roytak2161df62023-08-02 15:04:42 +02001055 * If NULL, all of the Call Home clients will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001056 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001057 * @return 0 on success, non-zero otherwise.
1058 */
Roytak7b9bf292023-10-04 14:06:38 +02001059int nc_server_config_new_ch_del_ch_client(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +02001060
1061/**
Roytak2161df62023-08-02 15:04:42 +02001062 * @brief Deletes a Call Home endpoint from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001063 *
Roytak2161df62023-08-02 15:04:42 +02001064 * @param[in] client_name Identifier of an existing Call Home client.
roman8ba6efa2023-07-12 15:27:52 +02001065 * @param[in] endpt_name Optional identifier of a CH endpoint to be deleted.
1066 * If NULL, all of the CH endpoints which belong to the given client will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001067 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001068 * @return 0 on success, non-zero otherwise.
1069 */
1070int nc_server_config_new_ch_del_endpt(const char *client_name, const char *endpt_name, struct lyd_node **config);
1071
1072/**
Roytak2161df62023-08-02 15:04:42 +02001073 * @brief Creates new YANG configuration data nodes for the Call Home persistent connection type.
roman8ba6efa2023-07-12 15:27:52 +02001074 *
1075 * This is the default connection type. If periodic connection type was set before, it will be unset.
1076 *
1077 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001078 * @param[in] client_name Arbitrary identifier of the Call Home client.
1079 * If a Call Home client with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001080 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001081 * Otherwise the new YANG data will be added to the previous data and may override it.
1082 * @return 0 on success, non-zero otherwise.
1083 */
1084int nc_server_config_new_ch_persistent(const struct ly_ctx *ctx, const char *client_name, struct lyd_node **config);
1085
1086/**
Roytak2161df62023-08-02 15:04:42 +02001087 * @brief Creates new YANG configuration data nodes for the period parameter of the Call Home periodic connection type.
roman8ba6efa2023-07-12 15:27:52 +02001088 *
1089 * If called, the persistent connection type will be replaced by periodic.
1090 *
1091 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001092 * @param[in] client_name Arbitrary identifier of the Call Home client.
1093 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +02001094 * @param[in] period Duration between periodic connections in minutes.
Roytak9b32c0f2023-08-02 15:07:29 +02001095 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001096 * Otherwise the new YANG data will be added to the previous data and may override it.
1097 * @return 0 on success, non-zero otherwise.
1098 */
1099int nc_server_config_new_ch_period(const struct ly_ctx *ctx, const char *client_name, uint16_t period,
1100 struct lyd_node **config);
1101
1102/**
Roytak2161df62023-08-02 15:04:42 +02001103 * @brief Deletes the Call Home period parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001104 *
1105 * This behaves the same as setting the period to 60 minutes, which is the default value of this node.
1106 *
Roytak2161df62023-08-02 15:04:42 +02001107 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001108 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001109 * @return 0 on success, non-zero otherwise.
1110 */
1111int nc_server_config_new_ch_del_period(const char *client_name, struct lyd_node **config);
1112
1113/**
Roytak2161df62023-08-02 15:04:42 +02001114 * @brief Creates new YANG configuration data nodes for the anchor time parameter of the Call Home periodic connection type.
roman8ba6efa2023-07-12 15:27:52 +02001115 *
1116 * If called, the persistent connection type will be replaced by periodic.
1117 *
1118 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001119 * @param[in] client_name Arbitrary identifier of the Call Home client.
1120 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +02001121 * @param[in] anchor_time Timestamp before or after which a series of periodic connections are determined.
Roytak9b32c0f2023-08-02 15:07:29 +02001122 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001123 * Otherwise the new YANG data will be added to the previous data and may override it.
1124 * @return 0 on success, non-zero otherwise.
1125 */
1126int nc_server_config_new_ch_anchor_time(const struct ly_ctx *ctx, const char *client_name,
1127 const char *anchor_time, struct lyd_node **config);
1128
1129/**
Roytak2161df62023-08-02 15:04:42 +02001130 * @brief Deletes the Call Home anchor time parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001131 *
Roytak2161df62023-08-02 15:04:42 +02001132 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001133 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001134 * @return 0 on success, non-zero otherwise.
1135 */
1136int nc_server_config_new_ch_del_anchor_time(const char *client_name, struct lyd_node **config);
1137
1138/**
Roytak2161df62023-08-02 15:04:42 +02001139 * @brief Creates new YANG configuration data nodes for the idle timeout parameter of the Call Home periodic connection type.
roman8ba6efa2023-07-12 15:27:52 +02001140 *
1141 * If called, the persistent connection type will be replaced by periodic.
1142 *
1143 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001144 * @param[in] client_name Arbitrary identifier of the Call Home client.
1145 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +02001146 * @param[in] idle_timeout Specifies the maximum number of seconds that a session may remain idle.
Roytak9b32c0f2023-08-02 15:07:29 +02001147 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001148 * Otherwise the new YANG data will be added to the previous data and may override it.
1149 * @return 0 on success, non-zero otherwise.
1150 */
1151int nc_server_config_new_ch_idle_timeout(const struct ly_ctx *ctx, const char *client_name,
1152 uint16_t idle_timeout, struct lyd_node **config);
1153
1154/**
Roytak2161df62023-08-02 15:04:42 +02001155 * @brief Deletes the Call Home idle timeout parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001156 *
1157 * This behaves the same as setting the timeout to 180 seconds, which is the default value of this node.
1158 *
Roytak2161df62023-08-02 15:04:42 +02001159 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001160 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001161 * @return 0 on success, non-zero otherwise.
1162 */
1163int nc_server_config_new_ch_del_idle_timeout(const char *client_name, struct lyd_node **config);
1164
1165/**
Roytak2161df62023-08-02 15:04:42 +02001166 * @brief Creates new YANG configuration data nodes for the Call Home reconnect strategy.
roman8ba6efa2023-07-12 15:27:52 +02001167 *
1168 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001169 * @param[in] client_name Arbitrary identifier of the Call Home client.
1170 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +02001171 * @param[in] start_with Specifies which endpoint to try if a connection is unsuccessful. Default value is NC_CH_FIRST_LISTED.
1172 * @param[in] max_wait The number of seconds after which a connection to an endpoint is deemed unsuccessful. Default value if 5.
1173 * @param[in] max_attempts The number of unsuccessful connection attempts before moving to the next endpoint. Default value is 3.
Roytak9b32c0f2023-08-02 15:07:29 +02001174 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001175 * Otherwise the new YANG data will be added to the previous data and may override it.
1176 * @return 0 on success, non-zero otherwise.
1177 */
1178int nc_server_config_new_ch_reconnect_strategy(const struct ly_ctx *ctx, const char *client_name,
1179 NC_CH_START_WITH start_with, uint16_t max_wait, uint8_t max_attempts, struct lyd_node **config);
1180
1181/**
Roytak2161df62023-08-02 15:04:42 +02001182 * @brief Resets the values of the Call Home reconnect strategy nodes to their defaults.
roman8ba6efa2023-07-12 15:27:52 +02001183 *
1184 * The default values are: start-with = NC_CH_FIRST_LISTED, max-wait = 5 and max-attempts = 3.
1185 *
Roytak2161df62023-08-02 15:04:42 +02001186 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001187 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001188 * @return 0 on success, non-zero otherwise.
1189 */
1190int nc_server_config_new_ch_del_reconnect_strategy(const char *client_name, struct lyd_node **config);
1191
1192/**
roman35120972023-08-08 10:39:12 +02001193 * @} Call Home Server Configuration Functions
roman8ba6efa2023-07-12 15:27:52 +02001194 */
1195
1196#ifdef NC_ENABLED_SSH_TLS
1197
1198/**
Roytak2161df62023-08-02 15:04:42 +02001199 * @defgroup server_config_ch_ssh SSH Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001200 * @ingroup server_config_ch
1201 *
Roytak2161df62023-08-02 15:04:42 +02001202 * @brief SSH Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +02001203 * @{
1204 */
1205
roman142718b2023-06-29 09:15:29 +02001206/**
Roytak2161df62023-08-02 15:04:42 +02001207 * @brief Creates new YANG data nodes for a Call Home SSH hostkey.
roman142718b2023-06-29 09:15:29 +02001208 *
1209 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001210 * @param[in] client_name Arbitrary identifier of the Call Home client.
1211 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +02001212 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1213 * If the client's endpoint with this identifier already exists, its contents will be changed.
1214 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
1215 * If the endpoint's hostkey with this identifier already exists, its contents will be changed.
1216 * @param[in] privkey_path Path to a file containing a private key.
1217 * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
1218 * @param[in] pubkey_path Path to a file containing a public key. If NULL, public key will be
1219 * generated from the private key.
1220 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1221 * Otherwise the new YANG data will be added to the previous data and may override it.
1222 * @return 0 on success, non-zero otherwise.
1223 */
roman8ba6efa2023-07-12 15:27:52 +02001224int nc_server_config_new_ch_ssh_hostkey(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman5cbb6532023-06-22 12:53:17 +02001225 const char *hostkey_name, const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
1226
roman142718b2023-06-29 09:15:29 +02001227/**
Roytak2161df62023-08-02 15:04:42 +02001228 * @brief Deletes a Call Home hostkey from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001229 *
Roytak2161df62023-08-02 15:04:42 +02001230 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001231 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
roman8ba6efa2023-07-12 15:27:52 +02001232 * @param[in] hostkey_name Optional identifier of a hostkey to be deleted.
1233 * If NULL, all of the hostkeys on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001234 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001235 * @return 0 on success, non-zero otherwise.
1236 */
1237int nc_server_config_new_ch_ssh_del_hostkey(const char *client_name, const char *endpt_name,
1238 const char *hostkey_name, struct lyd_node **config);
1239
1240/**
roman9d5e5a52023-07-14 12:43:44 +02001241 * @brief Creates new YANG data nodes for a reference to an asymmetric key located in the keystore.
1242 *
Roytak2161df62023-08-02 15:04:42 +02001243 * This asymmetric key pair will be used as the Call Home SSH hostkey.
roman9d5e5a52023-07-14 12:43:44 +02001244 *
1245 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001246 * @param[in] client_name Arbitrary identifier of the Call Home client.
1247 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001248 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1249 * If the client's endpoint with this identifier already exists, its contents will be changed.
1250 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
1251 * If the endpoint's hostkey with this identifier already exists, its contents will be changed.
1252 * @param[in] keystore_reference Name of the asymmetric key pair to be referenced and used as a hostkey.
Roytak9b32c0f2023-08-02 15:07:29 +02001253 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001254 * Otherwise the new YANG data will be added to the previous data and may override it.
1255 * @return 0 on success, non-zero otherwise.
1256 */
roman67af8982023-08-08 10:56:04 +02001257int nc_server_config_new_ch_ssh_keystore_ref(const struct ly_ctx *ctx, const char *client_name,
roman9d5e5a52023-07-14 12:43:44 +02001258 const char *endpt_name, const char *hostkey_name, const char *keystore_reference, struct lyd_node **config);
1259
1260/**
Roytak2161df62023-08-02 15:04:42 +02001261 * @brief Deletes a Call Home keystore reference from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001262 *
Roytak2161df62023-08-02 15:04:42 +02001263 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001264 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1265 * @param[in] hostkey_name Identifier of an existing hostkey that belongs to the given CH endpoint.
Roytak9b32c0f2023-08-02 15:07:29 +02001266 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001267 * @return 0 on success, non-zero otherwise.
1268 */
roman67af8982023-08-08 10:56:04 +02001269int nc_server_config_new_ch_ssh_del_keystore_ref(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001270 const char *hostkey_name, struct lyd_node **config);
1271
1272/**
Roytak2161df62023-08-02 15:04:42 +02001273 * @brief Creates new YANG configuration data nodes for the maximum amount of failed Call Home SSH authentication attempts.
roman68404fd2023-07-24 10:40:59 +02001274 *
1275 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001276 * @param[in] client_name Arbitrary identifier of the Call Home client.
1277 * If a Call Home client with this identifier already exists, its contents will be changed.
roman68404fd2023-07-24 10:40:59 +02001278 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1279 * If the client's endpoint with this identifier already exists, its contents will be changed.
1280 * @param[in] auth_attempts Maximum amount of failed SSH authentication attempts after which a
1281 * client is disconnected. The default value is 3.
1282 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1283 * Otherwise the new YANG data will be added to the previous data and may override it.
1284 * @return 0 on success, non-zero otherwise.
1285 */
1286int nc_server_config_new_ch_ssh_auth_attempts(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1287 uint16_t auth_attempts, struct lyd_node **config);
1288
1289/**
Roytak2161df62023-08-02 15:04:42 +02001290 * @brief Creates new YANG configuration data nodes for a Call Home SSH authentication timeout.
roman68404fd2023-07-24 10:40:59 +02001291 *
1292 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001293 * @param[in] client_name Arbitrary identifier of the Call Home client.
1294 * If a Call Home client with this identifier already exists, its contents will be changed.
roman68404fd2023-07-24 10:40:59 +02001295 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1296 * If the client's endpoint with this identifier already exists, its contents will be changed.
1297 * @param[in] auth_timeout Maximum amount of time in seconds after which the authentication is deemed
1298 * unsuccessful. The default value is 10.
1299 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1300 * Otherwise the new YANG data will be added to the previous data and may override it.
1301 * @return 0 on success, non-zero otherwise.
1302 */
1303int nc_server_config_new_ch_ssh_auth_timeout(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1304 uint16_t auth_timeout, struct lyd_node **config);
1305
1306/**
Roytak2161df62023-08-02 15:04:42 +02001307 * @brief Creates new YANG data nodes for a Call Home SSH user's public key authentication method.
roman142718b2023-06-29 09:15:29 +02001308 *
1309 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001310 * @param[in] client_name Arbitrary identifier of the Call Home client.
1311 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +02001312 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1313 * If the client's endpoint with this identifier already exists, its contents will be changed.
1314 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1315 * If the endpoint's user with this identifier already exists, its contents will be changed.
1316 * @param[in] pubkey_name Arbitrary identifier of the user's public key.
1317 * If the user's public key with this identifier already exists, its contents will be changed.
1318 * @param[in] pubkey_path Path to a file containing a public key.
1319 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1320 * Otherwise the new YANG data will be added to the previous data and may override it.
1321 * @return 0 on success, non-zero otherwise.
1322 */
roman8ba6efa2023-07-12 15:27:52 +02001323int nc_server_config_new_ch_ssh_user_pubkey(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman5cbb6532023-06-22 12:53:17 +02001324 const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config);
1325
roman142718b2023-06-29 09:15:29 +02001326/**
Roytak2161df62023-08-02 15:04:42 +02001327 * @brief Deletes a Call Home SSH user's public key from the YANG data.
roman142718b2023-06-29 09:15:29 +02001328 *
Roytak2161df62023-08-02 15:04:42 +02001329 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001330 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1331 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
roman8ba6efa2023-07-12 15:27:52 +02001332 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
1333 * If NULL, all of the public keys which belong to the given SSH user will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001334 * @param[in,out] config Modified configuration YANG data tree.
roman142718b2023-06-29 09:15:29 +02001335 * @return 0 on success, non-zero otherwise.
1336 */
roman8ba6efa2023-07-12 15:27:52 +02001337int nc_server_config_new_ch_ssh_del_user_pubkey(const char *client_name, const char *endpt_name,
1338 const char *user_name, const char *pubkey_name, struct lyd_node **config);
roman5cbb6532023-06-22 12:53:17 +02001339
roman142718b2023-06-29 09:15:29 +02001340/**
Roytak2161df62023-08-02 15:04:42 +02001341 * @brief Creates new YANG data nodes for a Call Home SSH user's password authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001342 *
1343 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001344 * @param[in] client_name Arbitrary identifier of the Call Home client.
1345 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001346 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1347 * If the client's endpoint with this identifier already exists, its contents will be changed.
1348 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1349 * If the endpoint's user with this identifier already exists, its contents will be changed.
roman35120972023-08-08 10:39:12 +02001350 * @param[in] password Clear-text password to be set for the user. It will be hashed.
roman9d5e5a52023-07-14 12:43:44 +02001351 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1352 * Otherwise the new YANG data will be added to the previous data and may override it.
1353 * @return 0 on success, non-zero otherwise.
1354 */
1355int nc_server_config_new_ch_ssh_user_password(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1356 const char *user_name, const char *password, struct lyd_node **config);
1357
1358/**
Roytak2161df62023-08-02 15:04:42 +02001359 * @brief Deletes a Call Home SSH user's password from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001360 *
Roytak2161df62023-08-02 15:04:42 +02001361 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001362 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1363 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1364 * @param[in,out] config Modified configuration YANG data tree.
1365 * @return 0 on success, non-zero otherwise.
1366 */
1367int nc_server_config_new_ch_ssh_del_user_password(const char *client_name, const char *endpt_name,
1368 const char *user_name, struct lyd_node **config);
1369
1370/**
Roytak2161df62023-08-02 15:04:42 +02001371 * @brief Creates new YANG configuration data nodes for a Call Home SSH user's none authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001372 *
1373 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001374 * @param[in] client_name Arbitrary identifier of the Call Home client.
1375 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001376 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1377 * If the client's endpoint with this identifier already exists, its contents will be changed.
1378 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1379 * If the endpoint's user with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001380 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001381 * Otherwise the new YANG data will be added to the previous data and may override it.
1382 * @return 0 on success, non-zero otherwise.
1383 */
1384int nc_server_config_new_ch_ssh_user_none(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1385 const char *user_name, struct lyd_node **config);
1386
1387/**
Roytak2161df62023-08-02 15:04:42 +02001388 * @brief Deletes a Call Home SSH user's none authentication method from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001389 *
Roytak2161df62023-08-02 15:04:42 +02001390 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001391 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1392 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1393 * @param[in,out] config Modified configuration YANG data tree.
1394 * @return 0 on success, non-zero otherwise.
1395 */
1396int nc_server_config_new_ch_ssh_del_user_none(const char *client_name, const char *endpt_name,
1397 const char *user_name, struct lyd_node **config);
1398
1399/**
Roytak2161df62023-08-02 15:04:42 +02001400 * @brief Creates new YANG configuration data nodes for a Call Home SSH user's keyboard interactive authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001401 *
1402 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001403 * @param[in] client_name Arbitrary identifier of the Call Home client.
1404 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001405 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1406 * If the client's endpoint with this identifier already exists, its contents will be changed.
1407 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1408 * If the endpoint's user with this identifier already exists, its contents will be changed.
1409 * @param[in] pam_config_name Name of the PAM configuration file.
roman0f5fa422023-08-07 09:03:24 +02001410 * @param[in] pam_config_dir Optional. The absolute path to the directory in which the configuration file
1411 * with the name pam_config_name is located. A newer version (>= 1.4) of PAM library is required to be able to specify
roman9d5e5a52023-07-14 12:43:44 +02001412 * the path. If NULL is passed, then the PAM's system directories will be searched (usually /etc/pam.d/).
1413 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1414 * Otherwise the new YANG data will be added to the previous data and may override it.
1415 * @return 0 on success, non-zero otherwise.
1416 */
1417int nc_server_config_new_ch_ssh_user_interactive(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1418 const char *user_name, const char *pam_config_name, const char *pam_config_dir, struct lyd_node **config);
1419
1420/**
Roytak2161df62023-08-02 15:04:42 +02001421 * @brief Deletes a Call Home SSH user's keyboard interactive authentication from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001422 *
Roytak2161df62023-08-02 15:04:42 +02001423 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001424 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1425 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1426 * @param[in,out] config Modified configuration YANG data tree.
1427 * @return 0 on success, non-zero otherwise.
1428 */
1429int nc_server_config_new_ch_ssh_del_user_interactive(const char *client_name, const char *endpt_name,
1430 const char *user_name, struct lyd_node **config);
1431
1432/**
Roytak2161df62023-08-02 15:04:42 +02001433 * @brief Deletes a Call Home SSH user from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001434 *
Roytak2161df62023-08-02 15:04:42 +02001435 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001436 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1437 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1438 * @param[in,out] config Modified configuration YANG data tree.
1439 * @return 0 on success, non-zero otherwise.
1440 */
1441int nc_server_config_new_ch_ssh_del_user(const char *client_name, const char *endpt_name,
1442 const char *user_name, struct lyd_node **config);
1443
1444/**
1445 * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore.
1446 *
Roytak2161df62023-08-02 15:04:42 +02001447 * The public key's located in the bag will be used for Call Home SSH client authentication.
roman9d5e5a52023-07-14 12:43:44 +02001448 *
1449 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001450 * @param[in] client_name Arbitrary identifier of the Call Home client.
1451 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001452 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1453 * If the client's endpoint with this identifier already exists, its contents will be changed.
1454 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1455 * If the endpoint's user with this identifier already exists, its contents will be changed.
1456 * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication.
Roytak9b32c0f2023-08-02 15:07:29 +02001457 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001458 * Otherwise the new YANG data will be added to the previous data and may override it.
1459 * @return 0 on success, non-zero otherwise.
1460 */
roman67af8982023-08-08 10:56:04 +02001461int nc_server_config_new_ch_ssh_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
roman9d5e5a52023-07-14 12:43:44 +02001462 const char *endpt_name, const char *user_name, const char *truststore_reference, struct lyd_node **config);
1463
1464/**
Roytak2161df62023-08-02 15:04:42 +02001465 * @brief Deletes a Call Home SSH truststore reference from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001466 *
Roytak2161df62023-08-02 15:04:42 +02001467 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001468 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1469 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1470 * @param[in,out] config Modified configuration YANG data tree.
1471 * @return 0 on success, non-zero otherwise.
1472 */
roman67af8982023-08-08 10:56:04 +02001473int nc_server_config_new_ch_ssh_del_truststore_ref(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001474 const char *user_name, struct lyd_node **config);
1475
1476/**
Roytak2161df62023-08-02 15:04:42 +02001477 * @brief Creates new YANG configuration data nodes for Call Home host-key algorithms replacing any previous ones.
roman9d5e5a52023-07-14 12:43:44 +02001478 *
1479 * Supported algorithms are: ssh-ed25519, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521,
1480 * rsa-sha2-512, rsa-sha2-256, ssh-rsa and ssh-dss.
1481 *
1482 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001483 * @param[in] client_name Arbitrary identifier of the Call Home client.
1484 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001485 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1486 * If the client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001487 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001488 * Otherwise the new YANG data will be added to the previous data and may override it.
1489 * @param[in] alg_count Number of following algorithms.
1490 * @param[in] ... String literals of host-key algorithms in a decreasing order of preference.
1491 * @return 0 on success, non-zero otherwise.
1492 */
1493int nc_server_config_new_ch_ssh_host_key_algs(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1494 struct lyd_node **config, int alg_count, ...);
1495
1496/**
Roytak2161df62023-08-02 15:04:42 +02001497 * @brief Deletes a Call Home hostkey algorithm from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001498 *
Roytak2161df62023-08-02 15:04:42 +02001499 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001500 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1501 * @param[in] alg Optional algorithm to be deleted.
1502 * If NULL, all of the hostkey algorithms on this endpoint will be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001503 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001504 * @return 0 on success, non-zero otherwise.
1505 */
1506int nc_server_config_new_ch_ssh_del_host_key_alg(const char *client_name, const char *endpt_name,
1507 const char *alg, struct lyd_node **config);
1508
1509/**
Roytak2161df62023-08-02 15:04:42 +02001510 * @brief Creates new YANG configuration data nodes for Call Home key exchange algorithms replacing any previous ones.
roman9d5e5a52023-07-14 12:43:44 +02001511 *
1512 * Supported algorithms are: diffie-hellman-group-exchange-sha1, curve25519-sha256, ecdh-sha2-nistp256,
1513 * ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group18-sha512, diffie-hellman-group16-sha512,
1514 * diffie-hellman-group-exchange-sha256 and diffie-hellman-group14-sha256.
1515 *
1516 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001517 * @param[in] client_name Arbitrary identifier of the Call Home client.
1518 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001519 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1520 * If the client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001521 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001522 * Otherwise the new YANG data will be added to the previous data and may override it.
1523 * @param[in] alg_count Number of following algorithms.
1524 * @param[in] ... String literals of key exchange algorithms in a decreasing order of preference.
1525 * @return 0 on success, non-zero otherwise.
1526 */
1527int nc_server_config_new_ch_ssh_key_exchange_algs(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1528 struct lyd_node **config, int alg_count, ...);
1529
1530/**
Roytak2161df62023-08-02 15:04:42 +02001531 * @brief Deletes a Call Home key exchange algorithm from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001532 *
Roytak2161df62023-08-02 15:04:42 +02001533 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001534 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1535 * @param[in] alg Optional algorithm to be deleted.
1536 * If NULL, all of the key exchange algorithms on this endpoint will be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001537 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001538 * @return 0 on success, non-zero otherwise.
1539 */
1540int nc_server_config_new_ch_ssh_del_key_exchange_alg(const char *client_name, const char *endpt_name,
1541 const char *alg, struct lyd_node **config);
1542
1543/**
Roytak2161df62023-08-02 15:04:42 +02001544 * @brief Creates new YANG configuration data nodes for Call Home encryption algorithms replacing any previous ones.
roman9d5e5a52023-07-14 12:43:44 +02001545 *
1546 * Supported algorithms are: aes256-ctr, aes192-ctr, aes128-ctr, aes256-cbc, aes192-cbc, aes128-cbc, blowfish-cbc
1547 * triple-des-cbc and none.
1548 *
1549 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001550 * @param[in] client_name Arbitrary identifier of the Call Home client.
1551 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001552 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1553 * If the client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001554 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001555 * Otherwise the new YANG data will be added to the previous data and may override it.
1556 * @param[in] alg_count Number of following algorithms.
1557 * @param[in] ... String literals of encryption algorithms in a decreasing order of preference.
1558 * @return 0 on success, non-zero otherwise.
1559 */
1560int nc_server_config_new_ch_ssh_encryption_algs(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1561 struct lyd_node **config, int alg_count, ...);
1562
1563/**
Roytak2161df62023-08-02 15:04:42 +02001564 * @brief Deletes a Call Home encryption algorithm from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001565 *
Roytak2161df62023-08-02 15:04:42 +02001566 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001567 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1568 * @param[in] alg Optional algorithm to be deleted.
1569 * If NULL, all of the encryption algorithms on this endpoint will be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001570 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001571 * @return 0 on success, non-zero otherwise.
1572 */
1573int nc_server_config_new_ch_ssh_del_encryption_alg(const char *client_name, const char *endpt_name,
1574 const char *alg, struct lyd_node **config);
1575
1576/**
Roytak2161df62023-08-02 15:04:42 +02001577 * @brief Creates new YANG configuration data nodes for Call Home mac algorithms replacing any previous ones.
roman9d5e5a52023-07-14 12:43:44 +02001578 *
1579 * Supported algorithms are: hmac-sha2-256, hmac-sha2-512 and hmac-sha1.
1580 *
1581 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001582 * @param[in] client_name Arbitrary identifier of the Call Home client.
1583 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001584 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1585 * If the client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001586 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001587 * Otherwise the new YANG data will be added to the previous data and may override it.
1588 * @param[in] alg_count Number of following algorithms.
1589 * @param[in] ... String literals of mac algorithms in a decreasing order of preference.
1590 * @return 0 on success, non-zero otherwise.
1591 */
1592int nc_server_config_new_ch_ssh_mac_algs(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1593 struct lyd_node **config, int alg_count, ...);
1594
1595/**
Roytak2161df62023-08-02 15:04:42 +02001596 * @brief Deletes a Call Home mac algorithm from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001597 *
Roytak2161df62023-08-02 15:04:42 +02001598 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001599 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1600 * @param[in] alg Optional algorithm to be deleted.
1601 * If NULL, all of the mac algorithms on this endpoint will be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001602 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001603 * @return 0 on success, non-zero otherwise.
1604 */
1605int nc_server_config_new_ch_ssh_del_mac_alg(const char *client_name, const char *endpt_name,
1606 const char *alg, struct lyd_node **config);
1607
1608/**
roman35120972023-08-08 10:39:12 +02001609 * @} SSH Call Home Server Configuration
roman142718b2023-06-29 09:15:29 +02001610 */
roman142718b2023-06-29 09:15:29 +02001611
1612/**
Roytak2161df62023-08-02 15:04:42 +02001613 * @defgroup server_config_ch_tls TLS Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001614 * @ingroup server_config_ch
roman142718b2023-06-29 09:15:29 +02001615 *
Roytak2161df62023-08-02 15:04:42 +02001616 * @brief TLS Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +02001617 * @{
roman142718b2023-06-29 09:15:29 +02001618 */
roman142718b2023-06-29 09:15:29 +02001619
romanb6f44032023-06-30 15:07:56 +02001620/**
Roytak2161df62023-08-02 15:04:42 +02001621 * @brief Creates new YANG configuration data nodes for a Call Home server's certificate.
romanb6f44032023-06-30 15:07:56 +02001622 *
1623 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001624 * @param[in] client_name Arbitrary identifier of the Call Home client.
1625 * If a Call Home client with this identifier already exists, its contents will be changed.
1626 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1627 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman6c4efcd2023-08-08 10:18:44 +02001628 * @param[in] privkey_path Path to the server's PEM encoded private key file.
romanb6f44032023-06-30 15:07:56 +02001629 * @param[in] pubkey_path Optional path to the server's public key file. If not provided,
1630 * it will be generated from the private key.
romanb6f44032023-06-30 15:07:56 +02001631 * @param[in] certificate_path Path to the server's certificate file.
Roytak934edc32023-07-27 12:04:18 +02001632 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001633 * Otherwise the new YANG data will be added to the previous data and may override it.
1634 * @return 0 on success, non-zero otherwise.
1635 */
roman8ba6efa2023-07-12 15:27:52 +02001636int nc_server_config_new_ch_tls_server_certificate(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman6c4efcd2023-08-08 10:18:44 +02001637 const char *privkey_path, const char *pubkey_path, const char *certificate_path, struct lyd_node **config);
romanb6f44032023-06-30 15:07:56 +02001638
1639/**
Roytak2161df62023-08-02 15:04:42 +02001640 * @brief Deletes a Call Home server certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001641 *
Roytak2161df62023-08-02 15:04:42 +02001642 * @param[in] client_name Identifier of an existing Call Home client.
1643 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman9d5e5a52023-07-14 12:43:44 +02001644 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001645 * @return 0 on success, non-zero otherwise.
1646 */
1647int nc_server_config_new_ch_tls_del_server_certificate(const char *client_name, const char *endpt_name,
1648 struct lyd_node **config);
1649
1650/**
Roytak934edc32023-07-27 12:04:18 +02001651 * @brief Creates new YANG configuration data nodes for a keystore reference to the Call Home TLS server's certificate.
1652 *
1653 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001654 * @param[in] client_name Arbitrary identifier of the Call Home client.
1655 * If a Call Home client with this identifier already exists, its contents will be changed.
1656 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1657 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
Roytak934edc32023-07-27 12:04:18 +02001658 * @param[in] asym_key_ref Name of the asymmetric key pair in the keystore to be referenced.
1659 * @param[in] cert_ref Name of the certificate, which must belong to the given asymmetric key pair, to be referenced.
1660 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1661 * Otherwise the new YANG data will be added to the previous data and may override it.
1662 * @return 0 on success, non-zero otherwise.
1663 */
roman67af8982023-08-08 10:56:04 +02001664int nc_server_config_new_ch_tls_keystore_ref(const struct ly_ctx *ctx, const char *client_name,
Roytak934edc32023-07-27 12:04:18 +02001665 const char *endpt_name, const char *asym_key_ref, const char *cert_ref, struct lyd_node **config);
1666
1667/**
1668 * @brief Deletes a TLS server certificate keystore reference from the YANG data.
1669 *
Roytak2161df62023-08-02 15:04:42 +02001670 * @param[in] client_name Identifier of an existing Call Home client.
1671 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
Roytak934edc32023-07-27 12:04:18 +02001672 * @param[in,out] config Modified configuration YANG data tree.
1673 * @return 0 on success, non-zero otherwise.
1674 */
roman67af8982023-08-08 10:56:04 +02001675int nc_server_config_new_ch_tls_del_keystore_ref(const char *client_name, const char *endpt_name,
Roytak934edc32023-07-27 12:04:18 +02001676 struct lyd_node **config);
1677
1678/**
Roytak2161df62023-08-02 15:04:42 +02001679 * @brief Creates new YANG configuration data nodes for a Call Home client's (end-entity) certificate.
romanb6f44032023-06-30 15:07:56 +02001680 *
1681 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001682 * @param[in] client_name Arbitrary identifier of the Call Home client.
1683 * If a Call Home client with this identifier already exists, its contents will be changed.
1684 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1685 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1686 * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's end-entity certificate.
1687 * If an Call Home endpoint's end-entity certificate with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001688 * @param[in] cert_path Path to the certificate file.
Roytak934edc32023-07-27 12:04:18 +02001689 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001690 * Otherwise the new YANG data will be added to the previous data and may override it.
1691 * @return 0 on success, non-zero otherwise.
1692 */
roman8ba6efa2023-07-12 15:27:52 +02001693int nc_server_config_new_ch_tls_client_certificate(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
romanb6f44032023-06-30 15:07:56 +02001694 const char *cert_name, const char *cert_path, struct lyd_node **config);
1695
1696/**
Roytak2161df62023-08-02 15:04:42 +02001697 * @brief Deletes a Call Home client (end-entity) certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001698 *
Roytak2161df62023-08-02 15:04:42 +02001699 * @param[in] client_name Identifier of an existing Call Home client.
1700 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman8ba6efa2023-07-12 15:27:52 +02001701 * @param[in] cert_name Optional identifier of a client certificate to be deleted.
1702 * If NULL, all of the client certificates will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001703 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001704 * @return 0 on success, non-zero otherwise.
1705 */
1706int nc_server_config_new_ch_tls_del_client_certificate(const char *client_name, const char *endpt_name,
1707 const char *cert_name, struct lyd_node **config);
1708
1709/**
Roytak934edc32023-07-27 12:04:18 +02001710 * @brief Creates new YANG configuration data nodes for a Call Home truststore reference to a set of client (end-entity) certificates.
1711 *
1712 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001713 * @param[in] client_name Arbitrary identifier of the Call Home client.
1714 * If a Call Home client with this identifier already exists, its contents will be changed.
1715 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1716 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
Roytak934edc32023-07-27 12:04:18 +02001717 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
1718 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1719 * Otherwise the new YANG data will be added to the previous data and may override it.
1720 * @return 0 on success, non-zero otherwise.
1721 */
1722int nc_server_config_new_ch_tls_client_cert_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
1723 const char *endpt_name, const char *cert_bag_ref, struct lyd_node **config);
1724
1725/**
1726 * @brief Deletes a Call Home client (end-entity) certificates truststore reference from the YANG data.
1727 *
Roytak2161df62023-08-02 15:04:42 +02001728 * @param[in] client_name Identifier of an existing Call Home client.
1729 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
Roytak934edc32023-07-27 12:04:18 +02001730 * @param[in,out] config Modified configuration YANG data tree.
1731 * @return 0 on success, non-zero otherwise.
1732 */
1733int nc_server_config_new_ch_tls_del_client_cert_truststore_ref(const char *client_name, const char *endpt_name,
1734 struct lyd_node **config);
1735
1736/**
romanb6f44032023-06-30 15:07:56 +02001737 * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate.
1738 *
1739 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001740 * @param[in] client_name Arbitrary identifier of the Call Home client.
1741 * If a Call Home client with this identifier already exists, its contents will be changed.
1742 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1743 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1744 * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's certificate authority certificate.
1745 * If an Call Home endpoint's CA certificate with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001746 * @param[in] cert_path Path to the certificate file.
Roytak9b32c0f2023-08-02 15:07:29 +02001747 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001748 * Otherwise the new YANG data will be added to the previous data and may override it.
1749 * @return 0 on success, non-zero otherwise.
1750 */
roman8ba6efa2023-07-12 15:27:52 +02001751int nc_server_config_new_ch_tls_client_ca(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
romanb6f44032023-06-30 15:07:56 +02001752 const char *cert_name, const char *cert_path, struct lyd_node **config);
1753
1754/**
Roytak2161df62023-08-02 15:04:42 +02001755 * @brief Deletes a Call Home client certificate authority (trust-anchor) certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001756 *
Roytak2161df62023-08-02 15:04:42 +02001757 * @param[in] client_name Identifier of an existing Call Home client.
1758 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman8ba6efa2023-07-12 15:27:52 +02001759 * @param[in] cert_name Optional identifier of a CA certificate to be deleted.
1760 * If NULL, all of the CA certificates will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001761 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001762 * @return 0 on success, non-zero otherwise.
1763 */
1764int nc_server_config_new_ch_tls_del_client_ca(const char *client_name, const char *endpt_name,
1765 const char *cert_name, struct lyd_node **config);
1766
1767/**
Roytak934edc32023-07-27 12:04:18 +02001768 * @brief Creates new YANG configuration data nodes for a Call Home truststore reference to a set of client certificate authority (trust-anchor) certificates.
1769 *
1770 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001771 * @param[in] client_name Arbitrary identifier of the Call Home client.
1772 * If a Call Home client with this identifier already exists, its contents will be changed.
1773 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1774 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
Roytak934edc32023-07-27 12:04:18 +02001775 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
1776 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1777 * Otherwise the new YANG data will be added to the previous data and may override it.
1778 * @return 0 on success, non-zero otherwise.
1779 */
1780int nc_server_config_new_ch_tls_client_ca_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
1781 const char *endpt_name, const char *cert_bag_ref, struct lyd_node **config);
1782
1783/**
1784 * @brief Deletes a Call Home client certificate authority (trust-anchor) certificates truststore reference from the YANG data.
1785 *
Roytak2161df62023-08-02 15:04:42 +02001786 * @param[in] client_name Identifier of an existing Call Home client.
1787 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
Roytak934edc32023-07-27 12:04:18 +02001788 * @param[in,out] config Modified configuration YANG data tree.
1789 * @return 0 on success, non-zero otherwise.
1790 */
1791int nc_server_config_new_ch_tls_del_client_ca_truststore_ref(const char *client_name, const char *endpt_name,
1792 struct lyd_node **config);
1793
1794/**
Roytak2161df62023-08-02 15:04:42 +02001795 * @brief Creates new YANG configuration data nodes for a Call Home cert-to-name entry.
romanb6f44032023-06-30 15:07:56 +02001796 *
1797 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001798 * @param[in] client_name Arbitrary identifier of the Call Home client.
1799 * If a Call Home client with this identifier already exists, its contents will be changed.
1800 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1801 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001802 * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier).
1803 * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is
1804 * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry.
1805 * @param[in] map_type Mapping username to the certificate option.
1806 * @param[in] name Username for this cert-to-name entry.
Roytak9b32c0f2023-08-02 15:07:29 +02001807 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001808 * Otherwise the new YANG data will be added to the previous data and may override it.
1809 * @return 0 on success, non-zero otherwise.
1810 */
roman8ba6efa2023-07-12 15:27:52 +02001811int nc_server_config_new_ch_tls_ctn(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
romanb6f44032023-06-30 15:07:56 +02001812 uint32_t id, const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config);
1813
roman8ba6efa2023-07-12 15:27:52 +02001814/**
Roytak2161df62023-08-02 15:04:42 +02001815 * @brief Deletes a Call Home cert-to-name entry from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001816 *
Roytak2161df62023-08-02 15:04:42 +02001817 * @param[in] client_name Identifier of an existing Call Home client.
1818 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1819 * @param[in] id Optional identifier of the Call Home CTN entry to be deleted.
roman8ba6efa2023-07-12 15:27:52 +02001820 * If 0, all of the CTN entries will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001821 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001822 * @return 0 on success, non-zero otherwise.
1823 */
1824int nc_server_config_new_ch_tls_del_ctn(const char *client_name, const char *endpt_name,
1825 uint32_t id, struct lyd_node **config);
1826
1827/**
Roytak2161df62023-08-02 15:04:42 +02001828 * @brief Creates new YANG configuration data nodes for a Call Home TLS version.
roman9d5e5a52023-07-14 12:43:44 +02001829 *
1830 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001831 * @param[in] client_name Arbitrary identifier of the Call Home client.
1832 * If a Call Home client with this identifier already exists, its contents will be changed.
1833 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1834 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001835 * @param[in] tls_version TLS version to be used. Call this multiple times to set the accepted versions
1836 * of the TLS protocol and let the client and server negotiate the given version.
Roytak9b32c0f2023-08-02 15:07:29 +02001837 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001838 * Otherwise the new YANG data will be added to the previous data and may override it.
1839 * @return 0 on success, non-zero otherwise.
1840 */
1841int nc_server_config_new_ch_tls_version(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1842 NC_TLS_VERSION tls_version, struct lyd_node **config);
1843
1844/**
1845 * @brief Deletes a TLS version from the YANG data.
1846 *
Roytak2161df62023-08-02 15:04:42 +02001847 * @param[in] client_name Identifier of an existing Call Home client.
1848 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman9d5e5a52023-07-14 12:43:44 +02001849 * @param[in] tls_version TLS version to be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001850 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001851 * @return 0 on success, non-zero otherwise.
1852 */
1853int nc_server_config_new_ch_tls_del_version(const char *client_name, const char *endpt_name,
1854 NC_TLS_VERSION tls_version, struct lyd_node **config);
1855
1856/**
Roytak2161df62023-08-02 15:04:42 +02001857 * @brief Creates new YANG configuration data nodes for a Call Home TLS cipher.
roman9d5e5a52023-07-14 12:43:44 +02001858 *
1859 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001860 * @param[in] client_name Arbitrary identifier of the Call Home client.
1861 * If a Call Home client with this identifier already exists, its contents will be changed.
1862 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1863 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001864 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001865 * Otherwise the new YANG data will be added to the previous data and may override it.
1866 * @param[in] cipher_count Number of following ciphers.
1867 * @param[in] ... TLS ciphers. These ciphers MUST be in the format as listed in the
1868 * iana-tls-cipher-suite-algs YANG model (lowercase and separated by dashes). Regardless
1869 * of the TLS protocol version used, all of these ciphers will be tried and some of them
1870 * might not be set (TLS handshake might fail then). For the list of supported ciphers see
1871 * the OpenSSL documentation.
1872 * @return 0 on success, non-zero otherwise.
1873 */
1874int nc_server_config_new_ch_tls_ciphers(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1875 struct lyd_node **config, int cipher_count, ...);
1876
1877/**
Roytak2161df62023-08-02 15:04:42 +02001878 * @brief Deletes a Call Home TLS cipher from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001879 *
Roytak2161df62023-08-02 15:04:42 +02001880 * @param[in] client_name Identifier of an existing Call Home client.
1881 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman9d5e5a52023-07-14 12:43:44 +02001882 * @param[in] cipher TLS cipher to be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001883 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001884 * @return 0 on success, non-zero otherwise.
1885 */
1886int nc_server_config_new_ch_tls_del_cipher(const char *client_name, const char *endpt_name,
1887 const char *cipher, struct lyd_node **config);
1888
1889/**
Roytak2161df62023-08-02 15:04:42 +02001890 * @brief Creates new YANG configuration data nodes for a Call Home Certificate Revocation List via a local file.
roman9d5e5a52023-07-14 12:43:44 +02001891 *
1892 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
1893 * this function will remove any CRL YANG nodes created by the other two functions.
1894 *
1895 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001896 * @param[in] client_name Arbitrary identifier of the Call Home client.
1897 * If a Call Home client with this identifier already exists, its contents will be changed.
1898 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1899 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001900 * @param[in] crl_path Path to a DER/PEM encoded CRL file.
Roytak9b32c0f2023-08-02 15:07:29 +02001901 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001902 * Otherwise the new YANG data will be added to the previous data and may override it.
1903 * @return 0 on success, non-zero otherwise.
1904 */
1905int nc_server_config_new_ch_tls_crl_path(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1906 const char *crl_path, struct lyd_node **config);
1907
1908/**
Roytak2161df62023-08-02 15:04:42 +02001909 * @brief Creates new YANG configuration data nodes for a Call Home Certificate Revocation List via an URL.
roman9d5e5a52023-07-14 12:43:44 +02001910 *
1911 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
1912 * this function will remove any CRL YANG nodes created by the other two functions.
1913 *
1914 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001915 * @param[in] client_name Arbitrary identifier of the Call Home client.
1916 * If a Call Home client with this identifier already exists, its contents will be changed.
1917 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1918 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001919 * @param[in] crl_url URL from which the CRL file will be downloaded. The file has to be in the DER or PEM format.
1920 * The allowed protocols are all the protocols supported by CURL.
Roytak9b32c0f2023-08-02 15:07:29 +02001921 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001922 * Otherwise the new YANG data will be added to the previous data and may override it.
1923 * @return 0 on success, non-zero otherwise.
1924 */
1925int nc_server_config_new_ch_tls_crl_url(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1926 const char *crl_url, struct lyd_node **config);
1927
1928/**
Roytak2161df62023-08-02 15:04:42 +02001929 * @brief Creates new YANG configuration data nodes for a Call Home Certificate Revocation List via certificate extensions.
roman9d5e5a52023-07-14 12:43:44 +02001930 *
1931 * The chain of configured Certificate Authorities will be examined. For each certificate in this chain all the
1932 * CRLs from the URLs specified in their extension fields CRL Distribution Points will be downloaded and used.
1933 *
1934 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
1935 * this function will remove any CRL YANG nodes created by the other two functions.
1936 *
1937 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001938 * @param[in] client_name Arbitrary identifier of the Call Home client.
1939 * If a Call Home client with this identifier already exists, its contents will be changed.
1940 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1941 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001942 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001943 * Otherwise the new YANG data will be added to the previous data and may override it.
1944 * @return 0 on success, non-zero otherwise.
1945 */
1946int nc_server_config_new_ch_tls_crl_cert_ext(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1947 struct lyd_node **config);
1948
1949/**
1950 * @brief Deletes all the CRL nodes from the YANG data.
1951 *
Roytak2161df62023-08-02 15:04:42 +02001952 * @param[in] client_name Identifier of an existing Call Home client.
1953 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
Roytak9b32c0f2023-08-02 15:07:29 +02001954 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001955 * @return 0 on success, non-zero otherwise.
1956 */
1957int nc_server_config_new_ch_tls_del_crl(const char *client_name, const char *endpt_name, struct lyd_node **config);
1958
1959/**
roman35120972023-08-08 10:39:12 +02001960 * @} TLS Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001961 */
1962
roman2eab4742023-06-06 10:00:26 +02001963#endif /* NC_ENABLED_SSH_TLS */
roman45cec4e2023-02-17 10:21:39 +01001964
romanc1d2b092023-02-02 08:58:27 +01001965#ifdef __cplusplus
1966}
1967#endif
1968
1969#endif /* NC_SESSION_SERVER_H_ */