7108fd32de5e462d4c60c786eb001b5b3aec594c
[krb5.git] / src / lib / krb5 / krb / authdata.h
1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* lib/krb5/krb/authdata.h */
3 /*
4  * Copyright (C) 2009 by the Massachusetts Institute of Technology.
5  * All rights reserved.
6  *
7  * Export of this software from the United States of America may
8  *   require a specific license from the United States Government.
9  *   It is the responsibility of any person or organization contemplating
10  *   export to obtain such a license before exporting.
11  *
12  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13  * distribute this software and its documentation for any purpose and
14  * without fee is hereby granted, provided that the above copyright
15  * notice appear in all copies and that both that copyright notice and
16  * this permission notice appear in supporting documentation, and that
17  * the name of M.I.T. not be used in advertising or publicity pertaining
18  * to distribution of the software without specific, written prior
19  * permission.  Furthermore if you modify this software you must label
20  * your software as modified software and not distribute it in such a
21  * fashion that it might be confused with the original M.I.T. software.
22  * M.I.T. makes no representations about the suitability of
23  * this software for any purpose.  It is provided "as is" without express
24  * or implied warranty.
25  */
26
27 #ifndef KRB_AUTHDATA_H
28
29 #define KRB_AUTHDATA_H
30
31 #include <k5-int.h>
32 #include "k5-utf8.h"
33
34
35 /* authdata.c */
36 krb5_error_code
37 krb5int_authdata_verify(krb5_context context,
38                         krb5_authdata_context,
39                         krb5_flags usage,
40                         const krb5_auth_context *auth_context,
41                         const krb5_keyblock *key,
42                         const krb5_ap_req *ap_req);
43
44 /* PAC */
45 /*
46  * A PAC consists of a sequence of PAC_INFO_BUFFERs, preceeded by
47  * a PACTYPE header. Decoding the contents of the buffers is left
48  * to the application (notwithstanding signature verification).
49  */
50
51 typedef struct _PAC_INFO_BUFFER {
52     krb5_ui_4 ulType;
53     krb5_ui_4 cbBufferSize;
54     krb5_ui_8 Offset;
55 } PAC_INFO_BUFFER;
56
57 typedef struct _PACTYPE {
58     krb5_ui_4 cBuffers;
59     krb5_ui_4 Version;
60     PAC_INFO_BUFFER Buffers[1];
61 } PACTYPE;
62
63 struct krb5_pac_data {
64     PACTYPE *pac;       /* PAC header + info buffer array */
65     krb5_data data;     /* PAC data (including uninitialised header) */
66     krb5_boolean verified;
67 };
68
69
70
71 #define PAC_ALIGNMENT               8
72 #define PACTYPE_LENGTH              8U
73 #define PAC_SIGNATURE_DATA_LENGTH   4U
74 #define PAC_CLIENT_INFO_LENGTH      10U
75 #define PAC_INFO_BUFFER_LENGTH  16
76 /* ulType */
77 #define PAC_LOGON_INFO          1
78 #define PAC_CREDENTIALS_INFO    2
79 #define PAC_SERVER_CHECKSUM     6
80 #define PAC_PRIVSVR_CHECKSUM    7
81 #define PAC_CLIENT_INFO         10
82 #define PAC_DELEGATION_INFO     11
83 #define PAC_UPN_DNS_INFO        12
84
85 #define NT_TIME_EPOCH               11644473600LL
86
87 extern krb5plugin_authdata_client_ftable_v0 krb5int_mspac_authdata_client_ftable;
88 extern krb5plugin_authdata_client_ftable_v0 krb5int_s4u2proxy_authdata_client_ftable;
89
90 krb5_error_code
91 k5_pac_locate_buffer(krb5_context context,
92                      const krb5_pac pac,
93                      krb5_ui_4 type,
94                      krb5_data *data);
95
96 krb5_error_code
97 k5_pac_validate_client(krb5_context context,
98                        const krb5_pac pac,
99                        krb5_timestamp authtime,
100                        krb5_const_principal principal);
101
102 krb5_error_code
103 k5_pac_add_buffer(krb5_context context,
104                   krb5_pac pac,
105                   krb5_ui_4 type,
106                   const krb5_data *data,
107                   krb5_boolean zerofill,
108                   krb5_data *out_data);
109
110 krb5_error_code
111 k5_seconds_since_1970_to_time(krb5_timestamp elapsedSeconds,
112                               krb5_ui_8 *ntTime);
113
114
115 #endif /* !KRB_AUTHDATA_H */