roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 1 | /** |
roman | e028ef9 | 2023-02-24 16:33:08 +0100 | [diff] [blame] | 2 | * @file server_config.h |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 3 | * @author Roman Janota <janota@cesnet.cz> |
| 4 | * @brief libnetconf2 server configuration |
| 5 | * |
| 6 | * @copyright |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 7 | * Copyright (c) 2023 CESNET, z.s.p.o. |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 8 | * |
| 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 |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 23 | #include <stdarg.h> |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 24 | #include <stdint.h> |
| 25 | |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 26 | #include <libyang/libyang.h> |
| 27 | |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 28 | #include "session.h" |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 29 | |
| 30 | /** |
roman | f02273a | 2023-05-25 09:44:11 +0200 | [diff] [blame] | 31 | * @brief Configure server based on the given diff data. |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 32 | * |
roman | f6f37a5 | 2023-05-25 14:27:51 +0200 | [diff] [blame] | 33 | * Expected data are a validated instance of a ietf-netconf-server YANG data. |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 34 | * The data must be in the diff format and supported operations are: create, replace, |
| 35 | * delete and none. Context must already have implemented the required modules, see |
| 36 | * ::nc_config_load_modules(). |
| 37 | * |
roman | f6f37a5 | 2023-05-25 14:27:51 +0200 | [diff] [blame] | 38 | * @param[in] diff ietf-netconf-server YANG diff data. |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 39 | * @return 0 on success, 1 on error. |
| 40 | */ |
roman | f6f37a5 | 2023-05-25 14:27:51 +0200 | [diff] [blame] | 41 | int nc_server_config_setup_diff(const struct lyd_node *diff); |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 42 | |
| 43 | /** |
roman | f02273a | 2023-05-25 09:44:11 +0200 | [diff] [blame] | 44 | * @brief Configure server based on the given data. |
| 45 | * |
| 46 | * Expected data is a validated instance of a ietf-netconf-server YANG data. |
| 47 | * Behaves as if all the nodes in data had the replace operation. That means that the current configuration will be deleted |
| 48 | * and just the given data will all be applied. |
roman | f6f37a5 | 2023-05-25 14:27:51 +0200 | [diff] [blame] | 49 | * The data must not contain any operation attribute, see ::nc_config_setup_diff() which works with diff. |
roman | f02273a | 2023-05-25 09:44:11 +0200 | [diff] [blame] | 50 | * Context must already have implemented the required modules, see * ::nc_config_load_modules(). |
| 51 | * |
| 52 | * @param[in] data ietf-netconf-server YANG data. |
| 53 | * @return 0 on success, 1 on error. |
| 54 | */ |
roman | f6f37a5 | 2023-05-25 14:27:51 +0200 | [diff] [blame] | 55 | int nc_server_config_setup_data(const struct lyd_node *data); |
roman | f02273a | 2023-05-25 09:44:11 +0200 | [diff] [blame] | 56 | |
| 57 | /** |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 58 | * @brief Configure server based on the given ietf-netconf-server YANG data. |
roman | f6f37a5 | 2023-05-25 14:27:51 +0200 | [diff] [blame] | 59 | * Wrapper around ::nc_config_setup_server_data() hiding work with parsing the data. |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 60 | * |
| 61 | * @param[in] ctx libyang context. |
| 62 | * @param[in] path Path to the file with YANG data in XML format. |
| 63 | * @return 0 on success, 1 on error. |
| 64 | */ |
| 65 | int nc_server_config_setup_path(const struct ly_ctx *ctx, const char *path); |
| 66 | |
| 67 | /** |
| 68 | * @brief Implements all the required modules and their features in the context. |
| 69 | * Needs to be called before any other configuration functions. |
| 70 | * |
| 71 | * If ctx is : |
| 72 | * - NULL: a new context will be created and if the call is successful you have to free it, |
| 73 | * - non NULL: modules will simply be implemented. |
| 74 | * |
| 75 | * Implemented modules: ietf-netconf-server, ietf-x509-cert-to-name, ietf-crypto-types, |
| 76 | * ietf-tcp-common, ietf-ssh-common, iana-ssh-encryption-algs, iana-ssh-key-exchange-algs, |
| 77 | * iana-ssh-mac-algs, iana-ssh-public-key-algs, ietf-keystore, ietf-ssh-server, ietf-truststore, |
| 78 | * ietf-tls-server and libnetconf2-netconf-server. |
| 79 | * |
| 80 | * @param[in, out] ctx Optional context in which the modules will be implemented. Created if ctx is null. |
| 81 | * @return 0 on success, 1 on error. |
| 82 | */ |
| 83 | int nc_server_config_load_modules(struct ly_ctx **ctx); |
| 84 | |
roman | 2eab474 | 2023-06-06 10:00:26 +0200 | [diff] [blame] | 85 | #ifdef NC_ENABLED_SSH_TLS |
| 86 | |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 87 | /** |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 88 | * @brief Creates new YANG configuration data nodes for a local-address and local-port. |
| 89 | * |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 90 | * @param[in] ctx libyang context. |
| 91 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 92 | * @param[in] transport Either SSH or TLS transport for the given endpoint. |
| 93 | * @param[in] address New listening address. |
| 94 | * @param[in] port New listening port. |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 95 | * If an endpoint with this identifier already exists, it's address and port will be overriden. |
| 96 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 97 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 98 | * @return 0 on success, non-zero otherwise. |
roman | 45cec4e | 2023-02-17 10:21:39 +0100 | [diff] [blame] | 99 | */ |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 100 | int nc_server_config_new_address_port(const struct ly_ctx *ctx, const char *endpt_name, NC_TRANSPORT_IMPL transport, |
| 101 | const char *address, const char *port, struct lyd_node **config); |
| 102 | |
| 103 | /** |
| 104 | * @brief Creates new YANG configuration data nodes for a hostkey. |
| 105 | * |
| 106 | * @param[in] ctx libyang context. |
| 107 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 108 | * If an endpoint with this identifier already exists, it's hostkey might be changed. |
| 109 | * @param[in] hostkey_name Arbitrary identifier of the hostkey. |
| 110 | * If a hostkey with this identifier already exists, it's contents will be changed. |
| 111 | * @param[in] privkey_path Path to a file containing a private key. |
| 112 | * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported. |
| 113 | * @param[in] pubkey_path Path to a file containing a public key. If NULL, public key will be |
| 114 | * generated from the private key. |
| 115 | * @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. |
| 118 | */ |
| 119 | int nc_server_config_new_ssh_hostkey(const struct ly_ctx *ctx, |
| 120 | const char *endpt_name, const char *hostkey_name, const char *privkey_path, const char *pubkey_path, struct lyd_node **config); |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 121 | |
| 122 | /** |
| 123 | * @brief Creates new YANG configuration data nodes for host-key algorithms replacing any previous ones. |
| 124 | * |
| 125 | * Supported algorithms are: ssh-ed25519, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, |
| 126 | * rsa-sha2-512, rsa-sha2-256, ssh-rsa and ssh-dss. |
| 127 | * |
| 128 | * @param[in] ctx libyang context |
| 129 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 130 | * If an endpoint with this identifier already exists, it's host-key algorithms will be replaced. |
| 131 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 132 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 133 | * @param[in] alg_count Number of following algorithms. |
| 134 | * @param[in] ... String literals of host-key algorithms in a decreasing order of preference. |
| 135 | * @return 0 on success, non-zero otherwise. |
| 136 | */ |
roman | 466719d | 2023-05-05 16:14:37 +0200 | [diff] [blame] | 137 | int nc_server_config_new_ssh_host_key_algs(const struct ly_ctx *ctx, const char *endpt_name, |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 138 | struct lyd_node **config, int alg_count, ...); |
| 139 | |
| 140 | /** |
| 141 | * @brief Creates new YANG configuration data nodes for key exchange algorithms replacing any previous ones. |
| 142 | * |
| 143 | * Supported algorithms are: diffie-hellman-group-exchange-sha1, curve25519-sha256, ecdh-sha2-nistp256, |
| 144 | * ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group18-sha512, diffie-hellman-group16-sha512, |
| 145 | * diffie-hellman-group-exchange-sha256 and diffie-hellman-group14-sha256. |
| 146 | * |
| 147 | * @param[in] ctx libyang context |
| 148 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 149 | * If an endpoint with this identifier already exists, it's key exchange algorithms will be replaced. |
| 150 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 151 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 152 | * @param[in] alg_count Number of following algorithms. |
| 153 | * @param[in] ... String literals of key exchange algorithms in a decreasing order of preference. |
| 154 | * @return 0 on success, non-zero otherwise. |
| 155 | */ |
roman | 466719d | 2023-05-05 16:14:37 +0200 | [diff] [blame] | 156 | int nc_server_config_new_ssh_key_exchange_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config, |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 157 | int alg_count, ...); |
| 158 | |
| 159 | /** |
| 160 | * @brief Creates new YANG configuration data nodes for encryption algorithms replacing any previous ones. |
| 161 | * |
| 162 | * Supported algorithms are: aes256-ctr, aes192-ctr, aes128-ctr, aes256-cbc, aes192-cbc, aes128-cbc, blowfish-cbc |
| 163 | * triple-des-cbc and none. |
| 164 | * |
| 165 | * @param[in] ctx libyang context |
| 166 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 167 | * If an endpoint with this identifier already exists, it's encryption algorithms will be replaced. |
| 168 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 169 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 170 | * @param[in] alg_count Number of following algorithms. |
| 171 | * @param[in] ... String literals of encryption algorithms in a decreasing order of preference. |
| 172 | * @return 0 on success, non-zero otherwise. |
| 173 | */ |
roman | 466719d | 2023-05-05 16:14:37 +0200 | [diff] [blame] | 174 | int nc_server_config_new_ssh_encryption_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config, |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 175 | int alg_count, ...); |
| 176 | |
| 177 | /** |
| 178 | * @brief Creates new YANG configuration data nodes for mac algorithms replacing any previous ones. |
| 179 | * |
| 180 | * Supported algorithms are: hmac-sha2-256, hmac-sha2-512 and hmac-sha1. |
| 181 | * |
| 182 | * @param[in] ctx libyang context |
| 183 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 184 | * If an endpoint with this identifier already exists, it's mac algorithms will be replaced. |
| 185 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 186 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 187 | * @param[in] alg_count Number of following algorithms. |
| 188 | * @param[in] ... String literals of mac algorithms in a decreasing order of preference. |
| 189 | * @return 0 on success, non-zero otherwise. |
| 190 | */ |
roman | 466719d | 2023-05-05 16:14:37 +0200 | [diff] [blame] | 191 | int nc_server_config_new_ssh_mac_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config, |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 192 | int alg_count, ...); |
| 193 | |
| 194 | /** |
| 195 | * @brief Creates new YANG configuration data nodes for a client, which supports the public key authentication method. |
| 196 | * |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 197 | * @param[in] ctx libyang context. |
| 198 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 199 | * If an endpoint with this identifier already exists, it's user might be changed. |
| 200 | * @param[in] user_name Arbitrary identifier of the user. |
| 201 | * If an user with this identifier already exists, it's contents will be changed. |
| 202 | * @param[in] pubkey_name Arbitrary identifier of the user's public key. |
| 203 | * If a public key with this identifier already exists for this user, it's contents will be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 204 | * @param[in] pubkey_path Path to a file containing the user's public key. |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 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 | */ |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 209 | int nc_server_config_new_ssh_client_auth_pubkey(const struct ly_ctx *ctx, const char *endpt_name, |
| 210 | const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config); |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 211 | |
| 212 | /** |
| 213 | * @brief Creates new YANG configuration data nodes for a client, which supports the password authentication method. |
| 214 | * |
| 215 | * This function sets the password for the given user. |
| 216 | * |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 217 | * @param[in] ctx libyang context. |
| 218 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 219 | * If an endpoint with this identifier already exists, it's user might be changed. |
| 220 | * @param[in] user_name Arbitrary identifier of the user. |
| 221 | * If an user with this identifier already exists, it's contents will be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 222 | * @param[in] password Cleartext user's password. |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 223 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 224 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 225 | * @return 0 on success, non-zero otherwise. |
| 226 | */ |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 227 | int nc_server_config_new_ssh_client_auth_password(const struct ly_ctx *ctx, const char *endpt_name, |
| 228 | const char *user_name, const char *password, struct lyd_node **config); |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 229 | |
| 230 | /** |
| 231 | * @brief Creates new YANG configuration data nodes for a client, which supports the none authentication method. |
| 232 | * |
| 233 | * @param[in] ctx libyang context. |
| 234 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 235 | * If an endpoint with this identifier already exists, it's user might be changed. |
| 236 | * @param[in] user_name Arbitrary identifier of the user. |
| 237 | * If an user with this identifier already exists, it's contents will be changed. |
| 238 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 239 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 240 | * @return 0 on success, non-zero otherwise. |
| 241 | */ |
roman | 466719d | 2023-05-05 16:14:37 +0200 | [diff] [blame] | 242 | int nc_server_config_new_ssh_client_auth_none(const struct ly_ctx *ctx, const char *endpt_name, |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 243 | const char *user_name, struct lyd_node **config); |
| 244 | |
| 245 | /** |
| 246 | * @brief Creates new YANG configuration data nodes for a client, which supports the interactive authentication method. |
| 247 | * |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 248 | * @param[in] ctx libyang context. |
| 249 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 250 | * If an endpoint with this identifier already exists, it's user might be changed. |
| 251 | * @param[in] user_name Arbitrary identifier of the user. |
| 252 | * If an user with this identifier already exists, it's contents will be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 253 | * @param[in] pam_config_name Name of the PAM configuration file. |
| 254 | * @param[in] pam_config_name Optional. The absolute path to the directory in which the configuration file |
| 255 | * with the name conf_name is located. A newer version (>= 1.4) of PAM library is required to be able to specify |
| 256 | * the path. If NULL is passed, then the PAM's system directories will be searched (usually /etc/pam.d/). |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 257 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 258 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 259 | * @return 0 on success, non-zero otherwise. |
| 260 | */ |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 261 | int nc_server_config_new_ssh_client_auth_interactive(const struct ly_ctx *ctx, const char *endpt_name, |
| 262 | const char *user_name, const char *pam_config_name, const char *pam_config_dir, struct lyd_node **config); |
| 263 | |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 264 | /** |
| 265 | * @brief Creates new YANG configuration data nodes for a server's certificate. |
| 266 | * |
| 267 | * @param[in] ctx libyang context. |
| 268 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 269 | * If an endpoint with this identifier already exists, it's server certificate will be changed. |
| 270 | * @param[in] pubkey_path Optional path to the server's public key file. If not provided, |
| 271 | * it will be generated from the private key. |
| 272 | * @param[in] privkey_path Path to the server's private key file. |
| 273 | * @param[in] certificate_path Path to the server's certificate file. |
| 274 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 275 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 276 | * @return 0 on success, non-zero otherwise. |
| 277 | */ |
| 278 | int nc_server_config_new_tls_server_certificate(const struct ly_ctx *ctx, const char *endpt_name, const char *pubkey_path, |
| 279 | const char *privkey_path, const char *certificate_path, struct lyd_node **config); |
| 280 | |
| 281 | /** |
| 282 | * @brief Creates new YANG configuration data nodes for a client's (end-entity) certificate. |
| 283 | * |
| 284 | * @param[in] ctx libyang context. |
| 285 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 286 | * If an endpoint with this identifier already exists, it's contents will be changed. |
| 287 | * @param[in] cert_name Arbitrary identifier of the client's certificate. |
| 288 | * If a client certificate with this indetifier already exists, it will be changed. |
| 289 | * @param[in] cert_path Path to the client's certificate file. |
| 290 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 291 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 292 | * @return 0 on success, non-zero otherwise. |
| 293 | */ |
| 294 | int nc_server_config_new_tls_client_certificate(const struct ly_ctx *ctx, const char *endpt_name, const char *cert_name, |
| 295 | const char *cert_path, struct lyd_node **config); |
| 296 | |
| 297 | /** |
| 298 | * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate. |
| 299 | * |
| 300 | * @param[in] ctx libyang context. |
| 301 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 302 | * If an endpoint with this identifier already exists, it's contents will be changed. |
| 303 | * @param[in] cert_name Arbitrary identifier of the certificate authority certificate. |
| 304 | * If a CA with this indetifier already exists, it will be changed. |
| 305 | * @param[in] cert_path Path to the CA certificate file. |
| 306 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 307 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 308 | * @return 0 on success, non-zero otherwise. |
| 309 | */ |
| 310 | int nc_server_config_new_tls_client_ca(const struct ly_ctx *ctx, const char *endpt_name, const char *cert_name, |
| 311 | const char *cert_path, struct lyd_node **config); |
| 312 | |
| 313 | /** |
| 314 | * @brief Creates new YANG configuration data nodes for a cert-to-name entry. |
| 315 | * |
| 316 | * @param[in] ctx libyang context. |
| 317 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 318 | * If an endpoint with this identifier already exists, it's contents will be changed. |
| 319 | * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier). |
| 320 | * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is |
| 321 | * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry. |
| 322 | * @param[in] map_type Mapping username to the certificate option. |
| 323 | * @param[in] name Username for this cert-to-name entry. |
| 324 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 325 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 326 | * @return 0 on success, non-zero otherwise. |
| 327 | */ |
| 328 | int nc_server_config_new_tls_ctn(const struct ly_ctx *ctx, const char *endpt_name, uint32_t id, const char *fingerprint, |
| 329 | NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config); |
| 330 | |
roman | 12644fe | 2023-06-08 11:06:42 +0200 | [diff] [blame^] | 331 | /** |
| 332 | * @brief Creates new YANG configuration data nodes for a TLS version. |
| 333 | * |
| 334 | * @param[in] ctx libyang context. |
| 335 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 336 | * If an endpoint with this identifier already exists, it's contents will be changed. |
| 337 | * @param[in] tls_version TLS version to be used. Call this multiple times to set |
| 338 | * the accepted versions of the TLS protocol and let the client and server negotiate |
| 339 | * the given version. |
| 340 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 341 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 342 | * @return 0 on success, non-zero otherwise. |
| 343 | */ |
| 344 | int nc_server_config_new_tls_version(const struct ly_ctx *ctx, const char *endpt_name, |
| 345 | NC_TLS_VERSION tls_version, struct lyd_node **config); |
| 346 | |
| 347 | /** |
| 348 | * @brief Creates new YANG configuration data nodes for a TLS cipher. |
| 349 | * |
| 350 | * @param[in] ctx libyang context. |
| 351 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 352 | * If an endpoint with this identifier already exists, it's contents will be changed. |
| 353 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 354 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 355 | * @param[in] cipher_count Number of ciphers. |
| 356 | * @param[in] ... TLS ciphers. These ciphers MUST be in the format as listed in the |
| 357 | * iana-tls-cipher-suite-algs YANG model (lowercase and separated by dashes). Regardless |
| 358 | * of the TLS protocol version used, all of these ciphers will be tried and some of them |
| 359 | * might not be set (TLS handshake might fail then). For the list of supported ciphers see |
| 360 | * the OpenSSL documentation. |
| 361 | * @return 0 on success, non-zero otherwise. |
| 362 | */ |
| 363 | int nc_server_config_new_tls_ciphers(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config, |
| 364 | uint16_t cipher_count, ...); |
| 365 | |
roman | 2eab474 | 2023-06-06 10:00:26 +0200 | [diff] [blame] | 366 | #endif /* NC_ENABLED_SSH_TLS */ |
roman | 45cec4e | 2023-02-17 10:21:39 +0100 | [diff] [blame] | 367 | |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 368 | #ifdef __cplusplus |
| 369 | } |
| 370 | #endif |
| 371 | |
| 372 | #endif /* NC_SESSION_SERVER_H_ */ |