Home | History | Annotate | Line # | Download | only in ntlm
      1  1.1     elric /*	$NetBSD: ntlm.h,v 1.2 2017/01/28 21:31:47 christos Exp $	*/
      2  1.1     elric 
      3  1.1     elric /*
      4  1.1     elric  * Copyright (c) 2006 - 2007 Kungliga Tekniska Hgskolan
      5  1.1     elric  * (Royal Institute of Technology, Stockholm, Sweden).
      6  1.1     elric  * All rights reserved.
      7  1.1     elric  *
      8  1.1     elric  * Redistribution and use in source and binary forms, with or without
      9  1.1     elric  * modification, are permitted provided that the following conditions
     10  1.1     elric  * are met:
     11  1.1     elric  *
     12  1.1     elric  * 1. Redistributions of source code must retain the above copyright
     13  1.1     elric  *    notice, this list of conditions and the following disclaimer.
     14  1.1     elric  *
     15  1.1     elric  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1     elric  *    notice, this list of conditions and the following disclaimer in the
     17  1.1     elric  *    documentation and/or other materials provided with the distribution.
     18  1.1     elric  *
     19  1.1     elric  * 3. Neither the name of the Institute nor the names of its contributors
     20  1.1     elric  *    may be used to endorse or promote products derived from this software
     21  1.1     elric  *    without specific prior written permission.
     22  1.1     elric  *
     23  1.1     elric  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
     24  1.1     elric  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  1.1     elric  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  1.1     elric  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
     27  1.1     elric  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  1.1     elric  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  1.1     elric  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  1.1     elric  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  1.1     elric  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  1.1     elric  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  1.1     elric  * SUCH DAMAGE.
     34  1.1     elric  */
     35  1.1     elric 
     36  1.2  christos /* Id */
     37  1.1     elric 
     38  1.1     elric #ifndef NTLM_NTLM_H
     39  1.1     elric #define NTLM_NTLM_H
     40  1.1     elric 
     41  1.1     elric #include <config.h>
     42  1.1     elric 
     43  1.1     elric #include <stdio.h>
     44  1.1     elric #include <stdlib.h>
     45  1.1     elric #include <assert.h>
     46  1.1     elric #include <string.h>
     47  1.1     elric #include <errno.h>
     48  1.1     elric 
     49  1.1     elric #include <krb5/roken.h>
     50  1.1     elric 
     51  1.1     elric #include <gssapi/gssapi.h>
     52  1.1     elric #include <gssapi/gssapi_ntlm.h>
     53  1.1     elric #include <gssapi_mech.h>
     54  1.1     elric #include <gssapi/gssapi_oid.h>
     55  1.1     elric 
     56  1.1     elric #include <krb5/krb5.h>
     57  1.1     elric #include <krb5/kcm.h>
     58  1.1     elric #include <heim_threads.h>
     59  1.1     elric 
     60  1.1     elric #include <krb5/heimntlm.h>
     61  1.1     elric 
     62  1.1     elric #define HC_DEPRECATED_CRYPTO
     63  1.1     elric #include "crypto-headers.h"
     64  1.1     elric 
     65  1.1     elric typedef OM_uint32
     66  1.1     elric (*ntlm_interface_init)(OM_uint32 *, void **);
     67  1.1     elric 
     68  1.1     elric typedef OM_uint32
     69  1.1     elric (*ntlm_interface_destroy)(OM_uint32 *, void *);
     70  1.1     elric 
     71  1.1     elric typedef int
     72  1.1     elric (*ntlm_interface_probe)(OM_uint32 *, void *, const char *);
     73  1.1     elric 
     74  1.1     elric typedef OM_uint32
     75  1.1     elric (*ntlm_interface_type2)(OM_uint32 *, void *, uint32_t, const char *,
     76  1.1     elric 			const char *, uint32_t *, struct ntlm_buf *);
     77  1.1     elric 
     78  1.1     elric typedef OM_uint32
     79  1.1     elric (*ntlm_interface_type3)(OM_uint32 *, void *, const struct ntlm_type3 *,
     80  1.1     elric 			struct ntlm_buf *);
     81  1.1     elric 
     82  1.1     elric typedef void
     83  1.1     elric (*ntlm_interface_free_buffer)(struct ntlm_buf *);
     84  1.1     elric 
     85  1.1     elric struct ntlm_server_interface {
     86  1.1     elric     ntlm_interface_init nsi_init;
     87  1.1     elric     ntlm_interface_destroy nsi_destroy;
     88  1.1     elric     ntlm_interface_probe nsi_probe;
     89  1.1     elric     ntlm_interface_type2 nsi_type2;
     90  1.1     elric     ntlm_interface_type3 nsi_type3;
     91  1.1     elric     ntlm_interface_free_buffer nsi_free_buffer;
     92  1.1     elric };
     93  1.1     elric 
     94  1.1     elric 
     95  1.1     elric struct ntlmv2_key {
     96  1.1     elric     uint32_t seq;
     97  1.1     elric     RC4_KEY sealkey;
     98  1.1     elric     RC4_KEY *signsealkey;
     99  1.1     elric     unsigned char signkey[16];
    100  1.1     elric };
    101  1.1     elric 
    102  1.1     elric extern struct ntlm_server_interface ntlmsspi_kdc_digest;
    103  1.1     elric 
    104  1.1     elric typedef struct ntlm_cred {
    105  1.1     elric     gss_cred_usage_t usage;
    106  1.1     elric     char *username;
    107  1.1     elric     char *domain;
    108  1.1     elric     struct ntlm_buf key;
    109  1.1     elric } *ntlm_cred;
    110  1.1     elric 
    111  1.1     elric typedef struct {
    112  1.1     elric     struct ntlm_server_interface *server;
    113  1.1     elric     void *ictx;
    114  1.1     elric     ntlm_cred client;
    115  1.1     elric     OM_uint32 gssflags;
    116  1.1     elric     uint32_t kcmflags;
    117  1.1     elric     uint32_t flags;
    118  1.1     elric     uint32_t status;
    119  1.1     elric #define STATUS_OPEN 1
    120  1.1     elric #define STATUS_CLIENT 2
    121  1.1     elric #define STATUS_SESSIONKEY 4
    122  1.1     elric     krb5_data sessionkey;
    123  1.1     elric 
    124  1.1     elric     gss_buffer_desc pac;
    125  1.1     elric 
    126  1.1     elric     union {
    127  1.1     elric 	struct {
    128  1.1     elric 	    struct {
    129  1.1     elric 		uint32_t seq;
    130  1.1     elric 		RC4_KEY key;
    131  1.1     elric 	    } crypto_send, crypto_recv;
    132  1.1     elric 	} v1;
    133  1.1     elric 	struct {
    134  1.1     elric 	    struct ntlmv2_key send, recv;
    135  1.1     elric 	} v2;
    136  1.1     elric     } u;
    137  1.1     elric } *ntlm_ctx;
    138  1.1     elric 
    139  1.1     elric typedef struct {
    140  1.1     elric     char *user;
    141  1.1     elric     char *domain;
    142  1.1     elric } *ntlm_name;
    143  1.1     elric 
    144  1.1     elric #include <ntlm-private.h>
    145  1.1     elric 
    146  1.1     elric 
    147  1.1     elric #endif /* NTLM_NTLM_H */
    148