blob: e3a8544c914af56b2cc5d5e3fed52383c1c98b71 [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 *
roman6430c152023-10-12 11:28:47 +020063 * @param[in, out] ctx Optional context in which the modules will be implemented. Created if *ctx is null.
roman35120972023-08-08 10:39:12 +020064 * @return 0 on success, 1 on error.
65 */
66int nc_server_config_load_modules(struct ly_ctx **ctx);
67
68/**
roman6430c152023-10-12 11:28:47 +020069 * @brief Configure server based on the given diff.
romanc1d2b092023-02-02 08:58:27 +010070 *
roman6430c152023-10-12 11:28:47 +020071 * Context must already have implemented the required modules, see ::nc_server_config_load_modules().
romanc1d2b092023-02-02 08:58:27 +010072 *
roman6430c152023-10-12 11:28:47 +020073 * @param[in] diff YANG diff belonging to either ietf-netconf-server, ietf-keystore or ietf-truststore modules.
74 * This diff should be validated. The top level node HAS to have an operation (create, replace, delete or none).
romanc1d2b092023-02-02 08:58:27 +010075 * @return 0 on success, 1 on error.
76 */
romanf6f37a52023-05-25 14:27:51 +020077int nc_server_config_setup_diff(const struct lyd_node *diff);
romanc1d2b092023-02-02 08:58:27 +010078
79/**
romanf02273a2023-05-25 09:44:11 +020080 * @brief Configure server based on the given data.
81 *
romanf02273a2023-05-25 09:44:11 +020082 * Behaves as if all the nodes in data had the replace operation. That means that the current configuration will be deleted
roman6430c152023-10-12 11:28:47 +020083 * and just the given data will be applied.
roman0f5fa422023-08-07 09:03:24 +020084 * Context must already have implemented the required modules, see ::nc_server_config_load_modules().
romanf02273a2023-05-25 09:44:11 +020085 *
roman6430c152023-10-12 11:28:47 +020086 * @param[in] data YANG data belonging to either ietf-netconf-server, ietf-keystore or ietf-truststore modules.
87 * This data should be validated. No node can have an operation attribute.
romanf02273a2023-05-25 09:44:11 +020088 * @return 0 on success, 1 on error.
89 */
romanf6f37a52023-05-25 14:27:51 +020090int nc_server_config_setup_data(const struct lyd_node *data);
romanf02273a2023-05-25 09:44:11 +020091
92/**
roman6430c152023-10-12 11:28:47 +020093 * @brief Configure server based on the given data stored in a file.
94 *
roman0f5fa422023-08-07 09:03:24 +020095 * Wrapper around ::nc_server_config_setup_data() hiding work with parsing the data.
roman6430c152023-10-12 11:28:47 +020096 * Context must already have implemented the required modules, see ::nc_server_config_load_modules().
romanc1d2b092023-02-02 08:58:27 +010097 *
98 * @param[in] ctx libyang context.
roman6430c152023-10-12 11:28:47 +020099 * @param[in] path Path to a file with ietf-netconf-server, ietf-keystore or ietf-truststore YANG data.
romanc1d2b092023-02-02 08:58:27 +0100100 * @return 0 on success, 1 on error.
101 */
102int nc_server_config_setup_path(const struct ly_ctx *ctx, const char *path);
103
roman2eab4742023-06-06 10:00:26 +0200104#ifdef NC_ENABLED_SSH_TLS
105
romanc1d2b092023-02-02 08:58:27 +0100106/**
roman6430c152023-10-12 11:28:47 +0200107 * @brief Creates new YANG configuration data nodes for address and port.
roman9b1379c2023-03-31 10:11:10 +0200108 *
roman9b1379c2023-03-31 10:11:10 +0200109 * @param[in] ctx libyang context.
110 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman35120972023-08-08 10:39:12 +0200111 * If an endpoint with this identifier already exists, its contents might be changed.
roman3f9b65c2023-06-05 14:26:58 +0200112 * @param[in] transport Either SSH or TLS transport for the given endpoint.
113 * @param[in] address New listening address.
114 * @param[in] port New listening port.
roman9b1379c2023-03-31 10:11:10 +0200115 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
116 * Otherwise the new YANG data will be added to the previous data and may override it.
117 * @return 0 on success, non-zero otherwise.
roman45cec4e2023-02-17 10:21:39 +0100118 */
roman3f9b65c2023-06-05 14:26:58 +0200119int 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 +0200120 const char *address, uint16_t port, struct lyd_node **config);
roman3f9b65c2023-06-05 14:26:58 +0200121
roman8ba6efa2023-07-12 15:27:52 +0200122#endif /* NC_ENABLED_SSH_TLS */
123
124/**
romand0b78372023-09-14 10:06:03 +0200125 * @brief Creates new YANG data nodes for a UNIX socket.
126 *
127 * @param[in] ctx libyang context.
128 * @param[in] endpt_name Arbitrary identifier of the endpoint.
129 * If an endpoint with this identifier already exists, its contents might be changed.
130 * @param[in] path Path to the socket.
131 * @param[in] mode New mode, use -1 for default.
132 * @param[in] uid New uid, use -1 for default
133 * @param[in] gid New gid, use -1 for default
134 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
135 * Otherwise the new YANG data will be added to the previous data and may override it.
136 * @return 0 on success, non-zero otherwise.
137 */
138int nc_server_config_new_unix_socket(const struct ly_ctx *ctx, const char *endpt_name, const char *path,
139 mode_t mode, uid_t uid, gid_t gid, struct lyd_node **config);
140
141/**
roman8ba6efa2023-07-12 15:27:52 +0200142 * @brief Deletes an endpoint from the YANG data.
143 *
144 * @param[in] endpt_name Optional identifier of an endpoint to be deleted.
145 * If NULL, all of the endpoints will be deleted.
roman35120972023-08-08 10:39:12 +0200146 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200147 * @return 0 on success, non-zero otherwise.
148 */
149int nc_server_config_new_del_endpt(const char *endpt_name, struct lyd_node **config);
150
151#ifdef NC_ENABLED_SSH_TLS
152
153/**
154 * @brief Creates new YANG data nodes for an asymmetric key in the keystore.
155 *
156 * @param[in] ctx libyang context.
roman13145912023-08-17 15:36:54 +0200157 * @param[in] ti Transport in which the key pair will be used. Either SSH or TLS.
roman12c3d522023-07-26 13:39:30 +0200158 * @param[in] asym_key_name Identifier of the asymmetric key pair.
159 * This identifier is used to reference the key pair.
roman8ba6efa2023-07-12 15:27:52 +0200160 * @param[in] privkey_path Path to a private key file.
161 * @param[in] pubkey_path Optional path a public key file.
162 * If not supplied, it will be generated from the private key.
163 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
164 * Otherwise the new YANG data will be added to the previous data and may override it.
165 * @return 0 on success, non-zero otherwise.
166 */
roman13145912023-08-17 15:36:54 +0200167int nc_server_config_new_keystore_asym_key(const struct ly_ctx *ctx, NC_TRANSPORT_IMPL ti, const char *asym_key_name,
168 const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200169
170/**
171 * @brief Deletes a keystore's asymmetric key from the YANG data.
172 *
roman12c3d522023-07-26 13:39:30 +0200173 * @param[in] asym_key_name Optional identifier of the asymmetric key to be deleted.
roman8ba6efa2023-07-12 15:27:52 +0200174 * If NULL, all of the asymmetric keys in the keystore will be deleted.
175 * @param[in,out] config Configuration YANG data tree.
176 * @return 0 on success, non-zero otherwise.
177 */
roman12c3d522023-07-26 13:39:30 +0200178int nc_server_config_new_del_keystore_asym_key(const char *asym_key_name, struct lyd_node **config);
179
180/**
181 * @brief Creates new YANG data nodes for a certificate in the keystore.
182 *
roman6430c152023-10-12 11:28:47 +0200183 * A certificate can not exist without its asymmetric key, so you must create an asymmetric key
184 * with the same identifier you pass to this function.
roman12c3d522023-07-26 13:39:30 +0200185 *
186 * @param[in] ctx libyang context.
187 * @param[in] asym_key_name Arbitrary identifier of the asymmetric key.
188 * If an asymmetric key pair with this name already exists, its contents will be changed.
189 * @param[in] cert_name Arbitrary identifier of the key pair's certificate.
190 * If a certificate with this name already exists, its contents will be changed.
191 * @param[in] cert_path Path to the PEM encoded certificate file.
192 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
193 * Otherwise the new YANG data will be added to the previous data and may override it.
194 * @return 0 on success, non-zero otherwise.
195 */
196int nc_server_config_new_keystore_cert(const struct ly_ctx *ctx, const char *asym_key_name, const char *cert_name,
197 const char *cert_path, struct lyd_node **config);
198
199/**
200 * @brief Deletes a keystore's certificate from the YANG data.
201 *
202 * @param[in] asym_key_name Identifier of an existing asymmetric key pair.
203 * @param[in] cert_name Optional identifier of a certificate to be deleted.
204 * If NULL, all of the certificates belonging to the asymmetric key pair will be deleted.
205 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
206 * Otherwise the new YANG data will be added to the previous data and may override it.
207 * @return 0 on success, non-zero otherwise.
208 */
209int 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 +0200210
211/**
212 * @brief Creates new YANG data nodes for a public key in the truststore.
213 *
214 * @param[in] ctx libyang context.
roman12c3d522023-07-26 13:39:30 +0200215 * @param[in] pub_bag_name Arbitrary identifier of the public key bag.
roman8ba6efa2023-07-12 15:27:52 +0200216 * This name is used to reference the public keys in the bag.
217 * If a public key bag with this name already exists, its contents will be changed.
218 * @param[in] pubkey_name Arbitrary identifier of the public key.
roman12c3d522023-07-26 13:39:30 +0200219 * If a public key with this name already exists in the given bag, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +0200220 * @param[in] pubkey_path Path to a file containing a public key.
221 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
222 * Otherwise the new YANG data will be added to the previous data and may override it.
223 * @return 0 on success, non-zero otherwise.
224 */
roman12c3d522023-07-26 13:39:30 +0200225int 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 +0200226 const char *pubkey_path, struct lyd_node **config);
227
228/**
229 * @brief Deletes a truststore's public key from the YANG data.
230 *
roman12c3d522023-07-26 13:39:30 +0200231 * @param[in] pub_bag_name Identifier of an existing public key bag.
roman8ba6efa2023-07-12 15:27:52 +0200232 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
233 * If NULL, all of the public keys in the given bag will be deleted.
234 * @param[in,out] config Configuration YANG data tree.
235 * @return 0 on success, non-zero otherwise.
236 */
roman12c3d522023-07-26 13:39:30 +0200237int nc_server_config_new_del_truststore_pubkey(const char *pub_bag_name, const char *pubkey_name, struct lyd_node **config);
238
239/**
240 * @brief Creates new YANG data nodes for a certificate in the truststore.
241 *
242 * @param[in] ctx libyang context.
243 * @param[in] cert_bag_name Arbitrary identifier of the certificate bag.
244 * This name is used to reference the certificates in the bag.
245 * If a certificate bag with this name already exists, its contents will be changed.
246 * @param[in] cert_name Arbitrary identifier of the certificate.
247 * If a certificate with this name already exists in the given bag, its contents will be changed.
248 * @param[in] cert_path Path to a file containing a PEM encoded certificate.
249 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
250 * Otherwise the new YANG data will be added to the previous data and may override it.
251 * @return 0 on success, non-zero otherwise.
252 */
253int nc_server_config_new_truststore_cert(const struct ly_ctx *ctx, const char *cert_bag_name, const char *cert_name,
254 const char *cert_path, struct lyd_node **config);
255
256/**
257 * @brief Deletes a truststore's certificate from the YANG data.
258 *
259 * @param[in] cert_bag_name Identifier of an existing certificate bag.
260 * @param[in] cert_name Optional identifier of a certificate to be deleted.
261 * If NULL, all of the certificates in the given bag will be deleted.
262 * @param[in,out] config Configuration YANG data tree.
263 * @return 0 on success, non-zero otherwise.
264 */
265int nc_server_config_new_del_truststore_cert(const char *cert_bag_name,
266 const char *cert_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +0200267
268/**
roman35120972023-08-08 10:39:12 +0200269 * @} Server Configuration Functions
roman8ba6efa2023-07-12 15:27:52 +0200270 */
271
272/**
273 * @defgroup server_config_ssh SSH Server Configuration
274 * @ingroup server_config
275 *
276 * @brief SSH server configuration creation and deletion
277 * @{
278 */
279
roman3f9b65c2023-06-05 14:26:58 +0200280/**
281 * @brief Creates new YANG configuration data nodes for a hostkey.
282 *
283 * @param[in] ctx libyang context.
284 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200285 * If an endpoint with this identifier already exists, its hostkey might be changed.
roman3f9b65c2023-06-05 14:26:58 +0200286 * @param[in] hostkey_name Arbitrary identifier of the hostkey.
roman142718b2023-06-29 09:15:29 +0200287 * If a hostkey with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200288 * @param[in] privkey_path Path to a file containing a private key.
289 * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
roman35120972023-08-08 10:39:12 +0200290 * @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 +0200291 * generated from the private key.
292 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
293 * Otherwise the new YANG data will be added to the previous data and may override it.
294 * @return 0 on success, non-zero otherwise.
295 */
roman8ba6efa2023-07-12 15:27:52 +0200296int nc_server_config_new_ssh_hostkey(const struct ly_ctx *ctx, const char *endpt_name, const char *hostkey_name,
297 const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
298
299/**
300 * @brief Deletes a hostkey from the YANG data.
301 *
302 * @param[in] ctx libyang context.
303 * @param[in] endpt_name Identifier of an existing endpoint.
304 * @param[in] hostkey_name Optional identifier of the hostkey to be deleted.
305 * If NULL, all of the hostkeys on this endpoint will be deleted.
306 * @param[in,out] config Configuration YANG data tree.
307 * @return 0 on success, non-zero otherwise.
308 */
309int nc_server_config_new_ssh_del_hostkey(const struct ly_ctx *ctx, const char *endpt_name,
310 const char *hostkey_name, struct lyd_node **config);
311
312/**
313 * @brief Creates new YANG data nodes for a reference to an asymmetric key located in the keystore.
314 *
315 * This asymmetric key pair will be used as the SSH hostkey.
316 *
317 * @param[in] ctx libyang context.
318 * @param[in] endpt_name Arbitrary identifier of an endpoint.
319 * If an endpoint with this identifier already exists, its contents will be changed.
320 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
321 * If an endpoint's hostkey with this identifier already exists, its contents will be changed.
322 * @param[in] keystore_reference Name of the asymmetric key pair to be referenced and used as a hostkey.
323 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
324 * Otherwise the new YANG data will be added to the previous data and may override it.
325 * @return 0 on success, non-zero otherwise.
326 */
roman67af8982023-08-08 10:56:04 +0200327int 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 +0200328 const char *keystore_reference, struct lyd_node **config);
329
330/**
331 * @brief Deletes a keystore reference from the YANG data.
332 *
333 * @param[in] endpt_name Identifier of an existing endpoint.
334 * @param[in] hostkey_name Identifier of an existing hostkey on the given endpoint.
335 * @param[in,out] config Configuration YANG data tree.
336 * @return 0 on success, non-zero otherwise.
337 */
roman67af8982023-08-08 10:56:04 +0200338int nc_server_config_new_ssh_del_keystore_ref(const char *endpt_name, const char *hostkey_name,
roman8ba6efa2023-07-12 15:27:52 +0200339 struct lyd_node **config);
340
341/**
roman68404fd2023-07-24 10:40:59 +0200342 * @brief Creates new YANG configuration data nodes for the maximum amount of failed SSH authentication attempts.
343 *
344 * @param[in] ctx libyang context.
345 * @param[in] endpt_name Arbitrary identifier of the endpoint.
346 * If an endpoint with this identifier already exists, its contents might be changed.
347 * @param[in] auth_attempts Maximum amount of failed SSH authentication attempts after which a
348 * client is disconnected. The default value is 3.
349 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
350 * Otherwise the new YANG data will be added to the previous data and may override it.
351 * @return 0 on success, non-zero otherwise.
352 */
353int nc_server_config_new_ssh_auth_attempts(const struct ly_ctx *ctx, const char *endpt_name, uint16_t auth_attempts,
354 struct lyd_node **config);
355
356/**
357 * @brief Creates new YANG configuration data nodes for an SSH authentication timeout.
358 *
359 * @param[in] ctx libyang context.
360 * @param[in] endpt_name Arbitrary identifier of the endpoint.
361 * If an endpoint with this identifier already exists, its contents might be changed.
362 * @param[in] auth_timeout Maximum amount of time in seconds after which the authentication is deemed
363 * unsuccessful. The default value is 10.
364 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
365 * Otherwise the new YANG data will be added to the previous data and may override it.
366 * @return 0 on success, non-zero otherwise.
367 */
368int nc_server_config_new_ssh_auth_timeout(const struct ly_ctx *ctx, const char *endpt_name, uint16_t auth_timeout,
369 struct lyd_node **config);
370
371/**
roman8ba6efa2023-07-12 15:27:52 +0200372 * @brief Creates new YANG configuration data nodes for an SSH user's public key authentication method.
373 *
374 * @param[in] ctx libyang context.
375 * @param[in] endpt_name Arbitrary identifier of the endpoint.
376 * If an endpoint with this identifier already exists, its user might be changed.
377 * @param[in] user_name Arbitrary identifier of the user.
378 * If an user with this identifier already exists, its contents will be changed.
379 * @param[in] pubkey_name Arbitrary identifier of the user's public key.
380 * If a public key with this identifier already exists for this user, its contents will be changed.
381 * @param[in] pubkey_path Path to a file containing the user's public key.
382 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
383 * Otherwise the new YANG data will be added to the previous data and may override it.
384 * @return 0 on success, non-zero otherwise.
385 */
386int nc_server_config_new_ssh_user_pubkey(const struct ly_ctx *ctx, const char *endpt_name,
387 const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config);
388
389/**
390 * @brief Deletes an SSH user's public key from the YANG data.
391 *
392 * @param[in] endpt_name Identifier of an existing endpoint.
393 * @param[in] user_name Identifier of an existing user on the given endpoint.
394 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
395 * If NULL, all of the users public keys will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200396 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200397 * @return 0 on success, non-zero otherwise.
398 */
399int nc_server_config_new_ssh_del_user_pubkey(const char *endpt_name, const char *user_name,
400 const char *pubkey_name, struct lyd_node **config);
401
402/**
403 * @brief Creates new YANG configuration data nodes for an SSH user's password authentication method.
404 *
405 * @param[in] ctx libyang context.
406 * @param[in] endpt_name Arbitrary identifier of the endpoint.
407 * If an endpoint with this identifier already exists, its user might be changed.
408 * @param[in] user_name Arbitrary identifier of the user.
409 * If an user with this identifier already exists, its contents will be changed.
roman35120972023-08-08 10:39:12 +0200410 * @param[in] password Clear-text password to be set for the user. It will be hashed.
roman8ba6efa2023-07-12 15:27:52 +0200411 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
412 * Otherwise the new YANG data will be added to the previous data and may override it.
413 * @return 0 on success, non-zero otherwise.
414 */
415int nc_server_config_new_ssh_user_password(const struct ly_ctx *ctx, const char *endpt_name,
416 const char *user_name, const char *password, struct lyd_node **config);
417
418/**
419 * @brief Deletes an SSH user's password from the YANG data.
420 *
421 * @param[in] endpt_name Identifier of an existing endpoint.
422 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200423 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200424 * @return 0 on success, non-zero otherwise.
425 */
426int nc_server_config_new_ssh_del_user_password(const char *endpt_name, const char *user_name,
427 struct lyd_node **config);
428
429/**
430 * @brief Creates new YANG configuration data nodes for an SSH user's none authentication method.
431 *
432 * @param[in] ctx libyang context.
433 * @param[in] endpt_name Arbitrary identifier of the endpoint.
434 * If an endpoint with this identifier already exists, its user might be changed.
435 * @param[in] user_name Arbitrary identifier of the user.
436 * If an user with this identifier already exists, its contents will be changed.
437 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
438 * Otherwise the new YANG data will be added to the previous data and may override it.
439 * @return 0 on success, non-zero otherwise.
440 */
441int nc_server_config_new_ssh_user_none(const struct ly_ctx *ctx, const char *endpt_name,
442 const char *user_name, struct lyd_node **config);
443
444/**
445 * @brief Deletes an SSH user's none authentication method from the YANG data.
446 *
447 * @param[in] endpt_name Identifier of an existing endpoint.
448 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200449 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200450 * @return 0 on success, non-zero otherwise.
451 */
452int nc_server_config_new_ssh_del_user_none(const char *endpt_name, const char *user_name,
453 struct lyd_node **config);
454
455/**
456 * @brief Creates new YANG configuration data nodes for an SSH user's keyboard interactive authentication method.
457 *
458 * @param[in] ctx libyang context.
459 * @param[in] endpt_name Arbitrary identifier of the endpoint.
460 * If an endpoint with this identifier already exists, its user might be changed.
461 * @param[in] user_name Arbitrary identifier of the user.
462 * If an user with this identifier already exists, its contents will be changed.
463 * @param[in] pam_config_name Name of the PAM configuration file.
roman0f5fa422023-08-07 09:03:24 +0200464 * @param[in] pam_config_dir Optional. The absolute path to the directory in which the configuration file
465 * 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 +0200466 * the path. If NULL is passed, then the PAM's system directories will be searched (usually /etc/pam.d/).
467 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
468 * Otherwise the new YANG data will be added to the previous data and may override it.
469 * @return 0 on success, non-zero otherwise.
470 */
471int nc_server_config_new_ssh_user_interactive(const struct ly_ctx *ctx, const char *endpt_name,
472 const char *user_name, const char *pam_config_name, const char *pam_config_dir, struct lyd_node **config);
473
474/**
475 * @brief Deletes an SSH user's keyboard interactive authentication from the YANG data.
476 *
477 * @param[in] endpt_name Identifier of an existing endpoint.
478 * @param[in] user_name Identifier of an existing user on the given endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200479 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200480 * @return 0 on success, non-zero otherwise.
481 */
482int nc_server_config_new_ssh_del_user_interactive(const char *endpt_name, const char *user_name,
483 struct lyd_node **config);
484
485/**
486 * @brief Deletes an SSH user from the YANG data.
487 *
488 * @param[in] endpt_name Identifier of an existing endpoint.
489 * @param[in] user_name Optional identifier of an user to be deleted.
490 * If NULL, all of the users on this endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200491 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200492 * @return 0 on success, non-zero otherwise.
493 */
494int nc_server_config_new_ssh_del_user(const char *endpt_name,
495 const char *user_name, struct lyd_node **config);
496
497/**
498 * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore.
499 *
500 * The public key's located in the bag will be used for client authentication.
501 *
502 * @param[in] ctx libyang context.
503 * @param[in] endpt_name Arbitrary identifier of an endpoint.
504 * If an endpoint with this identifier already exists, its contents will be changed.
505 * @param[in] user_name Arbitrary identifier of the endpoint's user.
506 * If an endpoint's user with this identifier already exists, its contents will be changed.
507 * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication.
Roytak9b32c0f2023-08-02 15:07:29 +0200508 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +0200509 * Otherwise the new YANG data will be added to the previous data and may override it.
510 * @return 0 on success, non-zero otherwise.
511 */
roman67af8982023-08-08 10:56:04 +0200512int 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 +0200513 const char *truststore_reference, struct lyd_node **config);
514
515/**
516 * @brief Deletes a truststore reference from the YANG data.
517 *
518 * @param[in] endpt_name Identifier of an existing endpoint.
519 * @param[in] user_name Identifier of an user on the given endpoint whose truststore reference will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200520 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200521 * @return 0 on success, non-zero otherwise.
522 */
roman67af8982023-08-08 10:56:04 +0200523int nc_server_config_new_ssh_del_truststore_ref(const char *endpt_name, const char *user_name,
roman8ba6efa2023-07-12 15:27:52 +0200524 struct lyd_node **config);
525
526/**
527 * @brief Creates new YANG configuration data nodes, which will be a reference to another SSH endpoint's users.
528 *
529 * Whenever a client tries to connect to the referencing endpoint, all of its users will be tried first. If no match is
530 * found, the referenced endpoint's configured users will be tried.
531 *
532 * @param[in] ctx libyang context
533 * @param[in] endpt_name Arbitrary identifier of the endpoint.
534 * If an endpoint with this identifier already exists, its contents will be changed.
535 * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data
536 * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle.
537 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
538 * Otherwise the new YANG data will be added to the previous data and may override it.
539 * @return 0 on success, non-zero otherwise.
540 */
roman67af8982023-08-08 10:56:04 +0200541int nc_config_new_ssh_endpoint_user_ref(const struct ly_ctx *ctx, const char *endpt_name,
roman8ba6efa2023-07-12 15:27:52 +0200542 const char *referenced_endpt, struct lyd_node **config);
543
544/**
545 * @brief Deletes reference to another SSH endpoint's users from the YANG data.
546 *
547 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200548 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200549 * @return 0 on success, non-zero otherwise.
550 */
roman67af8982023-08-08 10:56:04 +0200551int nc_config_new_ssh_del_endpoint_user_ref(const char *endpt_name, struct lyd_node **config);
roman9b1379c2023-03-31 10:11:10 +0200552
553/**
554 * @brief Creates new YANG configuration data nodes for host-key algorithms replacing any previous ones.
555 *
556 * Supported algorithms are: ssh-ed25519, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521,
557 * rsa-sha2-512, rsa-sha2-256, ssh-rsa and ssh-dss.
558 *
559 * @param[in] ctx libyang context
560 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200561 * If an endpoint with this identifier already exists, its host-key algorithms will be replaced.
roman9b1379c2023-03-31 10:11:10 +0200562 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
563 * Otherwise the new YANG data will be added to the previous data and may override it.
564 * @param[in] alg_count Number of following algorithms.
565 * @param[in] ... String literals of host-key algorithms in a decreasing order of preference.
566 * @return 0 on success, non-zero otherwise.
567 */
roman466719d2023-05-05 16:14:37 +0200568int nc_server_config_new_ssh_host_key_algs(const struct ly_ctx *ctx, const char *endpt_name,
roman9b1379c2023-03-31 10:11:10 +0200569 struct lyd_node **config, int alg_count, ...);
570
571/**
roman8ba6efa2023-07-12 15:27:52 +0200572 * @brief Deletes a hostkey algorithm from the YANG data.
573 *
574 * @param[in] endpt_name Identifier of an existing endpoint.
575 * @param[in] alg Optional algorithm to be deleted.
576 * If NULL, all of the hostkey algorithms on this endpoint will be deleted.
roman35120972023-08-08 10:39:12 +0200577 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200578 * @return 0 on success, non-zero otherwise.
579 */
580int nc_server_config_new_ssh_del_host_key_alg(const char *endpt_name, const char *alg, struct lyd_node **config);
581
582/**
roman9b1379c2023-03-31 10:11:10 +0200583 * @brief Creates new YANG configuration data nodes for key exchange algorithms replacing any previous ones.
584 *
585 * Supported algorithms are: diffie-hellman-group-exchange-sha1, curve25519-sha256, ecdh-sha2-nistp256,
586 * ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group18-sha512, diffie-hellman-group16-sha512,
587 * diffie-hellman-group-exchange-sha256 and diffie-hellman-group14-sha256.
588 *
589 * @param[in] ctx libyang context
590 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200591 * If an endpoint with this identifier already exists, its key exchange algorithms will be replaced.
roman9b1379c2023-03-31 10:11:10 +0200592 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
593 * Otherwise the new YANG data will be added to the previous data and may override it.
594 * @param[in] alg_count Number of following algorithms.
595 * @param[in] ... String literals of key exchange algorithms in a decreasing order of preference.
596 * @return 0 on success, non-zero otherwise.
597 */
roman466719d2023-05-05 16:14:37 +0200598int 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 +0200599 int alg_count, ...);
600
601/**
roman8ba6efa2023-07-12 15:27:52 +0200602 * @brief Deletes a key exchange algorithm from the YANG data.
603 *
604 * @param[in] endpt_name Identifier of an existing endpoint.
605 * @param[in] alg Optional algorithm to be deleted.
606 * If NULL, all of the key exchange algorithms on this endpoint will be deleted.
roman35120972023-08-08 10:39:12 +0200607 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200608 * @return 0 on success, non-zero otherwise.
609 */
610int nc_server_config_new_ssh_del_key_exchange_alg(const char *endpt_name, const char *alg, struct lyd_node **config);
611
612/**
roman9b1379c2023-03-31 10:11:10 +0200613 * @brief Creates new YANG configuration data nodes for encryption algorithms replacing any previous ones.
614 *
615 * Supported algorithms are: aes256-ctr, aes192-ctr, aes128-ctr, aes256-cbc, aes192-cbc, aes128-cbc, blowfish-cbc
616 * triple-des-cbc and none.
617 *
618 * @param[in] ctx libyang context
619 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200620 * If an endpoint with this identifier already exists, its encryption algorithms will be replaced.
roman9b1379c2023-03-31 10:11:10 +0200621 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
622 * Otherwise the new YANG data will be added to the previous data and may override it.
623 * @param[in] alg_count Number of following algorithms.
624 * @param[in] ... String literals of encryption algorithms in a decreasing order of preference.
625 * @return 0 on success, non-zero otherwise.
626 */
roman466719d2023-05-05 16:14:37 +0200627int 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 +0200628 int alg_count, ...);
629
630/**
roman8ba6efa2023-07-12 15:27:52 +0200631 * @brief Deletes an encryption algorithm from the YANG data.
632 *
633 * @param[in] endpt_name Identifier of an existing endpoint.
634 * @param[in] alg Optional algorithm to be deleted.
635 * If NULL, all of the encryption algorithms on this endpoint will be deleted.
roman35120972023-08-08 10:39:12 +0200636 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200637 * @return 0 on success, non-zero otherwise.
638 */
639int nc_server_config_new_ssh_del_encryption_alg(const char *endpt_name, const char *alg, struct lyd_node **config);
640
641/**
roman9b1379c2023-03-31 10:11:10 +0200642 * @brief Creates new YANG configuration data nodes for mac algorithms replacing any previous ones.
643 *
644 * Supported algorithms are: hmac-sha2-256, hmac-sha2-512 and hmac-sha1.
645 *
646 * @param[in] ctx libyang context
647 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200648 * If an endpoint with this identifier already exists, its mac algorithms will be replaced.
roman9b1379c2023-03-31 10:11:10 +0200649 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
650 * Otherwise the new YANG data will be added to the previous data and may override it.
651 * @param[in] alg_count Number of following algorithms.
652 * @param[in] ... String literals of mac algorithms in a decreasing order of preference.
653 * @return 0 on success, non-zero otherwise.
654 */
roman466719d2023-05-05 16:14:37 +0200655int 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 +0200656 int alg_count, ...);
657
658/**
roman8ba6efa2023-07-12 15:27:52 +0200659 * @brief Deletes a mac algorithm from the YANG data.
roman9b1379c2023-03-31 10:11:10 +0200660 *
roman8ba6efa2023-07-12 15:27:52 +0200661 * @param[in] endpt_name Identifier of an existing endpoint.
662 * @param[in] alg Optional algorithm to be deleted.
663 * If NULL, all of the mac algorithms on this endpoint will be deleted.
roman35120972023-08-08 10:39:12 +0200664 * @param[in,out] config Modified configuration YANG data tree.
roman9b1379c2023-03-31 10:11:10 +0200665 * @return 0 on success, non-zero otherwise.
666 */
roman8ba6efa2023-07-12 15:27:52 +0200667int 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 +0200668
669/**
roman35120972023-08-08 10:39:12 +0200670 * @} SSH Server Configuration
roman9b1379c2023-03-31 10:11:10 +0200671 */
roman9b1379c2023-03-31 10:11:10 +0200672
673/**
roman8ba6efa2023-07-12 15:27:52 +0200674 * @defgroup server_config_tls TLS Server Configuration
675 * @ingroup server_config
roman9b1379c2023-03-31 10:11:10 +0200676 *
roman8ba6efa2023-07-12 15:27:52 +0200677 * @brief TLS server configuration creation and deletion
678 * @{
roman9b1379c2023-03-31 10:11:10 +0200679 */
roman2e797ef2023-06-19 10:47:49 +0200680
681/**
roman3f9b65c2023-06-05 14:26:58 +0200682 * @brief Creates new YANG configuration data nodes for a server's certificate.
683 *
684 * @param[in] ctx libyang context.
685 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200686 * If an endpoint with this identifier already exists, its server certificate will be changed.
roman6c4efcd2023-08-08 10:18:44 +0200687 * @param[in] privkey_path Path to the server's PEM encoded private key file.
roman3f9b65c2023-06-05 14:26:58 +0200688 * @param[in] pubkey_path Optional path to the server's public key file. If not provided,
689 * it will be generated from the private key.
roman3f9b65c2023-06-05 14:26:58 +0200690 * @param[in] certificate_path Path to the server's certificate file.
691 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
692 * Otherwise the new YANG data will be added to the previous data and may override it.
693 * @return 0 on success, non-zero otherwise.
694 */
roman6c4efcd2023-08-08 10:18:44 +0200695int nc_server_config_new_tls_server_certificate(const struct ly_ctx *ctx, const char *endpt_name, const char *privkey_path,
696 const char *pubkey_path, const char *certificate_path, struct lyd_node **config);
roman3f9b65c2023-06-05 14:26:58 +0200697
698/**
roman8ba6efa2023-07-12 15:27:52 +0200699 * @brief Deletes the server's certificate from the YANG data.
700 *
701 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200702 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200703 * @return 0 on success, non-zero otherwise.
704 */
705int nc_server_config_new_tls_del_server_certificate(const char *endpt_name, struct lyd_node **config);
706
707/**
roman12c3d522023-07-26 13:39:30 +0200708 * @brief Creates new YANG configuration data nodes for a keystore reference to the TLS server's certificate.
709 *
710 * @param[in] ctx libyang context.
711 * @param[in] endpt_name Arbitrary identifier of the endpoint.
712 * If an endpoint with this identifier already exists, its contents will be changed.
713 * @param[in] asym_key_ref Name of the asymmetric key pair in the keystore to be referenced.
714 * @param[in] cert_ref Name of the certificate, which must belong to the given asymmetric key pair, to be referenced.
715 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
716 * Otherwise the new YANG data will be added to the previous data and may override it.
717 * @return 0 on success, non-zero otherwise.
718 */
roman67af8982023-08-08 10:56:04 +0200719int 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 +0200720 const char *cert_ref, struct lyd_node **config);
721
722/**
723 * @brief Deletes a TLS server certificate keystore reference from the YANG data.
724 *
725 * @param[in] endpt_name Identifier of an existing endpoint.
726 * @param[in,out] config Modified configuration YANG data tree.
727 * @return 0 on success, non-zero otherwise.
728 */
roman67af8982023-08-08 10:56:04 +0200729int nc_server_config_new_tls_del_keystore_ref(const char *endpt_name, struct lyd_node **config);
roman12c3d522023-07-26 13:39:30 +0200730
731/**
roman3f9b65c2023-06-05 14:26:58 +0200732 * @brief Creates new YANG configuration data nodes for a client's (end-entity) certificate.
733 *
734 * @param[in] ctx libyang context.
735 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200736 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200737 * @param[in] cert_name Arbitrary identifier of the client's certificate.
roman35120972023-08-08 10:39:12 +0200738 * If a client certificate with this identifier already exists, it will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200739 * @param[in] cert_path Path to the client's certificate file.
740 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
741 * Otherwise the new YANG data will be added to the previous data and may override it.
742 * @return 0 on success, non-zero otherwise.
743 */
744int nc_server_config_new_tls_client_certificate(const struct ly_ctx *ctx, const char *endpt_name, const char *cert_name,
745 const char *cert_path, struct lyd_node **config);
746
747/**
roman8ba6efa2023-07-12 15:27:52 +0200748 * @brief Deletes a client (end-entity) certificate from the YANG data.
749 *
750 * @param[in] endpt_name Identifier of an existing endpoint.
751 * @param[in] cert_name Optional name of a certificate to be deleted.
752 * If NULL, all of the end-entity certificates on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200753 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200754 * @return 0 on success, non-zero otherwise.
755 */
756int nc_server_config_new_tls_del_client_certificate(const char *endpt_name, const char *cert_name, struct lyd_node **config);
757
758/**
roman12c3d522023-07-26 13:39:30 +0200759 * @brief Creates new YANG configuration data nodes for a truststore reference to a set of client (end-entity) certificates.
760 *
761 * @param[in] ctx libyang context.
762 * @param[in] endpt_name Arbitrary identifier of the endpoint.
763 * If an endpoint with this identifier already exists, its contents will be changed.
764 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
765 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
766 * Otherwise the new YANG data will be added to the previous data and may override it.
767 * @return 0 on success, non-zero otherwise.
768 */
769int nc_server_config_new_tls_client_cert_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name,
770 const char *cert_bag_ref, struct lyd_node **config);
771
772/**
773 * @brief Deletes a client (end-entity) certificates truststore reference from the YANG data.
774 *
775 * @param[in] endpt_name Identifier of an existing endpoint.
776 * @param[in,out] config Modified configuration YANG data tree.
777 * @return 0 on success, non-zero otherwise.
778 */
779int nc_server_config_new_tls_del_client_cert_truststore_ref(const char *endpt_name, struct lyd_node **config);
780
781/**
roman3f9b65c2023-06-05 14:26:58 +0200782 * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate.
783 *
784 * @param[in] ctx libyang context.
785 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200786 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200787 * @param[in] cert_name Arbitrary identifier of the certificate authority certificate.
roman35120972023-08-08 10:39:12 +0200788 * If a CA with this identifier already exists, it will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200789 * @param[in] cert_path Path to the CA certificate file.
790 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
791 * Otherwise the new YANG data will be added to the previous data and may override it.
792 * @return 0 on success, non-zero otherwise.
793 */
794int nc_server_config_new_tls_client_ca(const struct ly_ctx *ctx, const char *endpt_name, const char *cert_name,
795 const char *cert_path, struct lyd_node **config);
796
797/**
roman8ba6efa2023-07-12 15:27:52 +0200798 * @brief Deletes a client certificate authority (trust-anchor) certificate from the YANG data.
799 *
800 * @param[in] endpt_name Identifier of an existing endpoint.
801 * @param[in] cert_name Optional name of a certificate to be deleted.
802 * If NULL, all of the CA certificates on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200803 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200804 * @return 0 on success, non-zero otherwise.
805 */
806int nc_server_config_new_tls_del_client_ca(const char *endpt_name, const char *cert_name, struct lyd_node **config);
807
808/**
roman12c3d522023-07-26 13:39:30 +0200809 * @brief Creates new YANG configuration data nodes for a truststore reference to a set of client certificate authority (trust-anchor) certificates.
810 *
811 * @param[in] ctx libyang context.
812 * @param[in] endpt_name Arbitrary identifier of the endpoint.
813 * If an endpoint with this identifier already exists, its contents will be changed.
814 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
815 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
816 * Otherwise the new YANG data will be added to the previous data and may override it.
817 * @return 0 on success, non-zero otherwise.
818 */
819int nc_server_config_new_tls_client_ca_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name,
820 const char *cert_bag_ref, struct lyd_node **config);
821
822/**
823 * @brief Deletes a client certificate authority (trust-anchor) certificates truststore reference from the YANG data.
824 *
825 * @param[in] endpt_name Identifier of an existing endpoint.
826 * @param[in,out] config Modified configuration YANG data tree.
827 * @return 0 on success, non-zero otherwise.
828 */
829int nc_server_config_new_tls_del_client_ca_truststore_ref(const char *endpt_name, struct lyd_node **config);
830
831/**
Roytak76958912023-09-29 15:25:14 +0200832 * @brief Creates new YANG configuration data nodes, which will be a reference to another TLS endpoint's certificates.
833 *
834 * Whenever an user tries to connect to the referencing endpoint, all of its certificates will be tried first. If no match is
835 * found, the referenced endpoint's configured certificates will be tried. The same applies to cert-to-name entries.
836 *
837 * @param[in] ctx libyang context
838 * @param[in] endpt_name Arbitrary identifier of the endpoint.
839 * If an endpoint with this identifier already exists, its contents will be changed.
840 * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data
841 * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle.
842 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
843 * Otherwise the new YANG data will be added to the previous data and may override it.
844 * @return 0 on success, non-zero otherwise.
845 */
846int nc_config_new_tls_endpoint_client_ref(const struct ly_ctx *ctx, const char *endpt_name,
847 const char *referenced_endpt, struct lyd_node **config);
848
849/**
850 * @brief Deletes reference to another TLS endpoint's users from the YANG data.
851 *
852 * @param[in] endpt_name Identifier of an existing endpoint.
853 * @param[in,out] config Modified configuration YANG data tree.
854 * @return 0 on success, non-zero otherwise.
855 */
856int nc_config_new_tls_del_endpoint_client_ref(const char *endpt_name, struct lyd_node **config);
857
858/**
roman3f9b65c2023-06-05 14:26:58 +0200859 * @brief Creates new YANG configuration data nodes for a cert-to-name entry.
860 *
861 * @param[in] ctx libyang context.
862 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200863 * If an endpoint with this identifier already exists, its contents will be changed.
roman3f9b65c2023-06-05 14:26:58 +0200864 * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier).
865 * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is
866 * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry.
867 * @param[in] map_type Mapping username to the certificate option.
868 * @param[in] name Username for this cert-to-name entry.
869 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
870 * Otherwise the new YANG data will be added to the previous data and may override it.
871 * @return 0 on success, non-zero otherwise.
872 */
873int nc_server_config_new_tls_ctn(const struct ly_ctx *ctx, const char *endpt_name, uint32_t id, const char *fingerprint,
874 NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config);
875
roman12644fe2023-06-08 11:06:42 +0200876/**
roman8ba6efa2023-07-12 15:27:52 +0200877 * @brief Deletes a cert-to-name entry from the YANG data.
878 *
879 * @param[in] endpt_name Identifier of an existing endpoint.
880 * @param[in] id Optional ID of the CTN entry.
881 * If 0, all of the cert-to-name entries on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200882 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200883 * @return 0 on success, non-zero otherwise.
884 */
885int nc_server_config_new_tls_del_ctn(const char *endpt_name, uint32_t id, struct lyd_node **config);
886
887/**
roman12644fe2023-06-08 11:06:42 +0200888 * @brief Creates new YANG configuration data nodes for a TLS version.
889 *
890 * @param[in] ctx libyang context.
891 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200892 * If an endpoint with this identifier already exists, its contents will be changed.
roman12644fe2023-06-08 11:06:42 +0200893 * @param[in] tls_version TLS version to be used. Call this multiple times to set
894 * the accepted versions of the TLS protocol and let the client and server negotiate
895 * the given version.
896 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
897 * Otherwise the new YANG data will be added to the previous data and may override it.
898 * @return 0 on success, non-zero otherwise.
899 */
900int nc_server_config_new_tls_version(const struct ly_ctx *ctx, const char *endpt_name,
901 NC_TLS_VERSION tls_version, struct lyd_node **config);
902
903/**
roman8ba6efa2023-07-12 15:27:52 +0200904 * @brief Deletes a TLS version from the YANG data.
905 *
906 * @param[in] endpt_name Identifier of an existing endpoint.
907 * @param[in] tls_version TLS version to be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200908 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200909 * @return 0 on success, non-zero otherwise.
910 */
911int nc_server_config_new_tls_del_version(const char *endpt_name, NC_TLS_VERSION tls_version, struct lyd_node **config);
912
913/**
roman12644fe2023-06-08 11:06:42 +0200914 * @brief Creates new YANG configuration data nodes for a TLS cipher.
915 *
916 * @param[in] ctx libyang context.
917 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200918 * If an endpoint with this identifier already exists, its contents will be changed.
roman12644fe2023-06-08 11:06:42 +0200919 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
920 * Otherwise the new YANG data will be added to the previous data and may override it.
roman35120972023-08-08 10:39:12 +0200921 * @param[in] cipher_count Number of following ciphers.
roman12644fe2023-06-08 11:06:42 +0200922 * @param[in] ... TLS ciphers. These ciphers MUST be in the format as listed in the
923 * iana-tls-cipher-suite-algs YANG model (lowercase and separated by dashes). Regardless
924 * of the TLS protocol version used, all of these ciphers will be tried and some of them
925 * might not be set (TLS handshake might fail then). For the list of supported ciphers see
926 * the OpenSSL documentation.
927 * @return 0 on success, non-zero otherwise.
928 */
929int 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 +0200930 int cipher_count, ...);
roman12644fe2023-06-08 11:06:42 +0200931
romanfaecc582023-06-15 16:13:31 +0200932/**
roman8ba6efa2023-07-12 15:27:52 +0200933 * @brief Deletes a TLS cipher from the YANG data.
934 *
935 * @param[in] endpt_name Identifier of an existing endpoint.
936 * @param[in] cipher TLS cipher to be deleted.
roman9d5e5a52023-07-14 12:43:44 +0200937 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200938 * @return 0 on success, non-zero otherwise.
939 */
940int nc_server_config_new_tls_del_cipher(const char *endpt_name, const char *cipher, struct lyd_node **config);
941
942/**
romanfaecc582023-06-15 16:13:31 +0200943 * @brief Creates new YANG configuration data nodes for a Certificate Revocation List via a local file.
944 *
945 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
946 * this function will remove any CRL YANG nodes created by the other two functions.
947 *
948 * @param[in] ctx libyang context.
949 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200950 * If an endpoint with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +0200951 * @param[in] crl_path Path to a DER/PEM encoded CRL file.
romanfaecc582023-06-15 16:13:31 +0200952 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
953 * Otherwise the new YANG data will be added to the previous data and may override it.
954 * @return 0 on success, non-zero otherwise.
955 */
roman9d5e5a52023-07-14 12:43:44 +0200956int nc_server_config_new_tls_crl_path(const struct ly_ctx *ctx, const char *endpt_name,
957 const char *crl_path, struct lyd_node **config);
romanfaecc582023-06-15 16:13:31 +0200958
959/**
960 * @brief Creates new YANG configuration data nodes for a Certificate Revocation List via an URL.
961 *
962 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
963 * this function will remove any CRL YANG nodes created by the other two functions.
964 *
965 * @param[in] ctx libyang context.
966 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200967 * If an endpoint with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +0200968 * @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 +0200969 * The allowed protocols are all the protocols supported by CURL.
970 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
971 * Otherwise the new YANG data will be added to the previous data and may override it.
972 * @return 0 on success, non-zero otherwise.
973 */
roman9d5e5a52023-07-14 12:43:44 +0200974int 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 +0200975
976/**
977 * @brief Creates new YANG configuration data nodes for a Certificate Revocation List via certificate extensions.
978 *
979 * The chain of configured Certificate Authorities will be examined. For each certificate in this chain all the
980 * CRLs from the URLs specified in their extension fields CRL Distribution Points will be downloaded and used.
roman9d5e5a52023-07-14 12:43:44 +0200981 *
romanfaecc582023-06-15 16:13:31 +0200982 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
983 * this function will remove any CRL YANG nodes created by the other two functions.
984 *
985 * @param[in] ctx libyang context.
986 * @param[in] endpt_name Arbitrary identifier of the endpoint.
roman142718b2023-06-29 09:15:29 +0200987 * If an endpoint with this identifier already exists, its contents will be changed.
romanfaecc582023-06-15 16:13:31 +0200988 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
989 * Otherwise the new YANG data will be added to the previous data and may override it.
990 * @return 0 on success, non-zero otherwise.
991 */
992int nc_server_config_new_tls_crl_cert_ext(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config);
993
roman2e797ef2023-06-19 10:47:49 +0200994/**
roman8ba6efa2023-07-12 15:27:52 +0200995 * @brief Deletes all the CRL nodes from the YANG data.
996 *
997 * @param[in] endpt_name Identifier of an existing endpoint.
roman9d5e5a52023-07-14 12:43:44 +0200998 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +0200999 * @return 0 on success, non-zero otherwise.
1000 */
1001int nc_server_config_new_tls_del_crl(const char *endpt_name, struct lyd_node **config);
1002
1003/**
roman35120972023-08-08 10:39:12 +02001004 * @} TLS Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001005 */
1006
1007/**
roman35120972023-08-08 10:39:12 +02001008 * @defgroup server_config_ch Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001009 * @ingroup server_config
1010 *
Roytak2161df62023-08-02 15:04:42 +02001011 * @brief Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +02001012 * @{
1013 */
1014
1015/**
roman35120972023-08-08 10:39:12 +02001016 * @} Call Home Server Configuration
1017 */
1018
1019/**
1020 * @defgroup server_config_ch_functions Call Home Server Configuration Functions
1021 * @ingroup server_config_ch
1022 *
1023 * @brief Call Home server configuration functions
1024 * @{
1025 */
1026
1027/**
Roytak2161df62023-08-02 15:04:42 +02001028 * @brief Creates new YANG configuration data nodes for a Call Home client's address and port.
roman142718b2023-06-29 09:15:29 +02001029 *
1030 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001031 * @param[in] client_name Arbitrary identifier of the Call Home client.
1032 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +02001033 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1034 * If the client's endpoint with this identifier already exists, its contents will be changed.
1035 * @param[in] transport Transport protocol to be used on this endpoint - either SSH or TLS.
1036 * @param[in] address Address to connect to.
1037 * @param[in] port Port to connect to.
1038 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1039 * Otherwise the new YANG data will be added to the previous data and may override it.
1040 * @return 0 on success, non-zero otherwise.
1041 */
roman8ba6efa2023-07-12 15:27:52 +02001042int 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 +02001043 NC_TRANSPORT_IMPL transport, const char *address, const char *port, struct lyd_node **config);
1044
roman8ba6efa2023-07-12 15:27:52 +02001045#endif /* NC_ENABLED_SSH_TLS */
1046
1047/**
Roytak2161df62023-08-02 15:04:42 +02001048 * @brief Deletes a Call Home client from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001049 *
1050 * @param[in] client_name Optional identifier of a client to be deleted.
Roytak2161df62023-08-02 15:04:42 +02001051 * If NULL, all of the Call Home clients will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001052 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001053 * @return 0 on success, non-zero otherwise.
1054 */
Roytak7b9bf292023-10-04 14:06:38 +02001055int nc_server_config_new_ch_del_ch_client(const char *client_name, struct lyd_node **config);
roman8ba6efa2023-07-12 15:27:52 +02001056
1057/**
Roytak2161df62023-08-02 15:04:42 +02001058 * @brief Deletes a Call Home endpoint from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001059 *
Roytak2161df62023-08-02 15:04:42 +02001060 * @param[in] client_name Identifier of an existing Call Home client.
roman8ba6efa2023-07-12 15:27:52 +02001061 * @param[in] endpt_name Optional identifier of a CH endpoint to be deleted.
1062 * If NULL, all of the CH endpoints which belong to the given client will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001063 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001064 * @return 0 on success, non-zero otherwise.
1065 */
1066int nc_server_config_new_ch_del_endpt(const char *client_name, const char *endpt_name, struct lyd_node **config);
1067
1068/**
Roytak2161df62023-08-02 15:04:42 +02001069 * @brief Creates new YANG configuration data nodes for the Call Home persistent connection type.
roman8ba6efa2023-07-12 15:27:52 +02001070 *
1071 * This is the default connection type. If periodic connection type was set before, it will be unset.
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.
Roytak9b32c0f2023-08-02 15:07:29 +02001076 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001077 * Otherwise the new YANG data will be added to the previous data and may override it.
1078 * @return 0 on success, non-zero otherwise.
1079 */
1080int nc_server_config_new_ch_persistent(const struct ly_ctx *ctx, const char *client_name, struct lyd_node **config);
1081
1082/**
Roytak2161df62023-08-02 15:04:42 +02001083 * @brief Creates new YANG configuration data nodes for the period parameter of the Call Home periodic connection type.
roman8ba6efa2023-07-12 15:27:52 +02001084 *
1085 * If called, the persistent connection type will be replaced by periodic.
1086 *
1087 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001088 * @param[in] client_name Arbitrary identifier of the Call Home client.
1089 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +02001090 * @param[in] period Duration between periodic connections in minutes.
Roytak9b32c0f2023-08-02 15:07:29 +02001091 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001092 * Otherwise the new YANG data will be added to the previous data and may override it.
1093 * @return 0 on success, non-zero otherwise.
1094 */
1095int nc_server_config_new_ch_period(const struct ly_ctx *ctx, const char *client_name, uint16_t period,
1096 struct lyd_node **config);
1097
1098/**
Roytak2161df62023-08-02 15:04:42 +02001099 * @brief Deletes the Call Home period parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001100 *
1101 * This behaves the same as setting the period to 60 minutes, which is the default value of this node.
1102 *
Roytak2161df62023-08-02 15:04:42 +02001103 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001104 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001105 * @return 0 on success, non-zero otherwise.
1106 */
1107int nc_server_config_new_ch_del_period(const char *client_name, struct lyd_node **config);
1108
1109/**
Roytak2161df62023-08-02 15:04:42 +02001110 * @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 +02001111 *
1112 * If called, the persistent connection type will be replaced by periodic.
1113 *
1114 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001115 * @param[in] client_name Arbitrary identifier of the Call Home client.
1116 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +02001117 * @param[in] anchor_time Timestamp before or after which a series of periodic connections are determined.
Roytak9b32c0f2023-08-02 15:07:29 +02001118 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001119 * Otherwise the new YANG data will be added to the previous data and may override it.
1120 * @return 0 on success, non-zero otherwise.
1121 */
1122int nc_server_config_new_ch_anchor_time(const struct ly_ctx *ctx, const char *client_name,
1123 const char *anchor_time, struct lyd_node **config);
1124
1125/**
Roytak2161df62023-08-02 15:04:42 +02001126 * @brief Deletes the Call Home anchor time parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001127 *
Roytak2161df62023-08-02 15:04:42 +02001128 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001129 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001130 * @return 0 on success, non-zero otherwise.
1131 */
1132int nc_server_config_new_ch_del_anchor_time(const char *client_name, struct lyd_node **config);
1133
1134/**
Roytak2161df62023-08-02 15:04:42 +02001135 * @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 +02001136 *
1137 * If called, the persistent connection type will be replaced by periodic.
1138 *
1139 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001140 * @param[in] client_name Arbitrary identifier of the Call Home client.
1141 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +02001142 * @param[in] idle_timeout Specifies the maximum number of seconds that a session may remain idle.
Roytak9b32c0f2023-08-02 15:07:29 +02001143 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001144 * Otherwise the new YANG data will be added to the previous data and may override it.
1145 * @return 0 on success, non-zero otherwise.
1146 */
1147int nc_server_config_new_ch_idle_timeout(const struct ly_ctx *ctx, const char *client_name,
1148 uint16_t idle_timeout, struct lyd_node **config);
1149
1150/**
Roytak2161df62023-08-02 15:04:42 +02001151 * @brief Deletes the Call Home idle timeout parameter of the periodic connection type from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001152 *
1153 * This behaves the same as setting the timeout to 180 seconds, which is the default value of this node.
1154 *
Roytak2161df62023-08-02 15:04:42 +02001155 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001156 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001157 * @return 0 on success, non-zero otherwise.
1158 */
1159int nc_server_config_new_ch_del_idle_timeout(const char *client_name, struct lyd_node **config);
1160
1161/**
Roytak2161df62023-08-02 15:04:42 +02001162 * @brief Creates new YANG configuration data nodes for the Call Home reconnect strategy.
roman8ba6efa2023-07-12 15:27:52 +02001163 *
1164 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001165 * @param[in] client_name Arbitrary identifier of the Call Home client.
1166 * If a Call Home client with this identifier already exists, its contents will be changed.
roman8ba6efa2023-07-12 15:27:52 +02001167 * @param[in] start_with Specifies which endpoint to try if a connection is unsuccessful. Default value is NC_CH_FIRST_LISTED.
1168 * @param[in] max_wait The number of seconds after which a connection to an endpoint is deemed unsuccessful. Default value if 5.
1169 * @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 +02001170 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman8ba6efa2023-07-12 15:27:52 +02001171 * Otherwise the new YANG data will be added to the previous data and may override it.
1172 * @return 0 on success, non-zero otherwise.
1173 */
1174int nc_server_config_new_ch_reconnect_strategy(const struct ly_ctx *ctx, const char *client_name,
1175 NC_CH_START_WITH start_with, uint16_t max_wait, uint8_t max_attempts, struct lyd_node **config);
1176
1177/**
Roytak2161df62023-08-02 15:04:42 +02001178 * @brief Resets the values of the Call Home reconnect strategy nodes to their defaults.
roman8ba6efa2023-07-12 15:27:52 +02001179 *
1180 * The default values are: start-with = NC_CH_FIRST_LISTED, max-wait = 5 and max-attempts = 3.
1181 *
Roytak2161df62023-08-02 15:04:42 +02001182 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001183 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001184 * @return 0 on success, non-zero otherwise.
1185 */
1186int nc_server_config_new_ch_del_reconnect_strategy(const char *client_name, struct lyd_node **config);
1187
1188/**
roman35120972023-08-08 10:39:12 +02001189 * @} Call Home Server Configuration Functions
roman8ba6efa2023-07-12 15:27:52 +02001190 */
1191
1192#ifdef NC_ENABLED_SSH_TLS
1193
1194/**
Roytak2161df62023-08-02 15:04:42 +02001195 * @defgroup server_config_ch_ssh SSH Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001196 * @ingroup server_config_ch
1197 *
Roytak2161df62023-08-02 15:04:42 +02001198 * @brief SSH Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +02001199 * @{
1200 */
1201
roman142718b2023-06-29 09:15:29 +02001202/**
Roytak2161df62023-08-02 15:04:42 +02001203 * @brief Creates new YANG data nodes for a Call Home SSH hostkey.
roman142718b2023-06-29 09:15:29 +02001204 *
1205 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001206 * @param[in] client_name Arbitrary identifier of the Call Home client.
1207 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +02001208 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1209 * If the client's endpoint with this identifier already exists, its contents will be changed.
1210 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
1211 * If the endpoint's hostkey with this identifier already exists, its contents will be changed.
1212 * @param[in] privkey_path Path to a file containing a private key.
1213 * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported.
1214 * @param[in] pubkey_path Path to a file containing a public key. If NULL, public key will be
1215 * generated from the private key.
1216 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1217 * Otherwise the new YANG data will be added to the previous data and may override it.
1218 * @return 0 on success, non-zero otherwise.
1219 */
roman8ba6efa2023-07-12 15:27:52 +02001220int 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 +02001221 const char *hostkey_name, const char *privkey_path, const char *pubkey_path, struct lyd_node **config);
1222
roman142718b2023-06-29 09:15:29 +02001223/**
Roytak2161df62023-08-02 15:04:42 +02001224 * @brief Deletes a Call Home hostkey from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001225 *
Roytak2161df62023-08-02 15:04:42 +02001226 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001227 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
roman8ba6efa2023-07-12 15:27:52 +02001228 * @param[in] hostkey_name Optional identifier of a hostkey to be deleted.
1229 * If NULL, all of the hostkeys on the given endpoint will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001230 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001231 * @return 0 on success, non-zero otherwise.
1232 */
1233int nc_server_config_new_ch_ssh_del_hostkey(const char *client_name, const char *endpt_name,
1234 const char *hostkey_name, struct lyd_node **config);
1235
1236/**
roman9d5e5a52023-07-14 12:43:44 +02001237 * @brief Creates new YANG data nodes for a reference to an asymmetric key located in the keystore.
1238 *
Roytak2161df62023-08-02 15:04:42 +02001239 * This asymmetric key pair will be used as the Call Home SSH hostkey.
roman9d5e5a52023-07-14 12:43:44 +02001240 *
1241 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001242 * @param[in] client_name Arbitrary identifier of the Call Home client.
1243 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001244 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1245 * If the client's endpoint with this identifier already exists, its contents will be changed.
1246 * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey.
1247 * If the endpoint's hostkey with this identifier already exists, its contents will be changed.
1248 * @param[in] keystore_reference Name of the asymmetric key pair to be referenced and used as a hostkey.
Roytak9b32c0f2023-08-02 15:07:29 +02001249 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001250 * Otherwise the new YANG data will be added to the previous data and may override it.
1251 * @return 0 on success, non-zero otherwise.
1252 */
roman67af8982023-08-08 10:56:04 +02001253int nc_server_config_new_ch_ssh_keystore_ref(const struct ly_ctx *ctx, const char *client_name,
roman9d5e5a52023-07-14 12:43:44 +02001254 const char *endpt_name, const char *hostkey_name, const char *keystore_reference, struct lyd_node **config);
1255
1256/**
Roytak2161df62023-08-02 15:04:42 +02001257 * @brief Deletes a Call Home keystore reference from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001258 *
Roytak2161df62023-08-02 15:04:42 +02001259 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001260 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1261 * @param[in] hostkey_name Identifier of an existing hostkey that belongs to the given CH endpoint.
Roytak9b32c0f2023-08-02 15:07:29 +02001262 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001263 * @return 0 on success, non-zero otherwise.
1264 */
roman67af8982023-08-08 10:56:04 +02001265int nc_server_config_new_ch_ssh_del_keystore_ref(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001266 const char *hostkey_name, struct lyd_node **config);
1267
1268/**
Roytak2161df62023-08-02 15:04:42 +02001269 * @brief Creates new YANG configuration data nodes for the maximum amount of failed Call Home SSH authentication attempts.
roman68404fd2023-07-24 10:40:59 +02001270 *
1271 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001272 * @param[in] client_name Arbitrary identifier of the Call Home client.
1273 * If a Call Home client with this identifier already exists, its contents will be changed.
roman68404fd2023-07-24 10:40:59 +02001274 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1275 * If the client's endpoint with this identifier already exists, its contents will be changed.
1276 * @param[in] auth_attempts Maximum amount of failed SSH authentication attempts after which a
1277 * client is disconnected. The default value is 3.
1278 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1279 * Otherwise the new YANG data will be added to the previous data and may override it.
1280 * @return 0 on success, non-zero otherwise.
1281 */
1282int nc_server_config_new_ch_ssh_auth_attempts(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1283 uint16_t auth_attempts, struct lyd_node **config);
1284
1285/**
Roytak2161df62023-08-02 15:04:42 +02001286 * @brief Creates new YANG configuration data nodes for a Call Home SSH authentication timeout.
roman68404fd2023-07-24 10:40:59 +02001287 *
1288 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001289 * @param[in] client_name Arbitrary identifier of the Call Home client.
1290 * If a Call Home client with this identifier already exists, its contents will be changed.
roman68404fd2023-07-24 10:40:59 +02001291 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1292 * If the client's endpoint with this identifier already exists, its contents will be changed.
1293 * @param[in] auth_timeout Maximum amount of time in seconds after which the authentication is deemed
1294 * unsuccessful. The default value is 10.
1295 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1296 * Otherwise the new YANG data will be added to the previous data and may override it.
1297 * @return 0 on success, non-zero otherwise.
1298 */
1299int nc_server_config_new_ch_ssh_auth_timeout(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1300 uint16_t auth_timeout, struct lyd_node **config);
1301
1302/**
Roytak2161df62023-08-02 15:04:42 +02001303 * @brief Creates new YANG data nodes for a Call Home SSH user's public key authentication method.
roman142718b2023-06-29 09:15:29 +02001304 *
1305 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001306 * @param[in] client_name Arbitrary identifier of the Call Home client.
1307 * If a Call Home client with this identifier already exists, its contents will be changed.
roman142718b2023-06-29 09:15:29 +02001308 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1309 * If the client's endpoint with this identifier already exists, its contents will be changed.
1310 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1311 * If the endpoint's user with this identifier already exists, its contents will be changed.
1312 * @param[in] pubkey_name Arbitrary identifier of the user's public key.
1313 * If the user's public key with this identifier already exists, its contents will be changed.
1314 * @param[in] pubkey_path Path to a file containing a public key.
1315 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1316 * Otherwise the new YANG data will be added to the previous data and may override it.
1317 * @return 0 on success, non-zero otherwise.
1318 */
roman8ba6efa2023-07-12 15:27:52 +02001319int 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 +02001320 const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config);
1321
roman142718b2023-06-29 09:15:29 +02001322/**
Roytak2161df62023-08-02 15:04:42 +02001323 * @brief Deletes a Call Home SSH user's public key from the YANG data.
roman142718b2023-06-29 09:15:29 +02001324 *
Roytak2161df62023-08-02 15:04:42 +02001325 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001326 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1327 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
roman8ba6efa2023-07-12 15:27:52 +02001328 * @param[in] pubkey_name Optional identifier of a public key to be deleted.
1329 * If NULL, all of the public keys which belong to the given SSH user will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001330 * @param[in,out] config Modified configuration YANG data tree.
roman142718b2023-06-29 09:15:29 +02001331 * @return 0 on success, non-zero otherwise.
1332 */
roman8ba6efa2023-07-12 15:27:52 +02001333int nc_server_config_new_ch_ssh_del_user_pubkey(const char *client_name, const char *endpt_name,
1334 const char *user_name, const char *pubkey_name, struct lyd_node **config);
roman5cbb6532023-06-22 12:53:17 +02001335
roman142718b2023-06-29 09:15:29 +02001336/**
Roytak2161df62023-08-02 15:04:42 +02001337 * @brief Creates new YANG data nodes for a Call Home SSH user's password authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001338 *
1339 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001340 * @param[in] client_name Arbitrary identifier of the Call Home client.
1341 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001342 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1343 * If the client's endpoint with this identifier already exists, its contents will be changed.
1344 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1345 * If the endpoint's user with this identifier already exists, its contents will be changed.
roman35120972023-08-08 10:39:12 +02001346 * @param[in] password Clear-text password to be set for the user. It will be hashed.
roman9d5e5a52023-07-14 12:43:44 +02001347 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1348 * Otherwise the new YANG data will be added to the previous data and may override it.
1349 * @return 0 on success, non-zero otherwise.
1350 */
1351int nc_server_config_new_ch_ssh_user_password(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1352 const char *user_name, const char *password, struct lyd_node **config);
1353
1354/**
Roytak2161df62023-08-02 15:04:42 +02001355 * @brief Deletes a Call Home SSH user's password from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001356 *
Roytak2161df62023-08-02 15:04:42 +02001357 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001358 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1359 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1360 * @param[in,out] config Modified configuration YANG data tree.
1361 * @return 0 on success, non-zero otherwise.
1362 */
1363int nc_server_config_new_ch_ssh_del_user_password(const char *client_name, const char *endpt_name,
1364 const char *user_name, struct lyd_node **config);
1365
1366/**
Roytak2161df62023-08-02 15:04:42 +02001367 * @brief Creates new YANG configuration data nodes for a Call Home SSH user's none authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001368 *
1369 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001370 * @param[in] client_name Arbitrary identifier of the Call Home client.
1371 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001372 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1373 * If the client's endpoint with this identifier already exists, its contents will be changed.
1374 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1375 * If the endpoint's user with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001376 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001377 * Otherwise the new YANG data will be added to the previous data and may override it.
1378 * @return 0 on success, non-zero otherwise.
1379 */
1380int nc_server_config_new_ch_ssh_user_none(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1381 const char *user_name, struct lyd_node **config);
1382
1383/**
Roytak2161df62023-08-02 15:04:42 +02001384 * @brief Deletes a Call Home SSH user's none authentication method from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001385 *
Roytak2161df62023-08-02 15:04:42 +02001386 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001387 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1388 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1389 * @param[in,out] config Modified configuration YANG data tree.
1390 * @return 0 on success, non-zero otherwise.
1391 */
1392int nc_server_config_new_ch_ssh_del_user_none(const char *client_name, const char *endpt_name,
1393 const char *user_name, struct lyd_node **config);
1394
1395/**
Roytak2161df62023-08-02 15:04:42 +02001396 * @brief Creates new YANG configuration data nodes for a Call Home SSH user's keyboard interactive authentication method.
roman9d5e5a52023-07-14 12:43:44 +02001397 *
1398 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001399 * @param[in] client_name Arbitrary identifier of the Call Home client.
1400 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001401 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1402 * If the client's endpoint with this identifier already exists, its contents will be changed.
1403 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1404 * If the endpoint's user with this identifier already exists, its contents will be changed.
1405 * @param[in] pam_config_name Name of the PAM configuration file.
roman0f5fa422023-08-07 09:03:24 +02001406 * @param[in] pam_config_dir Optional. The absolute path to the directory in which the configuration file
1407 * 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 +02001408 * the path. If NULL is passed, then the PAM's system directories will be searched (usually /etc/pam.d/).
1409 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1410 * Otherwise the new YANG data will be added to the previous data and may override it.
1411 * @return 0 on success, non-zero otherwise.
1412 */
1413int nc_server_config_new_ch_ssh_user_interactive(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1414 const char *user_name, const char *pam_config_name, const char *pam_config_dir, struct lyd_node **config);
1415
1416/**
Roytak2161df62023-08-02 15:04:42 +02001417 * @brief Deletes a Call Home SSH user's keyboard interactive authentication from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001418 *
Roytak2161df62023-08-02 15:04:42 +02001419 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001420 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1421 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1422 * @param[in,out] config Modified configuration YANG data tree.
1423 * @return 0 on success, non-zero otherwise.
1424 */
1425int nc_server_config_new_ch_ssh_del_user_interactive(const char *client_name, const char *endpt_name,
1426 const char *user_name, struct lyd_node **config);
1427
1428/**
Roytak2161df62023-08-02 15:04:42 +02001429 * @brief Deletes a Call Home SSH user from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001430 *
Roytak2161df62023-08-02 15:04:42 +02001431 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001432 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1433 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1434 * @param[in,out] config Modified configuration YANG data tree.
1435 * @return 0 on success, non-zero otherwise.
1436 */
1437int nc_server_config_new_ch_ssh_del_user(const char *client_name, const char *endpt_name,
1438 const char *user_name, struct lyd_node **config);
1439
1440/**
1441 * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore.
1442 *
Roytak2161df62023-08-02 15:04:42 +02001443 * The public key's located in the bag will be used for Call Home SSH client authentication.
roman9d5e5a52023-07-14 12:43:44 +02001444 *
1445 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001446 * @param[in] client_name Arbitrary identifier of the Call Home client.
1447 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001448 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1449 * If the client's endpoint with this identifier already exists, its contents will be changed.
1450 * @param[in] user_name Arbitrary identifier of the endpoint's user.
1451 * If the endpoint's user with this identifier already exists, its contents will be changed.
1452 * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication.
Roytak9b32c0f2023-08-02 15:07:29 +02001453 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001454 * Otherwise the new YANG data will be added to the previous data and may override it.
1455 * @return 0 on success, non-zero otherwise.
1456 */
roman67af8982023-08-08 10:56:04 +02001457int nc_server_config_new_ch_ssh_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
roman9d5e5a52023-07-14 12:43:44 +02001458 const char *endpt_name, const char *user_name, const char *truststore_reference, struct lyd_node **config);
1459
1460/**
Roytak2161df62023-08-02 15:04:42 +02001461 * @brief Deletes a Call Home SSH truststore reference from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001462 *
Roytak2161df62023-08-02 15:04:42 +02001463 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001464 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1465 * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint.
1466 * @param[in,out] config Modified configuration YANG data tree.
1467 * @return 0 on success, non-zero otherwise.
1468 */
roman67af8982023-08-08 10:56:04 +02001469int nc_server_config_new_ch_ssh_del_truststore_ref(const char *client_name, const char *endpt_name,
roman9d5e5a52023-07-14 12:43:44 +02001470 const char *user_name, struct lyd_node **config);
1471
1472/**
Roytak2161df62023-08-02 15:04:42 +02001473 * @brief Creates new YANG configuration data nodes for Call Home host-key algorithms replacing any previous ones.
roman9d5e5a52023-07-14 12:43:44 +02001474 *
1475 * Supported algorithms are: ssh-ed25519, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521,
1476 * rsa-sha2-512, rsa-sha2-256, ssh-rsa and ssh-dss.
1477 *
1478 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001479 * @param[in] client_name Arbitrary identifier of the Call Home client.
1480 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001481 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1482 * If the client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001483 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001484 * Otherwise the new YANG data will be added to the previous data and may override it.
1485 * @param[in] alg_count Number of following algorithms.
1486 * @param[in] ... String literals of host-key algorithms in a decreasing order of preference.
1487 * @return 0 on success, non-zero otherwise.
1488 */
1489int nc_server_config_new_ch_ssh_host_key_algs(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1490 struct lyd_node **config, int alg_count, ...);
1491
1492/**
Roytak2161df62023-08-02 15:04:42 +02001493 * @brief Deletes a Call Home hostkey algorithm from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001494 *
Roytak2161df62023-08-02 15:04:42 +02001495 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001496 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1497 * @param[in] alg Optional algorithm to be deleted.
1498 * If NULL, all of the hostkey algorithms on this endpoint will be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001499 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001500 * @return 0 on success, non-zero otherwise.
1501 */
1502int nc_server_config_new_ch_ssh_del_host_key_alg(const char *client_name, const char *endpt_name,
1503 const char *alg, struct lyd_node **config);
1504
1505/**
Roytak2161df62023-08-02 15:04:42 +02001506 * @brief Creates new YANG configuration data nodes for Call Home key exchange algorithms replacing any previous ones.
roman9d5e5a52023-07-14 12:43:44 +02001507 *
1508 * Supported algorithms are: diffie-hellman-group-exchange-sha1, curve25519-sha256, ecdh-sha2-nistp256,
1509 * ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group18-sha512, diffie-hellman-group16-sha512,
1510 * diffie-hellman-group-exchange-sha256 and diffie-hellman-group14-sha256.
1511 *
1512 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001513 * @param[in] client_name Arbitrary identifier of the Call Home client.
1514 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001515 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1516 * If the client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001517 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001518 * Otherwise the new YANG data will be added to the previous data and may override it.
1519 * @param[in] alg_count Number of following algorithms.
1520 * @param[in] ... String literals of key exchange algorithms in a decreasing order of preference.
1521 * @return 0 on success, non-zero otherwise.
1522 */
1523int nc_server_config_new_ch_ssh_key_exchange_algs(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1524 struct lyd_node **config, int alg_count, ...);
1525
1526/**
Roytak2161df62023-08-02 15:04:42 +02001527 * @brief Deletes a Call Home key exchange algorithm from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001528 *
Roytak2161df62023-08-02 15:04:42 +02001529 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001530 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1531 * @param[in] alg Optional algorithm to be deleted.
1532 * If NULL, all of the key exchange algorithms on this endpoint will be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001533 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001534 * @return 0 on success, non-zero otherwise.
1535 */
1536int nc_server_config_new_ch_ssh_del_key_exchange_alg(const char *client_name, const char *endpt_name,
1537 const char *alg, struct lyd_node **config);
1538
1539/**
Roytak2161df62023-08-02 15:04:42 +02001540 * @brief Creates new YANG configuration data nodes for Call Home encryption algorithms replacing any previous ones.
roman9d5e5a52023-07-14 12:43:44 +02001541 *
1542 * Supported algorithms are: aes256-ctr, aes192-ctr, aes128-ctr, aes256-cbc, aes192-cbc, aes128-cbc, blowfish-cbc
1543 * triple-des-cbc and none.
1544 *
1545 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001546 * @param[in] client_name Arbitrary identifier of the Call Home client.
1547 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001548 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1549 * If the client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001550 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001551 * Otherwise the new YANG data will be added to the previous data and may override it.
1552 * @param[in] alg_count Number of following algorithms.
1553 * @param[in] ... String literals of encryption algorithms in a decreasing order of preference.
1554 * @return 0 on success, non-zero otherwise.
1555 */
1556int nc_server_config_new_ch_ssh_encryption_algs(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1557 struct lyd_node **config, int alg_count, ...);
1558
1559/**
Roytak2161df62023-08-02 15:04:42 +02001560 * @brief Deletes a Call Home encryption algorithm from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001561 *
Roytak2161df62023-08-02 15:04:42 +02001562 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001563 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1564 * @param[in] alg Optional algorithm to be deleted.
1565 * If NULL, all of the encryption algorithms on this endpoint will be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001566 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001567 * @return 0 on success, non-zero otherwise.
1568 */
1569int nc_server_config_new_ch_ssh_del_encryption_alg(const char *client_name, const char *endpt_name,
1570 const char *alg, struct lyd_node **config);
1571
1572/**
Roytak2161df62023-08-02 15:04:42 +02001573 * @brief Creates new YANG configuration data nodes for Call Home mac algorithms replacing any previous ones.
roman9d5e5a52023-07-14 12:43:44 +02001574 *
1575 * Supported algorithms are: hmac-sha2-256, hmac-sha2-512 and hmac-sha1.
1576 *
1577 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001578 * @param[in] client_name Arbitrary identifier of the Call Home client.
1579 * If a Call Home client with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001580 * @param[in] endpt_name Arbitrary identifier of the client's endpoint.
1581 * If the client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001582 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001583 * Otherwise the new YANG data will be added to the previous data and may override it.
1584 * @param[in] alg_count Number of following algorithms.
1585 * @param[in] ... String literals of mac algorithms in a decreasing order of preference.
1586 * @return 0 on success, non-zero otherwise.
1587 */
1588int nc_server_config_new_ch_ssh_mac_algs(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1589 struct lyd_node **config, int alg_count, ...);
1590
1591/**
Roytak2161df62023-08-02 15:04:42 +02001592 * @brief Deletes a Call Home mac algorithm from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001593 *
Roytak2161df62023-08-02 15:04:42 +02001594 * @param[in] client_name Identifier of an existing Call Home client.
roman9d5e5a52023-07-14 12:43:44 +02001595 * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client.
1596 * @param[in] alg Optional algorithm to be deleted.
1597 * If NULL, all of the mac algorithms on this endpoint will be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001598 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001599 * @return 0 on success, non-zero otherwise.
1600 */
1601int nc_server_config_new_ch_ssh_del_mac_alg(const char *client_name, const char *endpt_name,
1602 const char *alg, struct lyd_node **config);
1603
1604/**
roman35120972023-08-08 10:39:12 +02001605 * @} SSH Call Home Server Configuration
roman142718b2023-06-29 09:15:29 +02001606 */
roman142718b2023-06-29 09:15:29 +02001607
1608/**
Roytak2161df62023-08-02 15:04:42 +02001609 * @defgroup server_config_ch_tls TLS Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001610 * @ingroup server_config_ch
roman142718b2023-06-29 09:15:29 +02001611 *
Roytak2161df62023-08-02 15:04:42 +02001612 * @brief TLS Call Home server configuration creation and deletion
roman8ba6efa2023-07-12 15:27:52 +02001613 * @{
roman142718b2023-06-29 09:15:29 +02001614 */
roman142718b2023-06-29 09:15:29 +02001615
romanb6f44032023-06-30 15:07:56 +02001616/**
Roytak2161df62023-08-02 15:04:42 +02001617 * @brief Creates new YANG configuration data nodes for a Call Home server's certificate.
romanb6f44032023-06-30 15:07:56 +02001618 *
1619 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001620 * @param[in] client_name Arbitrary identifier of the Call Home client.
1621 * If a Call Home client with this identifier already exists, its contents will be changed.
1622 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1623 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman6c4efcd2023-08-08 10:18:44 +02001624 * @param[in] privkey_path Path to the server's PEM encoded private key file.
romanb6f44032023-06-30 15:07:56 +02001625 * @param[in] pubkey_path Optional path to the server's public key file. If not provided,
1626 * it will be generated from the private key.
romanb6f44032023-06-30 15:07:56 +02001627 * @param[in] certificate_path Path to the server's certificate file.
Roytak934edc32023-07-27 12:04:18 +02001628 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001629 * Otherwise the new YANG data will be added to the previous data and may override it.
1630 * @return 0 on success, non-zero otherwise.
1631 */
roman8ba6efa2023-07-12 15:27:52 +02001632int 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 +02001633 const char *privkey_path, const char *pubkey_path, const char *certificate_path, struct lyd_node **config);
romanb6f44032023-06-30 15:07:56 +02001634
1635/**
Roytak2161df62023-08-02 15:04:42 +02001636 * @brief Deletes a Call Home server certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001637 *
Roytak2161df62023-08-02 15:04:42 +02001638 * @param[in] client_name Identifier of an existing Call Home client.
1639 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman9d5e5a52023-07-14 12:43:44 +02001640 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001641 * @return 0 on success, non-zero otherwise.
1642 */
1643int nc_server_config_new_ch_tls_del_server_certificate(const char *client_name, const char *endpt_name,
1644 struct lyd_node **config);
1645
1646/**
Roytak934edc32023-07-27 12:04:18 +02001647 * @brief Creates new YANG configuration data nodes for a keystore reference to the Call Home TLS server's certificate.
1648 *
1649 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001650 * @param[in] client_name Arbitrary identifier of the Call Home client.
1651 * If a Call Home client with this identifier already exists, its contents will be changed.
1652 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1653 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
Roytak934edc32023-07-27 12:04:18 +02001654 * @param[in] asym_key_ref Name of the asymmetric key pair in the keystore to be referenced.
1655 * @param[in] cert_ref Name of the certificate, which must belong to the given asymmetric key pair, to be referenced.
1656 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1657 * Otherwise the new YANG data will be added to the previous data and may override it.
1658 * @return 0 on success, non-zero otherwise.
1659 */
roman67af8982023-08-08 10:56:04 +02001660int nc_server_config_new_ch_tls_keystore_ref(const struct ly_ctx *ctx, const char *client_name,
Roytak934edc32023-07-27 12:04:18 +02001661 const char *endpt_name, const char *asym_key_ref, const char *cert_ref, struct lyd_node **config);
1662
1663/**
1664 * @brief Deletes a TLS server certificate keystore reference from the YANG data.
1665 *
Roytak2161df62023-08-02 15:04:42 +02001666 * @param[in] client_name Identifier of an existing Call Home client.
1667 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
Roytak934edc32023-07-27 12:04:18 +02001668 * @param[in,out] config Modified configuration YANG data tree.
1669 * @return 0 on success, non-zero otherwise.
1670 */
roman67af8982023-08-08 10:56:04 +02001671int nc_server_config_new_ch_tls_del_keystore_ref(const char *client_name, const char *endpt_name,
Roytak934edc32023-07-27 12:04:18 +02001672 struct lyd_node **config);
1673
1674/**
Roytak2161df62023-08-02 15:04:42 +02001675 * @brief Creates new YANG configuration data nodes for a Call Home client's (end-entity) certificate.
romanb6f44032023-06-30 15:07:56 +02001676 *
1677 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001678 * @param[in] client_name Arbitrary identifier of the Call Home client.
1679 * If a Call Home client with this identifier already exists, its contents will be changed.
1680 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1681 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1682 * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's end-entity certificate.
1683 * 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 +02001684 * @param[in] cert_path Path to the certificate file.
Roytak934edc32023-07-27 12:04:18 +02001685 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001686 * Otherwise the new YANG data will be added to the previous data and may override it.
1687 * @return 0 on success, non-zero otherwise.
1688 */
roman8ba6efa2023-07-12 15:27:52 +02001689int 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 +02001690 const char *cert_name, const char *cert_path, struct lyd_node **config);
1691
1692/**
Roytak2161df62023-08-02 15:04:42 +02001693 * @brief Deletes a Call Home client (end-entity) certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001694 *
Roytak2161df62023-08-02 15:04:42 +02001695 * @param[in] client_name Identifier of an existing Call Home client.
1696 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman8ba6efa2023-07-12 15:27:52 +02001697 * @param[in] cert_name Optional identifier of a client certificate to be deleted.
1698 * If NULL, all of the client certificates will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001699 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001700 * @return 0 on success, non-zero otherwise.
1701 */
1702int nc_server_config_new_ch_tls_del_client_certificate(const char *client_name, const char *endpt_name,
1703 const char *cert_name, struct lyd_node **config);
1704
1705/**
Roytak934edc32023-07-27 12:04:18 +02001706 * @brief Creates new YANG configuration data nodes for a Call Home truststore reference to a set of client (end-entity) certificates.
1707 *
1708 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001709 * @param[in] client_name Arbitrary identifier of the Call Home client.
1710 * If a Call Home client with this identifier already exists, its contents will be changed.
1711 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1712 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
Roytak934edc32023-07-27 12:04:18 +02001713 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
1714 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1715 * Otherwise the new YANG data will be added to the previous data and may override it.
1716 * @return 0 on success, non-zero otherwise.
1717 */
1718int nc_server_config_new_ch_tls_client_cert_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
1719 const char *endpt_name, const char *cert_bag_ref, struct lyd_node **config);
1720
1721/**
1722 * @brief Deletes a Call Home client (end-entity) certificates truststore reference from the YANG data.
1723 *
Roytak2161df62023-08-02 15:04:42 +02001724 * @param[in] client_name Identifier of an existing Call Home client.
1725 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
Roytak934edc32023-07-27 12:04:18 +02001726 * @param[in,out] config Modified configuration YANG data tree.
1727 * @return 0 on success, non-zero otherwise.
1728 */
1729int nc_server_config_new_ch_tls_del_client_cert_truststore_ref(const char *client_name, const char *endpt_name,
1730 struct lyd_node **config);
1731
1732/**
romanb6f44032023-06-30 15:07:56 +02001733 * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate.
1734 *
1735 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001736 * @param[in] client_name Arbitrary identifier of the Call Home client.
1737 * If a Call Home client with this identifier already exists, its contents will be changed.
1738 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1739 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
1740 * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's certificate authority certificate.
1741 * If an Call Home endpoint's CA certificate with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001742 * @param[in] cert_path Path to the certificate file.
Roytak9b32c0f2023-08-02 15:07:29 +02001743 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001744 * Otherwise the new YANG data will be added to the previous data and may override it.
1745 * @return 0 on success, non-zero otherwise.
1746 */
roman8ba6efa2023-07-12 15:27:52 +02001747int 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 +02001748 const char *cert_name, const char *cert_path, struct lyd_node **config);
1749
1750/**
Roytak2161df62023-08-02 15:04:42 +02001751 * @brief Deletes a Call Home client certificate authority (trust-anchor) certificate from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001752 *
Roytak2161df62023-08-02 15:04:42 +02001753 * @param[in] client_name Identifier of an existing Call Home client.
1754 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman8ba6efa2023-07-12 15:27:52 +02001755 * @param[in] cert_name Optional identifier of a CA certificate to be deleted.
1756 * If NULL, all of the CA certificates will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001757 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001758 * @return 0 on success, non-zero otherwise.
1759 */
1760int nc_server_config_new_ch_tls_del_client_ca(const char *client_name, const char *endpt_name,
1761 const char *cert_name, struct lyd_node **config);
1762
1763/**
Roytak934edc32023-07-27 12:04:18 +02001764 * @brief Creates new YANG configuration data nodes for a Call Home truststore reference to a set of client certificate authority (trust-anchor) certificates.
1765 *
1766 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001767 * @param[in] client_name Arbitrary identifier of the Call Home client.
1768 * If a Call Home client with this identifier already exists, its contents will be changed.
1769 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1770 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
Roytak934edc32023-07-27 12:04:18 +02001771 * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced.
1772 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
1773 * Otherwise the new YANG data will be added to the previous data and may override it.
1774 * @return 0 on success, non-zero otherwise.
1775 */
1776int nc_server_config_new_ch_tls_client_ca_truststore_ref(const struct ly_ctx *ctx, const char *client_name,
1777 const char *endpt_name, const char *cert_bag_ref, struct lyd_node **config);
1778
1779/**
1780 * @brief Deletes a Call Home client certificate authority (trust-anchor) certificates truststore reference from the YANG data.
1781 *
Roytak2161df62023-08-02 15:04:42 +02001782 * @param[in] client_name Identifier of an existing Call Home client.
1783 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
Roytak934edc32023-07-27 12:04:18 +02001784 * @param[in,out] config Modified configuration YANG data tree.
1785 * @return 0 on success, non-zero otherwise.
1786 */
1787int nc_server_config_new_ch_tls_del_client_ca_truststore_ref(const char *client_name, const char *endpt_name,
1788 struct lyd_node **config);
1789
1790/**
Roytak2161df62023-08-02 15:04:42 +02001791 * @brief Creates new YANG configuration data nodes for a Call Home cert-to-name entry.
romanb6f44032023-06-30 15:07:56 +02001792 *
1793 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001794 * @param[in] client_name Arbitrary identifier of the Call Home client.
1795 * If a Call Home client with this identifier already exists, its contents will be changed.
1796 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1797 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
romanb6f44032023-06-30 15:07:56 +02001798 * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier).
1799 * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is
1800 * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry.
1801 * @param[in] map_type Mapping username to the certificate option.
1802 * @param[in] name Username for this cert-to-name entry.
Roytak9b32c0f2023-08-02 15:07:29 +02001803 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
romanb6f44032023-06-30 15:07:56 +02001804 * Otherwise the new YANG data will be added to the previous data and may override it.
1805 * @return 0 on success, non-zero otherwise.
1806 */
roman8ba6efa2023-07-12 15:27:52 +02001807int 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 +02001808 uint32_t id, const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config);
1809
roman8ba6efa2023-07-12 15:27:52 +02001810/**
Roytak2161df62023-08-02 15:04:42 +02001811 * @brief Deletes a Call Home cert-to-name entry from the YANG data.
roman8ba6efa2023-07-12 15:27:52 +02001812 *
Roytak2161df62023-08-02 15:04:42 +02001813 * @param[in] client_name Identifier of an existing Call Home client.
1814 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
1815 * @param[in] id Optional identifier of the Call Home CTN entry to be deleted.
roman8ba6efa2023-07-12 15:27:52 +02001816 * If 0, all of the CTN entries will be deleted.
roman9d5e5a52023-07-14 12:43:44 +02001817 * @param[in,out] config Modified configuration YANG data tree.
roman8ba6efa2023-07-12 15:27:52 +02001818 * @return 0 on success, non-zero otherwise.
1819 */
1820int nc_server_config_new_ch_tls_del_ctn(const char *client_name, const char *endpt_name,
1821 uint32_t id, struct lyd_node **config);
1822
1823/**
Roytak2161df62023-08-02 15:04:42 +02001824 * @brief Creates new YANG configuration data nodes for a Call Home TLS version.
roman9d5e5a52023-07-14 12:43:44 +02001825 *
1826 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001827 * @param[in] client_name Arbitrary identifier of the Call Home client.
1828 * If a Call Home client with this identifier already exists, its contents will be changed.
1829 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1830 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001831 * @param[in] tls_version TLS version to be used. Call this multiple times to set the accepted versions
1832 * of the TLS protocol and let the client and server negotiate the given version.
Roytak9b32c0f2023-08-02 15:07:29 +02001833 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001834 * Otherwise the new YANG data will be added to the previous data and may override it.
1835 * @return 0 on success, non-zero otherwise.
1836 */
1837int nc_server_config_new_ch_tls_version(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1838 NC_TLS_VERSION tls_version, struct lyd_node **config);
1839
1840/**
1841 * @brief Deletes a TLS version from the YANG data.
1842 *
Roytak2161df62023-08-02 15:04:42 +02001843 * @param[in] client_name Identifier of an existing Call Home client.
1844 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman9d5e5a52023-07-14 12:43:44 +02001845 * @param[in] tls_version TLS version to be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001846 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001847 * @return 0 on success, non-zero otherwise.
1848 */
1849int nc_server_config_new_ch_tls_del_version(const char *client_name, const char *endpt_name,
1850 NC_TLS_VERSION tls_version, struct lyd_node **config);
1851
1852/**
Roytak2161df62023-08-02 15:04:42 +02001853 * @brief Creates new YANG configuration data nodes for a Call Home TLS cipher.
roman9d5e5a52023-07-14 12:43:44 +02001854 *
1855 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001856 * @param[in] client_name Arbitrary identifier of the Call Home client.
1857 * If a Call Home client with this identifier already exists, its contents will be changed.
1858 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1859 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001860 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001861 * Otherwise the new YANG data will be added to the previous data and may override it.
1862 * @param[in] cipher_count Number of following ciphers.
1863 * @param[in] ... TLS ciphers. These ciphers MUST be in the format as listed in the
1864 * iana-tls-cipher-suite-algs YANG model (lowercase and separated by dashes). Regardless
1865 * of the TLS protocol version used, all of these ciphers will be tried and some of them
1866 * might not be set (TLS handshake might fail then). For the list of supported ciphers see
1867 * the OpenSSL documentation.
1868 * @return 0 on success, non-zero otherwise.
1869 */
1870int nc_server_config_new_ch_tls_ciphers(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1871 struct lyd_node **config, int cipher_count, ...);
1872
1873/**
Roytak2161df62023-08-02 15:04:42 +02001874 * @brief Deletes a Call Home TLS cipher from the YANG data.
roman9d5e5a52023-07-14 12:43:44 +02001875 *
Roytak2161df62023-08-02 15:04:42 +02001876 * @param[in] client_name Identifier of an existing Call Home client.
1877 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
roman9d5e5a52023-07-14 12:43:44 +02001878 * @param[in] cipher TLS cipher to be deleted.
Roytak9b32c0f2023-08-02 15:07:29 +02001879 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001880 * @return 0 on success, non-zero otherwise.
1881 */
1882int nc_server_config_new_ch_tls_del_cipher(const char *client_name, const char *endpt_name,
1883 const char *cipher, struct lyd_node **config);
1884
1885/**
Roytak2161df62023-08-02 15:04:42 +02001886 * @brief Creates new YANG configuration data nodes for a Call Home Certificate Revocation List via a local file.
roman9d5e5a52023-07-14 12:43:44 +02001887 *
1888 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
1889 * this function will remove any CRL YANG nodes created by the other two functions.
1890 *
1891 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001892 * @param[in] client_name Arbitrary identifier of the Call Home client.
1893 * If a Call Home client with this identifier already exists, its contents will be changed.
1894 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1895 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001896 * @param[in] crl_path Path to a DER/PEM encoded CRL file.
Roytak9b32c0f2023-08-02 15:07:29 +02001897 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001898 * Otherwise the new YANG data will be added to the previous data and may override it.
1899 * @return 0 on success, non-zero otherwise.
1900 */
1901int nc_server_config_new_ch_tls_crl_path(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1902 const char *crl_path, struct lyd_node **config);
1903
1904/**
Roytak2161df62023-08-02 15:04:42 +02001905 * @brief Creates new YANG configuration data nodes for a Call Home Certificate Revocation List via an URL.
roman9d5e5a52023-07-14 12:43:44 +02001906 *
1907 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
1908 * this function will remove any CRL YANG nodes created by the other two functions.
1909 *
1910 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001911 * @param[in] client_name Arbitrary identifier of the Call Home client.
1912 * If a Call Home client with this identifier already exists, its contents will be changed.
1913 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1914 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
roman9d5e5a52023-07-14 12:43:44 +02001915 * @param[in] crl_url URL from which the CRL file will be downloaded. The file has to be in the DER or PEM format.
1916 * The allowed protocols are all the protocols supported by CURL.
Roytak9b32c0f2023-08-02 15:07:29 +02001917 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001918 * Otherwise the new YANG data will be added to the previous data and may override it.
1919 * @return 0 on success, non-zero otherwise.
1920 */
1921int nc_server_config_new_ch_tls_crl_url(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1922 const char *crl_url, struct lyd_node **config);
1923
1924/**
Roytak2161df62023-08-02 15:04:42 +02001925 * @brief Creates new YANG configuration data nodes for a Call Home Certificate Revocation List via certificate extensions.
roman9d5e5a52023-07-14 12:43:44 +02001926 *
1927 * The chain of configured Certificate Authorities will be examined. For each certificate in this chain all the
1928 * CRLs from the URLs specified in their extension fields CRL Distribution Points will be downloaded and used.
1929 *
1930 * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling
1931 * this function will remove any CRL YANG nodes created by the other two functions.
1932 *
1933 * @param[in] ctx libyang context.
Roytak2161df62023-08-02 15:04:42 +02001934 * @param[in] client_name Arbitrary identifier of the Call Home client.
1935 * If a Call Home client with this identifier already exists, its contents will be changed.
1936 * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint.
1937 * If a Call Home client's endpoint with this identifier already exists, its contents will be changed.
Roytak9b32c0f2023-08-02 15:07:29 +02001938 * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
roman9d5e5a52023-07-14 12:43:44 +02001939 * Otherwise the new YANG data will be added to the previous data and may override it.
1940 * @return 0 on success, non-zero otherwise.
1941 */
1942int nc_server_config_new_ch_tls_crl_cert_ext(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name,
1943 struct lyd_node **config);
1944
1945/**
1946 * @brief Deletes all the CRL nodes from the YANG data.
1947 *
Roytak2161df62023-08-02 15:04:42 +02001948 * @param[in] client_name Identifier of an existing Call Home client.
1949 * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client.
Roytak9b32c0f2023-08-02 15:07:29 +02001950 * @param[in,out] config Modified configuration YANG data tree.
roman9d5e5a52023-07-14 12:43:44 +02001951 * @return 0 on success, non-zero otherwise.
1952 */
1953int nc_server_config_new_ch_tls_del_crl(const char *client_name, const char *endpt_name, struct lyd_node **config);
1954
1955/**
roman35120972023-08-08 10:39:12 +02001956 * @} TLS Call Home Server Configuration
roman8ba6efa2023-07-12 15:27:52 +02001957 */
1958
roman2eab4742023-06-06 10:00:26 +02001959#endif /* NC_ENABLED_SSH_TLS */
roman45cec4e2023-02-17 10:21:39 +01001960
romanc1d2b092023-02-02 08:58:27 +01001961#ifdef __cplusplus
1962}
1963#endif
1964
1965#endif /* NC_SESSION_SERVER_H_ */