libssh: /build/libssh/src/libssh-0.12.2/include/libssh/gssapi.h Source File

libssh 0.12.2 The SSH library

Loading...
Searching...
No Matches
gssapi.h
1/*
2 * This file is part of the SSH Library
3 *
4 * Copyright (c) 2013 by Aris Adamantiadis
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef GSSAPI_H_
22#define GSSAPI_H_
23
24#include "config.h"
25#ifdef WITH_GSSAPI
26#include "session.h"
27#include <gssapi/gssapi.h>
28
29/* all OID begin with the tag identifier + length */
30#define SSH_OID_TAG 06
31
32#define GSSAPI_KEY_EXCHANGE_SUPPORTED "gss-group14-sha256-," \
33 "gss-group16-sha512-," \
34 "gss-nistp256-sha256-," \
35 "gss-curve25519-sha256-"
36
37typedef struct ssh_gssapi_struct *ssh_gssapi;
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
44enum ssh_gssapi_state_e {
45 SSH_GSSAPI_STATE_NONE, /* no status */
46 SSH_GSSAPI_STATE_RCV_TOKEN, /* Expecting a token */
47 SSH_GSSAPI_STATE_RCV_MIC, /* Expecting a MIC */
48};
49
50struct ssh_gssapi_struct{
51 enum ssh_gssapi_state_e state; /* current state */
52 gss_cred_id_t server_creds; /* credentials of server */
53 gss_cred_id_t client_creds; /* creds delegated by the client */
54 gss_ctx_id_t ctx; /* the authentication context */
55 gss_name_t client_name; /* Identity of the client */
56 char *user; /* username of client */
57 char *canonic_user; /* canonic form of the client's username */
58 struct {
59 gss_name_t server_name; /* identity of server */
60 OM_uint32 flags; /* flags used for init context */
61 gss_OID oid; /* mech being used for authentication */
62 gss_cred_id_t creds; /* creds used to initialize context */
63 gss_cred_id_t client_deleg_creds; /* delegated creds (const, not freeable) */
64 } client;
65};
66
67#ifdef WITH_SERVER
68int ssh_gssapi_handle_userauth(ssh_session session, const char *user, uint32_t n_oid, ssh_string *oids);
69 SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_server);
70 SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_mic);
71int ssh_gssapi_server_oids(gss_OID_set *selected);
72#endif /* WITH_SERVER */
73
74 SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token);
75 SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_client);
76 SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_response);
77
78
79int ssh_gssapi_init(ssh_session session);
80void ssh_gssapi_log_error(int verb, const char *msg_a, int maj_stat, int min_stat);
81int ssh_gssapi_auth_mic(ssh_session session);
82void ssh_gssapi_free(ssh_session session);
83int ssh_gssapi_client_identity(ssh_session session, gss_OID_set *valid_oids);
84char *ssh_gssapi_name_to_char(gss_name_t name);
85int ssh_gssapi_import_name(struct ssh_gssapi_struct *gssapi, const char *host);
86OM_uint32 ssh_gssapi_init_ctx(struct ssh_gssapi_struct *gssapi,
87 gss_buffer_desc *input_token,
88 gss_buffer_desc *output_token,
89 OM_uint32 *ret_flags);
90
91char *ssh_gssapi_oid_hash(ssh_string oid);
92char *ssh_gssapi_kex_mechs(ssh_session session);
93int ssh_gssapi_check_client_config(ssh_session session);
94ssh_buffer ssh_gssapi_build_mic(ssh_session session, const char *context);
95int ssh_gssapi_auth_keyex_mic(ssh_session session,
96 gss_buffer_desc *mic_token_buf);
97
98#ifdef __cplusplus
99}
100#endif
101
102#endif /* WITH_GSSAPI */
103#endif /* GSSAPI_H */
SSH_PACKET_CALLBACK
#define SSH_PACKET_CALLBACK(name)
This macro declares a packet callback handler.
Definition callbacks.h:625