OpenVAS Scanner 23.23.1
openvas-krb5.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Greenbone AG
2//
3// SPDX-License-Identifier: GPL-2.0-or-later WITH x11vnc-openssl-exception
4
5#ifndef OPENVAS_KRB5
6#define OPENVAS_KRB5 1
7#include <stdbool.h>
8#include <stddef.h>
9// Enables or disables the cache implementation.
10//
11// When using the cached functions it will store each credential in a memory
12// list and refresh a ticket when required or reauthenticate depending on the
13// requirements in the background.
14#define OPENVAS_KRB5_CACHED 1
15
16typedef enum
17{
19 // Is returned when the krb5.conf was not found
28 // can only happen when GFP_ATOMIC is set on the kernel.
30
31 // Is an transitive error code to indicate an error originating from the
32 // underlying krb5 implementation. It must be last and can not check by equals
33 // operation as each krb5 error return will be added with that number
34 // representation,
37
39{
40 void *data;
41 size_t len;
42};
43
45{
48};
49
56
57typedef struct
58{
61 // required for the case that the realm is not configured in the krb5.conf
62 // will be ignored otherwise.
67
68// Finds the kdc defined for the given realm.
69//
70// It returns the found kdc into `kdc` when `kdc` is not NULL.
71// If kdc is not NULL it requires that the value pointer is NULL otherwise an
72// error code is returned.
74o_krb5_find_kdc (const OKrb5Credential *creds, char **kdc);
75// Adds realm with the given kdc into krb5.conf if the krc5.conf is not found it
76// will create a new one
78o_krb5_add_realm (const OKrb5Credential *creds, const char *kdc);
79
80#define okrb5_slice_from_str(str) \
81 (struct OKrb5Slice) \
82 { \
83 .data = (void *) str, .len = str == NULL ? 0 : strlen (str) \
84 }
85
86#define okrb5_set_slice_from_str(slice, str) \
87 do \
88 { \
89 slice.data = (void *) str; \
90 slice.len = str == NULL ? 0 : strlen (str); \
91 } \
92 while (0)
93
95// Unsure about bool type
96
99 struct OKrb5Slice **out);
100
101struct OKrb5GSSContext *
103
104void
106
109 struct OKrb5GSSContext *gss_context);
110
112o_krb5_gss_update_context (struct OKrb5GSSContext *gss_context,
113 const struct OKrb5Slice *in_data,
114 struct OKrb5Slice **out_data, bool *more);
115
116// Returns NULL if the error code is not found. The returned string must be
117// freed by the caller.
118char *
120
121#endif
#define code
OKrb5ErrorCode
Definition openvas-krb5.h:17
@ O_KRB5_EXPECTED_NULL
Definition openvas-krb5.h:25
@ O_KRB5_SUCCESS
Definition openvas-krb5.h:18
@ O_KRB5_EXPECTED_NOT_NULL
Definition openvas-krb5.h:26
@ O_KRB5_ERROR
Definition openvas-krb5.h:35
@ O_KRB5_UNABLE_TO_WRITE
Definition openvas-krb5.h:27
@ O_KRB5_NOMEM
Definition openvas-krb5.h:29
@ O_KRB5_CONF_NOT_CREATED
Definition openvas-krb5.h:21
@ O_KRB5_REALM_NOT_FOUND
Definition openvas-krb5.h:24
@ O_KRB5_TMP_CONF_NOT_MOVED
Definition openvas-krb5.h:23
@ O_KRB5_TMP_CONF_NOT_CREATED
Definition openvas-krb5.h:22
@ O_KRB5_CONF_NOT_FOUND
Definition openvas-krb5.h:20
char * okrb5_error_code_to_string(const OKrb5ErrorCode code)
Definition openvas-krb5.c:600
void okrb5_gss_free_context(struct OKrb5GSSContext *context)
Definition openvas-krb5.c:405
OKrb5ErrorCode o_krb5_add_realm(const OKrb5Credential *creds, const char *kdc)
Definition openvas-krb5.c:247
OKrb5ErrorCode o_krb5_find_kdc(const OKrb5Credential *creds, char **kdc)
Definition openvas-krb5.c:85
OKrb5ErrorCode o_krb5_gss_prepare_context(const OKrb5Credential *creds, struct OKrb5GSSContext *gss_context)
Definition openvas-krb5.c:445
OKrb5ErrorCode o_krb5_gss_session_key_context(struct OKrb5GSSContext *gss_context, struct OKrb5Slice **out)
Definition openvas-krb5.c:563
struct OKrb5GSSContext * okrb5_gss_init_context(void)
Definition openvas-krb5.c:392
OKrb5ErrorCode o_krb5_gss_update_context(struct OKrb5GSSContext *gss_context, const struct OKrb5Slice *in_data, struct OKrb5Slice **out_data, bool *more)
Definition openvas-krb5.c:521
Definition openvas-krb5.h:58
struct OKrb5Slice kdc
Definition openvas-krb5.h:63
struct OKrb5Slice realm
Definition openvas-krb5.h:60
struct OKrb5Target target
Definition openvas-krb5.h:65
struct OKrb5Slice config_path
Definition openvas-krb5.h:59
struct OKrb5User user
Definition openvas-krb5.h:64
Definition openvas-krb5.c:308
Definition openvas-krb5.h:39
void * data
Definition openvas-krb5.h:40
size_t len
Definition openvas-krb5.h:41
Definition openvas-krb5.h:51
struct OKrb5Slice service
Definition openvas-krb5.h:53
struct OKrb5Slice domain
Definition openvas-krb5.h:54
struct OKrb5Slice host_name
Definition openvas-krb5.h:52
Definition openvas-krb5.h:45
struct OKrb5Slice password
Definition openvas-krb5.h:47
struct OKrb5Slice user
Definition openvas-krb5.h:46