blob: d14807603400960781ed6b41bdab533113fbde45 [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
romand348b942023-10-13 14:32:19 +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 *
roman6430c152023-10-12 11:28:47 +020063 * @param[in, out] ctx Optional context in which the modules will be implemented. Created if *ctx is null.
roman35120972023-08-08 10:39:12 +020064 * @return 0 on success, 1 on error.
65 */
66int nc_server_config_load_modules(struct ly_ctx **ctx);
67
68/**
roman6430c152023-10-12 11:28:47 +020069 * @brief Configure server based on the given diff.
romanc1d2b092023-02-02 08:58:27 +010070 *
roman6430c152023-10-12 11:28:47 +020071 * Context must already have implemented the required modules, see ::nc_server_config_load_modules().
romanc1d2b092023-02-02 08:58:27 +010072 *
roman6430c152023-10-12 11:28:47 +020073 * @param[in] diff YANG diff belonging to either ietf-netconf-server, ietf-keystore or ietf-truststore modules.
Roytakb2794852023-10-18 14:30:22 +020074 * The top level node HAS to have an operation (create, replace, delete or none).
romanc1d2b092023-02-02 08:58:27 +010075 * @return 0 on success, 1 on error.
76 */
romanf6f37a52023-05-25 14:27:51 +020077int nc_server_config_setup_diff(const struct lyd_node *diff);
romanc1d2b092023-02-02 08:58:27 +010078
79/**
romanf02273a2023-05-25 09:44:11 +020080 * @brief Configure server based on the given data.
81 *
romanf02273a2023-05-25 09:44:11 +020082 * Behaves as if all the nodes in data had the replace operation. That means that the current configuration will be deleted
roman6430c152023-10-12 11:28:47 +020083 * and just the given data will be applied.
roman0f5fa422023-08-07 09:03:24 +020084 * Context must already have implemented the required modules, see ::nc_server_config_load_modules().
romanf02273a2023-05-25 09:44:11 +020085 *
roman6430c152023-10-12 11:28:47 +020086 * @param[in] data YANG data belonging to either ietf-netconf-server, ietf-keystore or ietf-truststore modules.
Roytakb2794852023-10-18 14:30:22 +020087 * This data __must be valid__. No node can have an operation attribute.
romanf02273a2023-05-25 09:44:11 +020088 * @return 0 on success, 1 on error.
89 */
romanf6f37a52023-05-25 14:27:51 +020090int nc_server_config_setup_data(const struct lyd_node *data);
romanf02273a2023-05-25 09:44:11 +020091
92/**
roman6430c152023-10-12 11:28:47 +020093 * @brief Configure server based on the given data stored in a file.
94 *
roman0f5fa422023-08-07 09:03:24 +020095 * Wrapper around ::nc_server_config_setup_data() hiding work with parsing the data.
roman6430c152023-10-12 11:28:47 +020096 * Context must already have implemented the required modules, see ::nc_server_config_load_modules().
romanc1d2b092023-02-02 08:58:27 +010097 *
98 * @param[in] ctx libyang context.
roman6430c152023-10-12 11:28:47 +020099 * @param[in] path Path to a file with ietf-netconf-server, ietf-keystore or ietf-truststore YANG data.
Roytakb2794852023-10-18 14:30:22 +0200100 * This data __must be valid__. No node can have an operation attribute.
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/**
roman6430c152023-10-12 11:28:47 +0200108 * @brief Creates new YANG configuration data nodes for address and 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 */
Roytakb2794852023-10-18 14:30:22 +0200120int nc_server_config_add_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 */
Roytakb2794852023-10-18 14:30:22 +0200139int nc_server_config_add_unix_socket(const struct ly_ctx *ctx, const char *endpt_name, const char *path,
romand0b78372023-09-14 10:06:03 +0200140 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 */
Roytakb2794852023-10-18 14:30:22 +0200150int nc_server_config_del_endpt(const char *endpt_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200151
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 */
Roytakb2794852023-10-18 14:30:22 +0200168int nc_server_config_add_keystore_asym_key(const struct ly_ctx *ctx, NC_TRANSPORT_IMPL ti, const char *asym_key_name,
roman13145912023-08-17 15:36:54 +0200169 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 */
Roytakb2794852023-10-18 14:30:22 +0200179int nc_server_config_del_keystore_asym_key(const char *asym_key_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200180
181/**
182 * @brief Creates new YANG data nodes for a certificate in the keystore.
183 *
roman6430c152023-10-12 11:28:47 +0200184 * A certificate can not exist without its asymmetric key, so you must create an asymmetric key
185 * with the same identifier you pass to this function.
roman12c3d522023-07-26 13:39:30 +0200186 *
187 * @param[in] ctx libyang context.
188 * @param[in] asym_key_name Arbitrary identifier of the asymmetric key.
189 * If an asymmetric key pair with this name already exists, its contents will be changed.
190 * @param[in] cert_name Arbitrary identifier of the key pair's certificate.
191 * If a certificate with this name already exists, its contents will be changed.
192 * @param[in] cert_path Path to the PEM encoded certificate file.
193 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
194 * Otherwise the new YANG data will be added to the previous data and may override it.
195 * @return 0 on success, non-zero otherwise.
196 */
Roytakb2794852023-10-18 14:30:22 +0200197int nc_server_config_add_keystore_cert(const struct ly_ctx *ctx, const char *asym_key_name, const char *cert_name,
roman12c3d522023-07-26 13:39:30 +0200198 const char *cert_path, struct lyd_node **config);
199
200/**
201 * @brief Deletes a keystore's certificate from the YANG data.
202 *
203 * @param[in] asym_key_name Identifier of an existing asymmetric key pair.
204 * @param[in] cert_name Optional identifier of a certificate to be deleted.
205 * If NULL, all of the certificates belonging to the asymmetric key pair will be deleted.
206 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
207 * Otherwise the new YANG data will be added to the previous data and may override it.
208 * @return 0 on success, non-zero otherwise.
209 */
Roytakb2794852023-10-18 14:30:22 +0200210int nc_server_config_del_keystore_cert(const char *asym_key_name, const char *cert_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200211
212/**
213 * @brief Creates new YANG data nodes for a public key in the truststore.
214 *
215 * @param[in] ctx libyang context.
roman12c3d522023-07-26 13:39:30 +0200216 * @param[in] pub_bag_name Arbitrary identifier of the public key bag.
roman8ba6efa2023-07-12 15:27:52 +0200217 * This name is used to reference the public keys in the bag.
218 * If a public key bag with this name already exists, its contents will be changed.
219 * @param[in] pubkey_name Arbitrary identifier of the public key.
roman12c3d522023-07-26 13:39:30 +0200220 * If a public key with this name already exists in the given bag, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200221 * @param[in] pubkey_path Path to a file containing a public key.
222 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
223 * Otherwise the new YANG data will be added to the previous data and may override it.
224 * @return 0 on success, non-zero otherwise.
225 */
romand348b942023-10-13 14:32:19 +0200226int nc_server_config_add_truststore_pubkey(const struct ly_ctx *ctx, const char *pub_bag_name, const char *pubkey_name,
227 const char *pubkey_path, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200228
229/**
230 * @brief Deletes a truststore's public key from the YANG data.
231 *
roman12c3d522023-07-26 13:39:30 +0200232 * @param[in] pub_bag_name Identifier of an existing public key bag.
roman8ba6efa2023-07-12 15:27:52 +0200233 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
234 * If NULL, all of the public keys in the given bag will be deleted.
235 * @param[in,out] config Configuration YANG data tree.
236 * @return 0 on success, non-zero otherwise.
237 */
Roytakb2794852023-10-18 14:30:22 +0200238int nc_server_config_del_truststore_pubkey(const char *pub_bag_name, const char *pubkey_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200239
240/**
241 * @brief Creates new YANG data nodes for a certificate in the truststore.
242 *
243 * @param[in] ctx libyang context.
244 * @param[in] cert_bag_name Arbitrary identifier of the certificate bag.
245 * This name is used to reference the certificates in the bag.
246 * If a certificate bag with this name already exists, its contents will be changed.
247 * @param[in] cert_name Arbitrary identifier of the certificate.
248 * If a certificate with this name already exists in the given bag, its contents will be changed.
249 * @param[in] cert_path Path to a file containing a PEM encoded certificate.
250 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
251 * Otherwise the new YANG data will be added to the previous data and may override it.
252 * @return 0 on success, non-zero otherwise.
253 */
Roytakb2794852023-10-18 14:30:22 +0200254int nc_server_config_add_truststore_cert(const struct ly_ctx *ctx, const char *cert_bag_name, const char *cert_name,
roman12c3d522023-07-26 13:39:30 +0200255 const char *cert_path, struct lyd_node **config);
256
257/**
258 * @brief Deletes a truststore's certificate from the YANG data.
259 *
260 * @param[in] cert_bag_name Identifier of an existing certificate bag.
261 * @param[in] cert_name Optional identifier of a certificate to be deleted.
262 * If NULL, all of the certificates in the given bag will be deleted.
263 * @param[in,out] config Configuration YANG data tree.
264 * @return 0 on success, non-zero otherwise.
265 */
Roytakb2794852023-10-18 14:30:22 +0200266int nc_server_config_del_truststore_cert(const char *cert_bag_name,
roman12c3d522023-07-26 13:39:30 +0200267 const char *cert_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200268
269/**
roman35120972023-08-08 10:39:12 +0200270 * @} Server Configuration Functions
roman8ba6efa2023-07-12 15:27:52 +0200271 */
272
273/**
274 * @defgroup server_config_ssh SSH Server Configuration
275 * @ingroup server_config
276 *
277 * @brief SSH server configuration creation and deletion
278 * @{
279 */
280
roman3f9b65c2023-06-05 14:26:58 +0200281/**
282 * @brief Creates new YANG configuration data nodes for a hostkey.
283 *
284 * @param[in] ctx libyang context.
285 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200286 * If an endpoint with this identifier already exists, its hostkey might be changed.
roman3f9b65c2023-06-05 14:26:58 +0200287 * @param[in] hostkey_name Arbitrary identifier of the hostkey.
roman142718b2023-06-29 09:15:29 +0200288 * If a hostkey with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200289 * @param[in] privkey_path Path to a file containing a private key.
290 * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
roman35120972023-08-08 10:39:12 +0200291 * @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 +0200292 * generated from the private key.
293 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
294 * Otherwise the new YANG data will be added to the previous data and may override it.
295 * @return 0 on success, non-zero otherwise.
296 */
Roytakb2794852023-10-18 14:30:22 +0200297int nc_server_config_add_ssh_hostkey(const struct ly_ctx *ctx, const char *endpt_name, const char *hostkey_name,
roman8ba6efa2023-07-12 15:27:52 +0200298 const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
299
300/**
301 * @brief Deletes a hostkey from the YANG data.
302 *
303 * @param[in] ctx libyang context.
304 * @param[in] endpt_name Identifier of an existing endpoint.
305 * @param[in] hostkey_name Optional identifier of the hostkey to be deleted.
306 * If NULL, all of the hostkeys on this endpoint will be deleted.
307 * @param[in,out] config Configuration YANG data tree.
308 * @return 0 on success, non-zero otherwise.
309 */
Roytakb2794852023-10-18 14:30:22 +0200310int nc_server_config_del_ssh_hostkey(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200311 const char *hostkey_name, struct lyd_node **config);
312
313/**
romand348b942023-10-13 14:32:19 +0200314 * @brief Creates new YANG data nodes for a reference to an asymmetric key located in the keystore.
315 *
316 * This asymmetric key pair will be used as the SSH hostkey.
317 *
318 * @param[in] ctx libyang context.
319 * @param[in] endpt_name Arbitrary identifier of an endpoint.
320 * If an endpoint with this identifier already exists, its contents will be changed.
321 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
322 * If an endpoint's hostkey with this identifier already exists, its contents will be changed.
323 * @param[in] keystore_reference Name of the asymmetric key pair to be referenced and used as a hostkey.
324 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
325 * Otherwise the new YANG data will be added to the previous data and may override it.
326 * @return 0 on success, non-zero otherwise.
327 */
328int nc_server_config_add_ssh_keystore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *hostkey_name,
329 const char *keystore_reference, struct lyd_node **config);
330
331/**
332 * @brief Deletes a keystore reference from the YANG data.
333 *
334 * @param[in] endpt_name Identifier of an existing endpoint.
335 * @param[in] hostkey_name Identifier of an existing hostkey on the given endpoint.
336 * @param[in,out] config Configuration YANG data tree.
337 * @return 0 on success, non-zero otherwise.
338 */
339int nc_server_config_del_ssh_keystore_ref(const char *endpt_name, const char *hostkey_name,
340 struct lyd_node **config);
341
342/**
roman68404fd2023-07-24 10:40:59 +0200343 * @brief Creates new YANG configuration data nodes for the maximum amount of failed SSH authentication attempts.
344 *
345 * @param[in] ctx libyang context.
346 * @param[in] endpt_name Arbitrary identifier of the endpoint.
347 * If an endpoint with this identifier already exists, its contents might be changed.
348 * @param[in] auth_attempts Maximum amount of failed SSH authentication attempts after which a
349 * client is disconnected. The default value is 3.
350 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
351 * Otherwise the new YANG data will be added to the previous data and may override it.
352 * @return 0 on success, non-zero otherwise.
353 */
Roytakb2794852023-10-18 14:30:22 +0200354int nc_server_config_add_ssh_auth_attempts(const struct ly_ctx *ctx, const char *endpt_name, uint16_t auth_attempts,
roman68404fd2023-07-24 10:40:59 +0200355 struct lyd_node **config);
356
357/**
358 * @brief Creates new YANG configuration data nodes for an SSH authentication timeout.
359 *
360 * @param[in] ctx libyang context.
361 * @param[in] endpt_name Arbitrary identifier of the endpoint.
362 * If an endpoint with this identifier already exists, its contents might be changed.
363 * @param[in] auth_timeout Maximum amount of time in seconds after which the authentication is deemed
364 * unsuccessful. The default value is 10.
365 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
366 * Otherwise the new YANG data will be added to the previous data and may override it.
367 * @return 0 on success, non-zero otherwise.
368 */
Roytakb2794852023-10-18 14:30:22 +0200369int nc_server_config_add_ssh_auth_timeout(const struct ly_ctx *ctx, const char *endpt_name, uint16_t auth_timeout,
roman68404fd2023-07-24 10:40:59 +0200370 struct lyd_node **config);
371
372/**
roman8ba6efa2023-07-12 15:27:52 +0200373 * @brief Creates new YANG configuration data nodes for an SSH user's public key authentication method.
374 *
375 * @param[in] ctx libyang context.
376 * @param[in] endpt_name Arbitrary identifier of the endpoint.
377 * If an endpoint with this identifier already exists, its user might be changed.
378 * @param[in] user_name Arbitrary identifier of the user.
379 * If an user with this identifier already exists, its contents will be changed.
380 * @param[in] pubkey_name Arbitrary identifier of the user's public key.
381 * If a public key with this identifier already exists for this user, its contents will be changed.
382 * @param[in] pubkey_path Path to a file containing the user's public key.
383 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
384 * Otherwise the new YANG data will be added to the previous data and may override it.
385 * @return 0 on success, non-zero otherwise.
386 */
Roytakb2794852023-10-18 14:30:22 +0200387int nc_server_config_add_ssh_user_pubkey(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200388 const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config);
389
390/**
391 * @brief Deletes an SSH user's public key from the YANG data.
392 *
393 * @param[in] endpt_name Identifier of an existing endpoint.
394 * @param[in] user_name Identifier of an existing user on the given endpoint.
395 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
396 * If NULL, all of the users public keys will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200397 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200398 * @return 0 on success, non-zero otherwise.
399 */
Roytakb2794852023-10-18 14:30:22 +0200400int nc_server_config_del_ssh_user_pubkey(const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200401 const char *pubkey_name, struct lyd_node **config);
402
403/**
404 * @brief Creates new YANG configuration data nodes for an SSH user's password authentication method.
405 *
406 * @param[in] ctx libyang context.
407 * @param[in] endpt_name Arbitrary identifier of the endpoint.
408 * If an endpoint with this identifier already exists, its user might be changed.
409 * @param[in] user_name Arbitrary identifier of the user.
410 * If an user with this identifier already exists, its contents will be changed.
roman35120972023-08-08 10:39:12 +0200411 * @param[in] password Clear-text password to be set for the user. It will be hashed.
roman8ba6efa2023-07-12 15:27:52 +0200412 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
413 * Otherwise the new YANG data will be added to the previous data and may override it.
414 * @return 0 on success, non-zero otherwise.
415 */
Roytakb2794852023-10-18 14:30:22 +0200416int nc_server_config_add_ssh_user_password(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200417 const char *user_name, const char *password, struct lyd_node **config);
418
419/**
420 * @brief Deletes an SSH user's password from the YANG data.
421 *
422 * @param[in] endpt_name Identifier of an existing endpoint.
423 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200424 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200425 * @return 0 on success, non-zero otherwise.
426 */
Roytakb2794852023-10-18 14:30:22 +0200427int nc_server_config_del_ssh_user_password(const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200428 struct lyd_node **config);
429
430/**
romand348b942023-10-13 14:32:19 +0200431 * @brief Creates new YANG configuration data nodes for an SSH user's none authentication method.
432 *
433 * @param[in] ctx libyang context.
434 * @param[in] endpt_name Arbitrary identifier of the endpoint.
435 * If an endpoint with this identifier already exists, its user might be changed.
436 * @param[in] user_name Arbitrary identifier of the user.
437 * If an user with this identifier already exists, its contents will be changed.
438 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
439 * Otherwise the new YANG data will be added to the previous data and may override it.
440 * @return 0 on success, non-zero otherwise.
441 */
442int nc_server_config_add_ssh_user_none(const struct ly_ctx *ctx, const char *endpt_name,
443 const char *user_name, struct lyd_node **config);
444
445/**
446 * @brief Deletes an SSH user's none authentication method from the YANG data.
447 *
448 * @param[in] endpt_name Identifier of an existing endpoint.
449 * @param[in] user_name Identifier of an existing user on the given endpoint.
450 * @param[in,out] config Modified configuration YANG data tree.
451 * @return 0 on success, non-zero otherwise.
452 */
453int nc_server_config_del_ssh_user_none(const char *endpt_name, const char *user_name,
454 struct lyd_node **config);
455
456/**
roman8ba6efa2023-07-12 15:27:52 +0200457 * @brief Creates new YANG configuration data nodes for an SSH user's keyboard interactive authentication method.
458 *
459 * @param[in] ctx libyang context.
460 * @param[in] endpt_name Arbitrary identifier of the endpoint.
461 * If an endpoint with this identifier already exists, its user might be changed.
462 * @param[in] user_name Arbitrary identifier of the user.
463 * If an user with this identifier already exists, its contents will be changed.
464 * @param[in] pam_config_name Name of the PAM configuration file.
roman0f5fa422023-08-07 09:03:24 +0200465 * @param[in] pam_config_dir Optional. The absolute path to the directory in which the configuration file
466 * 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 +0200467 * the path. If NULL is passed, then the PAM's system directories will be searched (usually /etc/pam.d/).
468 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
469 * Otherwise the new YANG data will be added to the previous data and may override it.
470 * @return 0 on success, non-zero otherwise.
471 */
Roytakb2794852023-10-18 14:30:22 +0200472int nc_server_config_add_ssh_user_interactive(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200473 const char *user_name, const char *pam_config_name, const char *pam_config_dir, struct lyd_node **config);
474
475/**
476 * @brief Deletes an SSH user's keyboard interactive authentication from the YANG data.
477 *
478 * @param[in] endpt_name Identifier of an existing endpoint.
479 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200480 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200481 * @return 0 on success, non-zero otherwise.
482 */
Roytakb2794852023-10-18 14:30:22 +0200483int nc_server_config_del_ssh_user_interactive(const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200484 struct lyd_node **config);
485
486/**
487 * @brief Deletes an SSH user from the YANG data.
488 *
489 * @param[in] endpt_name Identifier of an existing endpoint.
490 * @param[in] user_name Optional identifier of an user to be deleted.
491 * If NULL, all of the users on this endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200492 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200493 * @return 0 on success, non-zero otherwise.
494 */
Roytakb2794852023-10-18 14:30:22 +0200495int nc_server_config_del_ssh_user(const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200496 const char *user_name, struct lyd_node **config);
497
498/**
romand348b942023-10-13 14:32:19 +0200499 * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore.
500 *
501 * The public key's located in the bag will be used for client authentication.
502 *
503 * @param[in] ctx libyang context.
504 * @param[in] endpt_name Arbitrary identifier of an endpoint.
505 * If an endpoint with this identifier already exists, its contents will be changed.
506 * @param[in] user_name Arbitrary identifier of the endpoint's user.
507 * If an endpoint's user with this identifier already exists, its contents will be changed.
508 * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication.
509 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
510 * Otherwise the new YANG data will be added to the previous data and may override it.
511 * @return 0 on success, non-zero otherwise.
512 */
513int nc_server_config_add_ssh_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *user_name,
514 const char *truststore_reference, struct lyd_node **config);
515
516/**
517 * @brief Deletes a truststore reference from the YANG data.
518 *
519 * @param[in] endpt_name Identifier of an existing endpoint.
520 * @param[in] user_name Identifier of an user on the given endpoint whose truststore reference will be deleted.
521 * @param[in,out] config Modified configuration YANG data tree.
522 * @return 0 on success, non-zero otherwise.
523 */
524int nc_server_config_del_ssh_truststore_ref(const char *endpt_name, const char *user_name,
525 struct lyd_node **config);
526
527/**
roman8ba6efa2023-07-12 15:27:52 +0200528 * @brief Creates new YANG configuration data nodes, which will be a reference to another SSH endpoint's users.
529 *
530 * Whenever a client tries to connect to the referencing endpoint, all of its users will be tried first. If no match is
531 * found, the referenced endpoint's configured users will be tried.
532 *
533 * @param[in] ctx libyang context
534 * @param[in] endpt_name Arbitrary identifier of the endpoint.
535 * If an endpoint with this identifier already exists, its contents will be changed.
536 * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data
537 * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle.
538 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
539 * Otherwise the new YANG data will be added to the previous data and may override it.
540 * @return 0 on success, non-zero otherwise.
541 */
Roytakb2794852023-10-18 14:30:22 +0200542int nc_server_config_add_ssh_endpoint_client_ref(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200543 const char *referenced_endpt, struct lyd_node **config);
544
545/**
546 * @brief Deletes reference to another SSH endpoint's users from the YANG data.
547 *
548 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200549 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200550 * @return 0 on success, non-zero otherwise.
551 */
Roytakb2794852023-10-18 14:30:22 +0200552int nc_server_config_del_ssh_endpoint_client_ref(const char *endpt_name, struct lyd_node **config);
roman9b1379c2023-03-31 10:11:10 +0200553
554/**
romand348b942023-10-13 14:32:19 +0200555 * @brief Creates new YANG configuration data nodes for host-key algorithms replacing any previous ones.
556 *
557 * Supported algorithms are: ssh-ed25519, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521,
558 * rsa-sha2-512, rsa-sha2-256, ssh-rsa and ssh-dss.
559 *
560 * @param[in] ctx libyang context
561 * @param[in] endpt_name Arbitrary identifier of the endpoint.
562 * If an endpoint with this identifier already exists, its host-key algorithms will be replaced.
563 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
564 * Otherwise the new YANG data will be added to the previous data and may override it.
565 * @param[in] alg_count Number of following algorithms.
566 * @param[in] ... String literals of host-key algorithms in a decreasing order of preference.
567 * @return 0 on success, non-zero otherwise.
568 */
569int nc_server_config_add_ssh_host_key_algs(const struct ly_ctx *ctx, const char *endpt_name,
570 struct lyd_node **config, int alg_count, ...);
571
572/**
573 * @brief Deletes a hostkey algorithm from the YANG data.
574 *
575 * @param[in] endpt_name Identifier of an existing endpoint.
576 * @param[in] alg Optional algorithm to be deleted.
577 * If NULL, all of the hostkey algorithms on this endpoint will be deleted.
578 * @param[in,out] config Modified configuration YANG data tree.
579 * @return 0 on success, non-zero otherwise.
580 */
581int nc_server_config_del_ssh_host_key_alg(const char *endpt_name, const char *alg, struct lyd_node **config);
582
583/**
584 * @brief Creates new YANG configuration data nodes for key exchange algorithms replacing any previous ones.
585 *
586 * Supported algorithms are: diffie-hellman-group-exchange-sha1, curve25519-sha256, ecdh-sha2-nistp256,
587 * ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group18-sha512, diffie-hellman-group16-sha512,
588 * diffie-hellman-group-exchange-sha256 and diffie-hellman-group14-sha256.
589 *
590 * @param[in] ctx libyang context
591 * @param[in] endpt_name Arbitrary identifier of the endpoint.
592 * If an endpoint with this identifier already exists, its key exchange algorithms will be replaced.
593 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
594 * Otherwise the new YANG data will be added to the previous data and may override it.
595 * @param[in] alg_count Number of following algorithms.
596 * @param[in] ... String literals of key exchange algorithms in a decreasing order of preference.
597 * @return 0 on success, non-zero otherwise.
598 */
599int nc_server_config_add_ssh_key_exchange_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config,
600 int alg_count, ...);
601
602/**
603 * @brief Deletes a key exchange algorithm from the YANG data.
604 *
605 * @param[in] endpt_name Identifier of an existing endpoint.
606 * @param[in] alg Optional algorithm to be deleted.
607 * If NULL, all of the key exchange algorithms on this endpoint will be deleted.
608 * @param[in,out] config Modified configuration YANG data tree.
609 * @return 0 on success, non-zero otherwise.
610 */
611int nc_server_config_del_ssh_key_exchange_alg(const char *endpt_name, const char *alg, struct lyd_node **config);
612
613/**
614 * @brief Creates new YANG configuration data nodes for encryption algorithms replacing any previous ones.
615 *
616 * Supported algorithms are: aes256-ctr, aes192-ctr, aes128-ctr, aes256-cbc, aes192-cbc, aes128-cbc, blowfish-cbc
617 * triple-des-cbc and none.
618 *
619 * @param[in] ctx libyang context
620 * @param[in] endpt_name Arbitrary identifier of the endpoint.
621 * If an endpoint with this identifier already exists, its encryption algorithms will be replaced.
622 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
623 * Otherwise the new YANG data will be added to the previous data and may override it.
624 * @param[in] alg_count Number of following algorithms.
625 * @param[in] ... String literals of encryption algorithms in a decreasing order of preference.
626 * @return 0 on success, non-zero otherwise.
627 */
628int nc_server_config_add_ssh_encryption_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config,
629 int alg_count, ...);
630
631/**
632 * @brief Deletes an encryption algorithm from the YANG data.
633 *
634 * @param[in] endpt_name Identifier of an existing endpoint.
635 * @param[in] alg Optional algorithm to be deleted.
636 * If NULL, all of the encryption algorithms on this endpoint will be deleted.
637 * @param[in,out] config Modified configuration YANG data tree.
638 * @return 0 on success, non-zero otherwise.
639 */
640int nc_server_config_del_ssh_encryption_alg(const char *endpt_name, const char *alg, struct lyd_node **config);
641
642/**
643 * @brief Creates new YANG configuration data nodes for mac algorithms replacing any previous ones.
644 *
645 * Supported algorithms are: hmac-sha2-256, hmac-sha2-512 and hmac-sha1.
646 *
647 * @param[in] ctx libyang context
648 * @param[in] endpt_name Arbitrary identifier of the endpoint.
649 * If an endpoint with this identifier already exists, its mac algorithms will be replaced.
650 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
651 * Otherwise the new YANG data will be added to the previous data and may override it.
652 * @param[in] alg_count Number of following algorithms.
653 * @param[in] ... String literals of mac algorithms in a decreasing order of preference.
654 * @return 0 on success, non-zero otherwise.
655 */
656int nc_server_config_add_ssh_mac_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config,
657 int alg_count, ...);
658
659/**
660 * @brief Deletes a mac algorithm from the YANG data.
661 *
662 * @param[in] endpt_name Identifier of an existing endpoint.
663 * @param[in] alg Optional algorithm to be deleted.
664 * If NULL, all of the mac algorithms on this endpoint will be deleted.
665 * @param[in,out] config Modified configuration YANG data tree.
666 * @return 0 on success, non-zero otherwise.
667 */
668int nc_server_config_del_ssh_mac_alg(const char *endpt_name, const char *alg, struct lyd_node **config);
669
670/**
roman35120972023-08-08 10:39:12 +0200671 * @} SSH Server Configuration
roman9b1379c2023-03-31 10:11:10 +0200672 */
roman9b1379c2023-03-31 10:11:10 +0200673
674/**
roman8ba6efa2023-07-12 15:27:52 +0200675 * @defgroup server_config_tls TLS Server Configuration
676 * @ingroup server_config
roman9b1379c2023-03-31 10:11:10 +0200677 *
roman8ba6efa2023-07-12 15:27:52 +0200678 * @brief TLS server configuration creation and deletion
679 * @{
roman9b1379c2023-03-31 10:11:10 +0200680 */
roman2e797ef2023-06-19 10:47:49 +0200681
682/**
roman3f9b65c2023-06-05 14:26:58 +0200683 * @brief Creates new YANG configuration data nodes for a server's certificate.
684 *
685 * @param[in] ctx libyang context.
686 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200687 * If an endpoint with this identifier already exists, its server certificate will be changed.
roman6c4efcd2023-08-08 10:18:44 +0200688 * @param[in] privkey_path Path to the server's PEM encoded private key file.
roman3f9b65c2023-06-05 14:26:58 +0200689 * @param[in] pubkey_path Optional path to the server's public key file. If not provided,
690 * it will be generated from the private key.
roman3f9b65c2023-06-05 14:26:58 +0200691 * @param[in] certificate_path Path to the server's certificate file.
692 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
693 * Otherwise the new YANG data will be added to the previous data and may override it.
694 * @return 0 on success, non-zero otherwise.
695 */
romand348b942023-10-13 14:32:19 +0200696int nc_server_config_add_tls_server_certificate(const struct ly_ctx *ctx, const char *endpt_name, const char *privkey_path,
roman6c4efcd2023-08-08 10:18:44 +0200697 const char *pubkey_path, const char *certificate_path, struct lyd_node **config);
roman3f9b65c2023-06-05 14:26:58 +0200698
699/**
roman8ba6efa2023-07-12 15:27:52 +0200700 * @brief Deletes the server's certificate from the YANG data.
701 *
702 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200703 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200704 * @return 0 on success, non-zero otherwise.
705 */
romand348b942023-10-13 14:32:19 +0200706int nc_server_config_del_tls_server_certificate(const char *endpt_name, struct lyd_node **config);
707
708/**
709 * @brief Creates new YANG configuration data nodes for a keystore reference to the TLS server's certificate.
710 *
711 * @param[in] ctx libyang context.
712 * @param[in] endpt_name Arbitrary identifier of the endpoint.
713 * If an endpoint with this identifier already exists, its contents will be changed.
714 * @param[in] asym_key_ref Name of the asymmetric key pair in the keystore to be referenced.
715 * @param[in] cert_ref Name of the certificate, which must belong to the given asymmetric key pair, to be referenced.
716 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
717 * Otherwise the new YANG data will be added to the previous data and may override it.
718 * @return 0 on success, non-zero otherwise.
719 */
720int nc_server_config_add_tls_keystore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *asym_key_ref,
721 const char *cert_ref, struct lyd_node **config);
722
723/**
724 * @brief Deletes a TLS server certificate keystore reference from the YANG data.
725 *
726 * @param[in] endpt_name Identifier of an existing endpoint.
727 * @param[in,out] config Modified configuration YANG data tree.
728 * @return 0 on success, non-zero otherwise.
729 */
730int nc_server_config_del_tls_keystore_ref(const char *endpt_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200731
732/**
roman3f9b65c2023-06-05 14:26:58 +0200733 * @brief Creates new YANG configuration data nodes for a client's (end-entity) certificate.
734 *
735 * @param[in] ctx libyang context.
736 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200737 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200738 * @param[in] cert_name Arbitrary identifier of the client's certificate.
roman35120972023-08-08 10:39:12 +0200739 * If a client certificate with this identifier already exists, it will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200740 * @param[in] cert_path Path to the client's certificate file.
741 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
742 * Otherwise the new YANG data will be added to the previous data and may override it.
743 * @return 0 on success, non-zero otherwise.
744 */
romand348b942023-10-13 14:32:19 +0200745int nc_server_config_add_tls_client_certificate(const struct ly_ctx *ctx, const char *endpt_name, const char *cert_name,
roman3f9b65c2023-06-05 14:26:58 +0200746 const char *cert_path, struct lyd_node **config);
747
748/**
roman8ba6efa2023-07-12 15:27:52 +0200749 * @brief Deletes a client (end-entity) certificate from the YANG data.
750 *
751 * @param[in] endpt_name Identifier of an existing endpoint.
752 * @param[in] cert_name Optional name of a certificate to be deleted.
753 * If NULL, all of the end-entity certificates on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200754 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200755 * @return 0 on success, non-zero otherwise.
756 */
romand348b942023-10-13 14:32:19 +0200757int nc_server_config_del_tls_client_certificate(const char *endpt_name, const char *cert_name, struct lyd_node **config);
758
759/**
760 * @brief Creates new YANG configuration data nodes for a truststore reference to a set of client (end-entity) certificates.
761 *
762 * @param[in] ctx libyang context.
763 * @param[in] endpt_name Arbitrary identifier of the endpoint.
764 * If an endpoint with this identifier already exists, its contents will be changed.
765 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
766 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
767 * Otherwise the new YANG data will be added to the previous data and may override it.
768 * @return 0 on success, non-zero otherwise.
769 */
770int nc_server_config_add_tls_client_cert_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name,
771 const char *cert_bag_ref, struct lyd_node **config);
772
773/**
774 * @brief Deletes a client (end-entity) certificates truststore reference from the YANG data.
775 *
776 * @param[in] endpt_name Identifier of an existing endpoint.
777 * @param[in,out] config Modified configuration YANG data tree.
778 * @return 0 on success, non-zero otherwise.
779 */
780int nc_server_config_del_tls_client_cert_truststore_ref(const char *endpt_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200781
782/**
roman3f9b65c2023-06-05 14:26:58 +0200783 * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate.
784 *
785 * @param[in] ctx libyang context.
786 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200787 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200788 * @param[in] cert_name Arbitrary identifier of the certificate authority certificate.
roman35120972023-08-08 10:39:12 +0200789 * If a CA with this identifier already exists, it will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200790 * @param[in] cert_path Path to the CA certificate file.
791 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
792 * Otherwise the new YANG data will be added to the previous data and may override it.
793 * @return 0 on success, non-zero otherwise.
794 */
romand348b942023-10-13 14:32:19 +0200795int nc_server_config_add_tls_client_ca(const struct ly_ctx *ctx, const char *endpt_name, const char *cert_name,
roman3f9b65c2023-06-05 14:26:58 +0200796 const char *cert_path, struct lyd_node **config);
797
798/**
roman8ba6efa2023-07-12 15:27:52 +0200799 * @brief Deletes a client certificate authority (trust-anchor) certificate from the YANG data.
800 *
801 * @param[in] endpt_name Identifier of an existing endpoint.
802 * @param[in] cert_name Optional name of a certificate to be deleted.
803 * If NULL, all of the CA certificates on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200804 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200805 * @return 0 on success, non-zero otherwise.
806 */
romand348b942023-10-13 14:32:19 +0200807int nc_server_config_del_tls_client_ca(const char *endpt_name, const char *cert_name, struct lyd_node **config);
808
809/**
810 * @brief Creates new YANG configuration data nodes for a truststore reference to a set of client certificate authority (trust-anchor) certificates.
811 *
812 * @param[in] ctx libyang context.
813 * @param[in] endpt_name Arbitrary identifier of the endpoint.
814 * If an endpoint with this identifier already exists, its contents will be changed.
815 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
816 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
817 * Otherwise the new YANG data will be added to the previous data and may override it.
818 * @return 0 on success, non-zero otherwise.
819 */
820int nc_server_config_add_tls_client_ca_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name,
821 const char *cert_bag_ref, struct lyd_node **config);
822
823/**
824 * @brief Deletes a client certificate authority (trust-anchor) certificates truststore reference from the YANG data.
825 *
826 * @param[in] endpt_name Identifier of an existing endpoint.
827 * @param[in,out] config Modified configuration YANG data tree.
828 * @return 0 on success, non-zero otherwise.
829 */
830int nc_server_config_del_tls_client_ca_truststore_ref(const char *endpt_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200831
832/**
Roytak76958912023-09-29 15:25:14 +0200833 * @brief Creates new YANG configuration data nodes, which will be a reference to another TLS endpoint's certificates.
834 *
835 * Whenever an user tries to connect to the referencing endpoint, all of its certificates will be tried first. If no match is
836 * found, the referenced endpoint's configured certificates will be tried. The same applies to cert-to-name entries.
837 *
838 * @param[in] ctx libyang context
839 * @param[in] endpt_name Arbitrary identifier of the endpoint.
840 * If an endpoint with this identifier already exists, its contents will be changed.
841 * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data
842 * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle.
843 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
844 * Otherwise the new YANG data will be added to the previous data and may override it.
845 * @return 0 on success, non-zero otherwise.
846 */
Roytakb2794852023-10-18 14:30:22 +0200847int nc_server_config_add_tls_endpoint_client_ref(const struct ly_ctx *ctx, const char *endpt_name,
Roytak76958912023-09-29 15:25:14 +0200848 const char *referenced_endpt, struct lyd_node **config);
849
850/**
851 * @brief Deletes reference to another TLS endpoint's users from the YANG data.
852 *
853 * @param[in] endpt_name Identifier of an existing endpoint.
854 * @param[in,out] config Modified configuration YANG data tree.
855 * @return 0 on success, non-zero otherwise.
856 */
Roytakb2794852023-10-18 14:30:22 +0200857int nc_server_config_del_tls_endpoint_client_ref(const char *endpt_name, struct lyd_node **config);
Roytak76958912023-09-29 15:25:14 +0200858
859/**
roman3f9b65c2023-06-05 14:26:58 +0200860 * @brief Creates new YANG configuration data nodes for a cert-to-name entry.
861 *
862 * @param[in] ctx libyang context.
863 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200864 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200865 * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier).
866 * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is
867 * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry.
868 * @param[in] map_type Mapping username to the certificate option.
869 * @param[in] name Username for this cert-to-name entry.
870 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
871 * Otherwise the new YANG data will be added to the previous data and may override it.
872 * @return 0 on success, non-zero otherwise.
873 */
Roytakb2794852023-10-18 14:30:22 +0200874int nc_server_config_add_tls_ctn(const struct ly_ctx *ctx, const char *endpt_name, uint32_t id, const char *fingerprint,
roman3f9b65c2023-06-05 14:26:58 +0200875 NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config);
876
roman12644fe2023-06-08 11:06:42 +0200877/**
roman8ba6efa2023-07-12 15:27:52 +0200878 * @brief Deletes a cert-to-name entry from the YANG data.
879 *
880 * @param[in] endpt_name Identifier of an existing endpoint.
881 * @param[in] id Optional ID of the CTN entry.
882 * If 0, all of the cert-to-name entries on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200883 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200884 * @return 0 on success, non-zero otherwise.
885 */
Roytakb2794852023-10-18 14:30:22 +0200886int nc_server_config_del_tls_ctn(const char *endpt_name, uint32_t id, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200887
888/**
romand348b942023-10-13 14:32:19 +0200889 * @brief Creates new YANG configuration data nodes for a TLS version.
890 *
891 * @param[in] ctx libyang context.
892 * @param[in] endpt_name Arbitrary identifier of the endpoint.
893 * If an endpoint with this identifier already exists, its contents will be changed.
894 * @param[in] tls_version TLS version to be used. Call this multiple times to set
895 * the accepted versions of the TLS protocol and let the client and server negotiate
896 * the given version.
897 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
898 * Otherwise the new YANG data will be added to the previous data and may override it.
899 * @return 0 on success, non-zero otherwise.
900 */
901int nc_server_config_add_tls_version(const struct ly_ctx *ctx, const char *endpt_name,
902 NC_TLS_VERSION tls_version, struct lyd_node **config);
903
904/**
905 * @brief Deletes a TLS version from the YANG data.
906 *
907 * @param[in] endpt_name Identifier of an existing endpoint.
908 * @param[in] tls_version TLS version to be deleted.
909 * @param[in,out] config Modified configuration YANG data tree.
910 * @return 0 on success, non-zero otherwise.
911 */
912int nc_server_config_del_tls_version(const char *endpt_name, NC_TLS_VERSION tls_version, struct lyd_node **config);
913
914/**
915 * @brief Creates new YANG configuration data nodes for a TLS cipher.
916 *
917 * @param[in] ctx libyang context.
918 * @param[in] endpt_name Arbitrary identifier of the endpoint.
919 * If an endpoint with this identifier already exists, its contents will be changed.
920 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
921 * Otherwise the new YANG data will be added to the previous data and may override it.
922 * @param[in] cipher_count Number of following ciphers.
923 * @param[in] ... TLS ciphers. These ciphers MUST be in the format as listed in the
924 * iana-tls-cipher-suite-algs YANG model (lowercase and separated by dashes). Regardless
925 * of the TLS protocol version used, all of these ciphers will be tried and some of them
926 * might not be set (TLS handshake might fail then). For the list of supported ciphers see
927 * the OpenSSL documentation.
928 * @return 0 on success, non-zero otherwise.
929 */
930int nc_server_config_add_tls_ciphers(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config,
931 int cipher_count, ...);
932
933/**
934 * @brief Deletes a TLS cipher from the YANG data.
935 *
936 * @param[in] endpt_name Identifier of an existing endpoint.
937 * @param[in] cipher TLS cipher to be deleted.
938 * @param[in,out] config Modified configuration YANG data tree.
939 * @return 0 on success, non-zero otherwise.
940 */
941int nc_server_config_del_tls_cipher(const char *endpt_name, const char *cipher, struct lyd_node **config);
942
943/**
944 * @brief Creates new YANG configuration data nodes for a Certificate Revocation List via a local file.
945 *
946 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
947 * this function will remove any CRL YANG nodes created by the other two functions.
948 *
949 * @param[in] ctx libyang context.
950 * @param[in] endpt_name Arbitrary identifier of the endpoint.
951 * If an endpoint with this identifier already exists, its contents will be changed.
952 * @param[in] crl_path Path to a DER/PEM encoded CRL file.
953 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
954 * Otherwise the new YANG data will be added to the previous data and may override it.
955 * @return 0 on success, non-zero otherwise.
956 */
957int nc_server_config_add_tls_crl_path(const struct ly_ctx *ctx, const char *endpt_name,
958 const char *crl_path, struct lyd_node **config);
959
960/**
961 * @brief Creates new YANG configuration data nodes for a Certificate Revocation List via an URL.
962 *
963 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
964 * this function will remove any CRL YANG nodes created by the other two functions.
965 *
966 * @param[in] ctx libyang context.
967 * @param[in] endpt_name Arbitrary identifier of the endpoint.
968 * If an endpoint with this identifier already exists, its contents will be changed.
969 * @param[in] crl_url URL from which the CRL file will be downloaded. The file has to be in the DER or PEM format.
970 * The allowed protocols are all the protocols supported by CURL.
971 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
972 * Otherwise the new YANG data will be added to the previous data and may override it.
973 * @return 0 on success, non-zero otherwise.
974 */
975int nc_server_config_add_tls_crl_url(const struct ly_ctx *ctx, const char *endpt_name, const char *crl_url, struct lyd_node **config);
976
977/**
978 * @brief Creates new YANG configuration data nodes for a Certificate Revocation List via certificate extensions.
979 *
980 * The chain of configured Certificate Authorities will be examined. For each certificate in this chain all the
981 * CRLs from the URLs specified in their extension fields CRL Distribution Points will be downloaded and used.
982 *
983 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
984 * this function will remove any CRL YANG nodes created by the other two functions.
985 *
986 * @param[in] ctx libyang context.
987 * @param[in] endpt_name Arbitrary identifier of the endpoint.
988 * If an endpoint with this identifier already exists, its contents will be changed.
989 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
990 * Otherwise the new YANG data will be added to the previous data and may override it.
991 * @return 0 on success, non-zero otherwise.
992 */
993int nc_server_config_add_tls_crl_cert_ext(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config);
994
995/**
996 * @brief Deletes all the CRL nodes from the YANG data.
997 *
998 * @param[in] endpt_name Identifier of an existing endpoint.
999 * @param[in,out] config Modified configuration YANG data tree.
1000 * @return 0 on success, non-zero otherwise.
1001 */
1002int nc_server_config_del_tls_crl(const char *endpt_name, struct lyd_node **config);
1003
1004/**
roman35120972023-08-08 10:39:12 +02001005 * @} TLS Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001006 */
1007
1008/**
roman35120972023-08-08 10:39:12 +02001009 * @defgroup server_config_ch Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001010 * @ingroup server_config
1011 *
Roytak2161df62023-08-02 15:04:42 +02001012 * @brief Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +02001013 * @{
1014 */
1015
1016/**
roman35120972023-08-08 10:39:12 +02001017 * @} Call Home Server Configuration
1018 */
1019
1020/**
1021 * @defgroup server_config_ch_functions Call Home Server Configuration Functions
1022 * @ingroup server_config_ch
1023 *
1024 * @brief Call Home server configuration functions
1025 * @{
1026 */
1027
1028/**
Roytak2161df62023-08-02 15:04:42 +02001029 * @brief Creates new YANG configuration data nodes for a Call Home client's address and port.
roman142718b2023-06-29 09:15:29 +02001030 *
1031 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001032 * @param[in] client_name Arbitrary identifier of the Call Home client.
1033 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +02001034 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1035 * If the client's endpoint with this identifier already exists, its contents will be changed.
1036 * @param[in] transport Transport protocol to be used on this endpoint - either SSH or TLS.
1037 * @param[in] address Address to connect to.
1038 * @param[in] port Port to connect to.
1039 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1040 * Otherwise the new YANG data will be added to the previous data and may override it.
1041 * @return 0 on success, non-zero otherwise.
1042 */
Roytakb2794852023-10-18 14:30:22 +02001043int nc_server_config_add_ch_address_port(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman5cbb6532023-06-22 12:53:17 +02001044 NC_TRANSPORT_IMPL transport, const char *address, const char *port, struct lyd_node **config);
1045
roman8ba6efa2023-07-12 15:27:52 +02001046#endif /* NC_ENABLED_SSH_TLS */
1047
1048/**
Roytak2161df62023-08-02 15:04:42 +02001049 * @brief Deletes a Call Home client from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001050 *
1051 * @param[in] client_name Optional identifier of a client to be deleted.
Roytak2161df62023-08-02 15:04:42 +02001052 * If NULL, all of the Call Home clients will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001053 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001054 * @return 0 on success, non-zero otherwise.
1055 */
Roytakb2794852023-10-18 14:30:22 +02001056int nc_server_config_del_ch_client(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +02001057
1058/**
Roytak2161df62023-08-02 15:04:42 +02001059 * @brief Deletes a Call Home endpoint from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001060 *
Roytak2161df62023-08-02 15:04:42 +02001061 * @param[in] client_name Identifier of an existing Call Home client.
roman8ba6efa2023-07-12 15:27:52 +02001062 * @param[in] endpt_name Optional identifier of a CH endpoint to be deleted.
1063 * If NULL, all of the CH endpoints which belong to the given client will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001064 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001065 * @return 0 on success, non-zero otherwise.
1066 */
Roytakb2794852023-10-18 14:30:22 +02001067int nc_server_config_del_ch_endpt(const char *client_name, const char *endpt_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +02001068
1069/**
Roytak2161df62023-08-02 15:04:42 +02001070 * @brief Creates new YANG configuration data nodes for the Call Home persistent connection type.
roman8ba6efa2023-07-12 15:27:52 +02001071 *
1072 * This is the default connection type. If periodic connection type was set before, it will be unset.
1073 *
1074 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001075 * @param[in] client_name Arbitrary identifier of the Call Home client.
1076 * If a Call Home client with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001077 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001078 * Otherwise the new YANG data will be added to the previous data and may override it.
1079 * @return 0 on success, non-zero otherwise.
1080 */
Roytakb2794852023-10-18 14:30:22 +02001081int nc_server_config_add_ch_persistent(const struct ly_ctx *ctx, const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +02001082
1083/**
Roytak2161df62023-08-02 15:04:42 +02001084 * @brief Creates new YANG configuration data nodes for the period parameter of the Call Home periodic connection type.
roman8ba6efa2023-07-12 15:27:52 +02001085 *
1086 * If called, the persistent connection type will be replaced by periodic.
1087 *
1088 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001089 * @param[in] client_name Arbitrary identifier of the Call Home client.
1090 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +02001091 * @param[in] period Duration between periodic connections in minutes.
Roytak9b32c0f2023-08-02 15:07:29 +02001092 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001093 * Otherwise the new YANG data will be added to the previous data and may override it.
1094 * @return 0 on success, non-zero otherwise.
1095 */
Roytakb2794852023-10-18 14:30:22 +02001096int nc_server_config_add_ch_period(const struct ly_ctx *ctx, const char *client_name, uint16_t period,
roman8ba6efa2023-07-12 15:27:52 +02001097 struct lyd_node **config);
1098
1099/**
Roytak2161df62023-08-02 15:04:42 +02001100 * @brief Deletes the Call Home period parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001101 *
1102 * This behaves the same as setting the period to 60 minutes, which is the default value of this node.
1103 *
Roytak2161df62023-08-02 15:04:42 +02001104 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001105 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001106 * @return 0 on success, non-zero otherwise.
1107 */
Roytakb2794852023-10-18 14:30:22 +02001108int nc_server_config_del_ch_period(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +02001109
1110/**
Roytak2161df62023-08-02 15:04:42 +02001111 * @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 +02001112 *
1113 * If called, the persistent connection type will be replaced by periodic.
1114 *
1115 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001116 * @param[in] client_name Arbitrary identifier of the Call Home client.
1117 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +02001118 * @param[in] anchor_time Timestamp before or after which a series of periodic connections are determined.
Roytak9b32c0f2023-08-02 15:07:29 +02001119 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001120 * Otherwise the new YANG data will be added to the previous data and may override it.
1121 * @return 0 on success, non-zero otherwise.
1122 */
Roytakb2794852023-10-18 14:30:22 +02001123int nc_server_config_add_ch_anchor_time(const struct ly_ctx *ctx, const char *client_name,
roman8ba6efa2023-07-12 15:27:52 +02001124 const char *anchor_time, struct lyd_node **config);
1125
1126/**
Roytak2161df62023-08-02 15:04:42 +02001127 * @brief Deletes the Call Home anchor time parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001128 *
Roytak2161df62023-08-02 15:04:42 +02001129 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001130 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001131 * @return 0 on success, non-zero otherwise.
1132 */
Roytakb2794852023-10-18 14:30:22 +02001133int nc_server_config_del_ch_anchor_time(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +02001134
1135/**
Roytak2161df62023-08-02 15:04:42 +02001136 * @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 +02001137 *
1138 * If called, the persistent connection type will be replaced by periodic.
1139 *
1140 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001141 * @param[in] client_name Arbitrary identifier of the Call Home client.
1142 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +02001143 * @param[in] idle_timeout Specifies the maximum number of seconds that a session may remain idle.
Roytak9b32c0f2023-08-02 15:07:29 +02001144 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001145 * Otherwise the new YANG data will be added to the previous data and may override it.
1146 * @return 0 on success, non-zero otherwise.
1147 */
Roytakb2794852023-10-18 14:30:22 +02001148int nc_server_config_add_ch_idle_timeout(const struct ly_ctx *ctx, const char *client_name,
roman8ba6efa2023-07-12 15:27:52 +02001149 uint16_t idle_timeout, struct lyd_node **config);
1150
1151/**
Roytak2161df62023-08-02 15:04:42 +02001152 * @brief Deletes the Call Home idle timeout parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001153 *
1154 * This behaves the same as setting the timeout to 180 seconds, which is the default value of this node.
1155 *
Roytak2161df62023-08-02 15:04:42 +02001156 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001157 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001158 * @return 0 on success, non-zero otherwise.
1159 */
Roytakb2794852023-10-18 14:30:22 +02001160int nc_server_config_del_ch_idle_timeout(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +02001161
1162/**
Roytak2161df62023-08-02 15:04:42 +02001163 * @brief Creates new YANG configuration data nodes for the Call Home reconnect strategy.
roman8ba6efa2023-07-12 15:27:52 +02001164 *
1165 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001166 * @param[in] client_name Arbitrary identifier of the Call Home client.
1167 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +02001168 * @param[in] start_with Specifies which endpoint to try if a connection is unsuccessful. Default value is NC_CH_FIRST_LISTED.
1169 * @param[in] max_wait The number of seconds after which a connection to an endpoint is deemed unsuccessful. Default value if 5.
1170 * @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 +02001171 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001172 * Otherwise the new YANG data will be added to the previous data and may override it.
1173 * @return 0 on success, non-zero otherwise.
1174 */
Roytakb2794852023-10-18 14:30:22 +02001175int nc_server_config_add_ch_reconnect_strategy(const struct ly_ctx *ctx, const char *client_name,
roman8ba6efa2023-07-12 15:27:52 +02001176 NC_CH_START_WITH start_with, uint16_t max_wait, uint8_t max_attempts, struct lyd_node **config);
1177
1178/**
Roytak2161df62023-08-02 15:04:42 +02001179 * @brief Resets the values of the Call Home reconnect strategy nodes to their defaults.
roman8ba6efa2023-07-12 15:27:52 +02001180 *
1181 * The default values are: start-with = NC_CH_FIRST_LISTED, max-wait = 5 and max-attempts = 3.
1182 *
Roytak2161df62023-08-02 15:04:42 +02001183 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001184 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001185 * @return 0 on success, non-zero otherwise.
1186 */
Roytakb2794852023-10-18 14:30:22 +02001187int nc_server_config_del_ch_reconnect_strategy(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +02001188
1189/**
roman35120972023-08-08 10:39:12 +02001190 * @} Call Home Server Configuration Functions
roman8ba6efa2023-07-12 15:27:52 +02001191 */
1192
1193#ifdef NC_ENABLED_SSH_TLS
1194
1195/**
Roytak2161df62023-08-02 15:04:42 +02001196 * @defgroup server_config_ch_ssh SSH Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001197 * @ingroup server_config_ch
1198 *
Roytak2161df62023-08-02 15:04:42 +02001199 * @brief SSH Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +02001200 * @{
1201 */
1202
roman142718b2023-06-29 09:15:29 +02001203/**
Roytak2161df62023-08-02 15:04:42 +02001204 * @brief Creates new YANG data nodes for a Call Home SSH hostkey.
roman142718b2023-06-29 09:15:29 +02001205 *
1206 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001207 * @param[in] client_name Arbitrary identifier of the Call Home client.
1208 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +02001209 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1210 * If the client's endpoint with this identifier already exists, its contents will be changed.
1211 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
1212 * If the endpoint's hostkey with this identifier already exists, its contents will be changed.
1213 * @param[in] privkey_path Path to a file containing a private key.
1214 * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
1215 * @param[in] pubkey_path Path to a file containing a public key. If NULL, public key will be
1216 * generated from the private key.
1217 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1218 * Otherwise the new YANG data will be added to the previous data and may override it.
1219 * @return 0 on success, non-zero otherwise.
1220 */
Roytakb2794852023-10-18 14:30:22 +02001221int nc_server_config_add_ch_ssh_hostkey(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman5cbb6532023-06-22 12:53:17 +02001222 const char *hostkey_name, const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
1223
roman142718b2023-06-29 09:15:29 +02001224/**
Roytak2161df62023-08-02 15:04:42 +02001225 * @brief Deletes a Call Home hostkey from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001226 *
Roytak2161df62023-08-02 15:04:42 +02001227 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001228 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
roman8ba6efa2023-07-12 15:27:52 +02001229 * @param[in] hostkey_name Optional identifier of a hostkey to be deleted.
1230 * If NULL, all of the hostkeys on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001231 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001232 * @return 0 on success, non-zero otherwise.
1233 */
Roytakb2794852023-10-18 14:30:22 +02001234int nc_server_config_del_ch_ssh_hostkey(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001235 const char *hostkey_name, struct lyd_node **config);
1236
1237/**
romand348b942023-10-13 14:32:19 +02001238 * @brief Creates new YANG data nodes for a reference to an asymmetric key located in the keystore.
1239 *
1240 * This asymmetric key pair will be used as the Call Home SSH hostkey.
1241 *
1242 * @param[in] ctx libyang context.
1243 * @param[in] client_name Arbitrary identifier of the Call Home client.
1244 * If a Call Home client with this identifier already exists, its contents will be changed.
1245 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1246 * If the client's endpoint with this identifier already exists, its contents will be changed.
1247 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
1248 * If the endpoint's hostkey with this identifier already exists, its contents will be changed.
1249 * @param[in] keystore_reference Name of the asymmetric key pair to be referenced and used as a hostkey.
1250 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1251 * Otherwise the new YANG data will be added to the previous data and may override it.
1252 * @return 0 on success, non-zero otherwise.
1253 */
1254int nc_server_config_add_ch_ssh_keystore_ref(const struct ly_ctx *ctx, const char *client_name,
1255 const char *endpt_name, const char *hostkey_name, const char *keystore_reference, struct lyd_node **config);
1256
1257/**
1258 * @brief Deletes a Call Home keystore reference from the YANG data.
1259 *
1260 * @param[in] client_name Identifier of an existing Call Home client.
1261 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1262 * @param[in] hostkey_name Identifier of an existing hostkey that belongs to the given CH endpoint.
1263 * @param[in,out] config Modified configuration YANG data tree.
1264 * @return 0 on success, non-zero otherwise.
1265 */
1266int nc_server_config_del_ch_ssh_keystore_ref(const char *client_name, const char *endpt_name,
1267 const char *hostkey_name, struct lyd_node **config);
1268
1269/**
Roytak2161df62023-08-02 15:04:42 +02001270 * @brief Creates new YANG configuration data nodes for the maximum amount of failed Call Home SSH authentication attempts.
roman68404fd2023-07-24 10:40:59 +02001271 *
1272 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001273 * @param[in] client_name Arbitrary identifier of the Call Home client.
1274 * If a Call Home client with this identifier already exists, its contents will be changed.
roman68404fd2023-07-24 10:40:59 +02001275 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1276 * If the client's endpoint with this identifier already exists, its contents will be changed.
1277 * @param[in] auth_attempts Maximum amount of failed SSH authentication attempts after which a
1278 * client is disconnected. The default value is 3.
1279 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1280 * Otherwise the new YANG data will be added to the previous data and may override it.
1281 * @return 0 on success, non-zero otherwise.
1282 */
Roytakb2794852023-10-18 14:30:22 +02001283int nc_server_config_add_ch_ssh_auth_attempts(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman68404fd2023-07-24 10:40:59 +02001284 uint16_t auth_attempts, struct lyd_node **config);
1285
1286/**
Roytak2161df62023-08-02 15:04:42 +02001287 * @brief Creates new YANG configuration data nodes for a Call Home SSH authentication timeout.
roman68404fd2023-07-24 10:40:59 +02001288 *
1289 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001290 * @param[in] client_name Arbitrary identifier of the Call Home client.
1291 * If a Call Home client with this identifier already exists, its contents will be changed.
roman68404fd2023-07-24 10:40:59 +02001292 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1293 * If the client's endpoint with this identifier already exists, its contents will be changed.
1294 * @param[in] auth_timeout Maximum amount of time in seconds after which the authentication is deemed
1295 * unsuccessful. The default value is 10.
1296 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1297 * Otherwise the new YANG data will be added to the previous data and may override it.
1298 * @return 0 on success, non-zero otherwise.
1299 */
Roytakb2794852023-10-18 14:30:22 +02001300int nc_server_config_add_ch_ssh_auth_timeout(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman68404fd2023-07-24 10:40:59 +02001301 uint16_t auth_timeout, struct lyd_node **config);
1302
1303/**
Roytak2161df62023-08-02 15:04:42 +02001304 * @brief Creates new YANG data nodes for a Call Home SSH user's public key authentication method.
roman142718b2023-06-29 09:15:29 +02001305 *
1306 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001307 * @param[in] client_name Arbitrary identifier of the Call Home client.
1308 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +02001309 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1310 * If the client's endpoint with this identifier already exists, its contents will be changed.
1311 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1312 * If the endpoint's user with this identifier already exists, its contents will be changed.
1313 * @param[in] pubkey_name Arbitrary identifier of the user's public key.
1314 * If the user's public key with this identifier already exists, its contents will be changed.
1315 * @param[in] pubkey_path Path to a file containing a public key.
1316 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1317 * Otherwise the new YANG data will be added to the previous data and may override it.
1318 * @return 0 on success, non-zero otherwise.
1319 */
Roytakb2794852023-10-18 14:30:22 +02001320int nc_server_config_add_ch_ssh_user_pubkey(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman5cbb6532023-06-22 12:53:17 +02001321 const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config);
1322
roman142718b2023-06-29 09:15:29 +02001323/**
Roytak2161df62023-08-02 15:04:42 +02001324 * @brief Deletes a Call Home SSH user's public key from the YANG data.
roman142718b2023-06-29 09:15:29 +02001325 *
Roytak2161df62023-08-02 15:04:42 +02001326 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001327 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1328 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
roman8ba6efa2023-07-12 15:27:52 +02001329 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
1330 * If NULL, all of the public keys which belong to the given SSH user will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001331 * @param[in,out] config Modified configuration YANG data tree.
roman142718b2023-06-29 09:15:29 +02001332 * @return 0 on success, non-zero otherwise.
1333 */
Roytakb2794852023-10-18 14:30:22 +02001334int nc_server_config_del_ch_ssh_user_pubkey(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001335 const char *user_name, const char *pubkey_name, struct lyd_node **config);
roman5cbb6532023-06-22 12:53:17 +02001336
roman142718b2023-06-29 09:15:29 +02001337/**
Roytak2161df62023-08-02 15:04:42 +02001338 * @brief Creates new YANG data nodes for a Call Home SSH user's password authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001339 *
1340 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001341 * @param[in] client_name Arbitrary identifier of the Call Home client.
1342 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001343 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1344 * If the client's endpoint with this identifier already exists, its contents will be changed.
1345 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1346 * If the endpoint's user with this identifier already exists, its contents will be changed.
roman35120972023-08-08 10:39:12 +02001347 * @param[in] password Clear-text password to be set for the user. It will be hashed.
roman9d5e5a52023-07-14 12:43:44 +02001348 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1349 * Otherwise the new YANG data will be added to the previous data and may override it.
1350 * @return 0 on success, non-zero otherwise.
1351 */
Roytakb2794852023-10-18 14:30:22 +02001352int nc_server_config_add_ch_ssh_user_password(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001353 const char *user_name, const char *password, struct lyd_node **config);
1354
1355/**
Roytak2161df62023-08-02 15:04:42 +02001356 * @brief Deletes a Call Home SSH user's password from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001357 *
Roytak2161df62023-08-02 15:04:42 +02001358 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001359 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1360 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1361 * @param[in,out] config Modified configuration YANG data tree.
1362 * @return 0 on success, non-zero otherwise.
1363 */
Roytakb2794852023-10-18 14:30:22 +02001364int nc_server_config_del_ch_ssh_user_password(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001365 const char *user_name, struct lyd_node **config);
1366
1367/**
romand348b942023-10-13 14:32:19 +02001368 * @brief Creates new YANG configuration data nodes for a Call Home SSH user's none authentication method.
1369 *
1370 * @param[in] ctx libyang context.
1371 * @param[in] client_name Arbitrary identifier of the Call Home client.
1372 * If a Call Home client with this identifier already exists, its contents will be changed.
1373 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1374 * If the client's endpoint with this identifier already exists, its contents will be changed.
1375 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1376 * If the endpoint's user with this identifier already exists, its contents will be changed.
1377 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1378 * Otherwise the new YANG data will be added to the previous data and may override it.
1379 * @return 0 on success, non-zero otherwise.
1380 */
1381int nc_server_config_add_ch_ssh_user_none(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1382 const char *user_name, struct lyd_node **config);
1383
1384/**
1385 * @brief Deletes a Call Home SSH user's none authentication method from the YANG data.
1386 *
1387 * @param[in] client_name Identifier of an existing Call Home client.
1388 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1389 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1390 * @param[in,out] config Modified configuration YANG data tree.
1391 * @return 0 on success, non-zero otherwise.
1392 */
1393int nc_server_config_del_ch_ssh_user_none(const char *client_name, const char *endpt_name,
1394 const char *user_name, struct lyd_node **config);
1395
1396/**
Roytak2161df62023-08-02 15:04:42 +02001397 * @brief Creates new YANG configuration data nodes for a Call Home SSH user's keyboard interactive authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001398 *
1399 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001400 * @param[in] client_name Arbitrary identifier of the Call Home client.
1401 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001402 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1403 * If the client's endpoint with this identifier already exists, its contents will be changed.
1404 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1405 * If the endpoint's user with this identifier already exists, its contents will be changed.
1406 * @param[in] pam_config_name Name of the PAM configuration file.
roman0f5fa422023-08-07 09:03:24 +02001407 * @param[in] pam_config_dir Optional. The absolute path to the directory in which the configuration file
1408 * 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 +02001409 * the path. If NULL is passed, then the PAM's system directories will be searched (usually /etc/pam.d/).
1410 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1411 * Otherwise the new YANG data will be added to the previous data and may override it.
1412 * @return 0 on success, non-zero otherwise.
1413 */
Roytakb2794852023-10-18 14:30:22 +02001414int nc_server_config_add_ch_ssh_user_interactive(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001415 const char *user_name, const char *pam_config_name, const char *pam_config_dir, struct lyd_node **config);
1416
1417/**
Roytak2161df62023-08-02 15:04:42 +02001418 * @brief Deletes a Call Home SSH user's keyboard interactive authentication from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001419 *
Roytak2161df62023-08-02 15:04:42 +02001420 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001421 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1422 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1423 * @param[in,out] config Modified configuration YANG data tree.
1424 * @return 0 on success, non-zero otherwise.
1425 */
Roytakb2794852023-10-18 14:30:22 +02001426int nc_server_config_del_ch_ssh_user_interactive(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001427 const char *user_name, struct lyd_node **config);
1428
1429/**
Roytak2161df62023-08-02 15:04:42 +02001430 * @brief Deletes a Call Home SSH user from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001431 *
Roytak2161df62023-08-02 15:04:42 +02001432 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001433 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1434 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1435 * @param[in,out] config Modified configuration YANG data tree.
1436 * @return 0 on success, non-zero otherwise.
1437 */
Roytakb2794852023-10-18 14:30:22 +02001438int nc_server_config_del_ch_ssh_user(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001439 const char *user_name, struct lyd_node **config);
1440
1441/**
romand348b942023-10-13 14:32:19 +02001442 * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore.
1443 *
1444 * The public key's located in the bag will be used for Call Home SSH client authentication.
1445 *
1446 * @param[in] ctx libyang context.
1447 * @param[in] client_name Arbitrary identifier of the Call Home client.
1448 * If a Call Home client with this identifier already exists, its contents will be changed.
1449 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1450 * If the client's endpoint with this identifier already exists, its contents will be changed.
1451 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1452 * If the endpoint's user with this identifier already exists, its contents will be changed.
1453 * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication.
1454 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1455 * Otherwise the new YANG data will be added to the previous data and may override it.
1456 * @return 0 on success, non-zero otherwise.
1457 */
1458int nc_server_config_add_ch_ssh_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
1459 const char *endpt_name, const char *user_name, const char *truststore_reference, struct lyd_node **config);
1460
1461/**
1462 * @brief Deletes a Call Home SSH truststore reference from the YANG data.
1463 *
1464 * @param[in] client_name Identifier of an existing Call Home client.
1465 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1466 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1467 * @param[in,out] config Modified configuration YANG data tree.
1468 * @return 0 on success, non-zero otherwise.
1469 */
1470int nc_server_config_del_ch_ssh_truststore_ref(const char *client_name, const char *endpt_name,
1471 const char *user_name, struct lyd_node **config);
1472
1473/**
1474 * @brief Creates new YANG configuration data nodes for Call Home host-key algorithms replacing any previous ones.
1475 *
1476 * Supported algorithms are: ssh-ed25519, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521,
1477 * rsa-sha2-512, rsa-sha2-256, ssh-rsa and ssh-dss.
1478 *
1479 * @param[in] ctx libyang context.
1480 * @param[in] client_name Arbitrary identifier of the Call Home client.
1481 * If a Call Home client with this identifier already exists, its contents will be changed.
1482 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1483 * If the client's endpoint with this identifier already exists, its contents will be changed.
1484 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1485 * Otherwise the new YANG data will be added to the previous data and may override it.
1486 * @param[in] alg_count Number of following algorithms.
1487 * @param[in] ... String literals of host-key algorithms in a decreasing order of preference.
1488 * @return 0 on success, non-zero otherwise.
1489 */
1490int nc_server_config_add_ch_ssh_host_key_algs(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1491 struct lyd_node **config, int alg_count, ...);
1492
1493/**
1494 * @brief Deletes a Call Home hostkey algorithm from the YANG data.
1495 *
1496 * @param[in] client_name Identifier of an existing Call Home client.
1497 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1498 * @param[in] alg Optional algorithm to be deleted.
1499 * If NULL, all of the hostkey algorithms on this endpoint will be deleted.
1500 * @param[in,out] config Modified configuration YANG data tree.
1501 * @return 0 on success, non-zero otherwise.
1502 */
1503int nc_server_config_del_ch_ssh_host_key_alg(const char *client_name, const char *endpt_name,
1504 const char *alg, struct lyd_node **config);
1505
1506/**
1507 * @brief Creates new YANG configuration data nodes for Call Home key exchange algorithms replacing any previous ones.
1508 *
1509 * Supported algorithms are: diffie-hellman-group-exchange-sha1, curve25519-sha256, ecdh-sha2-nistp256,
1510 * ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group18-sha512, diffie-hellman-group16-sha512,
1511 * diffie-hellman-group-exchange-sha256 and diffie-hellman-group14-sha256.
1512 *
1513 * @param[in] ctx libyang context.
1514 * @param[in] client_name Arbitrary identifier of the Call Home client.
1515 * If a Call Home client with this identifier already exists, its contents will be changed.
1516 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1517 * If the client's endpoint with this identifier already exists, its contents will be changed.
1518 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1519 * Otherwise the new YANG data will be added to the previous data and may override it.
1520 * @param[in] alg_count Number of following algorithms.
1521 * @param[in] ... String literals of key exchange algorithms in a decreasing order of preference.
1522 * @return 0 on success, non-zero otherwise.
1523 */
1524int nc_server_config_add_ch_ssh_key_exchange_algs(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1525 struct lyd_node **config, int alg_count, ...);
1526
1527/**
1528 * @brief Deletes a Call Home key exchange algorithm from the YANG data.
1529 *
1530 * @param[in] client_name Identifier of an existing Call Home client.
1531 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1532 * @param[in] alg Optional algorithm to be deleted.
1533 * If NULL, all of the key exchange algorithms on this endpoint will be deleted.
1534 * @param[in,out] config Modified configuration YANG data tree.
1535 * @return 0 on success, non-zero otherwise.
1536 */
1537int nc_server_config_del_ch_ssh_key_exchange_alg(const char *client_name, const char *endpt_name,
1538 const char *alg, struct lyd_node **config);
1539
1540/**
1541 * @brief Creates new YANG configuration data nodes for Call Home encryption algorithms replacing any previous ones.
1542 *
1543 * Supported algorithms are: aes256-ctr, aes192-ctr, aes128-ctr, aes256-cbc, aes192-cbc, aes128-cbc, blowfish-cbc
1544 * triple-des-cbc and none.
1545 *
1546 * @param[in] ctx libyang context.
1547 * @param[in] client_name Arbitrary identifier of the Call Home client.
1548 * If a Call Home client with this identifier already exists, its contents will be changed.
1549 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1550 * If the client's endpoint with this identifier already exists, its contents will be changed.
1551 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1552 * Otherwise the new YANG data will be added to the previous data and may override it.
1553 * @param[in] alg_count Number of following algorithms.
1554 * @param[in] ... String literals of encryption algorithms in a decreasing order of preference.
1555 * @return 0 on success, non-zero otherwise.
1556 */
1557int nc_server_config_add_ch_ssh_encryption_algs(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1558 struct lyd_node **config, int alg_count, ...);
1559
1560/**
1561 * @brief Deletes a Call Home encryption algorithm from the YANG data.
1562 *
1563 * @param[in] client_name Identifier of an existing Call Home client.
1564 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1565 * @param[in] alg Optional algorithm to be deleted.
1566 * If NULL, all of the encryption algorithms on this endpoint will be deleted.
1567 * @param[in,out] config Modified configuration YANG data tree.
1568 * @return 0 on success, non-zero otherwise.
1569 */
1570int nc_server_config_del_ch_ssh_encryption_alg(const char *client_name, const char *endpt_name,
1571 const char *alg, struct lyd_node **config);
1572
1573/**
1574 * @brief Creates new YANG configuration data nodes for Call Home mac algorithms replacing any previous ones.
1575 *
1576 * Supported algorithms are: hmac-sha2-256, hmac-sha2-512 and hmac-sha1.
1577 *
1578 * @param[in] ctx libyang context.
1579 * @param[in] client_name Arbitrary identifier of the Call Home client.
1580 * If a Call Home client with this identifier already exists, its contents will be changed.
1581 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1582 * If the client's endpoint with this identifier already exists, its contents will be changed.
1583 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1584 * Otherwise the new YANG data will be added to the previous data and may override it.
1585 * @param[in] alg_count Number of following algorithms.
1586 * @param[in] ... String literals of mac algorithms in a decreasing order of preference.
1587 * @return 0 on success, non-zero otherwise.
1588 */
1589int nc_server_config_add_ch_ssh_mac_algs(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1590 struct lyd_node **config, int alg_count, ...);
1591
1592/**
1593 * @brief Deletes a Call Home mac algorithm from the YANG data.
1594 *
1595 * @param[in] client_name Identifier of an existing Call Home client.
1596 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1597 * @param[in] alg Optional algorithm to be deleted.
1598 * If NULL, all of the mac algorithms on this endpoint will be deleted.
1599 * @param[in,out] config Modified configuration YANG data tree.
1600 * @return 0 on success, non-zero otherwise.
1601 */
1602int nc_server_config_del_ch_ssh_mac_alg(const char *client_name, const char *endpt_name,
1603 const char *alg, struct lyd_node **config);
1604
1605/**
roman35120972023-08-08 10:39:12 +02001606 * @} SSH Call Home Server Configuration
roman142718b2023-06-29 09:15:29 +02001607 */
roman142718b2023-06-29 09:15:29 +02001608
1609/**
Roytak2161df62023-08-02 15:04:42 +02001610 * @defgroup server_config_ch_tls TLS Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001611 * @ingroup server_config_ch
roman142718b2023-06-29 09:15:29 +02001612 *
Roytak2161df62023-08-02 15:04:42 +02001613 * @brief TLS Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +02001614 * @{
roman142718b2023-06-29 09:15:29 +02001615 */
roman142718b2023-06-29 09:15:29 +02001616
romanb6f44032023-06-30 15:07:56 +02001617/**
Roytak2161df62023-08-02 15:04:42 +02001618 * @brief Creates new YANG configuration data nodes for a Call Home server's certificate.
romanb6f44032023-06-30 15:07:56 +02001619 *
1620 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001621 * @param[in] client_name Arbitrary identifier of the Call Home client.
1622 * If a Call Home client with this identifier already exists, its contents will be changed.
1623 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1624 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman6c4efcd2023-08-08 10:18:44 +02001625 * @param[in] privkey_path Path to the server's PEM encoded private key file.
romanb6f44032023-06-30 15:07:56 +02001626 * @param[in] pubkey_path Optional path to the server's public key file. If not provided,
1627 * it will be generated from the private key.
romanb6f44032023-06-30 15:07:56 +02001628 * @param[in] certificate_path Path to the server's certificate file.
Roytak934edc32023-07-27 12:04:18 +02001629 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001630 * Otherwise the new YANG data will be added to the previous data and may override it.
1631 * @return 0 on success, non-zero otherwise.
1632 */
romand348b942023-10-13 14:32:19 +02001633int nc_server_config_add_ch_tls_server_certificate(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman6c4efcd2023-08-08 10:18:44 +02001634 const char *privkey_path, const char *pubkey_path, const char *certificate_path, struct lyd_node **config);
romanb6f44032023-06-30 15:07:56 +02001635
1636/**
Roytak2161df62023-08-02 15:04:42 +02001637 * @brief Deletes a Call Home server certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001638 *
Roytak2161df62023-08-02 15:04:42 +02001639 * @param[in] client_name Identifier of an existing Call Home client.
1640 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman9d5e5a52023-07-14 12:43:44 +02001641 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001642 * @return 0 on success, non-zero otherwise.
1643 */
romand348b942023-10-13 14:32:19 +02001644int nc_server_config_del_ch_tls_server_certificate(const char *client_name, const char *endpt_name,
1645 struct lyd_node **config);
1646
1647/**
1648 * @brief Creates new YANG configuration data nodes for a keystore reference to the Call Home TLS server's certificate.
1649 *
1650 * @param[in] ctx libyang context.
1651 * @param[in] client_name Arbitrary identifier of the Call Home client.
1652 * If a Call Home client with this identifier already exists, its contents will be changed.
1653 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1654 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1655 * @param[in] asym_key_ref Name of the asymmetric key pair in the keystore to be referenced.
1656 * @param[in] cert_ref Name of the certificate, which must belong to the given asymmetric key pair, to be referenced.
1657 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1658 * Otherwise the new YANG data will be added to the previous data and may override it.
1659 * @return 0 on success, non-zero otherwise.
1660 */
1661int nc_server_config_add_ch_tls_keystore_ref(const struct ly_ctx *ctx, const char *client_name,
1662 const char *endpt_name, const char *asym_key_ref, const char *cert_ref, struct lyd_node **config);
1663
1664/**
1665 * @brief Deletes a TLS server certificate keystore reference from the YANG data.
1666 *
1667 * @param[in] client_name Identifier of an existing Call Home client.
1668 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1669 * @param[in,out] config Modified configuration YANG data tree.
1670 * @return 0 on success, non-zero otherwise.
1671 */
1672int nc_server_config_del_ch_tls_keystore_ref(const char *client_name, const char *endpt_name,
Roytak934edc32023-07-27 12:04:18 +02001673 struct lyd_node **config);
1674
1675/**
Roytak2161df62023-08-02 15:04:42 +02001676 * @brief Creates new YANG configuration data nodes for a Call Home client's (end-entity) certificate.
romanb6f44032023-06-30 15:07:56 +02001677 *
1678 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001679 * @param[in] client_name Arbitrary identifier of the Call Home client.
1680 * If a Call Home client with this identifier already exists, its contents will be changed.
1681 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1682 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1683 * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's end-entity certificate.
1684 * 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 +02001685 * @param[in] cert_path Path to the certificate file.
Roytak934edc32023-07-27 12:04:18 +02001686 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001687 * Otherwise the new YANG data will be added to the previous data and may override it.
1688 * @return 0 on success, non-zero otherwise.
1689 */
romand348b942023-10-13 14:32:19 +02001690int nc_server_config_add_ch_tls_client_certificate(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
romanb6f44032023-06-30 15:07:56 +02001691 const char *cert_name, const char *cert_path, struct lyd_node **config);
1692
1693/**
Roytak2161df62023-08-02 15:04:42 +02001694 * @brief Deletes a Call Home client (end-entity) certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001695 *
Roytak2161df62023-08-02 15:04:42 +02001696 * @param[in] client_name Identifier of an existing Call Home client.
1697 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman8ba6efa2023-07-12 15:27:52 +02001698 * @param[in] cert_name Optional identifier of a client certificate to be deleted.
1699 * If NULL, all of the client certificates will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001700 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001701 * @return 0 on success, non-zero otherwise.
1702 */
romand348b942023-10-13 14:32:19 +02001703int nc_server_config_del_ch_tls_client_certificate(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001704 const char *cert_name, struct lyd_node **config);
1705
1706/**
romand348b942023-10-13 14:32:19 +02001707 * @brief Creates new YANG configuration data nodes for a Call Home truststore reference to a set of client (end-entity) certificates.
1708 *
1709 * @param[in] ctx libyang context.
1710 * @param[in] client_name Arbitrary identifier of the Call Home client.
1711 * If a Call Home client with this identifier already exists, its contents will be changed.
1712 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1713 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1714 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
1715 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1716 * Otherwise the new YANG data will be added to the previous data and may override it.
1717 * @return 0 on success, non-zero otherwise.
1718 */
1719int nc_server_config_add_ch_tls_client_cert_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
1720 const char *endpt_name, const char *cert_bag_ref, struct lyd_node **config);
1721
1722/**
1723 * @brief Deletes a Call Home client (end-entity) certificates truststore reference from the YANG data.
1724 *
1725 * @param[in] client_name Identifier of an existing Call Home client.
1726 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1727 * @param[in,out] config Modified configuration YANG data tree.
1728 * @return 0 on success, non-zero otherwise.
1729 */
1730int nc_server_config_del_ch_tls_client_cert_truststore_ref(const char *client_name, const char *endpt_name,
1731 struct lyd_node **config);
1732
1733/**
romanb6f44032023-06-30 15:07:56 +02001734 * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate.
1735 *
1736 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001737 * @param[in] client_name Arbitrary identifier of the Call Home client.
1738 * If a Call Home client with this identifier already exists, its contents will be changed.
1739 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1740 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1741 * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's certificate authority certificate.
1742 * If an Call Home endpoint's CA certificate with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001743 * @param[in] cert_path Path to the certificate file.
Roytak9b32c0f2023-08-02 15:07:29 +02001744 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001745 * Otherwise the new YANG data will be added to the previous data and may override it.
1746 * @return 0 on success, non-zero otherwise.
1747 */
romand348b942023-10-13 14:32:19 +02001748int nc_server_config_add_ch_tls_client_ca(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
romanb6f44032023-06-30 15:07:56 +02001749 const char *cert_name, const char *cert_path, struct lyd_node **config);
1750
1751/**
Roytak2161df62023-08-02 15:04:42 +02001752 * @brief Deletes a Call Home client certificate authority (trust-anchor) certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001753 *
Roytak2161df62023-08-02 15:04:42 +02001754 * @param[in] client_name Identifier of an existing Call Home client.
1755 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman8ba6efa2023-07-12 15:27:52 +02001756 * @param[in] cert_name Optional identifier of a CA certificate to be deleted.
1757 * If NULL, all of the CA certificates will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001758 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001759 * @return 0 on success, non-zero otherwise.
1760 */
romand348b942023-10-13 14:32:19 +02001761int nc_server_config_del_ch_tls_client_ca(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001762 const char *cert_name, struct lyd_node **config);
1763
1764/**
romand348b942023-10-13 14:32:19 +02001765 * @brief Creates new YANG configuration data nodes for a Call Home truststore reference to a set of client certificate authority (trust-anchor) certificates.
1766 *
1767 * @param[in] ctx libyang context.
1768 * @param[in] client_name Arbitrary identifier of the Call Home client.
1769 * If a Call Home client with this identifier already exists, its contents will be changed.
1770 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1771 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1772 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
1773 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1774 * Otherwise the new YANG data will be added to the previous data and may override it.
1775 * @return 0 on success, non-zero otherwise.
1776 */
1777int nc_server_config_add_ch_tls_client_ca_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
1778 const char *endpt_name, const char *cert_bag_ref, struct lyd_node **config);
1779
1780/**
1781 * @brief Deletes a Call Home client certificate authority (trust-anchor) certificates truststore reference from the YANG data.
1782 *
1783 * @param[in] client_name Identifier of an existing Call Home client.
1784 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1785 * @param[in,out] config Modified configuration YANG data tree.
1786 * @return 0 on success, non-zero otherwise.
1787 */
1788int nc_server_config_del_ch_tls_client_ca_truststore_ref(const char *client_name, const char *endpt_name,
1789 struct lyd_node **config);
1790
1791/**
Roytak2161df62023-08-02 15:04:42 +02001792 * @brief Creates new YANG configuration data nodes for a Call Home cert-to-name entry.
romanb6f44032023-06-30 15:07:56 +02001793 *
1794 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001795 * @param[in] client_name Arbitrary identifier of the Call Home client.
1796 * If a Call Home client with this identifier already exists, its contents will be changed.
1797 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1798 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001799 * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier).
1800 * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is
1801 * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry.
1802 * @param[in] map_type Mapping username to the certificate option.
1803 * @param[in] name Username for this cert-to-name entry.
Roytak9b32c0f2023-08-02 15:07:29 +02001804 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001805 * Otherwise the new YANG data will be added to the previous data and may override it.
1806 * @return 0 on success, non-zero otherwise.
1807 */
Roytakb2794852023-10-18 14:30:22 +02001808int nc_server_config_add_ch_tls_ctn(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
romanb6f44032023-06-30 15:07:56 +02001809 uint32_t id, const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config);
1810
roman8ba6efa2023-07-12 15:27:52 +02001811/**
Roytak2161df62023-08-02 15:04:42 +02001812 * @brief Deletes a Call Home cert-to-name entry from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001813 *
Roytak2161df62023-08-02 15:04:42 +02001814 * @param[in] client_name Identifier of an existing Call Home client.
1815 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1816 * @param[in] id Optional identifier of the Call Home CTN entry to be deleted.
roman8ba6efa2023-07-12 15:27:52 +02001817 * If 0, all of the CTN entries will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001818 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001819 * @return 0 on success, non-zero otherwise.
1820 */
Roytakb2794852023-10-18 14:30:22 +02001821int nc_server_config_del_ch_tls_ctn(const char *client_name, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +02001822 uint32_t id, struct lyd_node **config);
1823
1824/**
romand348b942023-10-13 14:32:19 +02001825 * @brief Creates new YANG configuration data nodes for a Call Home TLS version.
1826 *
1827 * @param[in] ctx libyang context.
1828 * @param[in] client_name Arbitrary identifier of the Call Home client.
1829 * If a Call Home client with this identifier already exists, its contents will be changed.
1830 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1831 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1832 * @param[in] tls_version TLS version to be used. Call this multiple times to set the accepted versions
1833 * of the TLS protocol and let the client and server negotiate the given version.
1834 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1835 * Otherwise the new YANG data will be added to the previous data and may override it.
1836 * @return 0 on success, non-zero otherwise.
1837 */
1838int nc_server_config_add_ch_tls_version(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1839 NC_TLS_VERSION tls_version, struct lyd_node **config);
1840
1841/**
1842 * @brief Deletes a TLS version from the YANG data.
1843 *
1844 * @param[in] client_name Identifier of an existing Call Home client.
1845 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1846 * @param[in] tls_version TLS version to be deleted.
1847 * @param[in,out] config Modified configuration YANG data tree.
1848 * @return 0 on success, non-zero otherwise.
1849 */
1850int nc_server_config_del_ch_tls_version(const char *client_name, const char *endpt_name,
1851 NC_TLS_VERSION tls_version, struct lyd_node **config);
1852
1853/**
1854 * @brief Creates new YANG configuration data nodes for a Call Home TLS cipher.
1855 *
1856 * @param[in] ctx libyang context.
1857 * @param[in] client_name Arbitrary identifier of the Call Home client.
1858 * If a Call Home client with this identifier already exists, its contents will be changed.
1859 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1860 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1861 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1862 * Otherwise the new YANG data will be added to the previous data and may override it.
1863 * @param[in] cipher_count Number of following ciphers.
1864 * @param[in] ... TLS ciphers. These ciphers MUST be in the format as listed in the
1865 * iana-tls-cipher-suite-algs YANG model (lowercase and separated by dashes). Regardless
1866 * of the TLS protocol version used, all of these ciphers will be tried and some of them
1867 * might not be set (TLS handshake might fail then). For the list of supported ciphers see
1868 * the OpenSSL documentation.
1869 * @return 0 on success, non-zero otherwise.
1870 */
1871int nc_server_config_add_ch_tls_ciphers(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1872 struct lyd_node **config, int cipher_count, ...);
1873
1874/**
1875 * @brief Deletes a Call Home TLS cipher from the YANG data.
1876 *
1877 * @param[in] client_name Identifier of an existing Call Home client.
1878 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1879 * @param[in] cipher TLS cipher to be deleted.
1880 * @param[in,out] config Modified configuration YANG data tree.
1881 * @return 0 on success, non-zero otherwise.
1882 */
1883int nc_server_config_del_ch_tls_cipher(const char *client_name, const char *endpt_name,
1884 const char *cipher, struct lyd_node **config);
1885
1886/**
1887 * @brief Creates new YANG configuration data nodes for a Call Home Certificate Revocation List via a local file.
1888 *
1889 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
1890 * this function will remove any CRL YANG nodes created by the other two functions.
1891 *
1892 * @param[in] ctx libyang context.
1893 * @param[in] client_name Arbitrary identifier of the Call Home client.
1894 * If a Call Home client with this identifier already exists, its contents will be changed.
1895 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1896 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1897 * @param[in] crl_path Path to a DER/PEM encoded CRL file.
1898 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1899 * Otherwise the new YANG data will be added to the previous data and may override it.
1900 * @return 0 on success, non-zero otherwise.
1901 */
1902int nc_server_config_add_ch_tls_crl_path(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1903 const char *crl_path, struct lyd_node **config);
1904
1905/**
1906 * @brief Creates new YANG configuration data nodes for a Call Home Certificate Revocation List via an URL.
1907 *
1908 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
1909 * this function will remove any CRL YANG nodes created by the other two functions.
1910 *
1911 * @param[in] ctx libyang context.
1912 * @param[in] client_name Arbitrary identifier of the Call Home client.
1913 * If a Call Home client with this identifier already exists, its contents will be changed.
1914 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1915 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1916 * @param[in] crl_url URL from which the CRL file will be downloaded. The file has to be in the DER or PEM format.
1917 * The allowed protocols are all the protocols supported by CURL.
1918 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1919 * Otherwise the new YANG data will be added to the previous data and may override it.
1920 * @return 0 on success, non-zero otherwise.
1921 */
1922int nc_server_config_add_ch_tls_crl_url(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1923 const char *crl_url, struct lyd_node **config);
1924
1925/**
1926 * @brief Creates new YANG configuration data nodes for a Call Home Certificate Revocation List via certificate extensions.
1927 *
1928 * The chain of configured Certificate Authorities will be examined. For each certificate in this chain all the
1929 * CRLs from the URLs specified in their extension fields CRL Distribution Points will be downloaded and used.
1930 *
1931 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
1932 * this function will remove any CRL YANG nodes created by the other two functions.
1933 *
1934 * @param[in] ctx libyang context.
1935 * @param[in] client_name Arbitrary identifier of the Call Home client.
1936 * If a Call Home client with this identifier already exists, its contents will be changed.
1937 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1938 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1939 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1940 * Otherwise the new YANG data will be added to the previous data and may override it.
1941 * @return 0 on success, non-zero otherwise.
1942 */
1943int nc_server_config_add_ch_tls_crl_cert_ext(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1944 struct lyd_node **config);
1945
1946/**
1947 * @brief Deletes all the CRL nodes from the YANG data.
1948 *
1949 * @param[in] client_name Identifier of an existing Call Home client.
1950 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1951 * @param[in,out] config Modified configuration YANG data tree.
1952 * @return 0 on success, non-zero otherwise.
1953 */
1954int nc_server_config_del_ch_tls_crl(const char *client_name, const char *endpt_name, struct lyd_node **config);
1955
1956/**
roman35120972023-08-08 10:39:12 +02001957 * @} TLS Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001958 */
1959
roman2eab4742023-06-06 10:00:26 +02001960#endif /* NC_ENABLED_SSH_TLS */
roman45cec4e2023-02-17 10:21:39 +01001961
romanc1d2b092023-02-02 08:58:27 +01001962#ifdef __cplusplus
1963}
1964#endif
1965
1966#endif /* NC_SESSION_SERVER_H_ */