blob: bf1275709aaf65fc0c674cf3272628681fa7fe0c [file] [log] [blame]
romanc1d2b092023-02-02 08:58:27 +01001/**
romane028ef92023-02-24 16:33:08 +01002 * @file server_config.h
romanc1d2b092023-02-02 08:58:27 +01003 * @author Roman Janota <janota@cesnet.cz>
4 * @brief libnetconf2 server configuration
5 *
6 * @copyright
roman3f9b65c2023-06-05 14:26:58 +02007 * Copyright (c) 2023 CESNET, z.s.p.o.
romanc1d2b092023-02-02 08:58:27 +01008 *
9 * This source code is licensed under BSD 3-Clause License (the "License").
10 * You may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * https://opensource.org/licenses/BSD-3-Clause
14 */
15
16#ifndef NC_CONFIG_SERVER_H_
17#define NC_CONFIG_SERVER_H_
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
roman3f9b65c2023-06-05 14:26:58 +020023#include <stdarg.h>
romanc1d2b092023-02-02 08:58:27 +010024#include <stdint.h>
25
roman3f9b65c2023-06-05 14:26:58 +020026#include <libyang/libyang.h>
27
romanc1d2b092023-02-02 08:58:27 +010028#include "session.h"
romanc1d2b092023-02-02 08:58:27 +010029
30/**
roman8ba6efa2023-07-12 15:27:52 +020031 * @defgroup server_config Server Configuration
32 * @ingroup server
33 *
34 * @brief Server-side configuration creation and application
35 * @{
36 */
37
38/**
roman35120972023-08-08 10:39:12 +020039 * @} Server Configuration
40 */
41
42/**
43 * @defgroup server_config_functions Server Configuration Functions
44 * @ingroup server_config
45 *
46 * @brief Server-side configuration functions
47 * @{
48 */
49
50/**
51 * @brief Implements all the required modules and their features in the context.
52 * Needs to be called before any other configuration functions.
53 *
54 * If ctx is :
55 * - NULL: a new context will be created and if the call is successful you have to free it,
56 * - non NULL: modules will simply be implemented.
57 *
58 * Implemented modules: ietf-netconf-server, ietf-x509-cert-to-name, ietf-crypto-types,
59 * ietf-tcp-common, ietf-ssh-common, iana-ssh-encryption-algs, iana-ssh-key-exchange-algs,
60 * iana-ssh-mac-algs, iana-ssh-public-key-algs, ietf-keystore, ietf-ssh-server, ietf-truststore,
61 * ietf-tls-server and libnetconf2-netconf-server.
62 *
63 * @param[in, out] ctx Optional context in which the modules will be implemented. Created if ctx is null.
64 * @return 0 on success, 1 on error.
65 */
66int nc_server_config_load_modules(struct ly_ctx **ctx);
67
68/**
romanf02273a2023-05-25 09:44:11 +020069 * @brief Configure server based on the given diff data.
romanc1d2b092023-02-02 08:58:27 +010070 *
romanf6f37a52023-05-25 14:27:51 +020071 * Expected data are a validated instance of a ietf-netconf-server YANG data.
romanc1d2b092023-02-02 08:58:27 +010072 * The data must be in the diff format and supported operations are: create, replace,
73 * delete and none. Context must already have implemented the required modules, see
roman0f5fa422023-08-07 09:03:24 +020074 * ::nc_server_config_load_modules().
romanc1d2b092023-02-02 08:58:27 +010075 *
romanf6f37a52023-05-25 14:27:51 +020076 * @param[in] diff ietf-netconf-server YANG diff data.
romanc1d2b092023-02-02 08:58:27 +010077 * @return 0 on success, 1 on error.
78 */
romanf6f37a52023-05-25 14:27:51 +020079int nc_server_config_setup_diff(const struct lyd_node *diff);
romanc1d2b092023-02-02 08:58:27 +010080
81/**
romanf02273a2023-05-25 09:44:11 +020082 * @brief Configure server based on the given data.
83 *
84 * Expected data is a validated instance of a ietf-netconf-server YANG data.
85 * Behaves as if all the nodes in data had the replace operation. That means that the current configuration will be deleted
86 * and just the given data will all be applied.
roman0f5fa422023-08-07 09:03:24 +020087 * The data must not contain any operation attribute, see ::nc_server_config_setup_diff() which works with diff.
88 * Context must already have implemented the required modules, see ::nc_server_config_load_modules().
romanf02273a2023-05-25 09:44:11 +020089 *
90 * @param[in] data ietf-netconf-server YANG data.
91 * @return 0 on success, 1 on error.
92 */
romanf6f37a52023-05-25 14:27:51 +020093int nc_server_config_setup_data(const struct lyd_node *data);
romanf02273a2023-05-25 09:44:11 +020094
95/**
roman35120972023-08-08 10:39:12 +020096 * @brief Configure server based on the given ietf-netconf-server YANG data from a file.
roman0f5fa422023-08-07 09:03:24 +020097 * Wrapper around ::nc_server_config_setup_data() hiding work with parsing the data.
romanc1d2b092023-02-02 08:58:27 +010098 *
99 * @param[in] ctx libyang context.
roman35120972023-08-08 10:39:12 +0200100 * @param[in] path Path to the file with ietf-netconf-server YANG data.
romanc1d2b092023-02-02 08:58:27 +0100101 * @return 0 on success, 1 on error.
102 */
103int nc_server_config_setup_path(const struct ly_ctx *ctx, const char *path);
104
roman2eab4742023-06-06 10:00:26 +0200105#ifdef NC_ENABLED_SSH_TLS
106
romanc1d2b092023-02-02 08:58:27 +0100107/**
roman35120972023-08-08 10:39:12 +0200108 * @brief Creates new YANG configuration data nodes for local-address and local-port.
roman9b1379c2023-03-31 10:11:10 +0200109 *
roman9b1379c2023-03-31 10:11:10 +0200110 * @param[in] ctx libyang context.
111 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman35120972023-08-08 10:39:12 +0200112 * If an endpoint with this identifier already exists, its contents might be changed.
roman3f9b65c2023-06-05 14:26:58 +0200113 * @param[in] transport Either SSH or TLS transport for the given endpoint.
114 * @param[in] address New listening address.
115 * @param[in] port New listening port.
roman9b1379c2023-03-31 10:11:10 +0200116 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
117 * Otherwise the new YANG data will be added to the previous data and may override it.
118 * @return 0 on success, non-zero otherwise.
roman45cec4e2023-02-17 10:21:39 +0100119 */
roman3f9b65c2023-06-05 14:26:58 +0200120int nc_server_config_new_address_port(const struct ly_ctx *ctx, const char *endpt_name, NC_TRANSPORT_IMPL transport,
roman142718b2023-06-29 09:15:29 +0200121 const char *address, uint16_t port, struct lyd_node **config);
roman3f9b65c2023-06-05 14:26:58 +0200122
roman8ba6efa2023-07-12 15:27:52 +0200123#endif /* NC_ENABLED_SSH_TLS */
124
125/**
126 * @brief Deletes an endpoint from the YANG data.
127 *
128 * @param[in] endpt_name Optional identifier of an endpoint to be deleted.
129 * If NULL, all of the endpoints will be deleted.
roman35120972023-08-08 10:39:12 +0200130 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200131 * @return 0 on success, non-zero otherwise.
132 */
133int nc_server_config_new_del_endpt(const char *endpt_name, struct lyd_node **config);
134
135#ifdef NC_ENABLED_SSH_TLS
136
137/**
138 * @brief Creates new YANG data nodes for an asymmetric key in the keystore.
139 *
140 * @param[in] ctx libyang context.
roman13145912023-08-17 15:36:54 +0200141 * @param[in] ti Transport in which the key pair will be used. Either SSH or TLS.
roman12c3d522023-07-26 13:39:30 +0200142 * @param[in] asym_key_name Identifier of the asymmetric key pair.
143 * This identifier is used to reference the key pair.
roman8ba6efa2023-07-12 15:27:52 +0200144 * @param[in] privkey_path Path to a private key file.
145 * @param[in] pubkey_path Optional path a public key file.
146 * If not supplied, it will be generated from the private key.
147 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
148 * Otherwise the new YANG data will be added to the previous data and may override it.
149 * @return 0 on success, non-zero otherwise.
150 */
roman13145912023-08-17 15:36:54 +0200151int nc_server_config_new_keystore_asym_key(const struct ly_ctx *ctx, NC_TRANSPORT_IMPL ti, const char *asym_key_name,
152 const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200153
154/**
155 * @brief Deletes a keystore's asymmetric key from the YANG data.
156 *
roman12c3d522023-07-26 13:39:30 +0200157 * @param[in] asym_key_name Optional identifier of the asymmetric key to be deleted.
roman8ba6efa2023-07-12 15:27:52 +0200158 * If NULL, all of the asymmetric keys in the keystore will be deleted.
159 * @param[in,out] config Configuration YANG data tree.
160 * @return 0 on success, non-zero otherwise.
161 */
roman12c3d522023-07-26 13:39:30 +0200162int nc_server_config_new_del_keystore_asym_key(const char *asym_key_name, struct lyd_node **config);
163
164/**
165 * @brief Creates new YANG data nodes for a certificate in the keystore.
166 *
167 * A certificate can not exist without its asymmetric key, so you must call ::nc_server_config_new_keystore_asym_key()
168 * either before or after calling this with the same identifier for the asymmetric key.
169 *
170 * An asymmetric key pair can have zero or more certificates associated with this key pair, however a certificate must
171 * have exactly one key pair it belongs to.
172 *
173 * @param[in] ctx libyang context.
174 * @param[in] asym_key_name Arbitrary identifier of the asymmetric key.
175 * If an asymmetric key pair with this name already exists, its contents will be changed.
176 * @param[in] cert_name Arbitrary identifier of the key pair's certificate.
177 * If a certificate with this name already exists, its contents will be changed.
178 * @param[in] cert_path Path to the PEM encoded certificate file.
179 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
180 * Otherwise the new YANG data will be added to the previous data and may override it.
181 * @return 0 on success, non-zero otherwise.
182 */
183int nc_server_config_new_keystore_cert(const struct ly_ctx *ctx, const char *asym_key_name, const char *cert_name,
184 const char *cert_path, struct lyd_node **config);
185
186/**
187 * @brief Deletes a keystore's certificate from the YANG data.
188 *
189 * @param[in] asym_key_name Identifier of an existing asymmetric key pair.
190 * @param[in] cert_name Optional identifier of a certificate to be deleted.
191 * If NULL, all of the certificates belonging to the asymmetric key pair will be deleted.
192 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
193 * Otherwise the new YANG data will be added to the previous data and may override it.
194 * @return 0 on success, non-zero otherwise.
195 */
196int nc_server_config_new_del_keystore_cert(const char *asym_key_name, const char *cert_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200197
198/**
199 * @brief Creates new YANG data nodes for a public key in the truststore.
200 *
201 * @param[in] ctx libyang context.
roman12c3d522023-07-26 13:39:30 +0200202 * @param[in] pub_bag_name Arbitrary identifier of the public key bag.
roman8ba6efa2023-07-12 15:27:52 +0200203 * This name is used to reference the public keys in the bag.
204 * If a public key bag with this name already exists, its contents will be changed.
205 * @param[in] pubkey_name Arbitrary identifier of the public key.
roman12c3d522023-07-26 13:39:30 +0200206 * If a public key with this name already exists in the given bag, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200207 * @param[in] pubkey_path Path to a file containing a public key.
208 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
209 * Otherwise the new YANG data will be added to the previous data and may override it.
210 * @return 0 on success, non-zero otherwise.
211 */
roman12c3d522023-07-26 13:39:30 +0200212int nc_server_config_new_truststore_pubkey(const struct ly_ctx *ctx, const char *pub_bag_name, const char *pubkey_name,
roman8ba6efa2023-07-12 15:27:52 +0200213 const char *pubkey_path, struct lyd_node **config);
214
215/**
216 * @brief Deletes a truststore's public key from the YANG data.
217 *
roman12c3d522023-07-26 13:39:30 +0200218 * @param[in] pub_bag_name Identifier of an existing public key bag.
roman8ba6efa2023-07-12 15:27:52 +0200219 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
220 * If NULL, all of the public keys in the given bag will be deleted.
221 * @param[in,out] config Configuration YANG data tree.
222 * @return 0 on success, non-zero otherwise.
223 */
roman12c3d522023-07-26 13:39:30 +0200224int nc_server_config_new_del_truststore_pubkey(const char *pub_bag_name, const char *pubkey_name, struct lyd_node **config);
225
226/**
227 * @brief Creates new YANG data nodes for a certificate in the truststore.
228 *
229 * @param[in] ctx libyang context.
230 * @param[in] cert_bag_name Arbitrary identifier of the certificate bag.
231 * This name is used to reference the certificates in the bag.
232 * If a certificate bag with this name already exists, its contents will be changed.
233 * @param[in] cert_name Arbitrary identifier of the certificate.
234 * If a certificate with this name already exists in the given bag, its contents will be changed.
235 * @param[in] cert_path Path to a file containing a PEM encoded certificate.
236 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
237 * Otherwise the new YANG data will be added to the previous data and may override it.
238 * @return 0 on success, non-zero otherwise.
239 */
240int nc_server_config_new_truststore_cert(const struct ly_ctx *ctx, const char *cert_bag_name, const char *cert_name,
241 const char *cert_path, struct lyd_node **config);
242
243/**
244 * @brief Deletes a truststore's certificate from the YANG data.
245 *
246 * @param[in] cert_bag_name Identifier of an existing certificate bag.
247 * @param[in] cert_name Optional identifier of a certificate to be deleted.
248 * If NULL, all of the certificates in the given bag will be deleted.
249 * @param[in,out] config Configuration YANG data tree.
250 * @return 0 on success, non-zero otherwise.
251 */
252int nc_server_config_new_del_truststore_cert(const char *cert_bag_name,
253 const char *cert_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200254
255/**
roman35120972023-08-08 10:39:12 +0200256 * @} Server Configuration Functions
roman8ba6efa2023-07-12 15:27:52 +0200257 */
258
259/**
260 * @defgroup server_config_ssh SSH Server Configuration
261 * @ingroup server_config
262 *
263 * @brief SSH server configuration creation and deletion
264 * @{
265 */
266
roman3f9b65c2023-06-05 14:26:58 +0200267/**
268 * @brief Creates new YANG configuration data nodes for a hostkey.
269 *
270 * @param[in] ctx libyang context.
271 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200272 * If an endpoint with this identifier already exists, its hostkey might be changed.
roman3f9b65c2023-06-05 14:26:58 +0200273 * @param[in] hostkey_name Arbitrary identifier of the hostkey.
roman142718b2023-06-29 09:15:29 +0200274 * If a hostkey with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200275 * @param[in] privkey_path Path to a file containing a private key.
276 * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
roman35120972023-08-08 10:39:12 +0200277 * @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 +0200278 * generated from the private key.
279 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
280 * Otherwise the new YANG data will be added to the previous data and may override it.
281 * @return 0 on success, non-zero otherwise.
282 */
roman8ba6efa2023-07-12 15:27:52 +0200283int nc_server_config_new_ssh_hostkey(const struct ly_ctx *ctx, const char *endpt_name, const char *hostkey_name,
284 const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
285
286/**
287 * @brief Deletes a hostkey from the YANG data.
288 *
289 * @param[in] ctx libyang context.
290 * @param[in] endpt_name Identifier of an existing endpoint.
291 * @param[in] hostkey_name Optional identifier of the hostkey to be deleted.
292 * If NULL, all of the hostkeys on this endpoint will be deleted.
293 * @param[in,out] config Configuration YANG data tree.
294 * @return 0 on success, non-zero otherwise.
295 */
296int nc_server_config_new_ssh_del_hostkey(const struct ly_ctx *ctx, const char *endpt_name,
297 const char *hostkey_name, struct lyd_node **config);
298
299/**
300 * @brief Creates new YANG data nodes for a reference to an asymmetric key located in the keystore.
301 *
302 * This asymmetric key pair will be used as the SSH hostkey.
303 *
304 * @param[in] ctx libyang context.
305 * @param[in] endpt_name Arbitrary identifier of an endpoint.
306 * If an endpoint with this identifier already exists, its contents will be changed.
307 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
308 * If an endpoint's hostkey with this identifier already exists, its contents will be changed.
309 * @param[in] keystore_reference Name of the asymmetric key pair to be referenced and used as a hostkey.
310 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
311 * Otherwise the new YANG data will be added to the previous data and may override it.
312 * @return 0 on success, non-zero otherwise.
313 */
roman67af8982023-08-08 10:56:04 +0200314int nc_server_config_new_ssh_keystore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *hostkey_name,
roman8ba6efa2023-07-12 15:27:52 +0200315 const char *keystore_reference, struct lyd_node **config);
316
317/**
318 * @brief Deletes a keystore reference from the YANG data.
319 *
320 * @param[in] endpt_name Identifier of an existing endpoint.
321 * @param[in] hostkey_name Identifier of an existing hostkey on the given endpoint.
322 * @param[in,out] config Configuration YANG data tree.
323 * @return 0 on success, non-zero otherwise.
324 */
roman67af8982023-08-08 10:56:04 +0200325int nc_server_config_new_ssh_del_keystore_ref(const char *endpt_name, const char *hostkey_name,
roman8ba6efa2023-07-12 15:27:52 +0200326 struct lyd_node **config);
327
328/**
roman68404fd2023-07-24 10:40:59 +0200329 * @brief Creates new YANG configuration data nodes for the maximum amount of failed SSH authentication attempts.
330 *
331 * @param[in] ctx libyang context.
332 * @param[in] endpt_name Arbitrary identifier of the endpoint.
333 * If an endpoint with this identifier already exists, its contents might be changed.
334 * @param[in] auth_attempts Maximum amount of failed SSH authentication attempts after which a
335 * client is disconnected. The default value is 3.
336 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
337 * Otherwise the new YANG data will be added to the previous data and may override it.
338 * @return 0 on success, non-zero otherwise.
339 */
340int nc_server_config_new_ssh_auth_attempts(const struct ly_ctx *ctx, const char *endpt_name, uint16_t auth_attempts,
341 struct lyd_node **config);
342
343/**
344 * @brief Creates new YANG configuration data nodes for an SSH authentication timeout.
345 *
346 * @param[in] ctx libyang context.
347 * @param[in] endpt_name Arbitrary identifier of the endpoint.
348 * If an endpoint with this identifier already exists, its contents might be changed.
349 * @param[in] auth_timeout Maximum amount of time in seconds after which the authentication is deemed
350 * unsuccessful. The default value is 10.
351 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
352 * Otherwise the new YANG data will be added to the previous data and may override it.
353 * @return 0 on success, non-zero otherwise.
354 */
355int nc_server_config_new_ssh_auth_timeout(const struct ly_ctx *ctx, const char *endpt_name, uint16_t auth_timeout,
356 struct lyd_node **config);
357
358/**
roman8ba6efa2023-07-12 15:27:52 +0200359 * @brief Creates new YANG configuration data nodes for an SSH user's public key authentication method.
360 *
361 * @param[in] ctx libyang context.
362 * @param[in] endpt_name Arbitrary identifier of the endpoint.
363 * If an endpoint with this identifier already exists, its user might be changed.
364 * @param[in] user_name Arbitrary identifier of the user.
365 * If an user with this identifier already exists, its contents will be changed.
366 * @param[in] pubkey_name Arbitrary identifier of the user's public key.
367 * If a public key with this identifier already exists for this user, its contents will be changed.
368 * @param[in] pubkey_path Path to a file containing the user's public key.
369 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
370 * Otherwise the new YANG data will be added to the previous data and may override it.
371 * @return 0 on success, non-zero otherwise.
372 */
373int nc_server_config_new_ssh_user_pubkey(const struct ly_ctx *ctx, const char *endpt_name,
374 const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config);
375
376/**
377 * @brief Deletes an SSH user's public key from the YANG data.
378 *
379 * @param[in] endpt_name Identifier of an existing endpoint.
380 * @param[in] user_name Identifier of an existing user on the given endpoint.
381 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
382 * If NULL, all of the users public keys will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200383 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200384 * @return 0 on success, non-zero otherwise.
385 */
386int nc_server_config_new_ssh_del_user_pubkey(const char *endpt_name, const char *user_name,
387 const char *pubkey_name, struct lyd_node **config);
388
389/**
390 * @brief Creates new YANG configuration data nodes for an SSH user's password authentication method.
391 *
392 * @param[in] ctx libyang context.
393 * @param[in] endpt_name Arbitrary identifier of the endpoint.
394 * If an endpoint with this identifier already exists, its user might be changed.
395 * @param[in] user_name Arbitrary identifier of the user.
396 * If an user with this identifier already exists, its contents will be changed.
roman35120972023-08-08 10:39:12 +0200397 * @param[in] password Clear-text password to be set for the user. It will be hashed.
roman8ba6efa2023-07-12 15:27:52 +0200398 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
399 * Otherwise the new YANG data will be added to the previous data and may override it.
400 * @return 0 on success, non-zero otherwise.
401 */
402int nc_server_config_new_ssh_user_password(const struct ly_ctx *ctx, const char *endpt_name,
403 const char *user_name, const char *password, struct lyd_node **config);
404
405/**
406 * @brief Deletes an SSH user's password from the YANG data.
407 *
408 * @param[in] endpt_name Identifier of an existing endpoint.
409 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200410 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200411 * @return 0 on success, non-zero otherwise.
412 */
413int nc_server_config_new_ssh_del_user_password(const char *endpt_name, const char *user_name,
414 struct lyd_node **config);
415
416/**
417 * @brief Creates new YANG configuration data nodes for an SSH user's none authentication method.
418 *
419 * @param[in] ctx libyang context.
420 * @param[in] endpt_name Arbitrary identifier of the endpoint.
421 * If an endpoint with this identifier already exists, its user might be changed.
422 * @param[in] user_name Arbitrary identifier of the user.
423 * If an user with this identifier already exists, its contents will be changed.
424 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
425 * Otherwise the new YANG data will be added to the previous data and may override it.
426 * @return 0 on success, non-zero otherwise.
427 */
428int nc_server_config_new_ssh_user_none(const struct ly_ctx *ctx, const char *endpt_name,
429 const char *user_name, struct lyd_node **config);
430
431/**
432 * @brief Deletes an SSH user's none authentication method from the YANG data.
433 *
434 * @param[in] endpt_name Identifier of an existing endpoint.
435 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200436 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200437 * @return 0 on success, non-zero otherwise.
438 */
439int nc_server_config_new_ssh_del_user_none(const char *endpt_name, const char *user_name,
440 struct lyd_node **config);
441
442/**
443 * @brief Creates new YANG configuration data nodes for an SSH user's keyboard interactive authentication method.
444 *
445 * @param[in] ctx libyang context.
446 * @param[in] endpt_name Arbitrary identifier of the endpoint.
447 * If an endpoint with this identifier already exists, its user might be changed.
448 * @param[in] user_name Arbitrary identifier of the user.
449 * If an user with this identifier already exists, its contents will be changed.
450 * @param[in] pam_config_name Name of the PAM configuration file.
roman0f5fa422023-08-07 09:03:24 +0200451 * @param[in] pam_config_dir Optional. The absolute path to the directory in which the configuration file
452 * 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 +0200453 * the path. If NULL is passed, then the PAM's system directories will be searched (usually /etc/pam.d/).
454 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
455 * Otherwise the new YANG data will be added to the previous data and may override it.
456 * @return 0 on success, non-zero otherwise.
457 */
458int nc_server_config_new_ssh_user_interactive(const struct ly_ctx *ctx, const char *endpt_name,
459 const char *user_name, const char *pam_config_name, const char *pam_config_dir, struct lyd_node **config);
460
461/**
462 * @brief Deletes an SSH user's keyboard interactive authentication from the YANG data.
463 *
464 * @param[in] endpt_name Identifier of an existing endpoint.
465 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200466 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200467 * @return 0 on success, non-zero otherwise.
468 */
469int nc_server_config_new_ssh_del_user_interactive(const char *endpt_name, const char *user_name,
470 struct lyd_node **config);
471
472/**
473 * @brief Deletes an SSH user from the YANG data.
474 *
475 * @param[in] endpt_name Identifier of an existing endpoint.
476 * @param[in] user_name Optional identifier of an user to be deleted.
477 * If NULL, all of the users on this endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200478 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200479 * @return 0 on success, non-zero otherwise.
480 */
481int nc_server_config_new_ssh_del_user(const char *endpt_name,
482 const char *user_name, struct lyd_node **config);
483
484/**
485 * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore.
486 *
487 * The public key's located in the bag will be used for client authentication.
488 *
489 * @param[in] ctx libyang context.
490 * @param[in] endpt_name Arbitrary identifier of an endpoint.
491 * If an endpoint with this identifier already exists, its contents will be changed.
492 * @param[in] user_name Arbitrary identifier of the endpoint's user.
493 * If an endpoint's user with this identifier already exists, its contents will be changed.
494 * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication.
Roytak9b32c0f2023-08-02 15:07:29 +0200495 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200496 * Otherwise the new YANG data will be added to the previous data and may override it.
497 * @return 0 on success, non-zero otherwise.
498 */
roman67af8982023-08-08 10:56:04 +0200499int nc_server_config_new_ssh_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200500 const char *truststore_reference, struct lyd_node **config);
501
502/**
503 * @brief Deletes a truststore reference from the YANG data.
504 *
505 * @param[in] endpt_name Identifier of an existing endpoint.
506 * @param[in] user_name Identifier of an user on the given endpoint whose truststore reference will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200507 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200508 * @return 0 on success, non-zero otherwise.
509 */
roman67af8982023-08-08 10:56:04 +0200510int nc_server_config_new_ssh_del_truststore_ref(const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200511 struct lyd_node **config);
512
513/**
514 * @brief Creates new YANG configuration data nodes, which will be a reference to another SSH endpoint's users.
515 *
516 * Whenever a client tries to connect to the referencing endpoint, all of its users will be tried first. If no match is
517 * found, the referenced endpoint's configured users will be tried.
518 *
519 * @param[in] ctx libyang context
520 * @param[in] endpt_name Arbitrary identifier of the endpoint.
521 * If an endpoint with this identifier already exists, its contents will be changed.
522 * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data
523 * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle.
524 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
525 * Otherwise the new YANG data will be added to the previous data and may override it.
526 * @return 0 on success, non-zero otherwise.
527 */
roman67af8982023-08-08 10:56:04 +0200528int nc_config_new_ssh_endpoint_user_ref(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200529 const char *referenced_endpt, struct lyd_node **config);
530
531/**
532 * @brief Deletes reference to another SSH endpoint's users from the YANG data.
533 *
534 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200535 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200536 * @return 0 on success, non-zero otherwise.
537 */
roman67af8982023-08-08 10:56:04 +0200538int nc_config_new_ssh_del_endpoint_user_ref(const char *endpt_name, struct lyd_node **config);
roman9b1379c2023-03-31 10:11:10 +0200539
540/**
541 * @brief Creates new YANG configuration data nodes for host-key algorithms replacing any previous ones.
542 *
543 * Supported algorithms are: ssh-ed25519, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521,
544 * rsa-sha2-512, rsa-sha2-256, ssh-rsa and ssh-dss.
545 *
546 * @param[in] ctx libyang context
547 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200548 * If an endpoint with this identifier already exists, its host-key algorithms will be replaced.
roman9b1379c2023-03-31 10:11:10 +0200549 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
550 * Otherwise the new YANG data will be added to the previous data and may override it.
551 * @param[in] alg_count Number of following algorithms.
552 * @param[in] ... String literals of host-key algorithms in a decreasing order of preference.
553 * @return 0 on success, non-zero otherwise.
554 */
roman466719d2023-05-05 16:14:37 +0200555int nc_server_config_new_ssh_host_key_algs(const struct ly_ctx *ctx, const char *endpt_name,
roman9b1379c2023-03-31 10:11:10 +0200556 struct lyd_node **config, int alg_count, ...);
557
558/**
roman8ba6efa2023-07-12 15:27:52 +0200559 * @brief Deletes a hostkey algorithm from the YANG data.
560 *
561 * @param[in] endpt_name Identifier of an existing endpoint.
562 * @param[in] alg Optional algorithm to be deleted.
563 * If NULL, all of the hostkey algorithms on this endpoint will be deleted.
roman35120972023-08-08 10:39:12 +0200564 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200565 * @return 0 on success, non-zero otherwise.
566 */
567int nc_server_config_new_ssh_del_host_key_alg(const char *endpt_name, const char *alg, struct lyd_node **config);
568
569/**
roman9b1379c2023-03-31 10:11:10 +0200570 * @brief Creates new YANG configuration data nodes for key exchange algorithms replacing any previous ones.
571 *
572 * Supported algorithms are: diffie-hellman-group-exchange-sha1, curve25519-sha256, ecdh-sha2-nistp256,
573 * ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group18-sha512, diffie-hellman-group16-sha512,
574 * diffie-hellman-group-exchange-sha256 and diffie-hellman-group14-sha256.
575 *
576 * @param[in] ctx libyang context
577 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200578 * If an endpoint with this identifier already exists, its key exchange algorithms will be replaced.
roman9b1379c2023-03-31 10:11:10 +0200579 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
580 * Otherwise the new YANG data will be added to the previous data and may override it.
581 * @param[in] alg_count Number of following algorithms.
582 * @param[in] ... String literals of key exchange algorithms in a decreasing order of preference.
583 * @return 0 on success, non-zero otherwise.
584 */
roman466719d2023-05-05 16:14:37 +0200585int nc_server_config_new_ssh_key_exchange_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config,
roman9b1379c2023-03-31 10:11:10 +0200586 int alg_count, ...);
587
588/**
roman8ba6efa2023-07-12 15:27:52 +0200589 * @brief Deletes a key exchange algorithm from the YANG data.
590 *
591 * @param[in] endpt_name Identifier of an existing endpoint.
592 * @param[in] alg Optional algorithm to be deleted.
593 * If NULL, all of the key exchange algorithms on this endpoint will be deleted.
roman35120972023-08-08 10:39:12 +0200594 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200595 * @return 0 on success, non-zero otherwise.
596 */
597int nc_server_config_new_ssh_del_key_exchange_alg(const char *endpt_name, const char *alg, struct lyd_node **config);
598
599/**
roman9b1379c2023-03-31 10:11:10 +0200600 * @brief Creates new YANG configuration data nodes for encryption algorithms replacing any previous ones.
601 *
602 * Supported algorithms are: aes256-ctr, aes192-ctr, aes128-ctr, aes256-cbc, aes192-cbc, aes128-cbc, blowfish-cbc
603 * triple-des-cbc and none.
604 *
605 * @param[in] ctx libyang context
606 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200607 * If an endpoint with this identifier already exists, its encryption algorithms will be replaced.
roman9b1379c2023-03-31 10:11:10 +0200608 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
609 * Otherwise the new YANG data will be added to the previous data and may override it.
610 * @param[in] alg_count Number of following algorithms.
611 * @param[in] ... String literals of encryption algorithms in a decreasing order of preference.
612 * @return 0 on success, non-zero otherwise.
613 */
roman466719d2023-05-05 16:14:37 +0200614int nc_server_config_new_ssh_encryption_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config,
roman9b1379c2023-03-31 10:11:10 +0200615 int alg_count, ...);
616
617/**
roman8ba6efa2023-07-12 15:27:52 +0200618 * @brief Deletes an encryption algorithm from the YANG data.
619 *
620 * @param[in] endpt_name Identifier of an existing endpoint.
621 * @param[in] alg Optional algorithm to be deleted.
622 * If NULL, all of the encryption algorithms on this endpoint will be deleted.
roman35120972023-08-08 10:39:12 +0200623 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200624 * @return 0 on success, non-zero otherwise.
625 */
626int nc_server_config_new_ssh_del_encryption_alg(const char *endpt_name, const char *alg, struct lyd_node **config);
627
628/**
roman9b1379c2023-03-31 10:11:10 +0200629 * @brief Creates new YANG configuration data nodes for mac algorithms replacing any previous ones.
630 *
631 * Supported algorithms are: hmac-sha2-256, hmac-sha2-512 and hmac-sha1.
632 *
633 * @param[in] ctx libyang context
634 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200635 * If an endpoint with this identifier already exists, its mac algorithms will be replaced.
roman9b1379c2023-03-31 10:11:10 +0200636 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
637 * Otherwise the new YANG data will be added to the previous data and may override it.
638 * @param[in] alg_count Number of following algorithms.
639 * @param[in] ... String literals of mac algorithms in a decreasing order of preference.
640 * @return 0 on success, non-zero otherwise.
641 */
roman466719d2023-05-05 16:14:37 +0200642int nc_server_config_new_ssh_mac_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config,
roman9b1379c2023-03-31 10:11:10 +0200643 int alg_count, ...);
644
645/**
roman8ba6efa2023-07-12 15:27:52 +0200646 * @brief Deletes a mac algorithm from the YANG data.
roman9b1379c2023-03-31 10:11:10 +0200647 *
roman8ba6efa2023-07-12 15:27:52 +0200648 * @param[in] endpt_name Identifier of an existing endpoint.
649 * @param[in] alg Optional algorithm to be deleted.
650 * If NULL, all of the mac algorithms on this endpoint will be deleted.
roman35120972023-08-08 10:39:12 +0200651 * @param[in,out] config Modified configuration YANG data tree.
roman9b1379c2023-03-31 10:11:10 +0200652 * @return 0 on success, non-zero otherwise.
653 */
roman8ba6efa2023-07-12 15:27:52 +0200654int nc_server_config_new_ssh_del_mac_alg(const char *endpt_name, const char *alg, struct lyd_node **config);
roman9b1379c2023-03-31 10:11:10 +0200655
656/**
roman35120972023-08-08 10:39:12 +0200657 * @} SSH Server Configuration
roman9b1379c2023-03-31 10:11:10 +0200658 */
roman9b1379c2023-03-31 10:11:10 +0200659
660/**
roman8ba6efa2023-07-12 15:27:52 +0200661 * @defgroup server_config_tls TLS Server Configuration
662 * @ingroup server_config
roman9b1379c2023-03-31 10:11:10 +0200663 *
roman8ba6efa2023-07-12 15:27:52 +0200664 * @brief TLS server configuration creation and deletion
665 * @{
roman9b1379c2023-03-31 10:11:10 +0200666 */
roman2e797ef2023-06-19 10:47:49 +0200667
668/**
roman3f9b65c2023-06-05 14:26:58 +0200669 * @brief Creates new YANG configuration data nodes for a server's certificate.
670 *
671 * @param[in] ctx libyang context.
672 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200673 * If an endpoint with this identifier already exists, its server certificate will be changed.
roman6c4efcd2023-08-08 10:18:44 +0200674 * @param[in] privkey_path Path to the server's PEM encoded private key file.
roman3f9b65c2023-06-05 14:26:58 +0200675 * @param[in] pubkey_path Optional path to the server's public key file. If not provided,
676 * it will be generated from the private key.
roman3f9b65c2023-06-05 14:26:58 +0200677 * @param[in] certificate_path Path to the server's certificate file.
678 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
679 * Otherwise the new YANG data will be added to the previous data and may override it.
680 * @return 0 on success, non-zero otherwise.
681 */
roman6c4efcd2023-08-08 10:18:44 +0200682int nc_server_config_new_tls_server_certificate(const struct ly_ctx *ctx, const char *endpt_name, const char *privkey_path,
683 const char *pubkey_path, const char *certificate_path, struct lyd_node **config);
roman3f9b65c2023-06-05 14:26:58 +0200684
685/**
roman8ba6efa2023-07-12 15:27:52 +0200686 * @brief Deletes the server's certificate from the YANG data.
687 *
688 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200689 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200690 * @return 0 on success, non-zero otherwise.
691 */
692int nc_server_config_new_tls_del_server_certificate(const char *endpt_name, struct lyd_node **config);
693
694/**
roman12c3d522023-07-26 13:39:30 +0200695 * @brief Creates new YANG configuration data nodes for a keystore reference to the TLS server's certificate.
696 *
697 * @param[in] ctx libyang context.
698 * @param[in] endpt_name Arbitrary identifier of the endpoint.
699 * If an endpoint with this identifier already exists, its contents will be changed.
700 * @param[in] asym_key_ref Name of the asymmetric key pair in the keystore to be referenced.
701 * @param[in] cert_ref Name of the certificate, which must belong to the given asymmetric key pair, to be referenced.
702 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
703 * Otherwise the new YANG data will be added to the previous data and may override it.
704 * @return 0 on success, non-zero otherwise.
705 */
roman67af8982023-08-08 10:56:04 +0200706int nc_server_config_new_tls_keystore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *asym_key_ref,
roman12c3d522023-07-26 13:39:30 +0200707 const char *cert_ref, struct lyd_node **config);
708
709/**
710 * @brief Deletes a TLS server certificate keystore reference from the YANG data.
711 *
712 * @param[in] endpt_name Identifier of an existing endpoint.
713 * @param[in,out] config Modified configuration YANG data tree.
714 * @return 0 on success, non-zero otherwise.
715 */
roman67af8982023-08-08 10:56:04 +0200716int nc_server_config_new_tls_del_keystore_ref(const char *endpt_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200717
718/**
roman3f9b65c2023-06-05 14:26:58 +0200719 * @brief Creates new YANG configuration data nodes for a client's (end-entity) certificate.
720 *
721 * @param[in] ctx libyang context.
722 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200723 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200724 * @param[in] cert_name Arbitrary identifier of the client's certificate.
roman35120972023-08-08 10:39:12 +0200725 * If a client certificate with this identifier already exists, it will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200726 * @param[in] cert_path Path to the client's certificate file.
727 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
728 * Otherwise the new YANG data will be added to the previous data and may override it.
729 * @return 0 on success, non-zero otherwise.
730 */
731int nc_server_config_new_tls_client_certificate(const struct ly_ctx *ctx, const char *endpt_name, const char *cert_name,
732 const char *cert_path, struct lyd_node **config);
733
734/**
roman8ba6efa2023-07-12 15:27:52 +0200735 * @brief Deletes a client (end-entity) certificate from the YANG data.
736 *
737 * @param[in] endpt_name Identifier of an existing endpoint.
738 * @param[in] cert_name Optional name of a certificate to be deleted.
739 * If NULL, all of the end-entity certificates on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200740 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200741 * @return 0 on success, non-zero otherwise.
742 */
743int nc_server_config_new_tls_del_client_certificate(const char *endpt_name, const char *cert_name, struct lyd_node **config);
744
745/**
roman12c3d522023-07-26 13:39:30 +0200746 * @brief Creates new YANG configuration data nodes for a truststore reference to a set of client (end-entity) certificates.
747 *
748 * @param[in] ctx libyang context.
749 * @param[in] endpt_name Arbitrary identifier of the endpoint.
750 * If an endpoint with this identifier already exists, its contents will be changed.
751 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
752 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
753 * Otherwise the new YANG data will be added to the previous data and may override it.
754 * @return 0 on success, non-zero otherwise.
755 */
756int nc_server_config_new_tls_client_cert_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name,
757 const char *cert_bag_ref, struct lyd_node **config);
758
759/**
760 * @brief Deletes a client (end-entity) certificates truststore reference from the YANG data.
761 *
762 * @param[in] endpt_name Identifier of an existing endpoint.
763 * @param[in,out] config Modified configuration YANG data tree.
764 * @return 0 on success, non-zero otherwise.
765 */
766int nc_server_config_new_tls_del_client_cert_truststore_ref(const char *endpt_name, struct lyd_node **config);
767
768/**
roman3f9b65c2023-06-05 14:26:58 +0200769 * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate.
770 *
771 * @param[in] ctx libyang context.
772 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200773 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200774 * @param[in] cert_name Arbitrary identifier of the certificate authority certificate.
roman35120972023-08-08 10:39:12 +0200775 * If a CA with this identifier already exists, it will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200776 * @param[in] cert_path Path to the CA certificate file.
777 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
778 * Otherwise the new YANG data will be added to the previous data and may override it.
779 * @return 0 on success, non-zero otherwise.
780 */
781int nc_server_config_new_tls_client_ca(const struct ly_ctx *ctx, const char *endpt_name, const char *cert_name,
782 const char *cert_path, struct lyd_node **config);
783
784/**
roman8ba6efa2023-07-12 15:27:52 +0200785 * @brief Deletes a client certificate authority (trust-anchor) certificate from the YANG data.
786 *
787 * @param[in] endpt_name Identifier of an existing endpoint.
788 * @param[in] cert_name Optional name of a certificate to be deleted.
789 * If NULL, all of the CA certificates on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200790 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200791 * @return 0 on success, non-zero otherwise.
792 */
793int nc_server_config_new_tls_del_client_ca(const char *endpt_name, const char *cert_name, struct lyd_node **config);
794
795/**
roman12c3d522023-07-26 13:39:30 +0200796 * @brief Creates new YANG configuration data nodes for a truststore reference to a set of client certificate authority (trust-anchor) certificates.
797 *
798 * @param[in] ctx libyang context.
799 * @param[in] endpt_name Arbitrary identifier of the endpoint.
800 * If an endpoint with this identifier already exists, its contents will be changed.
801 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
802 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
803 * Otherwise the new YANG data will be added to the previous data and may override it.
804 * @return 0 on success, non-zero otherwise.
805 */
806int nc_server_config_new_tls_client_ca_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name,
807 const char *cert_bag_ref, struct lyd_node **config);
808
809/**
810 * @brief Deletes a client certificate authority (trust-anchor) certificates truststore reference from the YANG data.
811 *
812 * @param[in] endpt_name Identifier of an existing endpoint.
813 * @param[in,out] config Modified configuration YANG data tree.
814 * @return 0 on success, non-zero otherwise.
815 */
816int nc_server_config_new_tls_del_client_ca_truststore_ref(const char *endpt_name, struct lyd_node **config);
817
818/**
roman3f9b65c2023-06-05 14:26:58 +0200819 * @brief Creates new YANG configuration data nodes for a cert-to-name entry.
820 *
821 * @param[in] ctx libyang context.
822 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200823 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200824 * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier).
825 * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is
826 * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry.
827 * @param[in] map_type Mapping username to the certificate option.
828 * @param[in] name Username for this cert-to-name entry.
829 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
830 * Otherwise the new YANG data will be added to the previous data and may override it.
831 * @return 0 on success, non-zero otherwise.
832 */
833int nc_server_config_new_tls_ctn(const struct ly_ctx *ctx, const char *endpt_name, uint32_t id, const char *fingerprint,
834 NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config);
835
roman12644fe2023-06-08 11:06:42 +0200836/**
roman8ba6efa2023-07-12 15:27:52 +0200837 * @brief Deletes a cert-to-name entry from the YANG data.
838 *
839 * @param[in] endpt_name Identifier of an existing endpoint.
840 * @param[in] id Optional ID of the CTN entry.
841 * If 0, all of the cert-to-name entries on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200842 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200843 * @return 0 on success, non-zero otherwise.
844 */
845int nc_server_config_new_tls_del_ctn(const char *endpt_name, uint32_t id, struct lyd_node **config);
846
847/**
roman12644fe2023-06-08 11:06:42 +0200848 * @brief Creates new YANG configuration data nodes for a TLS version.
849 *
850 * @param[in] ctx libyang context.
851 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200852 * If an endpoint with this identifier already exists, its contents will be changed.
roman12644fe2023-06-08 11:06:42 +0200853 * @param[in] tls_version TLS version to be used. Call this multiple times to set
854 * the accepted versions of the TLS protocol and let the client and server negotiate
855 * the given version.
856 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
857 * Otherwise the new YANG data will be added to the previous data and may override it.
858 * @return 0 on success, non-zero otherwise.
859 */
860int nc_server_config_new_tls_version(const struct ly_ctx *ctx, const char *endpt_name,
861 NC_TLS_VERSION tls_version, struct lyd_node **config);
862
863/**
roman8ba6efa2023-07-12 15:27:52 +0200864 * @brief Deletes a TLS version from the YANG data.
865 *
866 * @param[in] endpt_name Identifier of an existing endpoint.
867 * @param[in] tls_version TLS version to be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200868 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200869 * @return 0 on success, non-zero otherwise.
870 */
871int nc_server_config_new_tls_del_version(const char *endpt_name, NC_TLS_VERSION tls_version, struct lyd_node **config);
872
873/**
roman12644fe2023-06-08 11:06:42 +0200874 * @brief Creates new YANG configuration data nodes for a TLS cipher.
875 *
876 * @param[in] ctx libyang context.
877 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200878 * If an endpoint with this identifier already exists, its contents will be changed.
roman12644fe2023-06-08 11:06:42 +0200879 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
880 * Otherwise the new YANG data will be added to the previous data and may override it.
roman35120972023-08-08 10:39:12 +0200881 * @param[in] cipher_count Number of following ciphers.
roman12644fe2023-06-08 11:06:42 +0200882 * @param[in] ... TLS ciphers. These ciphers MUST be in the format as listed in the
883 * iana-tls-cipher-suite-algs YANG model (lowercase and separated by dashes). Regardless
884 * of the TLS protocol version used, all of these ciphers will be tried and some of them
885 * might not be set (TLS handshake might fail then). For the list of supported ciphers see
886 * the OpenSSL documentation.
887 * @return 0 on success, non-zero otherwise.
888 */
889int nc_server_config_new_tls_ciphers(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config,
roman08f67f42023-06-08 13:51:54 +0200890 int cipher_count, ...);
roman12644fe2023-06-08 11:06:42 +0200891
romanfaecc582023-06-15 16:13:31 +0200892/**
roman8ba6efa2023-07-12 15:27:52 +0200893 * @brief Deletes a TLS cipher from the YANG data.
894 *
895 * @param[in] endpt_name Identifier of an existing endpoint.
896 * @param[in] cipher TLS cipher to be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200897 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200898 * @return 0 on success, non-zero otherwise.
899 */
900int nc_server_config_new_tls_del_cipher(const char *endpt_name, const char *cipher, struct lyd_node **config);
901
902/**
romanfaecc582023-06-15 16:13:31 +0200903 * @brief Creates new YANG configuration data nodes for a Certificate Revocation List via a local file.
904 *
905 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
906 * this function will remove any CRL YANG nodes created by the other two functions.
907 *
908 * @param[in] ctx libyang context.
909 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200910 * If an endpoint with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +0200911 * @param[in] crl_path Path to a DER/PEM encoded CRL file.
romanfaecc582023-06-15 16:13:31 +0200912 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
913 * Otherwise the new YANG data will be added to the previous data and may override it.
914 * @return 0 on success, non-zero otherwise.
915 */
roman9d5e5a52023-07-14 12:43:44 +0200916int nc_server_config_new_tls_crl_path(const struct ly_ctx *ctx, const char *endpt_name,
917 const char *crl_path, struct lyd_node **config);
romanfaecc582023-06-15 16:13:31 +0200918
919/**
920 * @brief Creates new YANG configuration data nodes for a Certificate Revocation List via an URL.
921 *
922 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
923 * this function will remove any CRL YANG nodes created by the other two functions.
924 *
925 * @param[in] ctx libyang context.
926 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200927 * If an endpoint with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +0200928 * @param[in] crl_url URL from which the CRL file will be downloaded. The file has to be in the DER or PEM format.
romanfaecc582023-06-15 16:13:31 +0200929 * The allowed protocols are all the protocols supported by CURL.
930 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
931 * Otherwise the new YANG data will be added to the previous data and may override it.
932 * @return 0 on success, non-zero otherwise.
933 */
roman9d5e5a52023-07-14 12:43:44 +0200934int nc_server_config_new_tls_crl_url(const struct ly_ctx *ctx, const char *endpt_name, const char *crl_url, struct lyd_node **config);
romanfaecc582023-06-15 16:13:31 +0200935
936/**
937 * @brief Creates new YANG configuration data nodes for a Certificate Revocation List via certificate extensions.
938 *
939 * The chain of configured Certificate Authorities will be examined. For each certificate in this chain all the
940 * CRLs from the URLs specified in their extension fields CRL Distribution Points will be downloaded and used.
roman9d5e5a52023-07-14 12:43:44 +0200941 *
romanfaecc582023-06-15 16:13:31 +0200942 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
943 * this function will remove any CRL YANG nodes created by the other two functions.
944 *
945 * @param[in] ctx libyang context.
946 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200947 * If an endpoint with this identifier already exists, its contents will be changed.
romanfaecc582023-06-15 16:13:31 +0200948 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
949 * Otherwise the new YANG data will be added to the previous data and may override it.
950 * @return 0 on success, non-zero otherwise.
951 */
952int nc_server_config_new_tls_crl_cert_ext(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config);
953
roman2e797ef2023-06-19 10:47:49 +0200954/**
roman8ba6efa2023-07-12 15:27:52 +0200955 * @brief Deletes all the CRL nodes from the YANG data.
956 *
957 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200958 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200959 * @return 0 on success, non-zero otherwise.
960 */
961int nc_server_config_new_tls_del_crl(const char *endpt_name, struct lyd_node **config);
962
963/**
roman2e797ef2023-06-19 10:47:49 +0200964 * @brief Creates new YANG configuration data nodes, which will be a reference to another TLS endpoint's certificates.
965 *
966 * Whenever an user tries to connect to the referencing endpoint, all of its certificates will be tried first. If no match is
967 * found, the referenced endpoint's configured certificates will be tried. The same applies to cert-to-name entries.
968 *
969 * @param[in] ctx libyang context
970 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200971 * If an endpoint with this identifier already exists, its contents will be changed.
roman2e797ef2023-06-19 10:47:49 +0200972 * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data
973 * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle.
974 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
975 * Otherwise the new YANG data will be added to the previous data and may override it.
976 * @return 0 on success, non-zero otherwise.
977 */
roman67af8982023-08-08 10:56:04 +0200978int nc_config_new_tls_endpoint_client_ref(const struct ly_ctx *ctx, const char *endpt_name,
roman2e797ef2023-06-19 10:47:49 +0200979 const char *referenced_endpt, struct lyd_node **config);
980
roman142718b2023-06-29 09:15:29 +0200981/**
roman8ba6efa2023-07-12 15:27:52 +0200982 * @brief Deletes reference to another TLS endpoint's users from the YANG data.
983 *
984 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200985 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200986 * @return 0 on success, non-zero otherwise.
987 */
roman67af8982023-08-08 10:56:04 +0200988int nc_config_new_tls_del_endpoint_client_ref(const char *endpt_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200989
990/**
roman35120972023-08-08 10:39:12 +0200991 * @} TLS Server Configuration
roman8ba6efa2023-07-12 15:27:52 +0200992 */
993
994/**
roman35120972023-08-08 10:39:12 +0200995 * @defgroup server_config_ch Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +0200996 * @ingroup server_config
997 *
Roytak2161df62023-08-02 15:04:42 +0200998 * @brief Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +0200999 * @{
1000 */
1001
1002/**
roman35120972023-08-08 10:39:12 +02001003 * @} Call Home Server Configuration
1004 */
1005
1006/**
1007 * @defgroup server_config_ch_functions Call Home Server Configuration Functions
1008 * @ingroup server_config_ch
1009 *
1010 * @brief Call Home server configuration functions
1011 * @{
1012 */
1013
1014/**
Roytak2161df62023-08-02 15:04:42 +02001015 * @brief Creates new YANG configuration data nodes for a Call Home client's address and port.
roman142718b2023-06-29 09:15:29 +02001016 *
1017 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001018 * @param[in] client_name Arbitrary identifier of the Call Home client.
1019 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +02001020 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1021 * If the client's endpoint with this identifier already exists, its contents will be changed.
1022 * @param[in] transport Transport protocol to be used on this endpoint - either SSH or TLS.
1023 * @param[in] address Address to connect to.
1024 * @param[in] port Port to connect to.
1025 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1026 * Otherwise the new YANG data will be added to the previous data and may override it.
1027 * @return 0 on success, non-zero otherwise.
1028 */
roman8ba6efa2023-07-12 15:27:52 +02001029int nc_server_config_new_ch_address_port(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman5cbb6532023-06-22 12:53:17 +02001030 NC_TRANSPORT_IMPL transport, const char *address, const char *port, struct lyd_node **config);
1031
roman8ba6efa2023-07-12 15:27:52 +02001032#endif /* NC_ENABLED_SSH_TLS */
1033
1034/**
Roytak2161df62023-08-02 15:04:42 +02001035 * @brief Deletes a Call Home client from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001036 *
1037 * @param[in] client_name Optional identifier of a client to be deleted.
Roytak2161df62023-08-02 15:04:42 +02001038 * If NULL, all of the Call Home clients will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001039 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001040 * @return 0 on success, non-zero otherwise.
1041 */
1042int nc_server_config_new_del_ch_client(const char *client_name, struct lyd_node **config);
1043
1044/**
Roytak2161df62023-08-02 15:04:42 +02001045 * @brief Deletes a Call Home endpoint from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001046 *
Roytak2161df62023-08-02 15:04:42 +02001047 * @param[in] client_name Identifier of an existing Call Home client.
roman8ba6efa2023-07-12 15:27:52 +02001048 * @param[in] endpt_name Optional identifier of a CH endpoint to be deleted.
1049 * If NULL, all of the CH endpoints which belong to the given client will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001050 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001051 * @return 0 on success, non-zero otherwise.
1052 */
1053int nc_server_config_new_ch_del_endpt(const char *client_name, const char *endpt_name, struct lyd_node **config);
1054
1055/**
Roytak2161df62023-08-02 15:04:42 +02001056 * @brief Creates new YANG configuration data nodes for the Call Home persistent connection type.
roman8ba6efa2023-07-12 15:27:52 +02001057 *
1058 * This is the default connection type. If periodic connection type was set before, it will be unset.
1059 *
1060 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001061 * @param[in] client_name Arbitrary identifier of the Call Home client.
1062 * If a Call Home client with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001063 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001064 * Otherwise the new YANG data will be added to the previous data and may override it.
1065 * @return 0 on success, non-zero otherwise.
1066 */
1067int nc_server_config_new_ch_persistent(const struct ly_ctx *ctx, const char *client_name, struct lyd_node **config);
1068
1069/**
Roytak2161df62023-08-02 15:04:42 +02001070 * @brief Creates new YANG configuration data nodes for the period parameter of the Call Home periodic connection type.
roman8ba6efa2023-07-12 15:27:52 +02001071 *
1072 * If called, the persistent connection type will be replaced by periodic.
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.
roman8ba6efa2023-07-12 15:27:52 +02001077 * @param[in] period Duration between periodic connections in minutes.
Roytak9b32c0f2023-08-02 15:07:29 +02001078 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001079 * Otherwise the new YANG data will be added to the previous data and may override it.
1080 * @return 0 on success, non-zero otherwise.
1081 */
1082int nc_server_config_new_ch_period(const struct ly_ctx *ctx, const char *client_name, uint16_t period,
1083 struct lyd_node **config);
1084
1085/**
Roytak2161df62023-08-02 15:04:42 +02001086 * @brief Deletes the Call Home period parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001087 *
1088 * This behaves the same as setting the period to 60 minutes, which is the default value of this node.
1089 *
Roytak2161df62023-08-02 15:04:42 +02001090 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001091 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001092 * @return 0 on success, non-zero otherwise.
1093 */
1094int nc_server_config_new_ch_del_period(const char *client_name, struct lyd_node **config);
1095
1096/**
Roytak2161df62023-08-02 15:04:42 +02001097 * @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 +02001098 *
1099 * If called, the persistent connection type will be replaced by periodic.
1100 *
1101 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001102 * @param[in] client_name Arbitrary identifier of the Call Home client.
1103 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +02001104 * @param[in] anchor_time Timestamp before or after which a series of periodic connections are determined.
Roytak9b32c0f2023-08-02 15:07:29 +02001105 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001106 * Otherwise the new YANG data will be added to the previous data and may override it.
1107 * @return 0 on success, non-zero otherwise.
1108 */
1109int nc_server_config_new_ch_anchor_time(const struct ly_ctx *ctx, const char *client_name,
1110 const char *anchor_time, struct lyd_node **config);
1111
1112/**
Roytak2161df62023-08-02 15:04:42 +02001113 * @brief Deletes the Call Home anchor time parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001114 *
Roytak2161df62023-08-02 15:04:42 +02001115 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001116 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001117 * @return 0 on success, non-zero otherwise.
1118 */
1119int nc_server_config_new_ch_del_anchor_time(const char *client_name, struct lyd_node **config);
1120
1121/**
Roytak2161df62023-08-02 15:04:42 +02001122 * @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 +02001123 *
1124 * If called, the persistent connection type will be replaced by periodic.
1125 *
1126 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001127 * @param[in] client_name Arbitrary identifier of the Call Home client.
1128 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +02001129 * @param[in] idle_timeout Specifies the maximum number of seconds that a session may remain idle.
Roytak9b32c0f2023-08-02 15:07:29 +02001130 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001131 * Otherwise the new YANG data will be added to the previous data and may override it.
1132 * @return 0 on success, non-zero otherwise.
1133 */
1134int nc_server_config_new_ch_idle_timeout(const struct ly_ctx *ctx, const char *client_name,
1135 uint16_t idle_timeout, struct lyd_node **config);
1136
1137/**
Roytak2161df62023-08-02 15:04:42 +02001138 * @brief Deletes the Call Home idle timeout parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001139 *
1140 * This behaves the same as setting the timeout to 180 seconds, which is the default value of this node.
1141 *
Roytak2161df62023-08-02 15:04:42 +02001142 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001143 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001144 * @return 0 on success, non-zero otherwise.
1145 */
1146int nc_server_config_new_ch_del_idle_timeout(const char *client_name, struct lyd_node **config);
1147
1148/**
Roytak2161df62023-08-02 15:04:42 +02001149 * @brief Creates new YANG configuration data nodes for the Call Home reconnect strategy.
roman8ba6efa2023-07-12 15:27:52 +02001150 *
1151 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001152 * @param[in] client_name Arbitrary identifier of the Call Home client.
1153 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +02001154 * @param[in] start_with Specifies which endpoint to try if a connection is unsuccessful. Default value is NC_CH_FIRST_LISTED.
1155 * @param[in] max_wait The number of seconds after which a connection to an endpoint is deemed unsuccessful. Default value if 5.
1156 * @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 +02001157 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001158 * Otherwise the new YANG data will be added to the previous data and may override it.
1159 * @return 0 on success, non-zero otherwise.
1160 */
1161int nc_server_config_new_ch_reconnect_strategy(const struct ly_ctx *ctx, const char *client_name,
1162 NC_CH_START_WITH start_with, uint16_t max_wait, uint8_t max_attempts, struct lyd_node **config);
1163
1164/**
Roytak2161df62023-08-02 15:04:42 +02001165 * @brief Resets the values of the Call Home reconnect strategy nodes to their defaults.
roman8ba6efa2023-07-12 15:27:52 +02001166 *
1167 * The default values are: start-with = NC_CH_FIRST_LISTED, max-wait = 5 and max-attempts = 3.
1168 *
Roytak2161df62023-08-02 15:04:42 +02001169 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001170 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001171 * @return 0 on success, non-zero otherwise.
1172 */
1173int nc_server_config_new_ch_del_reconnect_strategy(const char *client_name, struct lyd_node **config);
1174
1175/**
roman35120972023-08-08 10:39:12 +02001176 * @} Call Home Server Configuration Functions
roman8ba6efa2023-07-12 15:27:52 +02001177 */
1178
1179#ifdef NC_ENABLED_SSH_TLS
1180
1181/**
Roytak2161df62023-08-02 15:04:42 +02001182 * @defgroup server_config_ch_ssh SSH Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001183 * @ingroup server_config_ch
1184 *
Roytak2161df62023-08-02 15:04:42 +02001185 * @brief SSH Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +02001186 * @{
1187 */
1188
roman142718b2023-06-29 09:15:29 +02001189/**
Roytak2161df62023-08-02 15:04:42 +02001190 * @brief Creates new YANG data nodes for a Call Home SSH hostkey.
roman142718b2023-06-29 09:15:29 +02001191 *
1192 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001193 * @param[in] client_name Arbitrary identifier of the Call Home client.
1194 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +02001195 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1196 * If the client's endpoint with this identifier already exists, its contents will be changed.
1197 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
1198 * If the endpoint's hostkey with this identifier already exists, its contents will be changed.
1199 * @param[in] privkey_path Path to a file containing a private key.
1200 * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
1201 * @param[in] pubkey_path Path to a file containing a public key. If NULL, public key will be
1202 * generated from the private key.
1203 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1204 * Otherwise the new YANG data will be added to the previous data and may override it.
1205 * @return 0 on success, non-zero otherwise.
1206 */
roman8ba6efa2023-07-12 15:27:52 +02001207int nc_server_config_new_ch_ssh_hostkey(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman5cbb6532023-06-22 12:53:17 +02001208 const char *hostkey_name, const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
1209
roman142718b2023-06-29 09:15:29 +02001210/**
Roytak2161df62023-08-02 15:04:42 +02001211 * @brief Deletes a Call Home hostkey from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001212 *
Roytak2161df62023-08-02 15:04:42 +02001213 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001214 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
roman8ba6efa2023-07-12 15:27:52 +02001215 * @param[in] hostkey_name Optional identifier of a hostkey to be deleted.
1216 * If NULL, all of the hostkeys on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001217 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001218 * @return 0 on success, non-zero otherwise.
1219 */
1220int nc_server_config_new_ch_ssh_del_hostkey(const char *client_name, const char *endpt_name,
1221 const char *hostkey_name, struct lyd_node **config);
1222
1223/**
roman9d5e5a52023-07-14 12:43:44 +02001224 * @brief Creates new YANG data nodes for a reference to an asymmetric key located in the keystore.
1225 *
Roytak2161df62023-08-02 15:04:42 +02001226 * This asymmetric key pair will be used as the Call Home SSH hostkey.
roman9d5e5a52023-07-14 12:43:44 +02001227 *
1228 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001229 * @param[in] client_name Arbitrary identifier of the Call Home client.
1230 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001231 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1232 * If the client's endpoint with this identifier already exists, its contents will be changed.
1233 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
1234 * If the endpoint's hostkey with this identifier already exists, its contents will be changed.
1235 * @param[in] keystore_reference Name of the asymmetric key pair to be referenced and used as a hostkey.
Roytak9b32c0f2023-08-02 15:07:29 +02001236 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001237 * Otherwise the new YANG data will be added to the previous data and may override it.
1238 * @return 0 on success, non-zero otherwise.
1239 */
roman67af8982023-08-08 10:56:04 +02001240int nc_server_config_new_ch_ssh_keystore_ref(const struct ly_ctx *ctx, const char *client_name,
roman9d5e5a52023-07-14 12:43:44 +02001241 const char *endpt_name, const char *hostkey_name, const char *keystore_reference, struct lyd_node **config);
1242
1243/**
Roytak2161df62023-08-02 15:04:42 +02001244 * @brief Deletes a Call Home keystore reference from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001245 *
Roytak2161df62023-08-02 15:04:42 +02001246 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001247 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1248 * @param[in] hostkey_name Identifier of an existing hostkey that belongs to the given CH endpoint.
Roytak9b32c0f2023-08-02 15:07:29 +02001249 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001250 * @return 0 on success, non-zero otherwise.
1251 */
roman67af8982023-08-08 10:56:04 +02001252int nc_server_config_new_ch_ssh_del_keystore_ref(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001253 const char *hostkey_name, struct lyd_node **config);
1254
1255/**
Roytak2161df62023-08-02 15:04:42 +02001256 * @brief Creates new YANG configuration data nodes for the maximum amount of failed Call Home SSH authentication attempts.
roman68404fd2023-07-24 10:40:59 +02001257 *
1258 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001259 * @param[in] client_name Arbitrary identifier of the Call Home client.
1260 * If a Call Home client with this identifier already exists, its contents will be changed.
roman68404fd2023-07-24 10:40:59 +02001261 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1262 * If the client's endpoint with this identifier already exists, its contents will be changed.
1263 * @param[in] auth_attempts Maximum amount of failed SSH authentication attempts after which a
1264 * client is disconnected. The default value is 3.
1265 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1266 * Otherwise the new YANG data will be added to the previous data and may override it.
1267 * @return 0 on success, non-zero otherwise.
1268 */
1269int nc_server_config_new_ch_ssh_auth_attempts(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1270 uint16_t auth_attempts, struct lyd_node **config);
1271
1272/**
Roytak2161df62023-08-02 15:04:42 +02001273 * @brief Creates new YANG configuration data nodes for a Call Home SSH authentication timeout.
roman68404fd2023-07-24 10:40:59 +02001274 *
1275 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001276 * @param[in] client_name Arbitrary identifier of the Call Home client.
1277 * If a Call Home client with this identifier already exists, its contents will be changed.
roman68404fd2023-07-24 10:40:59 +02001278 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1279 * If the client's endpoint with this identifier already exists, its contents will be changed.
1280 * @param[in] auth_timeout Maximum amount of time in seconds after which the authentication is deemed
1281 * unsuccessful. The default value is 10.
1282 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1283 * Otherwise the new YANG data will be added to the previous data and may override it.
1284 * @return 0 on success, non-zero otherwise.
1285 */
1286int nc_server_config_new_ch_ssh_auth_timeout(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1287 uint16_t auth_timeout, struct lyd_node **config);
1288
1289/**
Roytak2161df62023-08-02 15:04:42 +02001290 * @brief Creates new YANG data nodes for a Call Home SSH user's public key authentication method.
roman142718b2023-06-29 09:15:29 +02001291 *
1292 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001293 * @param[in] client_name Arbitrary identifier of the Call Home client.
1294 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +02001295 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1296 * If the client's endpoint with this identifier already exists, its contents will be changed.
1297 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1298 * If the endpoint's user with this identifier already exists, its contents will be changed.
1299 * @param[in] pubkey_name Arbitrary identifier of the user's public key.
1300 * If the user's public key with this identifier already exists, its contents will be changed.
1301 * @param[in] pubkey_path Path to a file containing a public key.
1302 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1303 * Otherwise the new YANG data will be added to the previous data and may override it.
1304 * @return 0 on success, non-zero otherwise.
1305 */
roman8ba6efa2023-07-12 15:27:52 +02001306int nc_server_config_new_ch_ssh_user_pubkey(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman5cbb6532023-06-22 12:53:17 +02001307 const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config);
1308
roman142718b2023-06-29 09:15:29 +02001309/**
Roytak2161df62023-08-02 15:04:42 +02001310 * @brief Deletes a Call Home SSH user's public key from the YANG data.
roman142718b2023-06-29 09:15:29 +02001311 *
Roytak2161df62023-08-02 15:04:42 +02001312 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001313 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1314 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
roman8ba6efa2023-07-12 15:27:52 +02001315 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
1316 * If NULL, all of the public keys which belong to the given SSH user will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001317 * @param[in,out] config Modified configuration YANG data tree.
roman142718b2023-06-29 09:15:29 +02001318 * @return 0 on success, non-zero otherwise.
1319 */
roman8ba6efa2023-07-12 15:27:52 +02001320int nc_server_config_new_ch_ssh_del_user_pubkey(const char *client_name, const char *endpt_name,
1321 const char *user_name, const char *pubkey_name, struct lyd_node **config);
roman5cbb6532023-06-22 12:53:17 +02001322
roman142718b2023-06-29 09:15:29 +02001323/**
Roytak2161df62023-08-02 15:04:42 +02001324 * @brief Creates new YANG data nodes for a Call Home SSH user's password authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001325 *
1326 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001327 * @param[in] client_name Arbitrary identifier of the Call Home client.
1328 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001329 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1330 * If the client's endpoint with this identifier already exists, its contents will be changed.
1331 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1332 * If the endpoint's user with this identifier already exists, its contents will be changed.
roman35120972023-08-08 10:39:12 +02001333 * @param[in] password Clear-text password to be set for the user. It will be hashed.
roman9d5e5a52023-07-14 12:43:44 +02001334 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1335 * Otherwise the new YANG data will be added to the previous data and may override it.
1336 * @return 0 on success, non-zero otherwise.
1337 */
1338int nc_server_config_new_ch_ssh_user_password(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1339 const char *user_name, const char *password, struct lyd_node **config);
1340
1341/**
Roytak2161df62023-08-02 15:04:42 +02001342 * @brief Deletes a Call Home SSH user's password from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001343 *
Roytak2161df62023-08-02 15:04:42 +02001344 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001345 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1346 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1347 * @param[in,out] config Modified configuration YANG data tree.
1348 * @return 0 on success, non-zero otherwise.
1349 */
1350int nc_server_config_new_ch_ssh_del_user_password(const char *client_name, const char *endpt_name,
1351 const char *user_name, struct lyd_node **config);
1352
1353/**
Roytak2161df62023-08-02 15:04:42 +02001354 * @brief Creates new YANG configuration data nodes for a Call Home SSH user's none authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001355 *
1356 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001357 * @param[in] client_name Arbitrary identifier of the Call Home client.
1358 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001359 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1360 * If the client's endpoint with this identifier already exists, its contents will be changed.
1361 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1362 * If the endpoint's user with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001363 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001364 * Otherwise the new YANG data will be added to the previous data and may override it.
1365 * @return 0 on success, non-zero otherwise.
1366 */
1367int nc_server_config_new_ch_ssh_user_none(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1368 const char *user_name, struct lyd_node **config);
1369
1370/**
Roytak2161df62023-08-02 15:04:42 +02001371 * @brief Deletes a Call Home SSH user's none authentication method from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001372 *
Roytak2161df62023-08-02 15:04:42 +02001373 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001374 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1375 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1376 * @param[in,out] config Modified configuration YANG data tree.
1377 * @return 0 on success, non-zero otherwise.
1378 */
1379int nc_server_config_new_ch_ssh_del_user_none(const char *client_name, const char *endpt_name,
1380 const char *user_name, struct lyd_node **config);
1381
1382/**
Roytak2161df62023-08-02 15:04:42 +02001383 * @brief Creates new YANG configuration data nodes for a Call Home SSH user's keyboard interactive authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001384 *
1385 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001386 * @param[in] client_name Arbitrary identifier of the Call Home client.
1387 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001388 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1389 * If the client's endpoint with this identifier already exists, its contents will be changed.
1390 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1391 * If the endpoint's user with this identifier already exists, its contents will be changed.
1392 * @param[in] pam_config_name Name of the PAM configuration file.
roman0f5fa422023-08-07 09:03:24 +02001393 * @param[in] pam_config_dir Optional. The absolute path to the directory in which the configuration file
1394 * 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 +02001395 * the path. If NULL is passed, then the PAM's system directories will be searched (usually /etc/pam.d/).
1396 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1397 * Otherwise the new YANG data will be added to the previous data and may override it.
1398 * @return 0 on success, non-zero otherwise.
1399 */
1400int nc_server_config_new_ch_ssh_user_interactive(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1401 const char *user_name, const char *pam_config_name, const char *pam_config_dir, struct lyd_node **config);
1402
1403/**
Roytak2161df62023-08-02 15:04:42 +02001404 * @brief Deletes a Call Home SSH user's keyboard interactive authentication from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001405 *
Roytak2161df62023-08-02 15:04:42 +02001406 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001407 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1408 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1409 * @param[in,out] config Modified configuration YANG data tree.
1410 * @return 0 on success, non-zero otherwise.
1411 */
1412int nc_server_config_new_ch_ssh_del_user_interactive(const char *client_name, const char *endpt_name,
1413 const char *user_name, struct lyd_node **config);
1414
1415/**
Roytak2161df62023-08-02 15:04:42 +02001416 * @brief Deletes a Call Home SSH user from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001417 *
Roytak2161df62023-08-02 15:04:42 +02001418 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001419 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1420 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1421 * @param[in,out] config Modified configuration YANG data tree.
1422 * @return 0 on success, non-zero otherwise.
1423 */
1424int nc_server_config_new_ch_ssh_del_user(const char *client_name, const char *endpt_name,
1425 const char *user_name, struct lyd_node **config);
1426
1427/**
1428 * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore.
1429 *
Roytak2161df62023-08-02 15:04:42 +02001430 * The public key's located in the bag will be used for Call Home SSH client authentication.
roman9d5e5a52023-07-14 12:43:44 +02001431 *
1432 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001433 * @param[in] client_name Arbitrary identifier of the Call Home client.
1434 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001435 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1436 * If the client's endpoint with this identifier already exists, its contents will be changed.
1437 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1438 * If the endpoint's user with this identifier already exists, its contents will be changed.
1439 * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication.
Roytak9b32c0f2023-08-02 15:07:29 +02001440 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001441 * Otherwise the new YANG data will be added to the previous data and may override it.
1442 * @return 0 on success, non-zero otherwise.
1443 */
roman67af8982023-08-08 10:56:04 +02001444int nc_server_config_new_ch_ssh_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
roman9d5e5a52023-07-14 12:43:44 +02001445 const char *endpt_name, const char *user_name, const char *truststore_reference, struct lyd_node **config);
1446
1447/**
Roytak2161df62023-08-02 15:04:42 +02001448 * @brief Deletes a Call Home SSH truststore reference from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001449 *
Roytak2161df62023-08-02 15:04:42 +02001450 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001451 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1452 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1453 * @param[in,out] config Modified configuration YANG data tree.
1454 * @return 0 on success, non-zero otherwise.
1455 */
roman67af8982023-08-08 10:56:04 +02001456int nc_server_config_new_ch_ssh_del_truststore_ref(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001457 const char *user_name, struct lyd_node **config);
1458
1459/**
Roytak2161df62023-08-02 15:04:42 +02001460 * @brief Creates new YANG configuration data nodes for Call Home host-key algorithms replacing any previous ones.
roman9d5e5a52023-07-14 12:43:44 +02001461 *
1462 * Supported algorithms are: ssh-ed25519, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521,
1463 * rsa-sha2-512, rsa-sha2-256, ssh-rsa and ssh-dss.
1464 *
1465 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001466 * @param[in] client_name Arbitrary identifier of the Call Home client.
1467 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001468 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1469 * If the client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001470 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001471 * Otherwise the new YANG data will be added to the previous data and may override it.
1472 * @param[in] alg_count Number of following algorithms.
1473 * @param[in] ... String literals of host-key algorithms in a decreasing order of preference.
1474 * @return 0 on success, non-zero otherwise.
1475 */
1476int nc_server_config_new_ch_ssh_host_key_algs(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1477 struct lyd_node **config, int alg_count, ...);
1478
1479/**
Roytak2161df62023-08-02 15:04:42 +02001480 * @brief Deletes a Call Home hostkey algorithm from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001481 *
Roytak2161df62023-08-02 15:04:42 +02001482 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001483 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1484 * @param[in] alg Optional algorithm to be deleted.
1485 * If NULL, all of the hostkey algorithms on this endpoint will be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001486 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001487 * @return 0 on success, non-zero otherwise.
1488 */
1489int nc_server_config_new_ch_ssh_del_host_key_alg(const char *client_name, const char *endpt_name,
1490 const char *alg, struct lyd_node **config);
1491
1492/**
Roytak2161df62023-08-02 15:04:42 +02001493 * @brief Creates new YANG configuration data nodes for Call Home key exchange algorithms replacing any previous ones.
roman9d5e5a52023-07-14 12:43:44 +02001494 *
1495 * Supported algorithms are: diffie-hellman-group-exchange-sha1, curve25519-sha256, ecdh-sha2-nistp256,
1496 * ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group18-sha512, diffie-hellman-group16-sha512,
1497 * diffie-hellman-group-exchange-sha256 and diffie-hellman-group14-sha256.
1498 *
1499 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001500 * @param[in] client_name Arbitrary identifier of the Call Home client.
1501 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001502 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1503 * If the client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001504 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001505 * Otherwise the new YANG data will be added to the previous data and may override it.
1506 * @param[in] alg_count Number of following algorithms.
1507 * @param[in] ... String literals of key exchange algorithms in a decreasing order of preference.
1508 * @return 0 on success, non-zero otherwise.
1509 */
1510int nc_server_config_new_ch_ssh_key_exchange_algs(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1511 struct lyd_node **config, int alg_count, ...);
1512
1513/**
Roytak2161df62023-08-02 15:04:42 +02001514 * @brief Deletes a Call Home key exchange algorithm from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001515 *
Roytak2161df62023-08-02 15:04:42 +02001516 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001517 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1518 * @param[in] alg Optional algorithm to be deleted.
1519 * If NULL, all of the key exchange algorithms on this endpoint will be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001520 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001521 * @return 0 on success, non-zero otherwise.
1522 */
1523int nc_server_config_new_ch_ssh_del_key_exchange_alg(const char *client_name, const char *endpt_name,
1524 const char *alg, struct lyd_node **config);
1525
1526/**
Roytak2161df62023-08-02 15:04:42 +02001527 * @brief Creates new YANG configuration data nodes for Call Home encryption algorithms replacing any previous ones.
roman9d5e5a52023-07-14 12:43:44 +02001528 *
1529 * Supported algorithms are: aes256-ctr, aes192-ctr, aes128-ctr, aes256-cbc, aes192-cbc, aes128-cbc, blowfish-cbc
1530 * triple-des-cbc and none.
1531 *
1532 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001533 * @param[in] client_name Arbitrary identifier of the Call Home client.
1534 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001535 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1536 * If the client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001537 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001538 * Otherwise the new YANG data will be added to the previous data and may override it.
1539 * @param[in] alg_count Number of following algorithms.
1540 * @param[in] ... String literals of encryption algorithms in a decreasing order of preference.
1541 * @return 0 on success, non-zero otherwise.
1542 */
1543int nc_server_config_new_ch_ssh_encryption_algs(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1544 struct lyd_node **config, int alg_count, ...);
1545
1546/**
Roytak2161df62023-08-02 15:04:42 +02001547 * @brief Deletes a Call Home encryption algorithm from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001548 *
Roytak2161df62023-08-02 15:04:42 +02001549 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001550 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1551 * @param[in] alg Optional algorithm to be deleted.
1552 * If NULL, all of the encryption algorithms on this endpoint will be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001553 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001554 * @return 0 on success, non-zero otherwise.
1555 */
1556int nc_server_config_new_ch_ssh_del_encryption_alg(const char *client_name, const char *endpt_name,
1557 const char *alg, struct lyd_node **config);
1558
1559/**
Roytak2161df62023-08-02 15:04:42 +02001560 * @brief Creates new YANG configuration data nodes for Call Home mac algorithms replacing any previous ones.
roman9d5e5a52023-07-14 12:43:44 +02001561 *
1562 * Supported algorithms are: hmac-sha2-256, hmac-sha2-512 and hmac-sha1.
1563 *
1564 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001565 * @param[in] client_name Arbitrary identifier of the Call Home client.
1566 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001567 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1568 * If the client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001569 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001570 * Otherwise the new YANG data will be added to the previous data and may override it.
1571 * @param[in] alg_count Number of following algorithms.
1572 * @param[in] ... String literals of mac algorithms in a decreasing order of preference.
1573 * @return 0 on success, non-zero otherwise.
1574 */
1575int nc_server_config_new_ch_ssh_mac_algs(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1576 struct lyd_node **config, int alg_count, ...);
1577
1578/**
Roytak2161df62023-08-02 15:04:42 +02001579 * @brief Deletes a Call Home mac algorithm from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001580 *
Roytak2161df62023-08-02 15:04:42 +02001581 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001582 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1583 * @param[in] alg Optional algorithm to be deleted.
1584 * If NULL, all of the mac algorithms on this endpoint will be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001585 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001586 * @return 0 on success, non-zero otherwise.
1587 */
1588int nc_server_config_new_ch_ssh_del_mac_alg(const char *client_name, const char *endpt_name,
1589 const char *alg, struct lyd_node **config);
1590
1591/**
roman35120972023-08-08 10:39:12 +02001592 * @} SSH Call Home Server Configuration
roman142718b2023-06-29 09:15:29 +02001593 */
roman142718b2023-06-29 09:15:29 +02001594
1595/**
Roytak2161df62023-08-02 15:04:42 +02001596 * @defgroup server_config_ch_tls TLS Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001597 * @ingroup server_config_ch
roman142718b2023-06-29 09:15:29 +02001598 *
Roytak2161df62023-08-02 15:04:42 +02001599 * @brief TLS Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +02001600 * @{
roman142718b2023-06-29 09:15:29 +02001601 */
roman142718b2023-06-29 09:15:29 +02001602
romanb6f44032023-06-30 15:07:56 +02001603/**
Roytak2161df62023-08-02 15:04:42 +02001604 * @brief Creates new YANG configuration data nodes for a Call Home server's certificate.
romanb6f44032023-06-30 15:07:56 +02001605 *
1606 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001607 * @param[in] client_name Arbitrary identifier of the Call Home client.
1608 * If a Call Home client with this identifier already exists, its contents will be changed.
1609 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1610 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman6c4efcd2023-08-08 10:18:44 +02001611 * @param[in] privkey_path Path to the server's PEM encoded private key file.
romanb6f44032023-06-30 15:07:56 +02001612 * @param[in] pubkey_path Optional path to the server's public key file. If not provided,
1613 * it will be generated from the private key.
romanb6f44032023-06-30 15:07:56 +02001614 * @param[in] certificate_path Path to the server's certificate file.
Roytak934edc32023-07-27 12:04:18 +02001615 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001616 * Otherwise the new YANG data will be added to the previous data and may override it.
1617 * @return 0 on success, non-zero otherwise.
1618 */
roman8ba6efa2023-07-12 15:27:52 +02001619int nc_server_config_new_ch_tls_server_certificate(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
roman6c4efcd2023-08-08 10:18:44 +02001620 const char *privkey_path, const char *pubkey_path, const char *certificate_path, struct lyd_node **config);
romanb6f44032023-06-30 15:07:56 +02001621
1622/**
Roytak2161df62023-08-02 15:04:42 +02001623 * @brief Deletes a Call Home server certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001624 *
Roytak2161df62023-08-02 15:04:42 +02001625 * @param[in] client_name Identifier of an existing Call Home client.
1626 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman9d5e5a52023-07-14 12:43:44 +02001627 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001628 * @return 0 on success, non-zero otherwise.
1629 */
1630int nc_server_config_new_ch_tls_del_server_certificate(const char *client_name, const char *endpt_name,
1631 struct lyd_node **config);
1632
1633/**
Roytak934edc32023-07-27 12:04:18 +02001634 * @brief Creates new YANG configuration data nodes for a keystore reference to the Call Home TLS server's certificate.
1635 *
1636 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001637 * @param[in] client_name Arbitrary identifier of the Call Home client.
1638 * If a Call Home client with this identifier already exists, its contents will be changed.
1639 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1640 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
Roytak934edc32023-07-27 12:04:18 +02001641 * @param[in] asym_key_ref Name of the asymmetric key pair in the keystore to be referenced.
1642 * @param[in] cert_ref Name of the certificate, which must belong to the given asymmetric key pair, to be referenced.
1643 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1644 * Otherwise the new YANG data will be added to the previous data and may override it.
1645 * @return 0 on success, non-zero otherwise.
1646 */
roman67af8982023-08-08 10:56:04 +02001647int nc_server_config_new_ch_tls_keystore_ref(const struct ly_ctx *ctx, const char *client_name,
Roytak934edc32023-07-27 12:04:18 +02001648 const char *endpt_name, const char *asym_key_ref, const char *cert_ref, struct lyd_node **config);
1649
1650/**
1651 * @brief Deletes a TLS server certificate keystore reference from the YANG data.
1652 *
Roytak2161df62023-08-02 15:04:42 +02001653 * @param[in] client_name Identifier of an existing Call Home client.
1654 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
Roytak934edc32023-07-27 12:04:18 +02001655 * @param[in,out] config Modified configuration YANG data tree.
1656 * @return 0 on success, non-zero otherwise.
1657 */
roman67af8982023-08-08 10:56:04 +02001658int nc_server_config_new_ch_tls_del_keystore_ref(const char *client_name, const char *endpt_name,
Roytak934edc32023-07-27 12:04:18 +02001659 struct lyd_node **config);
1660
1661/**
Roytak2161df62023-08-02 15:04:42 +02001662 * @brief Creates new YANG configuration data nodes for a Call Home client's (end-entity) certificate.
romanb6f44032023-06-30 15:07:56 +02001663 *
1664 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001665 * @param[in] client_name Arbitrary identifier of the Call Home client.
1666 * If a Call Home client with this identifier already exists, its contents will be changed.
1667 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1668 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1669 * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's end-entity certificate.
1670 * 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 +02001671 * @param[in] cert_path Path to the certificate file.
Roytak934edc32023-07-27 12:04:18 +02001672 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001673 * Otherwise the new YANG data will be added to the previous data and may override it.
1674 * @return 0 on success, non-zero otherwise.
1675 */
roman8ba6efa2023-07-12 15:27:52 +02001676int nc_server_config_new_ch_tls_client_certificate(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
romanb6f44032023-06-30 15:07:56 +02001677 const char *cert_name, const char *cert_path, struct lyd_node **config);
1678
1679/**
Roytak2161df62023-08-02 15:04:42 +02001680 * @brief Deletes a Call Home client (end-entity) certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001681 *
Roytak2161df62023-08-02 15:04:42 +02001682 * @param[in] client_name Identifier of an existing Call Home client.
1683 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman8ba6efa2023-07-12 15:27:52 +02001684 * @param[in] cert_name Optional identifier of a client certificate to be deleted.
1685 * If NULL, all of the client certificates will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001686 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001687 * @return 0 on success, non-zero otherwise.
1688 */
1689int nc_server_config_new_ch_tls_del_client_certificate(const char *client_name, const char *endpt_name,
1690 const char *cert_name, struct lyd_node **config);
1691
1692/**
Roytak934edc32023-07-27 12:04:18 +02001693 * @brief Creates new YANG configuration data nodes for a Call Home truststore reference to a set of client (end-entity) certificates.
1694 *
1695 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001696 * @param[in] client_name Arbitrary identifier of the Call Home client.
1697 * If a Call Home client with this identifier already exists, its contents will be changed.
1698 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1699 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
Roytak934edc32023-07-27 12:04:18 +02001700 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
1701 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1702 * Otherwise the new YANG data will be added to the previous data and may override it.
1703 * @return 0 on success, non-zero otherwise.
1704 */
1705int nc_server_config_new_ch_tls_client_cert_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
1706 const char *endpt_name, const char *cert_bag_ref, struct lyd_node **config);
1707
1708/**
1709 * @brief Deletes a Call Home client (end-entity) certificates truststore reference from the YANG data.
1710 *
Roytak2161df62023-08-02 15:04:42 +02001711 * @param[in] client_name Identifier of an existing Call Home client.
1712 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
Roytak934edc32023-07-27 12:04:18 +02001713 * @param[in,out] config Modified configuration YANG data tree.
1714 * @return 0 on success, non-zero otherwise.
1715 */
1716int nc_server_config_new_ch_tls_del_client_cert_truststore_ref(const char *client_name, const char *endpt_name,
1717 struct lyd_node **config);
1718
1719/**
romanb6f44032023-06-30 15:07:56 +02001720 * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate.
1721 *
1722 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001723 * @param[in] client_name Arbitrary identifier of the Call Home client.
1724 * If a Call Home client with this identifier already exists, its contents will be changed.
1725 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1726 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1727 * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's certificate authority certificate.
1728 * If an Call Home endpoint's CA certificate with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001729 * @param[in] cert_path Path to the certificate file.
Roytak9b32c0f2023-08-02 15:07:29 +02001730 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001731 * Otherwise the new YANG data will be added to the previous data and may override it.
1732 * @return 0 on success, non-zero otherwise.
1733 */
roman8ba6efa2023-07-12 15:27:52 +02001734int nc_server_config_new_ch_tls_client_ca(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
romanb6f44032023-06-30 15:07:56 +02001735 const char *cert_name, const char *cert_path, struct lyd_node **config);
1736
1737/**
Roytak2161df62023-08-02 15:04:42 +02001738 * @brief Deletes a Call Home client certificate authority (trust-anchor) certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001739 *
Roytak2161df62023-08-02 15:04:42 +02001740 * @param[in] client_name Identifier of an existing Call Home client.
1741 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman8ba6efa2023-07-12 15:27:52 +02001742 * @param[in] cert_name Optional identifier of a CA certificate to be deleted.
1743 * If NULL, all of the CA certificates will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001744 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001745 * @return 0 on success, non-zero otherwise.
1746 */
1747int nc_server_config_new_ch_tls_del_client_ca(const char *client_name, const char *endpt_name,
1748 const char *cert_name, struct lyd_node **config);
1749
1750/**
Roytak934edc32023-07-27 12:04:18 +02001751 * @brief Creates new YANG configuration data nodes for a Call Home truststore reference to a set of client certificate authority (trust-anchor) certificates.
1752 *
1753 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001754 * @param[in] client_name Arbitrary identifier of the Call Home client.
1755 * If a Call Home client with this identifier already exists, its contents will be changed.
1756 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1757 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
Roytak934edc32023-07-27 12:04:18 +02001758 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
1759 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1760 * Otherwise the new YANG data will be added to the previous data and may override it.
1761 * @return 0 on success, non-zero otherwise.
1762 */
1763int nc_server_config_new_ch_tls_client_ca_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
1764 const char *endpt_name, const char *cert_bag_ref, struct lyd_node **config);
1765
1766/**
1767 * @brief Deletes a Call Home client certificate authority (trust-anchor) certificates truststore reference from the YANG data.
1768 *
Roytak2161df62023-08-02 15:04:42 +02001769 * @param[in] client_name Identifier of an existing Call Home client.
1770 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
Roytak934edc32023-07-27 12:04:18 +02001771 * @param[in,out] config Modified configuration YANG data tree.
1772 * @return 0 on success, non-zero otherwise.
1773 */
1774int nc_server_config_new_ch_tls_del_client_ca_truststore_ref(const char *client_name, const char *endpt_name,
1775 struct lyd_node **config);
1776
1777/**
Roytak2161df62023-08-02 15:04:42 +02001778 * @brief Creates new YANG configuration data nodes for a Call Home cert-to-name entry.
romanb6f44032023-06-30 15:07:56 +02001779 *
1780 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001781 * @param[in] client_name Arbitrary identifier of the Call Home client.
1782 * If a Call Home client with this identifier already exists, its contents will be changed.
1783 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1784 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001785 * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier).
1786 * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is
1787 * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry.
1788 * @param[in] map_type Mapping username to the certificate option.
1789 * @param[in] name Username for this cert-to-name entry.
Roytak9b32c0f2023-08-02 15:07:29 +02001790 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001791 * Otherwise the new YANG data will be added to the previous data and may override it.
1792 * @return 0 on success, non-zero otherwise.
1793 */
roman8ba6efa2023-07-12 15:27:52 +02001794int nc_server_config_new_ch_tls_ctn(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
romanb6f44032023-06-30 15:07:56 +02001795 uint32_t id, const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config);
1796
roman8ba6efa2023-07-12 15:27:52 +02001797/**
Roytak2161df62023-08-02 15:04:42 +02001798 * @brief Deletes a Call Home cert-to-name entry from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001799 *
Roytak2161df62023-08-02 15:04:42 +02001800 * @param[in] client_name Identifier of an existing Call Home client.
1801 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1802 * @param[in] id Optional identifier of the Call Home CTN entry to be deleted.
roman8ba6efa2023-07-12 15:27:52 +02001803 * If 0, all of the CTN entries will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001804 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001805 * @return 0 on success, non-zero otherwise.
1806 */
1807int nc_server_config_new_ch_tls_del_ctn(const char *client_name, const char *endpt_name,
1808 uint32_t id, struct lyd_node **config);
1809
1810/**
Roytak2161df62023-08-02 15:04:42 +02001811 * @brief Creates new YANG configuration data nodes for a Call Home TLS version.
roman9d5e5a52023-07-14 12:43:44 +02001812 *
1813 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001814 * @param[in] client_name Arbitrary identifier of the Call Home client.
1815 * If a Call Home client with this identifier already exists, its contents will be changed.
1816 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1817 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001818 * @param[in] tls_version TLS version to be used. Call this multiple times to set the accepted versions
1819 * of the TLS protocol and let the client and server negotiate the given version.
Roytak9b32c0f2023-08-02 15:07:29 +02001820 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001821 * Otherwise the new YANG data will be added to the previous data and may override it.
1822 * @return 0 on success, non-zero otherwise.
1823 */
1824int nc_server_config_new_ch_tls_version(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1825 NC_TLS_VERSION tls_version, struct lyd_node **config);
1826
1827/**
1828 * @brief Deletes a TLS version from the YANG data.
1829 *
Roytak2161df62023-08-02 15:04:42 +02001830 * @param[in] client_name Identifier of an existing Call Home client.
1831 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman9d5e5a52023-07-14 12:43:44 +02001832 * @param[in] tls_version TLS version to be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001833 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001834 * @return 0 on success, non-zero otherwise.
1835 */
1836int nc_server_config_new_ch_tls_del_version(const char *client_name, const char *endpt_name,
1837 NC_TLS_VERSION tls_version, struct lyd_node **config);
1838
1839/**
Roytak2161df62023-08-02 15:04:42 +02001840 * @brief Creates new YANG configuration data nodes for a Call Home TLS cipher.
roman9d5e5a52023-07-14 12:43:44 +02001841 *
1842 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001843 * @param[in] client_name Arbitrary identifier of the Call Home client.
1844 * If a Call Home client with this identifier already exists, its contents will be changed.
1845 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1846 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001847 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001848 * Otherwise the new YANG data will be added to the previous data and may override it.
1849 * @param[in] cipher_count Number of following ciphers.
1850 * @param[in] ... TLS ciphers. These ciphers MUST be in the format as listed in the
1851 * iana-tls-cipher-suite-algs YANG model (lowercase and separated by dashes). Regardless
1852 * of the TLS protocol version used, all of these ciphers will be tried and some of them
1853 * might not be set (TLS handshake might fail then). For the list of supported ciphers see
1854 * the OpenSSL documentation.
1855 * @return 0 on success, non-zero otherwise.
1856 */
1857int nc_server_config_new_ch_tls_ciphers(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1858 struct lyd_node **config, int cipher_count, ...);
1859
1860/**
Roytak2161df62023-08-02 15:04:42 +02001861 * @brief Deletes a Call Home TLS cipher from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001862 *
Roytak2161df62023-08-02 15:04:42 +02001863 * @param[in] client_name Identifier of an existing Call Home client.
1864 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman9d5e5a52023-07-14 12:43:44 +02001865 * @param[in] cipher TLS cipher to be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001866 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001867 * @return 0 on success, non-zero otherwise.
1868 */
1869int nc_server_config_new_ch_tls_del_cipher(const char *client_name, const char *endpt_name,
1870 const char *cipher, struct lyd_node **config);
1871
1872/**
Roytak2161df62023-08-02 15:04:42 +02001873 * @brief Creates new YANG configuration data nodes for a Call Home Certificate Revocation List via a local file.
roman9d5e5a52023-07-14 12:43:44 +02001874 *
1875 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
1876 * this function will remove any CRL YANG nodes created by the other two functions.
1877 *
1878 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001879 * @param[in] client_name Arbitrary identifier of the Call Home client.
1880 * If a Call Home client with this identifier already exists, its contents will be changed.
1881 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1882 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001883 * @param[in] crl_path Path to a DER/PEM encoded CRL file.
Roytak9b32c0f2023-08-02 15:07:29 +02001884 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001885 * Otherwise the new YANG data will be added to the previous data and may override it.
1886 * @return 0 on success, non-zero otherwise.
1887 */
1888int nc_server_config_new_ch_tls_crl_path(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1889 const char *crl_path, struct lyd_node **config);
1890
1891/**
Roytak2161df62023-08-02 15:04:42 +02001892 * @brief Creates new YANG configuration data nodes for a Call Home Certificate Revocation List via an URL.
roman9d5e5a52023-07-14 12:43:44 +02001893 *
1894 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
1895 * this function will remove any CRL YANG nodes created by the other two functions.
1896 *
1897 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001898 * @param[in] client_name Arbitrary identifier of the Call Home client.
1899 * If a Call Home client with this identifier already exists, its contents will be changed.
1900 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1901 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001902 * @param[in] crl_url URL from which the CRL file will be downloaded. The file has to be in the DER or PEM format.
1903 * The allowed protocols are all the protocols supported by CURL.
Roytak9b32c0f2023-08-02 15:07:29 +02001904 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001905 * Otherwise the new YANG data will be added to the previous data and may override it.
1906 * @return 0 on success, non-zero otherwise.
1907 */
1908int nc_server_config_new_ch_tls_crl_url(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1909 const char *crl_url, struct lyd_node **config);
1910
1911/**
Roytak2161df62023-08-02 15:04:42 +02001912 * @brief Creates new YANG configuration data nodes for a Call Home Certificate Revocation List via certificate extensions.
roman9d5e5a52023-07-14 12:43:44 +02001913 *
1914 * The chain of configured Certificate Authorities will be examined. For each certificate in this chain all the
1915 * CRLs from the URLs specified in their extension fields CRL Distribution Points will be downloaded and used.
1916 *
1917 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
1918 * this function will remove any CRL YANG nodes created by the other two functions.
1919 *
1920 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001921 * @param[in] client_name Arbitrary identifier of the Call Home client.
1922 * If a Call Home client with this identifier already exists, its contents will be changed.
1923 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1924 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001925 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001926 * Otherwise the new YANG data will be added to the previous data and may override it.
1927 * @return 0 on success, non-zero otherwise.
1928 */
1929int nc_server_config_new_ch_tls_crl_cert_ext(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1930 struct lyd_node **config);
1931
1932/**
1933 * @brief Deletes all the CRL nodes from the YANG data.
1934 *
Roytak2161df62023-08-02 15:04:42 +02001935 * @param[in] client_name Identifier of an existing Call Home client.
1936 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
Roytak9b32c0f2023-08-02 15:07:29 +02001937 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001938 * @return 0 on success, non-zero otherwise.
1939 */
1940int nc_server_config_new_ch_tls_del_crl(const char *client_name, const char *endpt_name, struct lyd_node **config);
1941
1942/**
roman35120972023-08-08 10:39:12 +02001943 * @} TLS Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001944 */
1945
roman2eab4742023-06-06 10:00:26 +02001946#endif /* NC_ENABLED_SSH_TLS */
roman45cec4e2023-02-17 10:21:39 +01001947
romanc1d2b092023-02-02 08:58:27 +01001948#ifdef __cplusplus
1949}
1950#endif
1951
1952#endif /* NC_SESSION_SERVER_H_ */