1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
/* Generated from /usr/src/lib/libkrb5/../../kerberosV/src/lib/asn1/k5.asn1 */
/* Do not edit */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <errno.h>
#include <krb5_asn1.h>
#include <asn1_err.h>
#include <der.h>
#include <parse_units.h>
#define BACK if (e) return e; p -= l; len -= l; ret += l
int
encode_KDCOptions(unsigned char *p, size_t len, const KDCOptions *data, size_t *size)
{
size_t ret = 0;
size_t l;
int i, e;
i = 0;
{
unsigned char c = 0;
if(data->validate) c |= 1<<0;
if(data->renew) c |= 1<<1;
if(data->enc_tkt_in_skey) c |= 1<<3;
if(data->renewable_ok) c |= 1<<4;
if(data->disable_transited_check) c |= 1<<5;
*p-- = c; len--; ret++;
c = 0;
*p-- = c; len--; ret++;
c = 0;
if(data->canonicalize) c |= 1<<0;
if(data->request_anonymous) c |= 1<<1;
if(data->unused11) c |= 1<<4;
if(data->unused10) c |= 1<<5;
if(data->unused9) c |= 1<<6;
if(data->renewable) c |= 1<<7;
*p-- = c; len--; ret++;
c = 0;
if(data->unused7) c |= 1<<0;
if(data->postdated) c |= 1<<1;
if(data->allow_postdate) c |= 1<<2;
if(data->proxy) c |= 1<<3;
if(data->proxiable) c |= 1<<4;
if(data->forwarded) c |= 1<<5;
if(data->forwardable) c |= 1<<6;
if(data->reserved) c |= 1<<7;
*p-- = c;
*p-- = 0;
len -= 2;
ret += 2;
}
e = der_put_length_and_tag (p, len, ret, UNIV, PRIM,UT_BitString, &l);
BACK;
*size = ret;
return 0;
}
#define FORW if(e) goto fail; p += l; len -= l; ret += l
int
decode_KDCOptions(const unsigned char *p, size_t len, KDCOptions *data, size_t *size)
{
size_t ret = 0, reallen;
size_t l;
int e;
memset(data, 0, sizeof(*data));
reallen = 0;
e = der_match_tag_and_length (p, len, UNIV, PRIM, UT_BitString,&reallen, &l);
FORW;
if(len < reallen)
return ASN1_OVERRUN;
p++;
len--;
reallen--;
ret++;
data->reserved = (*p >> 7) & 1;
data->forwardable = (*p >> 6) & 1;
data->forwarded = (*p >> 5) & 1;
data->proxiable = (*p >> 4) & 1;
data->proxy = (*p >> 3) & 1;
data->allow_postdate = (*p >> 2) & 1;
data->postdated = (*p >> 1) & 1;
data->unused7 = (*p >> 0) & 1;
p++; len--; reallen--; ret++;
data->renewable = (*p >> 7) & 1;
data->unused9 = (*p >> 6) & 1;
data->unused10 = (*p >> 5) & 1;
data->unused11 = (*p >> 4) & 1;
data->request_anonymous = (*p >> 1) & 1;
data->canonicalize = (*p >> 0) & 1;
p++; len--; reallen--; ret++;
p++; len--; reallen--; ret++;
data->disable_transited_check = (*p >> 5) & 1;
data->renewable_ok = (*p >> 4) & 1;
data->enc_tkt_in_skey = (*p >> 3) & 1;
data->renew = (*p >> 1) & 1;
data->validate = (*p >> 0) & 1;
p += reallen; len -= reallen; ret += reallen;
if(size) *size = ret;
return 0;
fail:
free_KDCOptions(data);
return e;
}
void
free_KDCOptions(KDCOptions *data)
{
}
size_t
length_KDCOptions(const KDCOptions *data)
{
size_t ret = 0;
ret += 7;
return ret;
}
int
copy_KDCOptions(const KDCOptions *from, KDCOptions *to)
{
*(to) = *(from);
return 0;
}
unsigned KDCOptions2int(KDCOptions f)
{
unsigned r = 0;
if(f.reserved) r |= (1U << 0);
if(f.forwardable) r |= (1U << 1);
if(f.forwarded) r |= (1U << 2);
if(f.proxiable) r |= (1U << 3);
if(f.proxy) r |= (1U << 4);
if(f.allow_postdate) r |= (1U << 5);
if(f.postdated) r |= (1U << 6);
if(f.unused7) r |= (1U << 7);
if(f.renewable) r |= (1U << 8);
if(f.unused9) r |= (1U << 9);
if(f.unused10) r |= (1U << 10);
if(f.unused11) r |= (1U << 11);
if(f.request_anonymous) r |= (1U << 14);
if(f.canonicalize) r |= (1U << 15);
if(f.disable_transited_check) r |= (1U << 26);
if(f.renewable_ok) r |= (1U << 27);
if(f.enc_tkt_in_skey) r |= (1U << 28);
if(f.renew) r |= (1U << 30);
if(f.validate) r |= (1U << 31);
return r;
}
KDCOptions int2KDCOptions(unsigned n)
{
KDCOptions flags;
flags.reserved = (n >> 0) & 1;
flags.forwardable = (n >> 1) & 1;
flags.forwarded = (n >> 2) & 1;
flags.proxiable = (n >> 3) & 1;
flags.proxy = (n >> 4) & 1;
flags.allow_postdate = (n >> 5) & 1;
flags.postdated = (n >> 6) & 1;
flags.unused7 = (n >> 7) & 1;
flags.renewable = (n >> 8) & 1;
flags.unused9 = (n >> 9) & 1;
flags.unused10 = (n >> 10) & 1;
flags.unused11 = (n >> 11) & 1;
flags.request_anonymous = (n >> 14) & 1;
flags.canonicalize = (n >> 15) & 1;
flags.disable_transited_check = (n >> 26) & 1;
flags.renewable_ok = (n >> 27) & 1;
flags.enc_tkt_in_skey = (n >> 28) & 1;
flags.renew = (n >> 30) & 1;
flags.validate = (n >> 31) & 1;
return flags;
}
struct units KDCOptions_units[] = {
{"validate", 1U << 31},
{"renew", 1U << 30},
{"enc_tkt_in_skey", 1U << 28},
{"renewable_ok", 1U << 27},
{"disable_transited_check", 1U << 26},
{"canonicalize", 1U << 15},
{"request_anonymous", 1U << 14},
{"unused11", 1U << 11},
{"unused10", 1U << 10},
{"unused9", 1U << 9},
{"renewable", 1U << 8},
{"unused7", 1U << 7},
{"postdated", 1U << 6},
{"allow_postdate", 1U << 5},
{"proxy", 1U << 4},
{"proxiable", 1U << 3},
{"forwarded", 1U << 2},
{"forwardable", 1U << 1},
{"reserved", 1U << 0},
{NULL, 0}
};
|