OSDN Git Service

Update OpenSSL to 1.0.1g.
[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 #ifdef OPENSSL_SYS_WIN32\r
74 /* These can sometimes get redefined indirectly by krb5 header files\r
75  * after they get undefed in ossl_typ.h\r
76  */\r
77 #undef X509_NAME\r
78 #undef X509_EXTENSIONS\r
79 #undef OCSP_REQUEST\r
80 #undef OCSP_RESPONSE\r
81 #endif\r
82 \r
83 #ifdef  __cplusplus\r
84 extern "C" {\r
85 #endif\r
86 \r
87 /*\r
88 **      Depending on which KRB5 implementation used, some types from\r
89 **      the other may be missing.  Resolve that here and now\r
90 */\r
91 #ifdef KRB5_HEIMDAL\r
92 typedef unsigned char krb5_octet;\r
93 #define FAR\r
94 #else\r
95 \r
96 #ifndef FAR\r
97 #define FAR\r
98 #endif\r
99 \r
100 #endif\r
101 \r
102 /*      Uncomment this to debug kssl problems or\r
103 **      to trace usage of the Kerberos session key\r
104 **\r
105 **      #define         KSSL_DEBUG\r
106 */\r
107 \r
108 #ifndef KRB5SVC\r
109 #define KRB5SVC "host"\r
110 #endif\r
111 \r
112 #ifndef KRB5KEYTAB\r
113 #define KRB5KEYTAB      "/etc/krb5.keytab"\r
114 #endif\r
115 \r
116 #ifndef KRB5SENDAUTH\r
117 #define KRB5SENDAUTH    1\r
118 #endif\r
119 \r
120 #ifndef KRB5CHECKAUTH\r
121 #define KRB5CHECKAUTH   1\r
122 #endif\r
123 \r
124 #ifndef KSSL_CLOCKSKEW\r
125 #define KSSL_CLOCKSKEW  300;\r
126 #endif\r
127 \r
128 #define KSSL_ERR_MAX    255\r
129 typedef struct kssl_err_st  {\r
130         int  reason;\r
131         char text[KSSL_ERR_MAX+1];\r
132         } KSSL_ERR;\r
133 \r
134 \r
135 /*      Context for passing\r
136 **              (1) Kerberos session key to SSL, and\r
137 **              (2)     Config data between application and SSL lib\r
138 */\r
139 typedef struct kssl_ctx_st\r
140         {\r
141                                 /*      used by:    disposition:            */\r
142         char *service_name;     /*      C,S         default ok (kssl)       */\r
143         char *service_host;     /*      C           input, REQUIRED         */\r
144         char *client_princ;     /*      S           output from krb5 ticket */\r
145         char *keytab_file;      /*      S           NULL (/etc/krb5.keytab) */\r
146         char *cred_cache;       /*      C           NULL (default)          */\r
147         krb5_enctype enctype;\r
148         int length;\r
149         krb5_octet FAR *key;\r
150         } KSSL_CTX;\r
151 \r
152 #define KSSL_CLIENT     1\r
153 #define KSSL_SERVER     2\r
154 #define KSSL_SERVICE    3\r
155 #define KSSL_KEYTAB     4\r
156 \r
157 #define KSSL_CTX_OK     0\r
158 #define KSSL_CTX_ERR    1\r
159 #define KSSL_NOMEM      2\r
160 \r
161 /* Public (for use by applications that use OpenSSL with Kerberos 5 support */\r
162 krb5_error_code kssl_ctx_setstring(KSSL_CTX *kssl_ctx, int which, char *text);\r
163 KSSL_CTX *kssl_ctx_new(void);\r
164 KSSL_CTX *kssl_ctx_free(KSSL_CTX *kssl_ctx);\r
165 void kssl_ctx_show(KSSL_CTX *kssl_ctx);\r
166 krb5_error_code kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which,\r
167         krb5_data *realm, krb5_data *entity, int nentities);\r
168 krb5_error_code kssl_cget_tkt(KSSL_CTX *kssl_ctx,  krb5_data **enc_tktp,\r
169         krb5_data *authenp, KSSL_ERR *kssl_err);\r
170 krb5_error_code kssl_sget_tkt(KSSL_CTX *kssl_ctx,  krb5_data *indata,\r
171         krb5_ticket_times *ttimes, KSSL_ERR *kssl_err);\r
172 krb5_error_code kssl_ctx_setkey(KSSL_CTX *kssl_ctx, krb5_keyblock *session);\r
173 void    kssl_err_set(KSSL_ERR *kssl_err, int reason, char *text);\r
174 void kssl_krb5_free_data_contents(krb5_context context, krb5_data *data);\r
175 krb5_error_code  kssl_build_principal_2(krb5_context context,\r
176                         krb5_principal *princ, int rlen, const char *realm,\r
177                         int slen, const char *svc, int hlen, const char *host);\r
178 krb5_error_code  kssl_validate_times(krb5_timestamp atime,\r
179                                         krb5_ticket_times *ttimes);\r
180 krb5_error_code  kssl_check_authent(KSSL_CTX *kssl_ctx, krb5_data *authentp,\r
181                                     krb5_timestamp *atimep, KSSL_ERR *kssl_err);\r
182 unsigned char   *kssl_skip_confound(krb5_enctype enctype, unsigned char *authn);\r
183 \r
184 void SSL_set0_kssl_ctx(SSL *s, KSSL_CTX *kctx);\r
185 KSSL_CTX * SSL_get0_kssl_ctx(SSL *s);\r
186 char *kssl_ctx_get0_client_princ(KSSL_CTX *kctx);\r
187 \r
188 #ifdef  __cplusplus\r
189 }\r
190 #endif\r
191 #endif  /* OPENSSL_NO_KRB5      */\r
192 #endif  /* KSSL_H       */\r