blob: 129998ed4597bf90dbf69209adf182bd6688df2a [file] [log] [blame]
roman466719d2023-05-05 16:14:37 +02001/**
roman3f9b65c2023-06-05 14:26:58 +02002 * @file config_new.h
roman466719d2023-05-05 16:14:37 +02003 * @author Roman Janota <janota@cesnet.cz>
roman3f9b65c2023-06-05 14:26:58 +02004 * @brief libnetconf2 server new configuration creation header
roman466719d2023-05-05 16:14:37 +02005 *
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
roman3f9b65c2023-06-05 14:26:58 +020016#ifndef NC_CONFIG_NEW_H_
17#define NC_CONFIG_NEW_H_
roman466719d2023-05-05 16:14:37 +020018
19#include <libyang/libyang.h>
20
21#include "session_p.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
roman2eab4742023-06-06 10:00:26 +020027#ifdef NC_ENABLED_SSH_TLS
28
roman466719d2023-05-05 16:14:37 +020029/* 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
roman3f9b65c2023-06-05 14:26:58 +020062/* 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
roman466719d2023-05-05 16:14:37 +020068typedef enum {
69 NC_ALG_HOSTKEY,
70 NC_ALG_KEY_EXCHANGE,
71 NC_ALG_ENCRYPTION,
72 NC_ALG_MAC
73} NC_ALG_TYPE;
74
roman3f9b65c2023-06-05 14:26:58 +020075int 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
78int nc_server_config_new_get_pubkey(const char *pubkey_path, char **pubkey, NC_PUBKEY_FORMAT *pubkey_type);
79
80int nc_server_config_new_read_certificate(const char *cert_path, char **cert);
81
roman3f9b65c2023-06-05 14:26:58 +020082const char * nc_config_new_privkey_format_to_identityref(NC_PRIVKEY_FORMAT format);
83
roman2eab4742023-06-06 10:00:26 +020084#endif /* NC_ENABLED_SSH_TLS */
85
86int nc_config_new_check_add_operation(const struct ly_ctx *ctx, struct lyd_node *top);
87
roman466719d2023-05-05 16:14:37 +020088#ifdef __cplusplus
89}
90#endif
91
roman3f9b65c2023-06-05 14:26:58 +020092#endif /* NC_CONFIG_NEW_H_ */