roman | 466719d | 2023-05-05 16:14:37 +0200 | [diff] [blame] | 1 | /** |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 2 | * @file config_new.h |
roman | 466719d | 2023-05-05 16:14:37 +0200 | [diff] [blame] | 3 | * @author Roman Janota <janota@cesnet.cz> |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 4 | * @brief libnetconf2 server new configuration creation header |
roman | 466719d | 2023-05-05 16:14:37 +0200 | [diff] [blame] | 5 | * |
| 6 | * @copyright |
| 7 | * Copyright (c) 2023 CESNET, z.s.p.o. |
| 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 | |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 16 | #ifndef NC_CONFIG_NEW_H_ |
| 17 | #define NC_CONFIG_NEW_H_ |
roman | 466719d | 2023-05-05 16:14:37 +0200 | [diff] [blame] | 18 | |
| 19 | #include <libyang/libyang.h> |
| 20 | |
| 21 | #include "session_p.h" |
| 22 | |
| 23 | #ifdef __cplusplus |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
roman | 2eab474 | 2023-06-06 10:00:26 +0200 | [diff] [blame] | 27 | #ifdef NC_ENABLED_SSH_TLS |
| 28 | |
roman | 466719d | 2023-05-05 16:14:37 +0200 | [diff] [blame] | 29 | /* private key's pkcs8 header */ |
| 30 | #define NC_PKCS8_PRIVKEY_HEADER "-----BEGIN PRIVATE KEY-----\n" |
| 31 | |
| 32 | /* private key's pkcs8 footer */ |
| 33 | #define NC_PKCS8_PRIVKEY_FOOTER "\n-----END PRIVATE KEY-----\n" |
| 34 | |
| 35 | /* private key's openssh header */ |
| 36 | #define NC_OPENSSH_PRIVKEY_HEADER "-----BEGIN OPENSSH PRIVATE KEY-----\n" |
| 37 | |
| 38 | /* private key's openssh footer */ |
| 39 | #define NC_OPENSSH_PRIVKEY_FOOTER "\n-----END OPENSSH PRIVATE KEY-----\n" |
| 40 | |
| 41 | /* private key's pkcs1 rsa header */ |
| 42 | #define NC_PKCS1_RSA_PRIVKEY_HEADER "-----BEGIN RSA PRIVATE KEY-----\n" |
| 43 | |
| 44 | /* private key's sec1 ec header */ |
| 45 | #define NC_SEC1_EC_PRIVKEY_HEADER "-----BEGIN EC PRIVATE KEY-----\n" |
| 46 | |
| 47 | /* private key's header when getting an EC/RSA privkey from file using libssh */ |
| 48 | #define NC_LIBSSH_PRIVKEY_HEADER "-----BEGIN PRIVATE KEY-----\n" |
| 49 | |
| 50 | /* private key's footer when getting an EC/RSA privkey from file using libssh */ |
| 51 | #define NC_LIBSSH_PRIVKEY_FOOTER "\n-----END PRIVATE KEY-----\n" |
| 52 | |
| 53 | /* public key's ssh2 header */ |
| 54 | #define NC_SSH2_PUBKEY_HEADER "---- BEGIN SSH2 PUBLIC KEY ----\n" |
| 55 | |
| 56 | /* public key's SubjectPublicKeyInfo format header */ |
| 57 | #define NC_SUBJECT_PUBKEY_INFO_HEADER "-----BEGIN PUBLIC KEY-----\n" |
| 58 | |
| 59 | /* public key's SubjectPublicKeyInfo format footer */ |
| 60 | #define NC_SUBJECT_PUBKEY_INFO_FOOTER "\n-----END PUBLIC KEY-----\n" |
| 61 | |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 62 | /* certificate's PEM format header */ |
| 63 | #define NC_PEM_CERTIFICATE_HEADER "-----BEGIN CERTIFICATE-----\n" |
| 64 | |
| 65 | /* certificate's PEM format footer */ |
| 66 | #define NC_PEM_CERTIFICATE_FOOTER "\n-----END CERTIFICATE-----\n" |
| 67 | |
roman | 466719d | 2023-05-05 16:14:37 +0200 | [diff] [blame] | 68 | typedef enum { |
| 69 | NC_ALG_HOSTKEY, |
| 70 | NC_ALG_KEY_EXCHANGE, |
| 71 | NC_ALG_ENCRYPTION, |
| 72 | NC_ALG_MAC |
| 73 | } NC_ALG_TYPE; |
| 74 | |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 75 | int nc_server_config_new_get_keys(const char *privkey_path, const char *pubkey_path, |
| 76 | char **privkey, char **pubkey, NC_PRIVKEY_FORMAT *privkey_type, NC_PUBKEY_FORMAT *pubkey_type); |
| 77 | |
| 78 | int nc_server_config_new_get_pubkey(const char *pubkey_path, char **pubkey, NC_PUBKEY_FORMAT *pubkey_type); |
| 79 | |
| 80 | int nc_server_config_new_read_certificate(const char *cert_path, char **cert); |
| 81 | |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 82 | const char * nc_config_new_privkey_format_to_identityref(NC_PRIVKEY_FORMAT format); |
| 83 | |
roman | 2eab474 | 2023-06-06 10:00:26 +0200 | [diff] [blame] | 84 | #endif /* NC_ENABLED_SSH_TLS */ |
| 85 | |
| 86 | int nc_config_new_check_add_operation(const struct ly_ctx *ctx, struct lyd_node *top); |
| 87 | |
roman | 466719d | 2023-05-05 16:14:37 +0200 | [diff] [blame] | 88 | #ifdef __cplusplus |
| 89 | } |
| 90 | #endif |
| 91 | |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 92 | #endif /* NC_CONFIG_NEW_H_ */ |