OSDN Git Service

cb7feda77f3ca23c05bb60b83b98db576bff0a25
[ffftp/ffftp.git] / contrib / openssl / include / openssl / kssl.h
1 /* ssl/kssl.h -*- mode: C; c-file-style: "eay" -*- */\r
2 /* Written by Vern Staats <staatsvr@asc.hpc.mil> for the OpenSSL project 2000.\r
3  * project 2000.\r
4  */\r
5 /* ====================================================================\r
6  * Copyright (c) 2000 The OpenSSL Project.  All rights reserved.\r
7  *\r
8  * Redistribution and use in source and binary forms, with or without\r
9  * modification, are permitted provided that the following conditions\r
10  * are met:\r
11  *\r
12  * 1. Redistributions of source code must retain the above copyright\r
13  *    notice, this list of conditions and the following disclaimer.\r
14  *\r
15  * 2. Redistributions in binary form must reproduce the above copyright\r
16  *    notice, this list of conditions and the following disclaimer in\r
17  *    the documentation and/or other materials provided with the\r
18  *    distribution.\r
19  *\r
20  * 3. All advertising materials mentioning features or use of this\r
21  *    software must display the following acknowledgment:\r
22  *    "This product includes software developed by the OpenSSL Project\r
23  *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"\r
24  *\r
25  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to\r
26  *    endorse or promote products derived from this software without\r
27  *    prior written permission. For written permission, please contact\r
28  *    licensing@OpenSSL.org.\r
29  *\r
30  * 5. Products derived from this software may not be called "OpenSSL"\r
31  *    nor may "OpenSSL" appear in their names without prior written\r
32  *    permission of the OpenSSL Project.\r
33  *\r
34  * 6. Redistributions of any form whatsoever must retain the following\r
35  *    acknowledgment:\r
36  *    "This product includes software developed by the OpenSSL Project\r
37  *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"\r
38  *\r
39  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\r
40  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
41  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
42  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\r
43  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
44  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
45  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
46  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
47  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\r
48  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
49  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\r
50  * OF THE POSSIBILITY OF SUCH DAMAGE.\r
51  * ====================================================================\r
52  *\r
53  * This product includes cryptographic software written by Eric Young\r
54  * (eay@cryptsoft.com).  This product includes software written by Tim\r
55  * Hudson (tjh@cryptsoft.com).\r
56  *\r
57  */\r
58 \r
59 /*\r
60 **      19990701        VRS     Started.\r
61 */\r
62 \r
63 #ifndef KSSL_H\r
64 #define KSSL_H\r
65 \r
66 #include <openssl/opensslconf.h>\r
67 \r
68 #ifndef OPENSSL_NO_KRB5\r
69 \r
70 #include <stdio.h>\r
71 #include <ctype.h>\r
72 #include <krb5.h>\r
73 \r
74 #ifdef  __cplusplus\r
75 extern "C" {\r
76 #endif\r
77 \r
78 /*\r
79 **      Depending on which KRB5 implementation used, some types from\r
80 **      the other may be missing.  Resolve that here and now\r
81 */\r
82 #ifdef KRB5_HEIMDAL\r
83 typedef unsigned char krb5_octet;\r
84 #define FAR\r
85 #else\r
86 \r
87 #ifndef FAR\r
88 #define FAR\r
89 #endif\r
90 \r
91 #endif\r
92 \r
93 /*      Uncomment this to debug kssl problems or\r
94 **      to trace usage of the Kerberos session key\r
95 **\r
96 **      #define         KSSL_DEBUG\r
97 */\r
98 \r
99 #ifndef KRB5SVC\r
100 #define KRB5SVC "host"\r
101 #endif\r
102 \r
103 #ifndef KRB5KEYTAB\r
104 #define KRB5KEYTAB      "/etc/krb5.keytab"\r
105 #endif\r
106 \r
107 #ifndef KRB5SENDAUTH\r
108 #define KRB5SENDAUTH    1\r
109 #endif\r
110 \r
111 #ifndef KRB5CHECKAUTH\r
112 #define KRB5CHECKAUTH   1\r
113 #endif\r
114 \r
115 #ifndef KSSL_CLOCKSKEW\r
116 #define KSSL_CLOCKSKEW  300;\r
117 #endif\r
118 \r
119 #define KSSL_ERR_MAX    255\r
120 typedef struct kssl_err_st  {\r
121         int  reason;\r
122         char text[KSSL_ERR_MAX+1];\r
123         } KSSL_ERR;\r
124 \r
125 \r
126 /*      Context for passing\r
127 **              (1) Kerberos session key to SSL, and\r
128 **              (2)     Config data between application and SSL lib\r
129 */\r
130 typedef struct kssl_ctx_st\r
131         {\r
132                                 /*      used by:    disposition:            */\r
133         char *service_name;     /*      C,S         default ok (kssl)       */\r
134         char *service_host;     /*      C           input, REQUIRED         */\r
135         char *client_princ;     /*      S           output from krb5 ticket */\r
136         char *keytab_file;      /*      S           NULL (/etc/krb5.keytab) */\r
137         char *cred_cache;       /*      C           NULL (default)          */\r
138         krb5_enctype enctype;\r
139         int length;\r
140         krb5_octet FAR *key;\r
141         } KSSL_CTX;\r
142 \r
143 #define KSSL_CLIENT     1\r
144 #define KSSL_SERVER     2\r
145 #define KSSL_SERVICE    3\r
146 #define KSSL_KEYTAB     4\r
147 \r
148 #define KSSL_CTX_OK     0\r
149 #define KSSL_CTX_ERR    1\r
150 #define KSSL_NOMEM      2\r
151 \r
152 /* Public (for use by applications that use OpenSSL with Kerberos 5 support */\r
153 krb5_error_code kssl_ctx_setstring(KSSL_CTX *kssl_ctx, int which, char *text);\r
154 KSSL_CTX *kssl_ctx_new(void);\r
155 KSSL_CTX *kssl_ctx_free(KSSL_CTX *kssl_ctx);\r
156 void kssl_ctx_show(KSSL_CTX *kssl_ctx);\r
157 krb5_error_code kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which,\r
158         krb5_data *realm, krb5_data *entity, int nentities);\r
159 krb5_error_code kssl_cget_tkt(KSSL_CTX *kssl_ctx,  krb5_data **enc_tktp,\r
160         krb5_data *authenp, KSSL_ERR *kssl_err);\r
161 krb5_error_code kssl_sget_tkt(KSSL_CTX *kssl_ctx,  krb5_data *indata,\r
162         krb5_ticket_times *ttimes, KSSL_ERR *kssl_err);\r
163 krb5_error_code kssl_ctx_setkey(KSSL_CTX *kssl_ctx, krb5_keyblock *session);\r
164 void    kssl_err_set(KSSL_ERR *kssl_err, int reason, char *text);\r
165 void kssl_krb5_free_data_contents(krb5_context context, krb5_data *data);\r
166 krb5_error_code  kssl_build_principal_2(krb5_context context,\r
167                         krb5_principal *princ, int rlen, const char *realm,\r
168                         int slen, const char *svc, int hlen, const char *host);\r
169 krb5_error_code  kssl_validate_times(krb5_timestamp atime,\r
170                                         krb5_ticket_times *ttimes);\r
171 krb5_error_code  kssl_check_authent(KSSL_CTX *kssl_ctx, krb5_data *authentp,\r
172                                     krb5_timestamp *atimep, KSSL_ERR *kssl_err);\r
173 unsigned char   *kssl_skip_confound(krb5_enctype enctype, unsigned char *authn);\r
174 \r
175 #ifdef  __cplusplus\r
176 }\r
177 #endif\r
178 #endif  /* OPENSSL_NO_KRB5      */\r
179 #endif  /* KSSL_H       */\r