blob: ec48fb214db5177d18b1e4a6cfcd2241e48dd6b5 [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.
roman12c3d522023-07-26 13:39:30 +0200141 * @param[in] asym_key_name Identifier of the asymmetric key pair.
142 * This identifier is used to reference the key pair.
roman8ba6efa2023-07-12 15:27:52 +0200143 * @param[in] privkey_path Path to a private key file.
144 * @param[in] pubkey_path Optional path a public key file.
145 * If not supplied, it will be generated from the private key.
146 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
147 * Otherwise the new YANG data will be added to the previous data and may override it.
148 * @return 0 on success, non-zero otherwise.
149 */
roman12c3d522023-07-26 13:39:30 +0200150int nc_server_config_new_keystore_asym_key(const struct ly_ctx *ctx, const char *asym_key_name, const char *privkey_path,
roman8ba6efa2023-07-12 15:27:52 +0200151 const char *pubkey_path, struct lyd_node **config);
152
153/**
154 * @brief Deletes a keystore's asymmetric key from the YANG data.
155 *
roman12c3d522023-07-26 13:39:30 +0200156 * @param[in] asym_key_name Optional identifier of the asymmetric key to be deleted.
roman8ba6efa2023-07-12 15:27:52 +0200157 * If NULL, all of the asymmetric keys in the keystore will be deleted.
158 * @param[in,out] config Configuration YANG data tree.
159 * @return 0 on success, non-zero otherwise.
160 */
roman12c3d522023-07-26 13:39:30 +0200161int nc_server_config_new_del_keystore_asym_key(const char *asym_key_name, struct lyd_node **config);
162
163/**
164 * @brief Creates new YANG data nodes for a certificate in the keystore.
165 *
166 * A certificate can not exist without its asymmetric key, so you must call ::nc_server_config_new_keystore_asym_key()
167 * either before or after calling this with the same identifier for the asymmetric key.
168 *
169 * An asymmetric key pair can have zero or more certificates associated with this key pair, however a certificate must
170 * have exactly one key pair it belongs to.
171 *
172 * @param[in] ctx libyang context.
173 * @param[in] asym_key_name Arbitrary identifier of the asymmetric key.
174 * If an asymmetric key pair with this name already exists, its contents will be changed.
175 * @param[in] cert_name Arbitrary identifier of the key pair's certificate.
176 * If a certificate with this name already exists, its contents will be changed.
177 * @param[in] cert_path Path to the PEM encoded certificate file.
178 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
179 * Otherwise the new YANG data will be added to the previous data and may override it.
180 * @return 0 on success, non-zero otherwise.
181 */
182int nc_server_config_new_keystore_cert(const struct ly_ctx *ctx, const char *asym_key_name, const char *cert_name,
183 const char *cert_path, struct lyd_node **config);
184
185/**
186 * @brief Deletes a keystore's certificate from the YANG data.
187 *
188 * @param[in] asym_key_name Identifier of an existing asymmetric key pair.
189 * @param[in] cert_name Optional identifier of a certificate to be deleted.
190 * If NULL, all of the certificates belonging to the asymmetric key pair will be deleted.
191 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
192 * Otherwise the new YANG data will be added to the previous data and may override it.
193 * @return 0 on success, non-zero otherwise.
194 */
195int 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 +0200196
197/**
198 * @brief Creates new YANG data nodes for a public key in the truststore.
199 *
200 * @param[in] ctx libyang context.
roman12c3d522023-07-26 13:39:30 +0200201 * @param[in] pub_bag_name Arbitrary identifier of the public key bag.
roman8ba6efa2023-07-12 15:27:52 +0200202 * This name is used to reference the public keys in the bag.
203 * If a public key bag with this name already exists, its contents will be changed.
204 * @param[in] pubkey_name Arbitrary identifier of the public key.
roman12c3d522023-07-26 13:39:30 +0200205 * If a public key with this name already exists in the given bag, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200206 * @param[in] pubkey_path Path to a file containing a public key.
207 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
208 * Otherwise the new YANG data will be added to the previous data and may override it.
209 * @return 0 on success, non-zero otherwise.
210 */
roman12c3d522023-07-26 13:39:30 +0200211int 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 +0200212 const char *pubkey_path, struct lyd_node **config);
213
214/**
215 * @brief Deletes a truststore's public key from the YANG data.
216 *
roman12c3d522023-07-26 13:39:30 +0200217 * @param[in] pub_bag_name Identifier of an existing public key bag.
roman8ba6efa2023-07-12 15:27:52 +0200218 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
219 * If NULL, all of the public keys in the given bag will be deleted.
220 * @param[in,out] config Configuration YANG data tree.
221 * @return 0 on success, non-zero otherwise.
222 */
roman12c3d522023-07-26 13:39:30 +0200223int nc_server_config_new_del_truststore_pubkey(const char *pub_bag_name, const char *pubkey_name, struct lyd_node **config);
224
225/**
226 * @brief Creates new YANG data nodes for a certificate in the truststore.
227 *
228 * @param[in] ctx libyang context.
229 * @param[in] cert_bag_name Arbitrary identifier of the certificate bag.
230 * This name is used to reference the certificates in the bag.
231 * If a certificate bag with this name already exists, its contents will be changed.
232 * @param[in] cert_name Arbitrary identifier of the certificate.
233 * If a certificate with this name already exists in the given bag, its contents will be changed.
234 * @param[in] cert_path Path to a file containing a PEM encoded certificate.
235 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
236 * Otherwise the new YANG data will be added to the previous data and may override it.
237 * @return 0 on success, non-zero otherwise.
238 */
239int nc_server_config_new_truststore_cert(const struct ly_ctx *ctx, const char *cert_bag_name, const char *cert_name,
240 const char *cert_path, struct lyd_node **config);
241
242/**
243 * @brief Deletes a truststore's certificate from the YANG data.
244 *
245 * @param[in] cert_bag_name Identifier of an existing certificate bag.
246 * @param[in] cert_name Optional identifier of a certificate to be deleted.
247 * If NULL, all of the certificates in the given bag will be deleted.
248 * @param[in,out] config Configuration YANG data tree.
249 * @return 0 on success, non-zero otherwise.
250 */
251int nc_server_config_new_del_truststore_cert(const char *cert_bag_name,
252 const char *cert_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200253
254/**
roman35120972023-08-08 10:39:12 +0200255 * @} Server Configuration Functions
roman8ba6efa2023-07-12 15:27:52 +0200256 */
257
258/**
259 * @defgroup server_config_ssh SSH Server Configuration
260 * @ingroup server_config
261 *
262 * @brief SSH server configuration creation and deletion
263 * @{
264 */
265
roman3f9b65c2023-06-05 14:26:58 +0200266/**
267 * @brief Creates new YANG configuration data nodes for a hostkey.
268 *
269 * @param[in] ctx libyang context.
270 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200271 * If an endpoint with this identifier already exists, its hostkey might be changed.
roman3f9b65c2023-06-05 14:26:58 +0200272 * @param[in] hostkey_name Arbitrary identifier of the hostkey.
roman142718b2023-06-29 09:15:29 +0200273 * If a hostkey with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200274 * @param[in] privkey_path Path to a file containing a private key.
275 * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
roman35120972023-08-08 10:39:12 +0200276 * @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 +0200277 * generated from the private key.
278 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
279 * Otherwise the new YANG data will be added to the previous data and may override it.
280 * @return 0 on success, non-zero otherwise.
281 */
roman8ba6efa2023-07-12 15:27:52 +0200282int nc_server_config_new_ssh_hostkey(const struct ly_ctx *ctx, const char *endpt_name, const char *hostkey_name,
283 const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
284
285/**
286 * @brief Deletes a hostkey from the YANG data.
287 *
288 * @param[in] ctx libyang context.
289 * @param[in] endpt_name Identifier of an existing endpoint.
290 * @param[in] hostkey_name Optional identifier of the hostkey to be deleted.
291 * If NULL, all of the hostkeys on this endpoint will be deleted.
292 * @param[in,out] config Configuration YANG data tree.
293 * @return 0 on success, non-zero otherwise.
294 */
295int nc_server_config_new_ssh_del_hostkey(const struct ly_ctx *ctx, const char *endpt_name,
296 const char *hostkey_name, struct lyd_node **config);
297
298/**
299 * @brief Creates new YANG data nodes for a reference to an asymmetric key located in the keystore.
300 *
301 * This asymmetric key pair will be used as the SSH hostkey.
302 *
303 * @param[in] ctx libyang context.
304 * @param[in] endpt_name Arbitrary identifier of an endpoint.
305 * If an endpoint with this identifier already exists, its contents will be changed.
306 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
307 * If an endpoint's hostkey with this identifier already exists, its contents will be changed.
308 * @param[in] keystore_reference Name of the asymmetric key pair to be referenced and used as a hostkey.
309 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
310 * Otherwise the new YANG data will be added to the previous data and may override it.
311 * @return 0 on success, non-zero otherwise.
312 */
roman67af8982023-08-08 10:56:04 +0200313int 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 +0200314 const char *keystore_reference, struct lyd_node **config);
315
316/**
317 * @brief Deletes a keystore reference from the YANG data.
318 *
319 * @param[in] endpt_name Identifier of an existing endpoint.
320 * @param[in] hostkey_name Identifier of an existing hostkey on the given endpoint.
321 * @param[in,out] config Configuration YANG data tree.
322 * @return 0 on success, non-zero otherwise.
323 */
roman67af8982023-08-08 10:56:04 +0200324int nc_server_config_new_ssh_del_keystore_ref(const char *endpt_name, const char *hostkey_name,
roman8ba6efa2023-07-12 15:27:52 +0200325 struct lyd_node **config);
326
327/**
roman68404fd2023-07-24 10:40:59 +0200328 * @brief Creates new YANG configuration data nodes for the maximum amount of failed SSH authentication attempts.
329 *
330 * @param[in] ctx libyang context.
331 * @param[in] endpt_name Arbitrary identifier of the endpoint.
332 * If an endpoint with this identifier already exists, its contents might be changed.
333 * @param[in] auth_attempts Maximum amount of failed SSH authentication attempts after which a
334 * client is disconnected. The default value is 3.
335 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
336 * Otherwise the new YANG data will be added to the previous data and may override it.
337 * @return 0 on success, non-zero otherwise.
338 */
339int nc_server_config_new_ssh_auth_attempts(const struct ly_ctx *ctx, const char *endpt_name, uint16_t auth_attempts,
340 struct lyd_node **config);
341
342/**
343 * @brief Creates new YANG configuration data nodes for an SSH authentication timeout.
344 *
345 * @param[in] ctx libyang context.
346 * @param[in] endpt_name Arbitrary identifier of the endpoint.
347 * If an endpoint with this identifier already exists, its contents might be changed.
348 * @param[in] auth_timeout Maximum amount of time in seconds after which the authentication is deemed
349 * unsuccessful. The default value is 10.
350 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
351 * Otherwise the new YANG data will be added to the previous data and may override it.
352 * @return 0 on success, non-zero otherwise.
353 */
354int nc_server_config_new_ssh_auth_timeout(const struct ly_ctx *ctx, const char *endpt_name, uint16_t auth_timeout,
355 struct lyd_node **config);
356
357/**
roman8ba6efa2023-07-12 15:27:52 +0200358 * @brief Creates new YANG configuration data nodes for an SSH user's public key authentication method.
359 *
360 * @param[in] ctx libyang context.
361 * @param[in] endpt_name Arbitrary identifier of the endpoint.
362 * If an endpoint with this identifier already exists, its user might be changed.
363 * @param[in] user_name Arbitrary identifier of the user.
364 * If an user with this identifier already exists, its contents will be changed.
365 * @param[in] pubkey_name Arbitrary identifier of the user's public key.
366 * If a public key with this identifier already exists for this user, its contents will be changed.
367 * @param[in] pubkey_path Path to a file containing the user's public key.
368 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
369 * Otherwise the new YANG data will be added to the previous data and may override it.
370 * @return 0 on success, non-zero otherwise.
371 */
372int nc_server_config_new_ssh_user_pubkey(const struct ly_ctx *ctx, const char *endpt_name,
373 const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config);
374
375/**
376 * @brief Deletes an SSH user's public key from the YANG data.
377 *
378 * @param[in] endpt_name Identifier of an existing endpoint.
379 * @param[in] user_name Identifier of an existing user on the given endpoint.
380 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
381 * If NULL, all of the users public keys will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200382 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200383 * @return 0 on success, non-zero otherwise.
384 */
385int nc_server_config_new_ssh_del_user_pubkey(const char *endpt_name, const char *user_name,
386 const char *pubkey_name, struct lyd_node **config);
387
388/**
389 * @brief Creates new YANG configuration data nodes for an SSH user's password authentication method.
390 *
391 * @param[in] ctx libyang context.
392 * @param[in] endpt_name Arbitrary identifier of the endpoint.
393 * If an endpoint with this identifier already exists, its user might be changed.
394 * @param[in] user_name Arbitrary identifier of the user.
395 * If an user with this identifier already exists, its contents will be changed.
roman35120972023-08-08 10:39:12 +0200396 * @param[in] password Clear-text password to be set for the user. It will be hashed.
roman8ba6efa2023-07-12 15:27:52 +0200397 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
398 * Otherwise the new YANG data will be added to the previous data and may override it.
399 * @return 0 on success, non-zero otherwise.
400 */
401int nc_server_config_new_ssh_user_password(const struct ly_ctx *ctx, const char *endpt_name,
402 const char *user_name, const char *password, struct lyd_node **config);
403
404/**
405 * @brief Deletes an SSH user's password from the YANG data.
406 *
407 * @param[in] endpt_name Identifier of an existing endpoint.
408 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200409 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200410 * @return 0 on success, non-zero otherwise.
411 */
412int nc_server_config_new_ssh_del_user_password(const char *endpt_name, const char *user_name,
413 struct lyd_node **config);
414
415/**
416 * @brief Creates new YANG configuration data nodes for an SSH user's none authentication method.
417 *
418 * @param[in] ctx libyang context.
419 * @param[in] endpt_name Arbitrary identifier of the endpoint.
420 * If an endpoint with this identifier already exists, its user might be changed.
421 * @param[in] user_name Arbitrary identifier of the user.
422 * If an user with this identifier already exists, its contents will be changed.
423 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
424 * Otherwise the new YANG data will be added to the previous data and may override it.
425 * @return 0 on success, non-zero otherwise.
426 */
427int nc_server_config_new_ssh_user_none(const struct ly_ctx *ctx, const char *endpt_name,
428 const char *user_name, struct lyd_node **config);
429
430/**
431 * @brief Deletes an SSH user's none authentication method from the YANG data.
432 *
433 * @param[in] endpt_name Identifier of an existing endpoint.
434 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200435 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200436 * @return 0 on success, non-zero otherwise.
437 */
438int nc_server_config_new_ssh_del_user_none(const char *endpt_name, const char *user_name,
439 struct lyd_node **config);
440
441/**
442 * @brief Creates new YANG configuration data nodes for an SSH user's keyboard interactive authentication method.
443 *
444 * @param[in] ctx libyang context.
445 * @param[in] endpt_name Arbitrary identifier of the endpoint.
446 * If an endpoint with this identifier already exists, its user might be changed.
447 * @param[in] user_name Arbitrary identifier of the user.
448 * If an user with this identifier already exists, its contents will be changed.
449 * @param[in] pam_config_name Name of the PAM configuration file.
roman0f5fa422023-08-07 09:03:24 +0200450 * @param[in] pam_config_dir Optional. The absolute path to the directory in which the configuration file
451 * 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 +0200452 * the path. If NULL is passed, then the PAM's system directories will be searched (usually /etc/pam.d/).
453 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
454 * Otherwise the new YANG data will be added to the previous data and may override it.
455 * @return 0 on success, non-zero otherwise.
456 */
457int nc_server_config_new_ssh_user_interactive(const struct ly_ctx *ctx, const char *endpt_name,
458 const char *user_name, const char *pam_config_name, const char *pam_config_dir, struct lyd_node **config);
459
460/**
461 * @brief Deletes an SSH user's keyboard interactive authentication from the YANG data.
462 *
463 * @param[in] endpt_name Identifier of an existing endpoint.
464 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200465 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200466 * @return 0 on success, non-zero otherwise.
467 */
468int nc_server_config_new_ssh_del_user_interactive(const char *endpt_name, const char *user_name,
469 struct lyd_node **config);
470
471/**
472 * @brief Deletes an SSH user from the YANG data.
473 *
474 * @param[in] endpt_name Identifier of an existing endpoint.
475 * @param[in] user_name Optional identifier of an user to be deleted.
476 * If NULL, all of the users on this endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200477 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200478 * @return 0 on success, non-zero otherwise.
479 */
480int nc_server_config_new_ssh_del_user(const char *endpt_name,
481 const char *user_name, struct lyd_node **config);
482
483/**
484 * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore.
485 *
486 * The public key's located in the bag will be used for client authentication.
487 *
488 * @param[in] ctx libyang context.
489 * @param[in] endpt_name Arbitrary identifier of an endpoint.
490 * If an endpoint with this identifier already exists, its contents will be changed.
491 * @param[in] user_name Arbitrary identifier of the endpoint's user.
492 * If an endpoint's user with this identifier already exists, its contents will be changed.
493 * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication.
Roytak9b32c0f2023-08-02 15:07:29 +0200494 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200495 * Otherwise the new YANG data will be added to the previous data and may override it.
496 * @return 0 on success, non-zero otherwise.
497 */
roman67af8982023-08-08 10:56:04 +0200498int 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 +0200499 const char *truststore_reference, struct lyd_node **config);
500
501/**
502 * @brief Deletes a truststore reference from the YANG data.
503 *
504 * @param[in] endpt_name Identifier of an existing endpoint.
505 * @param[in] user_name Identifier of an user on the given endpoint whose truststore reference will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200506 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200507 * @return 0 on success, non-zero otherwise.
508 */
roman67af8982023-08-08 10:56:04 +0200509int nc_server_config_new_ssh_del_truststore_ref(const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200510 struct lyd_node **config);
511
512/**
513 * @brief Creates new YANG configuration data nodes, which will be a reference to another SSH endpoint's users.
514 *
515 * Whenever a client tries to connect to the referencing endpoint, all of its users will be tried first. If no match is
516 * found, the referenced endpoint's configured users will be tried.
517 *
518 * @param[in] ctx libyang context
519 * @param[in] endpt_name Arbitrary identifier of the endpoint.
520 * If an endpoint with this identifier already exists, its contents will be changed.
521 * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data
522 * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle.
523 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
524 * Otherwise the new YANG data will be added to the previous data and may override it.
525 * @return 0 on success, non-zero otherwise.
526 */
roman67af8982023-08-08 10:56:04 +0200527int nc_config_new_ssh_endpoint_user_ref(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200528 const char *referenced_endpt, struct lyd_node **config);
529
530/**
531 * @brief Deletes reference to another SSH endpoint's users from the YANG data.
532 *
533 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200534 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200535 * @return 0 on success, non-zero otherwise.
536 */
roman67af8982023-08-08 10:56:04 +0200537int nc_config_new_ssh_del_endpoint_user_ref(const char *endpt_name, struct lyd_node **config);
roman9b1379c2023-03-31 10:11:10 +0200538
539/**
540 * @brief Creates new YANG configuration data nodes for host-key algorithms replacing any previous ones.
541 *
542 * Supported algorithms are: ssh-ed25519, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521,
543 * rsa-sha2-512, rsa-sha2-256, ssh-rsa and ssh-dss.
544 *
545 * @param[in] ctx libyang context
546 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200547 * If an endpoint with this identifier already exists, its host-key algorithms will be replaced.
roman9b1379c2023-03-31 10:11:10 +0200548 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
549 * Otherwise the new YANG data will be added to the previous data and may override it.
550 * @param[in] alg_count Number of following algorithms.
551 * @param[in] ... String literals of host-key algorithms in a decreasing order of preference.
552 * @return 0 on success, non-zero otherwise.
553 */
roman466719d2023-05-05 16:14:37 +0200554int nc_server_config_new_ssh_host_key_algs(const struct ly_ctx *ctx, const char *endpt_name,
roman9b1379c2023-03-31 10:11:10 +0200555 struct lyd_node **config, int alg_count, ...);
556
557/**
roman8ba6efa2023-07-12 15:27:52 +0200558 * @brief Deletes a hostkey algorithm from the YANG data.
559 *
560 * @param[in] endpt_name Identifier of an existing endpoint.
561 * @param[in] alg Optional algorithm to be deleted.
562 * If NULL, all of the hostkey algorithms on this endpoint will be deleted.
roman35120972023-08-08 10:39:12 +0200563 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200564 * @return 0 on success, non-zero otherwise.
565 */
566int nc_server_config_new_ssh_del_host_key_alg(const char *endpt_name, const char *alg, struct lyd_node **config);
567
568/**
roman9b1379c2023-03-31 10:11:10 +0200569 * @brief Creates new YANG configuration data nodes for key exchange algorithms replacing any previous ones.
570 *
571 * Supported algorithms are: diffie-hellman-group-exchange-sha1, curve25519-sha256, ecdh-sha2-nistp256,
572 * ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group18-sha512, diffie-hellman-group16-sha512,
573 * diffie-hellman-group-exchange-sha256 and diffie-hellman-group14-sha256.
574 *
575 * @param[in] ctx libyang context
576 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200577 * If an endpoint with this identifier already exists, its key exchange algorithms will be replaced.
roman9b1379c2023-03-31 10:11:10 +0200578 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
579 * Otherwise the new YANG data will be added to the previous data and may override it.
580 * @param[in] alg_count Number of following algorithms.
581 * @param[in] ... String literals of key exchange algorithms in a decreasing order of preference.
582 * @return 0 on success, non-zero otherwise.
583 */
roman466719d2023-05-05 16:14:37 +0200584int 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 +0200585 int alg_count, ...);
586
587/**
roman8ba6efa2023-07-12 15:27:52 +0200588 * @brief Deletes a key exchange algorithm from the YANG data.
589 *
590 * @param[in] endpt_name Identifier of an existing endpoint.
591 * @param[in] alg Optional algorithm to be deleted.
592 * If NULL, all of the key exchange algorithms on this endpoint will be deleted.
roman35120972023-08-08 10:39:12 +0200593 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200594 * @return 0 on success, non-zero otherwise.
595 */
596int nc_server_config_new_ssh_del_key_exchange_alg(const char *endpt_name, const char *alg, struct lyd_node **config);
597
598/**
roman9b1379c2023-03-31 10:11:10 +0200599 * @brief Creates new YANG configuration data nodes for encryption algorithms replacing any previous ones.
600 *
601 * Supported algorithms are: aes256-ctr, aes192-ctr, aes128-ctr, aes256-cbc, aes192-cbc, aes128-cbc, blowfish-cbc
602 * triple-des-cbc and none.
603 *
604 * @param[in] ctx libyang context
605 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200606 * If an endpoint with this identifier already exists, its encryption algorithms will be replaced.
roman9b1379c2023-03-31 10:11:10 +0200607 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
608 * Otherwise the new YANG data will be added to the previous data and may override it.
609 * @param[in] alg_count Number of following algorithms.
610 * @param[in] ... String literals of encryption algorithms in a decreasing order of preference.
611 * @return 0 on success, non-zero otherwise.
612 */
roman466719d2023-05-05 16:14:37 +0200613int 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 +0200614 int alg_count, ...);
615
616/**
roman8ba6efa2023-07-12 15:27:52 +0200617 * @brief Deletes an encryption algorithm from the YANG data.
618 *
619 * @param[in] endpt_name Identifier of an existing endpoint.
620 * @param[in] alg Optional algorithm to be deleted.
621 * If NULL, all of the encryption algorithms on this endpoint will be deleted.
roman35120972023-08-08 10:39:12 +0200622 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200623 * @return 0 on success, non-zero otherwise.
624 */
625int nc_server_config_new_ssh_del_encryption_alg(const char *endpt_name, const char *alg, struct lyd_node **config);
626
627/**
roman9b1379c2023-03-31 10:11:10 +0200628 * @brief Creates new YANG configuration data nodes for mac algorithms replacing any previous ones.
629 *
630 * Supported algorithms are: hmac-sha2-256, hmac-sha2-512 and hmac-sha1.
631 *
632 * @param[in] ctx libyang context
633 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200634 * If an endpoint with this identifier already exists, its mac algorithms will be replaced.
roman9b1379c2023-03-31 10:11:10 +0200635 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
636 * Otherwise the new YANG data will be added to the previous data and may override it.
637 * @param[in] alg_count Number of following algorithms.
638 * @param[in] ... String literals of mac algorithms in a decreasing order of preference.
639 * @return 0 on success, non-zero otherwise.
640 */
roman466719d2023-05-05 16:14:37 +0200641int 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 +0200642 int alg_count, ...);
643
644/**
roman8ba6efa2023-07-12 15:27:52 +0200645 * @brief Deletes a mac algorithm from the YANG data.
roman9b1379c2023-03-31 10:11:10 +0200646 *
roman8ba6efa2023-07-12 15:27:52 +0200647 * @param[in] endpt_name Identifier of an existing endpoint.
648 * @param[in] alg Optional algorithm to be deleted.
649 * If NULL, all of the mac algorithms on this endpoint will be deleted.
roman35120972023-08-08 10:39:12 +0200650 * @param[in,out] config Modified configuration YANG data tree.
roman9b1379c2023-03-31 10:11:10 +0200651 * @return 0 on success, non-zero otherwise.
652 */
roman8ba6efa2023-07-12 15:27:52 +0200653int 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 +0200654
655/**
roman35120972023-08-08 10:39:12 +0200656 * @} SSH Server Configuration
roman9b1379c2023-03-31 10:11:10 +0200657 */
roman9b1379c2023-03-31 10:11:10 +0200658
659/**
roman8ba6efa2023-07-12 15:27:52 +0200660 * @defgroup server_config_tls TLS Server Configuration
661 * @ingroup server_config
roman9b1379c2023-03-31 10:11:10 +0200662 *
roman8ba6efa2023-07-12 15:27:52 +0200663 * @brief TLS server configuration creation and deletion
664 * @{
roman9b1379c2023-03-31 10:11:10 +0200665 */
roman2e797ef2023-06-19 10:47:49 +0200666
667/**
roman3f9b65c2023-06-05 14:26:58 +0200668 * @brief Creates new YANG configuration data nodes for a server's certificate.
669 *
670 * @param[in] ctx libyang context.
671 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200672 * If an endpoint with this identifier already exists, its server certificate will be changed.
roman6c4efcd2023-08-08 10:18:44 +0200673 * @param[in] privkey_path Path to the server's PEM encoded private key file.
roman3f9b65c2023-06-05 14:26:58 +0200674 * @param[in] pubkey_path Optional path to the server's public key file. If not provided,
675 * it will be generated from the private key.
roman3f9b65c2023-06-05 14:26:58 +0200676 * @param[in] certificate_path Path to the server's certificate file.
677 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
678 * Otherwise the new YANG data will be added to the previous data and may override it.
679 * @return 0 on success, non-zero otherwise.
680 */
roman6c4efcd2023-08-08 10:18:44 +0200681int nc_server_config_new_tls_server_certificate(const struct ly_ctx *ctx, const char *endpt_name, const char *privkey_path,
682 const char *pubkey_path, const char *certificate_path, struct lyd_node **config);
roman3f9b65c2023-06-05 14:26:58 +0200683
684/**
roman8ba6efa2023-07-12 15:27:52 +0200685 * @brief Deletes the server's certificate from the YANG data.
686 *
687 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200688 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200689 * @return 0 on success, non-zero otherwise.
690 */
691int nc_server_config_new_tls_del_server_certificate(const char *endpt_name, struct lyd_node **config);
692
693/**
roman12c3d522023-07-26 13:39:30 +0200694 * @brief Creates new YANG configuration data nodes for a keystore reference to the TLS server's certificate.
695 *
696 * @param[in] ctx libyang context.
697 * @param[in] endpt_name Arbitrary identifier of the endpoint.
698 * If an endpoint with this identifier already exists, its contents will be changed.
699 * @param[in] asym_key_ref Name of the asymmetric key pair in the keystore to be referenced.
700 * @param[in] cert_ref Name of the certificate, which must belong to the given asymmetric key pair, to be referenced.
701 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
702 * Otherwise the new YANG data will be added to the previous data and may override it.
703 * @return 0 on success, non-zero otherwise.
704 */
roman67af8982023-08-08 10:56:04 +0200705int 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 +0200706 const char *cert_ref, struct lyd_node **config);
707
708/**
709 * @brief Deletes a TLS server certificate keystore reference from the YANG data.
710 *
711 * @param[in] endpt_name Identifier of an existing endpoint.
712 * @param[in,out] config Modified configuration YANG data tree.
713 * @return 0 on success, non-zero otherwise.
714 */
roman67af8982023-08-08 10:56:04 +0200715int nc_server_config_new_tls_del_keystore_ref(const char *endpt_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200716
717/**
roman3f9b65c2023-06-05 14:26:58 +0200718 * @brief Creates new YANG configuration data nodes for a client's (end-entity) certificate.
719 *
720 * @param[in] ctx libyang context.
721 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200722 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200723 * @param[in] cert_name Arbitrary identifier of the client's certificate.
roman35120972023-08-08 10:39:12 +0200724 * If a client certificate with this identifier already exists, it will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200725 * @param[in] cert_path Path to the client's certificate file.
726 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
727 * Otherwise the new YANG data will be added to the previous data and may override it.
728 * @return 0 on success, non-zero otherwise.
729 */
730int nc_server_config_new_tls_client_certificate(const struct ly_ctx *ctx, const char *endpt_name, const char *cert_name,
731 const char *cert_path, struct lyd_node **config);
732
733/**
roman8ba6efa2023-07-12 15:27:52 +0200734 * @brief Deletes a client (end-entity) certificate from the YANG data.
735 *
736 * @param[in] endpt_name Identifier of an existing endpoint.
737 * @param[in] cert_name Optional name of a certificate to be deleted.
738 * If NULL, all of the end-entity certificates on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200739 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200740 * @return 0 on success, non-zero otherwise.
741 */
742int nc_server_config_new_tls_del_client_certificate(const char *endpt_name, const char *cert_name, struct lyd_node **config);
743
744/**
roman12c3d522023-07-26 13:39:30 +0200745 * @brief Creates new YANG configuration data nodes for a truststore reference to a set of client (end-entity) certificates.
746 *
747 * @param[in] ctx libyang context.
748 * @param[in] endpt_name Arbitrary identifier of the endpoint.
749 * If an endpoint with this identifier already exists, its contents will be changed.
750 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
751 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
752 * Otherwise the new YANG data will be added to the previous data and may override it.
753 * @return 0 on success, non-zero otherwise.
754 */
755int nc_server_config_new_tls_client_cert_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name,
756 const char *cert_bag_ref, struct lyd_node **config);
757
758/**
759 * @brief Deletes a client (end-entity) certificates truststore reference from the YANG data.
760 *
761 * @param[in] endpt_name Identifier of an existing endpoint.
762 * @param[in,out] config Modified configuration YANG data tree.
763 * @return 0 on success, non-zero otherwise.
764 */
765int nc_server_config_new_tls_del_client_cert_truststore_ref(const char *endpt_name, struct lyd_node **config);
766
767/**
roman3f9b65c2023-06-05 14:26:58 +0200768 * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate.
769 *
770 * @param[in] ctx libyang context.
771 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200772 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200773 * @param[in] cert_name Arbitrary identifier of the certificate authority certificate.
roman35120972023-08-08 10:39:12 +0200774 * If a CA with this identifier already exists, it will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200775 * @param[in] cert_path Path to the CA certificate file.
776 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
777 * Otherwise the new YANG data will be added to the previous data and may override it.
778 * @return 0 on success, non-zero otherwise.
779 */
780int nc_server_config_new_tls_client_ca(const struct ly_ctx *ctx, const char *endpt_name, const char *cert_name,
781 const char *cert_path, struct lyd_node **config);
782
783/**
roman8ba6efa2023-07-12 15:27:52 +0200784 * @brief Deletes a client certificate authority (trust-anchor) certificate from the YANG data.
785 *
786 * @param[in] endpt_name Identifier of an existing endpoint.
787 * @param[in] cert_name Optional name of a certificate to be deleted.
788 * If NULL, all of the CA certificates on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200789 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200790 * @return 0 on success, non-zero otherwise.
791 */
792int nc_server_config_new_tls_del_client_ca(const char *endpt_name, const char *cert_name, struct lyd_node **config);
793
794/**
roman12c3d522023-07-26 13:39:30 +0200795 * @brief Creates new YANG configuration data nodes for a truststore reference to a set of client certificate authority (trust-anchor) certificates.
796 *
797 * @param[in] ctx libyang context.
798 * @param[in] endpt_name Arbitrary identifier of the endpoint.
799 * If an endpoint with this identifier already exists, its contents will be changed.
800 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
801 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
802 * Otherwise the new YANG data will be added to the previous data and may override it.
803 * @return 0 on success, non-zero otherwise.
804 */
805int nc_server_config_new_tls_client_ca_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name,
806 const char *cert_bag_ref, struct lyd_node **config);
807
808/**
809 * @brief Deletes a client certificate authority (trust-anchor) certificates truststore reference from the YANG data.
810 *
811 * @param[in] endpt_name Identifier of an existing endpoint.
812 * @param[in,out] config Modified configuration YANG data tree.
813 * @return 0 on success, non-zero otherwise.
814 */
815int nc_server_config_new_tls_del_client_ca_truststore_ref(const char *endpt_name, struct lyd_node **config);
816
817/**
roman3f9b65c2023-06-05 14:26:58 +0200818 * @brief Creates new YANG configuration data nodes for a cert-to-name entry.
819 *
820 * @param[in] ctx libyang context.
821 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200822 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200823 * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier).
824 * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is
825 * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry.
826 * @param[in] map_type Mapping username to the certificate option.
827 * @param[in] name Username for this cert-to-name entry.
828 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
829 * Otherwise the new YANG data will be added to the previous data and may override it.
830 * @return 0 on success, non-zero otherwise.
831 */
832int nc_server_config_new_tls_ctn(const struct ly_ctx *ctx, const char *endpt_name, uint32_t id, const char *fingerprint,
833 NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config);
834
roman12644fe2023-06-08 11:06:42 +0200835/**
roman8ba6efa2023-07-12 15:27:52 +0200836 * @brief Deletes a cert-to-name entry from the YANG data.
837 *
838 * @param[in] endpt_name Identifier of an existing endpoint.
839 * @param[in] id Optional ID of the CTN entry.
840 * If 0, all of the cert-to-name entries on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200841 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200842 * @return 0 on success, non-zero otherwise.
843 */
844int nc_server_config_new_tls_del_ctn(const char *endpt_name, uint32_t id, struct lyd_node **config);
845
846/**
roman12644fe2023-06-08 11:06:42 +0200847 * @brief Creates new YANG configuration data nodes for a TLS version.
848 *
849 * @param[in] ctx libyang context.
850 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200851 * If an endpoint with this identifier already exists, its contents will be changed.
roman12644fe2023-06-08 11:06:42 +0200852 * @param[in] tls_version TLS version to be used. Call this multiple times to set
853 * the accepted versions of the TLS protocol and let the client and server negotiate
854 * the given version.
855 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
856 * Otherwise the new YANG data will be added to the previous data and may override it.
857 * @return 0 on success, non-zero otherwise.
858 */
859int nc_server_config_new_tls_version(const struct ly_ctx *ctx, const char *endpt_name,
860 NC_TLS_VERSION tls_version, struct lyd_node **config);
861
862/**
roman8ba6efa2023-07-12 15:27:52 +0200863 * @brief Deletes a TLS version from the YANG data.
864 *
865 * @param[in] endpt_name Identifier of an existing endpoint.
866 * @param[in] tls_version TLS version to be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200867 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200868 * @return 0 on success, non-zero otherwise.
869 */
870int nc_server_config_new_tls_del_version(const char *endpt_name, NC_TLS_VERSION tls_version, struct lyd_node **config);
871
872/**
roman12644fe2023-06-08 11:06:42 +0200873 * @brief Creates new YANG configuration data nodes for a TLS cipher.
874 *
875 * @param[in] ctx libyang context.
876 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200877 * If an endpoint with this identifier already exists, its contents will be changed.
roman12644fe2023-06-08 11:06:42 +0200878 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
879 * Otherwise the new YANG data will be added to the previous data and may override it.
roman35120972023-08-08 10:39:12 +0200880 * @param[in] cipher_count Number of following ciphers.
roman12644fe2023-06-08 11:06:42 +0200881 * @param[in] ... TLS ciphers. These ciphers MUST be in the format as listed in the
882 * iana-tls-cipher-suite-algs YANG model (lowercase and separated by dashes). Regardless
883 * of the TLS protocol version used, all of these ciphers will be tried and some of them
884 * might not be set (TLS handshake might fail then). For the list of supported ciphers see
885 * the OpenSSL documentation.
886 * @return 0 on success, non-zero otherwise.
887 */
888int 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 +0200889 int cipher_count, ...);
roman12644fe2023-06-08 11:06:42 +0200890
romanfaecc582023-06-15 16:13:31 +0200891/**
roman8ba6efa2023-07-12 15:27:52 +0200892 * @brief Deletes a TLS cipher from the YANG data.
893 *
894 * @param[in] endpt_name Identifier of an existing endpoint.
895 * @param[in] cipher TLS cipher to be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200896 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200897 * @return 0 on success, non-zero otherwise.
898 */
899int nc_server_config_new_tls_del_cipher(const char *endpt_name, const char *cipher, struct lyd_node **config);
900
901/**
romanfaecc582023-06-15 16:13:31 +0200902 * @brief Creates new YANG configuration data nodes for a Certificate Revocation List via a local file.
903 *
904 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
905 * this function will remove any CRL YANG nodes created by the other two functions.
906 *
907 * @param[in] ctx libyang context.
908 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200909 * If an endpoint with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +0200910 * @param[in] crl_path Path to a DER/PEM encoded CRL file.
romanfaecc582023-06-15 16:13:31 +0200911 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
912 * Otherwise the new YANG data will be added to the previous data and may override it.
913 * @return 0 on success, non-zero otherwise.
914 */
roman9d5e5a52023-07-14 12:43:44 +0200915int nc_server_config_new_tls_crl_path(const struct ly_ctx *ctx, const char *endpt_name,
916 const char *crl_path, struct lyd_node **config);
romanfaecc582023-06-15 16:13:31 +0200917
918/**
919 * @brief Creates new YANG configuration data nodes for a Certificate Revocation List via an URL.
920 *
921 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
922 * this function will remove any CRL YANG nodes created by the other two functions.
923 *
924 * @param[in] ctx libyang context.
925 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200926 * If an endpoint with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +0200927 * @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 +0200928 * The allowed protocols are all the protocols supported by CURL.
929 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
930 * Otherwise the new YANG data will be added to the previous data and may override it.
931 * @return 0 on success, non-zero otherwise.
932 */
roman9d5e5a52023-07-14 12:43:44 +0200933int 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 +0200934
935/**
936 * @brief Creates new YANG configuration data nodes for a Certificate Revocation List via certificate extensions.
937 *
938 * The chain of configured Certificate Authorities will be examined. For each certificate in this chain all the
939 * CRLs from the URLs specified in their extension fields CRL Distribution Points will be downloaded and used.
roman9d5e5a52023-07-14 12:43:44 +0200940 *
romanfaecc582023-06-15 16:13:31 +0200941 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
942 * this function will remove any CRL YANG nodes created by the other two functions.
943 *
944 * @param[in] ctx libyang context.
945 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200946 * If an endpoint with this identifier already exists, its contents will be changed.
romanfaecc582023-06-15 16:13:31 +0200947 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
948 * Otherwise the new YANG data will be added to the previous data and may override it.
949 * @return 0 on success, non-zero otherwise.
950 */
951int nc_server_config_new_tls_crl_cert_ext(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config);
952
roman2e797ef2023-06-19 10:47:49 +0200953/**
roman8ba6efa2023-07-12 15:27:52 +0200954 * @brief Deletes all the CRL nodes from the YANG data.
955 *
956 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200957 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200958 * @return 0 on success, non-zero otherwise.
959 */
960int nc_server_config_new_tls_del_crl(const char *endpt_name, struct lyd_node **config);
961
962/**
roman2e797ef2023-06-19 10:47:49 +0200963 * @brief Creates new YANG configuration data nodes, which will be a reference to another TLS endpoint's certificates.
964 *
965 * Whenever an user tries to connect to the referencing endpoint, all of its certificates will be tried first. If no match is
966 * found, the referenced endpoint's configured certificates will be tried. The same applies to cert-to-name entries.
967 *
968 * @param[in] ctx libyang context
969 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200970 * If an endpoint with this identifier already exists, its contents will be changed.
roman2e797ef2023-06-19 10:47:49 +0200971 * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data
972 * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle.
973 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
974 * Otherwise the new YANG data will be added to the previous data and may override it.
975 * @return 0 on success, non-zero otherwise.
976 */
roman67af8982023-08-08 10:56:04 +0200977int nc_config_new_tls_endpoint_client_ref(const struct ly_ctx *ctx, const char *endpt_name,
roman2e797ef2023-06-19 10:47:49 +0200978 const char *referenced_endpt, struct lyd_node **config);
979
roman142718b2023-06-29 09:15:29 +0200980/**
roman8ba6efa2023-07-12 15:27:52 +0200981 * @brief Deletes reference to another TLS endpoint's users from the YANG data.
982 *
983 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200984 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200985 * @return 0 on success, non-zero otherwise.
986 */
roman67af8982023-08-08 10:56:04 +0200987int nc_config_new_tls_del_endpoint_client_ref(const char *endpt_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200988
989/**
roman35120972023-08-08 10:39:12 +0200990 * @} TLS Server Configuration
roman8ba6efa2023-07-12 15:27:52 +0200991 */
992
993/**
roman35120972023-08-08 10:39:12 +0200994 * @defgroup server_config_ch Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +0200995 * @ingroup server_config
996 *
Roytak2161df62023-08-02 15:04:42 +0200997 * @brief Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +0200998 * @{
999 */
1000
1001/**
roman35120972023-08-08 10:39:12 +02001002 * @} Call Home Server Configuration
1003 */
1004
1005/**
1006 * @defgroup server_config_ch_functions Call Home Server Configuration Functions
1007 * @ingroup server_config_ch
1008 *
1009 * @brief Call Home server configuration functions
1010 * @{
1011 */
1012
1013/**
Roytak2161df62023-08-02 15:04:42 +02001014 * @brief Creates new YANG configuration data nodes for a Call Home client's address and port.
roman142718b2023-06-29 09:15:29 +02001015 *
1016 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001017 * @param[in] client_name Arbitrary identifier of the Call Home client.
1018 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +02001019 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1020 * If the client's endpoint with this identifier already exists, its contents will be changed.
1021 * @param[in] transport Transport protocol to be used on this endpoint - either SSH or TLS.
1022 * @param[in] address Address to connect to.
1023 * @param[in] port Port to connect to.
1024 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1025 * Otherwise the new YANG data will be added to the previous data and may override it.
1026 * @return 0 on success, non-zero otherwise.
1027 */
roman8ba6efa2023-07-12 15:27:52 +02001028int 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 +02001029 NC_TRANSPORT_IMPL transport, const char *address, const char *port, struct lyd_node **config);
1030
roman8ba6efa2023-07-12 15:27:52 +02001031#endif /* NC_ENABLED_SSH_TLS */
1032
1033/**
Roytak2161df62023-08-02 15:04:42 +02001034 * @brief Deletes a Call Home client from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001035 *
1036 * @param[in] client_name Optional identifier of a client to be deleted.
Roytak2161df62023-08-02 15:04:42 +02001037 * If NULL, all of the Call Home clients will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001038 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001039 * @return 0 on success, non-zero otherwise.
1040 */
1041int nc_server_config_new_del_ch_client(const char *client_name, struct lyd_node **config);
1042
1043/**
Roytak2161df62023-08-02 15:04:42 +02001044 * @brief Deletes a Call Home endpoint from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001045 *
Roytak2161df62023-08-02 15:04:42 +02001046 * @param[in] client_name Identifier of an existing Call Home client.
roman8ba6efa2023-07-12 15:27:52 +02001047 * @param[in] endpt_name Optional identifier of a CH endpoint to be deleted.
1048 * If NULL, all of the CH endpoints which belong to the given client will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001049 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001050 * @return 0 on success, non-zero otherwise.
1051 */
1052int nc_server_config_new_ch_del_endpt(const char *client_name, const char *endpt_name, struct lyd_node **config);
1053
1054/**
Roytak2161df62023-08-02 15:04:42 +02001055 * @brief Creates new YANG configuration data nodes for the Call Home persistent connection type.
roman8ba6efa2023-07-12 15:27:52 +02001056 *
1057 * This is the default connection type. If periodic connection type was set before, it will be unset.
1058 *
1059 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001060 * @param[in] client_name Arbitrary identifier of the Call Home client.
1061 * If a Call Home client with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001062 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001063 * Otherwise the new YANG data will be added to the previous data and may override it.
1064 * @return 0 on success, non-zero otherwise.
1065 */
1066int nc_server_config_new_ch_persistent(const struct ly_ctx *ctx, const char *client_name, struct lyd_node **config);
1067
1068/**
Roytak2161df62023-08-02 15:04:42 +02001069 * @brief Creates new YANG configuration data nodes for the period parameter of the Call Home periodic connection type.
roman8ba6efa2023-07-12 15:27:52 +02001070 *
1071 * If called, the persistent connection type will be replaced by periodic.
1072 *
1073 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001074 * @param[in] client_name Arbitrary identifier of the Call Home client.
1075 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +02001076 * @param[in] period Duration between periodic connections in minutes.
Roytak9b32c0f2023-08-02 15:07:29 +02001077 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001078 * Otherwise the new YANG data will be added to the previous data and may override it.
1079 * @return 0 on success, non-zero otherwise.
1080 */
1081int nc_server_config_new_ch_period(const struct ly_ctx *ctx, const char *client_name, uint16_t period,
1082 struct lyd_node **config);
1083
1084/**
Roytak2161df62023-08-02 15:04:42 +02001085 * @brief Deletes the Call Home period parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001086 *
1087 * This behaves the same as setting the period to 60 minutes, which is the default value of this node.
1088 *
Roytak2161df62023-08-02 15:04:42 +02001089 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001090 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001091 * @return 0 on success, non-zero otherwise.
1092 */
1093int nc_server_config_new_ch_del_period(const char *client_name, struct lyd_node **config);
1094
1095/**
Roytak2161df62023-08-02 15:04:42 +02001096 * @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 +02001097 *
1098 * If called, the persistent connection type will be replaced by periodic.
1099 *
1100 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001101 * @param[in] client_name Arbitrary identifier of the Call Home client.
1102 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +02001103 * @param[in] anchor_time Timestamp before or after which a series of periodic connections are determined.
Roytak9b32c0f2023-08-02 15:07:29 +02001104 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001105 * Otherwise the new YANG data will be added to the previous data and may override it.
1106 * @return 0 on success, non-zero otherwise.
1107 */
1108int nc_server_config_new_ch_anchor_time(const struct ly_ctx *ctx, const char *client_name,
1109 const char *anchor_time, struct lyd_node **config);
1110
1111/**
Roytak2161df62023-08-02 15:04:42 +02001112 * @brief Deletes the Call Home anchor time parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001113 *
Roytak2161df62023-08-02 15:04:42 +02001114 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001115 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001116 * @return 0 on success, non-zero otherwise.
1117 */
1118int nc_server_config_new_ch_del_anchor_time(const char *client_name, struct lyd_node **config);
1119
1120/**
Roytak2161df62023-08-02 15:04:42 +02001121 * @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 +02001122 *
1123 * If called, the persistent connection type will be replaced by periodic.
1124 *
1125 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001126 * @param[in] client_name Arbitrary identifier of the Call Home client.
1127 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +02001128 * @param[in] idle_timeout Specifies the maximum number of seconds that a session may remain idle.
Roytak9b32c0f2023-08-02 15:07:29 +02001129 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001130 * Otherwise the new YANG data will be added to the previous data and may override it.
1131 * @return 0 on success, non-zero otherwise.
1132 */
1133int nc_server_config_new_ch_idle_timeout(const struct ly_ctx *ctx, const char *client_name,
1134 uint16_t idle_timeout, struct lyd_node **config);
1135
1136/**
Roytak2161df62023-08-02 15:04:42 +02001137 * @brief Deletes the Call Home idle timeout parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001138 *
1139 * This behaves the same as setting the timeout to 180 seconds, which is the default value of this node.
1140 *
Roytak2161df62023-08-02 15:04:42 +02001141 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001142 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001143 * @return 0 on success, non-zero otherwise.
1144 */
1145int nc_server_config_new_ch_del_idle_timeout(const char *client_name, struct lyd_node **config);
1146
1147/**
Roytak2161df62023-08-02 15:04:42 +02001148 * @brief Creates new YANG configuration data nodes for the Call Home reconnect strategy.
roman8ba6efa2023-07-12 15:27:52 +02001149 *
1150 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001151 * @param[in] client_name Arbitrary identifier of the Call Home client.
1152 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +02001153 * @param[in] start_with Specifies which endpoint to try if a connection is unsuccessful. Default value is NC_CH_FIRST_LISTED.
1154 * @param[in] max_wait The number of seconds after which a connection to an endpoint is deemed unsuccessful. Default value if 5.
1155 * @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 +02001156 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001157 * Otherwise the new YANG data will be added to the previous data and may override it.
1158 * @return 0 on success, non-zero otherwise.
1159 */
1160int nc_server_config_new_ch_reconnect_strategy(const struct ly_ctx *ctx, const char *client_name,
1161 NC_CH_START_WITH start_with, uint16_t max_wait, uint8_t max_attempts, struct lyd_node **config);
1162
1163/**
Roytak2161df62023-08-02 15:04:42 +02001164 * @brief Resets the values of the Call Home reconnect strategy nodes to their defaults.
roman8ba6efa2023-07-12 15:27:52 +02001165 *
1166 * The default values are: start-with = NC_CH_FIRST_LISTED, max-wait = 5 and max-attempts = 3.
1167 *
Roytak2161df62023-08-02 15:04:42 +02001168 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001169 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001170 * @return 0 on success, non-zero otherwise.
1171 */
1172int nc_server_config_new_ch_del_reconnect_strategy(const char *client_name, struct lyd_node **config);
1173
1174/**
roman35120972023-08-08 10:39:12 +02001175 * @} Call Home Server Configuration Functions
roman8ba6efa2023-07-12 15:27:52 +02001176 */
1177
1178#ifdef NC_ENABLED_SSH_TLS
1179
1180/**
Roytak2161df62023-08-02 15:04:42 +02001181 * @defgroup server_config_ch_ssh SSH Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001182 * @ingroup server_config_ch
1183 *
Roytak2161df62023-08-02 15:04:42 +02001184 * @brief SSH Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +02001185 * @{
1186 */
1187
roman142718b2023-06-29 09:15:29 +02001188/**
Roytak2161df62023-08-02 15:04:42 +02001189 * @brief Creates new YANG data nodes for a Call Home SSH hostkey.
roman142718b2023-06-29 09:15:29 +02001190 *
1191 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001192 * @param[in] client_name Arbitrary identifier of the Call Home client.
1193 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +02001194 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1195 * If the client's endpoint with this identifier already exists, its contents will be changed.
1196 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
1197 * If the endpoint's hostkey with this identifier already exists, its contents will be changed.
1198 * @param[in] privkey_path Path to a file containing a private key.
1199 * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
1200 * @param[in] pubkey_path Path to a file containing a public key. If NULL, public key will be
1201 * generated from the private key.
1202 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1203 * Otherwise the new YANG data will be added to the previous data and may override it.
1204 * @return 0 on success, non-zero otherwise.
1205 */
roman8ba6efa2023-07-12 15:27:52 +02001206int 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 +02001207 const char *hostkey_name, const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
1208
roman142718b2023-06-29 09:15:29 +02001209/**
Roytak2161df62023-08-02 15:04:42 +02001210 * @brief Deletes a Call Home hostkey from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001211 *
Roytak2161df62023-08-02 15:04:42 +02001212 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001213 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
roman8ba6efa2023-07-12 15:27:52 +02001214 * @param[in] hostkey_name Optional identifier of a hostkey to be deleted.
1215 * If NULL, all of the hostkeys on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001216 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001217 * @return 0 on success, non-zero otherwise.
1218 */
1219int nc_server_config_new_ch_ssh_del_hostkey(const char *client_name, const char *endpt_name,
1220 const char *hostkey_name, struct lyd_node **config);
1221
1222/**
roman9d5e5a52023-07-14 12:43:44 +02001223 * @brief Creates new YANG data nodes for a reference to an asymmetric key located in the keystore.
1224 *
Roytak2161df62023-08-02 15:04:42 +02001225 * This asymmetric key pair will be used as the Call Home SSH hostkey.
roman9d5e5a52023-07-14 12:43:44 +02001226 *
1227 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001228 * @param[in] client_name Arbitrary identifier of the Call Home client.
1229 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001230 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1231 * If the client's endpoint with this identifier already exists, its contents will be changed.
1232 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
1233 * If the endpoint's hostkey with this identifier already exists, its contents will be changed.
1234 * @param[in] keystore_reference Name of the asymmetric key pair to be referenced and used as a hostkey.
Roytak9b32c0f2023-08-02 15:07:29 +02001235 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001236 * Otherwise the new YANG data will be added to the previous data and may override it.
1237 * @return 0 on success, non-zero otherwise.
1238 */
roman67af8982023-08-08 10:56:04 +02001239int nc_server_config_new_ch_ssh_keystore_ref(const struct ly_ctx *ctx, const char *client_name,
roman9d5e5a52023-07-14 12:43:44 +02001240 const char *endpt_name, const char *hostkey_name, const char *keystore_reference, struct lyd_node **config);
1241
1242/**
Roytak2161df62023-08-02 15:04:42 +02001243 * @brief Deletes a Call Home keystore reference from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001244 *
Roytak2161df62023-08-02 15:04:42 +02001245 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001246 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1247 * @param[in] hostkey_name Identifier of an existing hostkey that belongs to the given CH endpoint.
Roytak9b32c0f2023-08-02 15:07:29 +02001248 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001249 * @return 0 on success, non-zero otherwise.
1250 */
roman67af8982023-08-08 10:56:04 +02001251int nc_server_config_new_ch_ssh_del_keystore_ref(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001252 const char *hostkey_name, struct lyd_node **config);
1253
1254/**
Roytak2161df62023-08-02 15:04:42 +02001255 * @brief Creates new YANG configuration data nodes for the maximum amount of failed Call Home SSH authentication attempts.
roman68404fd2023-07-24 10:40:59 +02001256 *
1257 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001258 * @param[in] client_name Arbitrary identifier of the Call Home client.
1259 * If a Call Home client with this identifier already exists, its contents will be changed.
roman68404fd2023-07-24 10:40:59 +02001260 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1261 * If the client's endpoint with this identifier already exists, its contents will be changed.
1262 * @param[in] auth_attempts Maximum amount of failed SSH authentication attempts after which a
1263 * client is disconnected. The default value is 3.
1264 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1265 * Otherwise the new YANG data will be added to the previous data and may override it.
1266 * @return 0 on success, non-zero otherwise.
1267 */
1268int nc_server_config_new_ch_ssh_auth_attempts(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1269 uint16_t auth_attempts, struct lyd_node **config);
1270
1271/**
Roytak2161df62023-08-02 15:04:42 +02001272 * @brief Creates new YANG configuration data nodes for a Call Home SSH authentication timeout.
roman68404fd2023-07-24 10:40:59 +02001273 *
1274 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001275 * @param[in] client_name Arbitrary identifier of the Call Home client.
1276 * If a Call Home client with this identifier already exists, its contents will be changed.
roman68404fd2023-07-24 10:40:59 +02001277 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1278 * If the client's endpoint with this identifier already exists, its contents will be changed.
1279 * @param[in] auth_timeout Maximum amount of time in seconds after which the authentication is deemed
1280 * unsuccessful. The default value is 10.
1281 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1282 * Otherwise the new YANG data will be added to the previous data and may override it.
1283 * @return 0 on success, non-zero otherwise.
1284 */
1285int nc_server_config_new_ch_ssh_auth_timeout(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1286 uint16_t auth_timeout, struct lyd_node **config);
1287
1288/**
Roytak2161df62023-08-02 15:04:42 +02001289 * @brief Creates new YANG data nodes for a Call Home SSH user's public key authentication method.
roman142718b2023-06-29 09:15:29 +02001290 *
1291 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001292 * @param[in] client_name Arbitrary identifier of the Call Home client.
1293 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +02001294 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1295 * If the client's endpoint with this identifier already exists, its contents will be changed.
1296 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1297 * If the endpoint's user with this identifier already exists, its contents will be changed.
1298 * @param[in] pubkey_name Arbitrary identifier of the user's public key.
1299 * If the user's public key with this identifier already exists, its contents will be changed.
1300 * @param[in] pubkey_path Path to a file containing a public key.
1301 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1302 * Otherwise the new YANG data will be added to the previous data and may override it.
1303 * @return 0 on success, non-zero otherwise.
1304 */
roman8ba6efa2023-07-12 15:27:52 +02001305int 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 +02001306 const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config);
1307
roman142718b2023-06-29 09:15:29 +02001308/**
Roytak2161df62023-08-02 15:04:42 +02001309 * @brief Deletes a Call Home SSH user's public key from the YANG data.
roman142718b2023-06-29 09:15:29 +02001310 *
Roytak2161df62023-08-02 15:04:42 +02001311 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001312 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1313 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
roman8ba6efa2023-07-12 15:27:52 +02001314 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
1315 * If NULL, all of the public keys which belong to the given SSH user will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001316 * @param[in,out] config Modified configuration YANG data tree.
roman142718b2023-06-29 09:15:29 +02001317 * @return 0 on success, non-zero otherwise.
1318 */
roman8ba6efa2023-07-12 15:27:52 +02001319int nc_server_config_new_ch_ssh_del_user_pubkey(const char *client_name, const char *endpt_name,
1320 const char *user_name, const char *pubkey_name, struct lyd_node **config);
roman5cbb6532023-06-22 12:53:17 +02001321
roman142718b2023-06-29 09:15:29 +02001322/**
Roytak2161df62023-08-02 15:04:42 +02001323 * @brief Creates new YANG data nodes for a Call Home SSH user's password authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001324 *
1325 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001326 * @param[in] client_name Arbitrary identifier of the Call Home client.
1327 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001328 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1329 * If the client's endpoint with this identifier already exists, its contents will be changed.
1330 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1331 * If the endpoint's user with this identifier already exists, its contents will be changed.
roman35120972023-08-08 10:39:12 +02001332 * @param[in] password Clear-text password to be set for the user. It will be hashed.
roman9d5e5a52023-07-14 12:43:44 +02001333 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1334 * Otherwise the new YANG data will be added to the previous data and may override it.
1335 * @return 0 on success, non-zero otherwise.
1336 */
1337int nc_server_config_new_ch_ssh_user_password(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1338 const char *user_name, const char *password, struct lyd_node **config);
1339
1340/**
Roytak2161df62023-08-02 15:04:42 +02001341 * @brief Deletes a Call Home SSH user's password from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001342 *
Roytak2161df62023-08-02 15:04:42 +02001343 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001344 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1345 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1346 * @param[in,out] config Modified configuration YANG data tree.
1347 * @return 0 on success, non-zero otherwise.
1348 */
1349int nc_server_config_new_ch_ssh_del_user_password(const char *client_name, const char *endpt_name,
1350 const char *user_name, struct lyd_node **config);
1351
1352/**
Roytak2161df62023-08-02 15:04:42 +02001353 * @brief Creates new YANG configuration data nodes for a Call Home SSH user's none authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001354 *
1355 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001356 * @param[in] client_name Arbitrary identifier of the Call Home client.
1357 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001358 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1359 * If the client's endpoint with this identifier already exists, its contents will be changed.
1360 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1361 * If the endpoint's user with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001362 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001363 * Otherwise the new YANG data will be added to the previous data and may override it.
1364 * @return 0 on success, non-zero otherwise.
1365 */
1366int nc_server_config_new_ch_ssh_user_none(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1367 const char *user_name, struct lyd_node **config);
1368
1369/**
Roytak2161df62023-08-02 15:04:42 +02001370 * @brief Deletes a Call Home SSH user's none authentication method from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001371 *
Roytak2161df62023-08-02 15:04:42 +02001372 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001373 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1374 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1375 * @param[in,out] config Modified configuration YANG data tree.
1376 * @return 0 on success, non-zero otherwise.
1377 */
1378int nc_server_config_new_ch_ssh_del_user_none(const char *client_name, const char *endpt_name,
1379 const char *user_name, struct lyd_node **config);
1380
1381/**
Roytak2161df62023-08-02 15:04:42 +02001382 * @brief Creates new YANG configuration data nodes for a Call Home SSH user's keyboard interactive authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001383 *
1384 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001385 * @param[in] client_name Arbitrary identifier of the Call Home client.
1386 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001387 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1388 * If the client's endpoint with this identifier already exists, its contents will be changed.
1389 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1390 * If the endpoint's user with this identifier already exists, its contents will be changed.
1391 * @param[in] pam_config_name Name of the PAM configuration file.
roman0f5fa422023-08-07 09:03:24 +02001392 * @param[in] pam_config_dir Optional. The absolute path to the directory in which the configuration file
1393 * 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 +02001394 * the path. If NULL is passed, then the PAM's system directories will be searched (usually /etc/pam.d/).
1395 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1396 * Otherwise the new YANG data will be added to the previous data and may override it.
1397 * @return 0 on success, non-zero otherwise.
1398 */
1399int nc_server_config_new_ch_ssh_user_interactive(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1400 const char *user_name, const char *pam_config_name, const char *pam_config_dir, struct lyd_node **config);
1401
1402/**
Roytak2161df62023-08-02 15:04:42 +02001403 * @brief Deletes a Call Home SSH user's keyboard interactive authentication from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001404 *
Roytak2161df62023-08-02 15:04:42 +02001405 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001406 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1407 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1408 * @param[in,out] config Modified configuration YANG data tree.
1409 * @return 0 on success, non-zero otherwise.
1410 */
1411int nc_server_config_new_ch_ssh_del_user_interactive(const char *client_name, const char *endpt_name,
1412 const char *user_name, struct lyd_node **config);
1413
1414/**
Roytak2161df62023-08-02 15:04:42 +02001415 * @brief Deletes a Call Home SSH user from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001416 *
Roytak2161df62023-08-02 15:04:42 +02001417 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001418 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1419 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1420 * @param[in,out] config Modified configuration YANG data tree.
1421 * @return 0 on success, non-zero otherwise.
1422 */
1423int nc_server_config_new_ch_ssh_del_user(const char *client_name, const char *endpt_name,
1424 const char *user_name, struct lyd_node **config);
1425
1426/**
1427 * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore.
1428 *
Roytak2161df62023-08-02 15:04:42 +02001429 * The public key's located in the bag will be used for Call Home SSH client authentication.
roman9d5e5a52023-07-14 12:43:44 +02001430 *
1431 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001432 * @param[in] client_name Arbitrary identifier of the Call Home client.
1433 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001434 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1435 * If the client's endpoint with this identifier already exists, its contents will be changed.
1436 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1437 * If the endpoint's user with this identifier already exists, its contents will be changed.
1438 * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication.
Roytak9b32c0f2023-08-02 15:07:29 +02001439 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001440 * Otherwise the new YANG data will be added to the previous data and may override it.
1441 * @return 0 on success, non-zero otherwise.
1442 */
roman67af8982023-08-08 10:56:04 +02001443int nc_server_config_new_ch_ssh_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
roman9d5e5a52023-07-14 12:43:44 +02001444 const char *endpt_name, const char *user_name, const char *truststore_reference, struct lyd_node **config);
1445
1446/**
Roytak2161df62023-08-02 15:04:42 +02001447 * @brief Deletes a Call Home SSH truststore reference from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001448 *
Roytak2161df62023-08-02 15:04:42 +02001449 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001450 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1451 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1452 * @param[in,out] config Modified configuration YANG data tree.
1453 * @return 0 on success, non-zero otherwise.
1454 */
roman67af8982023-08-08 10:56:04 +02001455int nc_server_config_new_ch_ssh_del_truststore_ref(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001456 const char *user_name, struct lyd_node **config);
1457
1458/**
Roytak2161df62023-08-02 15:04:42 +02001459 * @brief Creates new YANG configuration data nodes for Call Home host-key algorithms replacing any previous ones.
roman9d5e5a52023-07-14 12:43:44 +02001460 *
1461 * Supported algorithms are: ssh-ed25519, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521,
1462 * rsa-sha2-512, rsa-sha2-256, ssh-rsa and ssh-dss.
1463 *
1464 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001465 * @param[in] client_name Arbitrary identifier of the Call Home client.
1466 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001467 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1468 * If the client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001469 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001470 * Otherwise the new YANG data will be added to the previous data and may override it.
1471 * @param[in] alg_count Number of following algorithms.
1472 * @param[in] ... String literals of host-key algorithms in a decreasing order of preference.
1473 * @return 0 on success, non-zero otherwise.
1474 */
1475int nc_server_config_new_ch_ssh_host_key_algs(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1476 struct lyd_node **config, int alg_count, ...);
1477
1478/**
Roytak2161df62023-08-02 15:04:42 +02001479 * @brief Deletes a Call Home hostkey algorithm from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001480 *
Roytak2161df62023-08-02 15:04:42 +02001481 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001482 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1483 * @param[in] alg Optional algorithm to be deleted.
1484 * If NULL, all of the hostkey algorithms on this endpoint will be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001485 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001486 * @return 0 on success, non-zero otherwise.
1487 */
1488int nc_server_config_new_ch_ssh_del_host_key_alg(const char *client_name, const char *endpt_name,
1489 const char *alg, struct lyd_node **config);
1490
1491/**
Roytak2161df62023-08-02 15:04:42 +02001492 * @brief Creates new YANG configuration data nodes for Call Home key exchange algorithms replacing any previous ones.
roman9d5e5a52023-07-14 12:43:44 +02001493 *
1494 * Supported algorithms are: diffie-hellman-group-exchange-sha1, curve25519-sha256, ecdh-sha2-nistp256,
1495 * ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group18-sha512, diffie-hellman-group16-sha512,
1496 * diffie-hellman-group-exchange-sha256 and diffie-hellman-group14-sha256.
1497 *
1498 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001499 * @param[in] client_name Arbitrary identifier of the Call Home client.
1500 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001501 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1502 * If the client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001503 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001504 * Otherwise the new YANG data will be added to the previous data and may override it.
1505 * @param[in] alg_count Number of following algorithms.
1506 * @param[in] ... String literals of key exchange algorithms in a decreasing order of preference.
1507 * @return 0 on success, non-zero otherwise.
1508 */
1509int nc_server_config_new_ch_ssh_key_exchange_algs(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1510 struct lyd_node **config, int alg_count, ...);
1511
1512/**
Roytak2161df62023-08-02 15:04:42 +02001513 * @brief Deletes a Call Home key exchange algorithm from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001514 *
Roytak2161df62023-08-02 15:04:42 +02001515 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001516 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1517 * @param[in] alg Optional algorithm to be deleted.
1518 * If NULL, all of the key exchange algorithms on this endpoint will be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001519 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001520 * @return 0 on success, non-zero otherwise.
1521 */
1522int nc_server_config_new_ch_ssh_del_key_exchange_alg(const char *client_name, const char *endpt_name,
1523 const char *alg, struct lyd_node **config);
1524
1525/**
Roytak2161df62023-08-02 15:04:42 +02001526 * @brief Creates new YANG configuration data nodes for Call Home encryption algorithms replacing any previous ones.
roman9d5e5a52023-07-14 12:43:44 +02001527 *
1528 * Supported algorithms are: aes256-ctr, aes192-ctr, aes128-ctr, aes256-cbc, aes192-cbc, aes128-cbc, blowfish-cbc
1529 * triple-des-cbc and none.
1530 *
1531 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001532 * @param[in] client_name Arbitrary identifier of the Call Home client.
1533 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001534 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1535 * If the client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001536 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001537 * Otherwise the new YANG data will be added to the previous data and may override it.
1538 * @param[in] alg_count Number of following algorithms.
1539 * @param[in] ... String literals of encryption algorithms in a decreasing order of preference.
1540 * @return 0 on success, non-zero otherwise.
1541 */
1542int nc_server_config_new_ch_ssh_encryption_algs(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1543 struct lyd_node **config, int alg_count, ...);
1544
1545/**
Roytak2161df62023-08-02 15:04:42 +02001546 * @brief Deletes a Call Home encryption algorithm from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001547 *
Roytak2161df62023-08-02 15:04:42 +02001548 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001549 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1550 * @param[in] alg Optional algorithm to be deleted.
1551 * If NULL, all of the encryption algorithms on this endpoint will be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001552 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001553 * @return 0 on success, non-zero otherwise.
1554 */
1555int nc_server_config_new_ch_ssh_del_encryption_alg(const char *client_name, const char *endpt_name,
1556 const char *alg, struct lyd_node **config);
1557
1558/**
Roytak2161df62023-08-02 15:04:42 +02001559 * @brief Creates new YANG configuration data nodes for Call Home mac algorithms replacing any previous ones.
roman9d5e5a52023-07-14 12:43:44 +02001560 *
1561 * Supported algorithms are: hmac-sha2-256, hmac-sha2-512 and hmac-sha1.
1562 *
1563 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001564 * @param[in] client_name Arbitrary identifier of the Call Home client.
1565 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001566 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1567 * If the client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001568 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001569 * Otherwise the new YANG data will be added to the previous data and may override it.
1570 * @param[in] alg_count Number of following algorithms.
1571 * @param[in] ... String literals of mac algorithms in a decreasing order of preference.
1572 * @return 0 on success, non-zero otherwise.
1573 */
1574int nc_server_config_new_ch_ssh_mac_algs(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1575 struct lyd_node **config, int alg_count, ...);
1576
1577/**
Roytak2161df62023-08-02 15:04:42 +02001578 * @brief Deletes a Call Home mac algorithm from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001579 *
Roytak2161df62023-08-02 15:04:42 +02001580 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001581 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1582 * @param[in] alg Optional algorithm to be deleted.
1583 * If NULL, all of the mac algorithms on this endpoint will be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001584 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001585 * @return 0 on success, non-zero otherwise.
1586 */
1587int nc_server_config_new_ch_ssh_del_mac_alg(const char *client_name, const char *endpt_name,
1588 const char *alg, struct lyd_node **config);
1589
1590/**
roman35120972023-08-08 10:39:12 +02001591 * @} SSH Call Home Server Configuration
roman142718b2023-06-29 09:15:29 +02001592 */
roman142718b2023-06-29 09:15:29 +02001593
1594/**
Roytak2161df62023-08-02 15:04:42 +02001595 * @defgroup server_config_ch_tls TLS Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001596 * @ingroup server_config_ch
roman142718b2023-06-29 09:15:29 +02001597 *
Roytak2161df62023-08-02 15:04:42 +02001598 * @brief TLS Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +02001599 * @{
roman142718b2023-06-29 09:15:29 +02001600 */
roman142718b2023-06-29 09:15:29 +02001601
romanb6f44032023-06-30 15:07:56 +02001602/**
Roytak2161df62023-08-02 15:04:42 +02001603 * @brief Creates new YANG configuration data nodes for a Call Home server's certificate.
romanb6f44032023-06-30 15:07:56 +02001604 *
1605 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001606 * @param[in] client_name Arbitrary identifier of the Call Home client.
1607 * If a Call Home client with this identifier already exists, its contents will be changed.
1608 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1609 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman6c4efcd2023-08-08 10:18:44 +02001610 * @param[in] privkey_path Path to the server's PEM encoded private key file.
romanb6f44032023-06-30 15:07:56 +02001611 * @param[in] pubkey_path Optional path to the server's public key file. If not provided,
1612 * it will be generated from the private key.
romanb6f44032023-06-30 15:07:56 +02001613 * @param[in] certificate_path Path to the server's certificate file.
Roytak934edc32023-07-27 12:04:18 +02001614 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001615 * Otherwise the new YANG data will be added to the previous data and may override it.
1616 * @return 0 on success, non-zero otherwise.
1617 */
roman8ba6efa2023-07-12 15:27:52 +02001618int 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 +02001619 const char *privkey_path, const char *pubkey_path, const char *certificate_path, struct lyd_node **config);
romanb6f44032023-06-30 15:07:56 +02001620
1621/**
Roytak2161df62023-08-02 15:04:42 +02001622 * @brief Deletes a Call Home server certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001623 *
Roytak2161df62023-08-02 15:04:42 +02001624 * @param[in] client_name Identifier of an existing Call Home client.
1625 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman9d5e5a52023-07-14 12:43:44 +02001626 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001627 * @return 0 on success, non-zero otherwise.
1628 */
1629int nc_server_config_new_ch_tls_del_server_certificate(const char *client_name, const char *endpt_name,
1630 struct lyd_node **config);
1631
1632/**
Roytak934edc32023-07-27 12:04:18 +02001633 * @brief Creates new YANG configuration data nodes for a keystore reference to the Call Home TLS server's certificate.
1634 *
1635 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001636 * @param[in] client_name Arbitrary identifier of the Call Home client.
1637 * If a Call Home client with this identifier already exists, its contents will be changed.
1638 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1639 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
Roytak934edc32023-07-27 12:04:18 +02001640 * @param[in] asym_key_ref Name of the asymmetric key pair in the keystore to be referenced.
1641 * @param[in] cert_ref Name of the certificate, which must belong to the given asymmetric key pair, to be referenced.
1642 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1643 * Otherwise the new YANG data will be added to the previous data and may override it.
1644 * @return 0 on success, non-zero otherwise.
1645 */
roman67af8982023-08-08 10:56:04 +02001646int nc_server_config_new_ch_tls_keystore_ref(const struct ly_ctx *ctx, const char *client_name,
Roytak934edc32023-07-27 12:04:18 +02001647 const char *endpt_name, const char *asym_key_ref, const char *cert_ref, struct lyd_node **config);
1648
1649/**
1650 * @brief Deletes a TLS server certificate keystore reference from the YANG data.
1651 *
Roytak2161df62023-08-02 15:04:42 +02001652 * @param[in] client_name Identifier of an existing Call Home client.
1653 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
Roytak934edc32023-07-27 12:04:18 +02001654 * @param[in,out] config Modified configuration YANG data tree.
1655 * @return 0 on success, non-zero otherwise.
1656 */
roman67af8982023-08-08 10:56:04 +02001657int nc_server_config_new_ch_tls_del_keystore_ref(const char *client_name, const char *endpt_name,
Roytak934edc32023-07-27 12:04:18 +02001658 struct lyd_node **config);
1659
1660/**
Roytak2161df62023-08-02 15:04:42 +02001661 * @brief Creates new YANG configuration data nodes for a Call Home client's (end-entity) certificate.
romanb6f44032023-06-30 15:07:56 +02001662 *
1663 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001664 * @param[in] client_name Arbitrary identifier of the Call Home client.
1665 * If a Call Home client with this identifier already exists, its contents will be changed.
1666 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1667 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1668 * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's end-entity certificate.
1669 * 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 +02001670 * @param[in] cert_path Path to the certificate file.
Roytak934edc32023-07-27 12:04:18 +02001671 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001672 * Otherwise the new YANG data will be added to the previous data and may override it.
1673 * @return 0 on success, non-zero otherwise.
1674 */
roman8ba6efa2023-07-12 15:27:52 +02001675int 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 +02001676 const char *cert_name, const char *cert_path, struct lyd_node **config);
1677
1678/**
Roytak2161df62023-08-02 15:04:42 +02001679 * @brief Deletes a Call Home client (end-entity) certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001680 *
Roytak2161df62023-08-02 15:04:42 +02001681 * @param[in] client_name Identifier of an existing Call Home client.
1682 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman8ba6efa2023-07-12 15:27:52 +02001683 * @param[in] cert_name Optional identifier of a client certificate to be deleted.
1684 * If NULL, all of the client certificates will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001685 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001686 * @return 0 on success, non-zero otherwise.
1687 */
1688int nc_server_config_new_ch_tls_del_client_certificate(const char *client_name, const char *endpt_name,
1689 const char *cert_name, struct lyd_node **config);
1690
1691/**
Roytak934edc32023-07-27 12:04:18 +02001692 * @brief Creates new YANG configuration data nodes for a Call Home truststore reference to a set of client (end-entity) certificates.
1693 *
1694 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001695 * @param[in] client_name Arbitrary identifier of the Call Home client.
1696 * If a Call Home client with this identifier already exists, its contents will be changed.
1697 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1698 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
Roytak934edc32023-07-27 12:04:18 +02001699 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
1700 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1701 * Otherwise the new YANG data will be added to the previous data and may override it.
1702 * @return 0 on success, non-zero otherwise.
1703 */
1704int nc_server_config_new_ch_tls_client_cert_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
1705 const char *endpt_name, const char *cert_bag_ref, struct lyd_node **config);
1706
1707/**
1708 * @brief Deletes a Call Home client (end-entity) certificates truststore reference from the YANG data.
1709 *
Roytak2161df62023-08-02 15:04:42 +02001710 * @param[in] client_name Identifier of an existing Call Home client.
1711 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
Roytak934edc32023-07-27 12:04:18 +02001712 * @param[in,out] config Modified configuration YANG data tree.
1713 * @return 0 on success, non-zero otherwise.
1714 */
1715int nc_server_config_new_ch_tls_del_client_cert_truststore_ref(const char *client_name, const char *endpt_name,
1716 struct lyd_node **config);
1717
1718/**
romanb6f44032023-06-30 15:07:56 +02001719 * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate.
1720 *
1721 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001722 * @param[in] client_name Arbitrary identifier of the Call Home client.
1723 * If a Call Home client with this identifier already exists, its contents will be changed.
1724 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1725 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1726 * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's certificate authority certificate.
1727 * If an Call Home endpoint's CA certificate with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001728 * @param[in] cert_path Path to the certificate file.
Roytak9b32c0f2023-08-02 15:07:29 +02001729 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001730 * Otherwise the new YANG data will be added to the previous data and may override it.
1731 * @return 0 on success, non-zero otherwise.
1732 */
roman8ba6efa2023-07-12 15:27:52 +02001733int 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 +02001734 const char *cert_name, const char *cert_path, struct lyd_node **config);
1735
1736/**
Roytak2161df62023-08-02 15:04:42 +02001737 * @brief Deletes a Call Home client certificate authority (trust-anchor) certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001738 *
Roytak2161df62023-08-02 15:04:42 +02001739 * @param[in] client_name Identifier of an existing Call Home client.
1740 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman8ba6efa2023-07-12 15:27:52 +02001741 * @param[in] cert_name Optional identifier of a CA certificate to be deleted.
1742 * If NULL, all of the CA certificates will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001743 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001744 * @return 0 on success, non-zero otherwise.
1745 */
1746int nc_server_config_new_ch_tls_del_client_ca(const char *client_name, const char *endpt_name,
1747 const char *cert_name, struct lyd_node **config);
1748
1749/**
Roytak934edc32023-07-27 12:04:18 +02001750 * @brief Creates new YANG configuration data nodes for a Call Home truststore reference to a set of client certificate authority (trust-anchor) certificates.
1751 *
1752 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001753 * @param[in] client_name Arbitrary identifier of the Call Home client.
1754 * If a Call Home client with this identifier already exists, its contents will be changed.
1755 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1756 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
Roytak934edc32023-07-27 12:04:18 +02001757 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
1758 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1759 * Otherwise the new YANG data will be added to the previous data and may override it.
1760 * @return 0 on success, non-zero otherwise.
1761 */
1762int nc_server_config_new_ch_tls_client_ca_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
1763 const char *endpt_name, const char *cert_bag_ref, struct lyd_node **config);
1764
1765/**
1766 * @brief Deletes a Call Home client certificate authority (trust-anchor) certificates truststore reference from the YANG data.
1767 *
Roytak2161df62023-08-02 15:04:42 +02001768 * @param[in] client_name Identifier of an existing Call Home client.
1769 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
Roytak934edc32023-07-27 12:04:18 +02001770 * @param[in,out] config Modified configuration YANG data tree.
1771 * @return 0 on success, non-zero otherwise.
1772 */
1773int nc_server_config_new_ch_tls_del_client_ca_truststore_ref(const char *client_name, const char *endpt_name,
1774 struct lyd_node **config);
1775
1776/**
Roytak2161df62023-08-02 15:04:42 +02001777 * @brief Creates new YANG configuration data nodes for a Call Home cert-to-name entry.
romanb6f44032023-06-30 15:07:56 +02001778 *
1779 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001780 * @param[in] client_name Arbitrary identifier of the Call Home client.
1781 * If a Call Home client with this identifier already exists, its contents will be changed.
1782 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1783 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001784 * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier).
1785 * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is
1786 * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry.
1787 * @param[in] map_type Mapping username to the certificate option.
1788 * @param[in] name Username for this cert-to-name entry.
Roytak9b32c0f2023-08-02 15:07:29 +02001789 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001790 * Otherwise the new YANG data will be added to the previous data and may override it.
1791 * @return 0 on success, non-zero otherwise.
1792 */
roman8ba6efa2023-07-12 15:27:52 +02001793int 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 +02001794 uint32_t id, const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config);
1795
roman8ba6efa2023-07-12 15:27:52 +02001796/**
Roytak2161df62023-08-02 15:04:42 +02001797 * @brief Deletes a Call Home cert-to-name entry from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001798 *
Roytak2161df62023-08-02 15:04:42 +02001799 * @param[in] client_name Identifier of an existing Call Home client.
1800 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1801 * @param[in] id Optional identifier of the Call Home CTN entry to be deleted.
roman8ba6efa2023-07-12 15:27:52 +02001802 * If 0, all of the CTN entries will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001803 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001804 * @return 0 on success, non-zero otherwise.
1805 */
1806int nc_server_config_new_ch_tls_del_ctn(const char *client_name, const char *endpt_name,
1807 uint32_t id, struct lyd_node **config);
1808
1809/**
Roytak2161df62023-08-02 15:04:42 +02001810 * @brief Creates new YANG configuration data nodes for a Call Home TLS version.
roman9d5e5a52023-07-14 12:43:44 +02001811 *
1812 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001813 * @param[in] client_name Arbitrary identifier of the Call Home client.
1814 * If a Call Home client with this identifier already exists, its contents will be changed.
1815 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1816 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001817 * @param[in] tls_version TLS version to be used. Call this multiple times to set the accepted versions
1818 * of the TLS protocol and let the client and server negotiate the given version.
Roytak9b32c0f2023-08-02 15:07:29 +02001819 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001820 * Otherwise the new YANG data will be added to the previous data and may override it.
1821 * @return 0 on success, non-zero otherwise.
1822 */
1823int nc_server_config_new_ch_tls_version(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1824 NC_TLS_VERSION tls_version, struct lyd_node **config);
1825
1826/**
1827 * @brief Deletes a TLS version from the YANG data.
1828 *
Roytak2161df62023-08-02 15:04:42 +02001829 * @param[in] client_name Identifier of an existing Call Home client.
1830 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman9d5e5a52023-07-14 12:43:44 +02001831 * @param[in] tls_version TLS version to be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001832 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001833 * @return 0 on success, non-zero otherwise.
1834 */
1835int nc_server_config_new_ch_tls_del_version(const char *client_name, const char *endpt_name,
1836 NC_TLS_VERSION tls_version, struct lyd_node **config);
1837
1838/**
Roytak2161df62023-08-02 15:04:42 +02001839 * @brief Creates new YANG configuration data nodes for a Call Home TLS cipher.
roman9d5e5a52023-07-14 12:43:44 +02001840 *
1841 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001842 * @param[in] client_name Arbitrary identifier of the Call Home client.
1843 * If a Call Home client with this identifier already exists, its contents will be changed.
1844 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1845 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001846 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001847 * Otherwise the new YANG data will be added to the previous data and may override it.
1848 * @param[in] cipher_count Number of following ciphers.
1849 * @param[in] ... TLS ciphers. These ciphers MUST be in the format as listed in the
1850 * iana-tls-cipher-suite-algs YANG model (lowercase and separated by dashes). Regardless
1851 * of the TLS protocol version used, all of these ciphers will be tried and some of them
1852 * might not be set (TLS handshake might fail then). For the list of supported ciphers see
1853 * the OpenSSL documentation.
1854 * @return 0 on success, non-zero otherwise.
1855 */
1856int nc_server_config_new_ch_tls_ciphers(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1857 struct lyd_node **config, int cipher_count, ...);
1858
1859/**
Roytak2161df62023-08-02 15:04:42 +02001860 * @brief Deletes a Call Home TLS cipher from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001861 *
Roytak2161df62023-08-02 15:04:42 +02001862 * @param[in] client_name Identifier of an existing Call Home client.
1863 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman9d5e5a52023-07-14 12:43:44 +02001864 * @param[in] cipher TLS cipher to be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001865 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001866 * @return 0 on success, non-zero otherwise.
1867 */
1868int nc_server_config_new_ch_tls_del_cipher(const char *client_name, const char *endpt_name,
1869 const char *cipher, struct lyd_node **config);
1870
1871/**
Roytak2161df62023-08-02 15:04:42 +02001872 * @brief Creates new YANG configuration data nodes for a Call Home Certificate Revocation List via a local file.
roman9d5e5a52023-07-14 12:43:44 +02001873 *
1874 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
1875 * this function will remove any CRL YANG nodes created by the other two functions.
1876 *
1877 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001878 * @param[in] client_name Arbitrary identifier of the Call Home client.
1879 * If a Call Home client with this identifier already exists, its contents will be changed.
1880 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1881 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001882 * @param[in] crl_path Path to a DER/PEM encoded CRL file.
Roytak9b32c0f2023-08-02 15:07:29 +02001883 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001884 * Otherwise the new YANG data will be added to the previous data and may override it.
1885 * @return 0 on success, non-zero otherwise.
1886 */
1887int nc_server_config_new_ch_tls_crl_path(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1888 const char *crl_path, struct lyd_node **config);
1889
1890/**
Roytak2161df62023-08-02 15:04:42 +02001891 * @brief Creates new YANG configuration data nodes for a Call Home Certificate Revocation List via an URL.
roman9d5e5a52023-07-14 12:43:44 +02001892 *
1893 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
1894 * this function will remove any CRL YANG nodes created by the other two functions.
1895 *
1896 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001897 * @param[in] client_name Arbitrary identifier of the Call Home client.
1898 * If a Call Home client with this identifier already exists, its contents will be changed.
1899 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1900 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001901 * @param[in] crl_url URL from which the CRL file will be downloaded. The file has to be in the DER or PEM format.
1902 * The allowed protocols are all the protocols supported by CURL.
Roytak9b32c0f2023-08-02 15:07:29 +02001903 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001904 * Otherwise the new YANG data will be added to the previous data and may override it.
1905 * @return 0 on success, non-zero otherwise.
1906 */
1907int nc_server_config_new_ch_tls_crl_url(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1908 const char *crl_url, struct lyd_node **config);
1909
1910/**
Roytak2161df62023-08-02 15:04:42 +02001911 * @brief Creates new YANG configuration data nodes for a Call Home Certificate Revocation List via certificate extensions.
roman9d5e5a52023-07-14 12:43:44 +02001912 *
1913 * The chain of configured Certificate Authorities will be examined. For each certificate in this chain all the
1914 * CRLs from the URLs specified in their extension fields CRL Distribution Points will be downloaded and used.
1915 *
1916 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
1917 * this function will remove any CRL YANG nodes created by the other two functions.
1918 *
1919 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001920 * @param[in] client_name Arbitrary identifier of the Call Home client.
1921 * If a Call Home client with this identifier already exists, its contents will be changed.
1922 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1923 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001924 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001925 * Otherwise the new YANG data will be added to the previous data and may override it.
1926 * @return 0 on success, non-zero otherwise.
1927 */
1928int nc_server_config_new_ch_tls_crl_cert_ext(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1929 struct lyd_node **config);
1930
1931/**
1932 * @brief Deletes all the CRL nodes from the YANG data.
1933 *
Roytak2161df62023-08-02 15:04:42 +02001934 * @param[in] client_name Identifier of an existing Call Home client.
1935 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
Roytak9b32c0f2023-08-02 15:07:29 +02001936 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001937 * @return 0 on success, non-zero otherwise.
1938 */
1939int nc_server_config_new_ch_tls_del_crl(const char *client_name, const char *endpt_name, struct lyd_node **config);
1940
1941/**
roman35120972023-08-08 10:39:12 +02001942 * @} TLS Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001943 */
1944
roman2eab4742023-06-06 10:00:26 +02001945#endif /* NC_ENABLED_SSH_TLS */
roman45cec4e2023-02-17 10:21:39 +01001946
romanc1d2b092023-02-02 08:58:27 +01001947#ifdef __cplusplus
1948}
1949#endif
1950
1951#endif /* NC_SESSION_SERVER_H_ */