| 1 | #include "puttyps.h" |
| 2 | |
| 3 | #define SSH2_GSS_OIDTYPE 0x06 |
| 4 | typedef void *Ssh_gss_ctx; |
| 5 | typedef void *Ssh_gss_name; |
| 6 | |
| 7 | typedef enum Ssh_gss_stat { |
| 8 | SSH_GSS_OK = 0, |
| 9 | SSH_GSS_S_CONTINUE_NEEDED, |
| 10 | SSH_GSS_NO_MEM, |
| 11 | SSH_GSS_BAD_HOST_NAME, |
| 12 | SSH_GSS_FAILURE |
| 13 | } Ssh_gss_stat; |
| 14 | |
| 15 | #define SSH_GSS_S_COMPLETE SSH_GSS_OK |
| 16 | |
| 17 | #define SSH_GSS_CLEAR_BUF(buf) do { \ |
| 18 | (*buf).length = 0; \ |
| 19 | (*buf).value = NULL; \ |
| 20 | } while (0) |
| 21 | |
| 22 | /* Functions, provided by either wingss.c or uxgss.c */ |
| 23 | |
| 24 | /* |
| 25 | * Do startup-time initialisation for using GSSAPI. (On Windows, |
| 26 | * for instance, this dynamically loads the GSSAPI DLL and |
| 27 | * retrieves some function pointers.) |
| 28 | * |
| 29 | * Return value is 1 on success, or 0 if initialisation failed. |
| 30 | * |
| 31 | * May be called multiple times (since the most convenient place |
| 32 | * to call it _from_ is the ssh.c setup code), and will harmlessly |
| 33 | * return success if already initialised. |
| 34 | */ |
| 35 | int ssh_gss_init(void); |
| 36 | |
| 37 | /* |
| 38 | * Fills in buf with a string describing the GSSAPI mechanism in |
| 39 | * use. buf->data is not dynamically allocated. |
| 40 | */ |
| 41 | Ssh_gss_stat ssh_gss_indicate_mech(Ssh_gss_buf *buf); |
| 42 | |
| 43 | /* |
| 44 | * Converts a name such as a hostname into a GSSAPI internal form, |
| 45 | * which is placed in "out". The result should be freed by |
| 46 | * ssh_gss_release_name(). |
| 47 | */ |
| 48 | Ssh_gss_stat ssh_gss_import_name(char *in, Ssh_gss_name *out); |
| 49 | |
| 50 | /* |
| 51 | * Frees the contents of an Ssh_gss_name structure filled in by |
| 52 | * ssh_gss_import_name(). |
| 53 | */ |
| 54 | Ssh_gss_stat ssh_gss_release_name(Ssh_gss_name *name); |
| 55 | |
| 56 | /* |
| 57 | * The main GSSAPI security context setup function. The "out" |
| 58 | * parameter will need to be freed by ssh_gss_free_tok. |
| 59 | */ |
| 60 | Ssh_gss_stat ssh_gss_init_sec_context(Ssh_gss_ctx *ctx, Ssh_gss_name name, int delegate, |
| 61 | Ssh_gss_buf *in, Ssh_gss_buf *out); |
| 62 | |
| 63 | /* |
| 64 | * Frees the contents of an Ssh_gss_buf filled in by |
| 65 | * ssh_gss_init_sec_context(). Do not accidentally call this on |
| 66 | * something filled in by ssh_gss_get_mic() (which requires a |
| 67 | * different free function) or something filled in by any other |
| 68 | * way. |
| 69 | */ |
| 70 | Ssh_gss_stat ssh_gss_free_tok(Ssh_gss_buf *); |
| 71 | |
| 72 | /* |
| 73 | * Acquires the credentials to perform authentication in the first |
| 74 | * place. Needs to be freed by ssh_gss_release_cred(). |
| 75 | */ |
| 76 | Ssh_gss_stat ssh_gss_acquire_cred(Ssh_gss_ctx *); |
| 77 | |
| 78 | /* |
| 79 | * Frees the contents of an Ssh_gss_ctx filled in by |
| 80 | * ssh_gss_acquire_cred(). |
| 81 | */ |
| 82 | Ssh_gss_stat ssh_gss_release_cred(Ssh_gss_ctx *); |
| 83 | |
| 84 | /* |
| 85 | * Gets a MIC for some input data. "out" needs to be freed by |
| 86 | * ssh_gss_free_mic(). |
| 87 | */ |
| 88 | Ssh_gss_stat ssh_gss_get_mic(Ssh_gss_ctx ctx, Ssh_gss_buf *in, |
| 89 | Ssh_gss_buf *out); |
| 90 | |
| 91 | /* |
| 92 | * Frees the contents of an Ssh_gss_buf filled in by |
| 93 | * ssh_gss_get_mic(). Do not accidentally call this on something |
| 94 | * filled in by ssh_gss_init_sec_context() (which requires a |
| 95 | * different free function) or something filled in by any other |
| 96 | * way. |
| 97 | */ |
| 98 | Ssh_gss_stat ssh_gss_free_mic(Ssh_gss_buf *); |
| 99 | |
| 100 | /* |
| 101 | * Return an error message after authentication failed. The |
| 102 | * message string is returned in "buf", with buf->len giving the |
| 103 | * number of characters of printable message text and buf->data |
| 104 | * containing one more character which is a trailing NUL. |
| 105 | * buf->data should be manually freed by the caller. |
| 106 | */ |
| 107 | Ssh_gss_stat ssh_gss_display_status(Ssh_gss_ctx, Ssh_gss_buf *buf); |