2 * Copyright (c) 2003 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include "gsskrb5_locl.h"
36 /* correct ordering */
37 OM_uint32 pattern1
[] = {
38 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13
42 OM_uint32 pattern2
[] = {
43 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13
47 OM_uint32 pattern3
[] = {
48 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 10, 11, 12, 13
52 OM_uint32 pattern4
[] = {
53 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 13, 14, 15, 16, 18, 100
57 OM_uint32 pattern5
[] = {
58 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21
62 OM_uint32 pattern6
[] = {
63 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
64 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
65 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
66 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
67 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
68 50, 51, 52, 53, 54, 55, 56, 57, 58, 59
72 OM_uint32 pattern7
[] = {
77 OM_uint32 pattern8
[] = {
78 4294967293U, 4294967294U, 4294967295U, 0, 1, 2
82 test_seq(int t
, OM_uint32 flags
, OM_uint32 start_seq
,
83 OM_uint32
*pattern
, int pattern_len
, OM_uint32 expected_error
)
85 struct gss_msg_order
*o
;
86 OM_uint32 maj_stat
, min_stat
;
90 maj_stat
= _gssapi_msg_order_create(&min_stat
, &o
, flags
,
93 errx(1, "create: %d %d", maj_stat
, min_stat
);
95 sp
= krb5_storage_emem();
97 errx(1, "krb5_storage_from_emem");
99 _gssapi_msg_order_export(sp
, o
);
101 for (i
= 0; i
< pattern_len
; i
++) {
102 maj_stat
= _gssapi_msg_order_check(o
, pattern
[i
]);
106 if (maj_stat
!= expected_error
) {
107 printf("test pattern %d failed with %d (should have been %d)\n",
108 t
, maj_stat
, expected_error
);
109 krb5_storage_free(sp
);
110 _gssapi_msg_order_destroy(&o
);
115 _gssapi_msg_order_destroy(&o
);
117 /* try again, now with export/imported blob */
118 krb5_storage_seek(sp
, 0, SEEK_SET
);
120 maj_stat
= _gssapi_msg_order_import(&min_stat
, sp
, &o
);
122 errx(1, "import: %d %d", maj_stat
, min_stat
);
124 for (i
= 0; i
< pattern_len
; i
++) {
125 maj_stat
= _gssapi_msg_order_check(o
, pattern
[i
]);
129 if (maj_stat
!= expected_error
) {
130 printf("import/export test pattern %d failed "
131 "with %d (should have been %d)\n",
132 t
, maj_stat
, expected_error
);
133 _gssapi_msg_order_destroy(&o
);
134 krb5_storage_free(sp
);
138 _gssapi_msg_order_destroy(&o
);
139 krb5_storage_free(sp
);
148 OM_uint32 error_code
;
152 GSS_C_REPLAY_FLAG
|GSS_C_SEQUENCE_FLAG
,
154 sizeof(pattern1
)/sizeof(pattern1
[0]),
158 GSS_C_REPLAY_FLAG
|GSS_C_SEQUENCE_FLAG
,
160 sizeof(pattern2
)/sizeof(pattern2
[0]),
164 GSS_C_REPLAY_FLAG
|GSS_C_SEQUENCE_FLAG
,
166 sizeof(pattern3
)/sizeof(pattern3
[0]),
167 GSS_S_DUPLICATE_TOKEN
170 GSS_C_REPLAY_FLAG
|GSS_C_SEQUENCE_FLAG
,
172 sizeof(pattern4
)/sizeof(pattern4
[0]),
176 GSS_C_REPLAY_FLAG
|GSS_C_SEQUENCE_FLAG
,
178 sizeof(pattern5
)/sizeof(pattern5
[0]),
182 GSS_C_REPLAY_FLAG
|GSS_C_SEQUENCE_FLAG
,
184 sizeof(pattern6
)/sizeof(pattern6
[0]),
188 GSS_C_REPLAY_FLAG
|GSS_C_SEQUENCE_FLAG
,
190 sizeof(pattern7
)/sizeof(pattern7
[0]),
194 GSS_C_REPLAY_FLAG
|GSS_C_SEQUENCE_FLAG
,
196 sizeof(pattern8
)/sizeof(pattern8
[0]),
203 sizeof(pattern1
)/sizeof(pattern1
[0]),
209 sizeof(pattern2
)/sizeof(pattern2
[0]),
215 sizeof(pattern3
)/sizeof(pattern3
[0]),
221 sizeof(pattern4
)/sizeof(pattern4
[0]),
227 sizeof(pattern5
)/sizeof(pattern5
[0]),
233 sizeof(pattern6
)/sizeof(pattern6
[0]),
239 sizeof(pattern7
)/sizeof(pattern7
[0]),
245 sizeof(pattern8
)/sizeof(pattern8
[0]),
253 sizeof(pattern1
)/sizeof(pattern1
[0]),
259 sizeof(pattern2
)/sizeof(pattern2
[0]),
265 sizeof(pattern3
)/sizeof(pattern3
[0]),
266 GSS_S_DUPLICATE_TOKEN
271 sizeof(pattern4
)/sizeof(pattern4
[0]),
277 sizeof(pattern5
)/sizeof(pattern5
[0]),
283 sizeof(pattern6
)/sizeof(pattern6
[0]),
289 sizeof(pattern7
)/sizeof(pattern7
[0]),
295 sizeof(pattern8
)/sizeof(pattern8
[0]),
302 sizeof(pattern1
)/sizeof(pattern1
[0]),
308 sizeof(pattern2
)/sizeof(pattern2
[0]),
314 sizeof(pattern3
)/sizeof(pattern3
[0]),
315 GSS_S_DUPLICATE_TOKEN
320 sizeof(pattern4
)/sizeof(pattern4
[0]),
326 sizeof(pattern5
)/sizeof(pattern5
[0]),
332 sizeof(pattern6
)/sizeof(pattern6
[0]),
338 sizeof(pattern7
)/sizeof(pattern7
[0]),
344 sizeof(pattern8
)/sizeof(pattern8
[0]),
351 main(int argc
, char **argv
)
355 for (i
= 0; i
< sizeof(pl
)/sizeof(pl
[0]); i
++) {
365 printf("FAILED %d tests\n", failed
);