2
* lib/krb5/krb/t_authdata.c
4
* Copyright (C) 2009 by the Massachusetts Institute of Technology.
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.
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.
28
* Test authorization data search
40
(unsigned char *) "abcd"};
45
(unsigned char *) "abcde"
52
(unsigned char *) "ab"
54
/* we want three results in the return from krb5int_find_authdata so
55
it has to grow its list.
61
(unsigned char *)"abcd"
64
krb5_authdata *adseq1[] = {&ad1, &ad2, &ad4, NULL};
66
krb5_authdata *adseq2[] = {&ad3, NULL};
68
static void compare_authdata(const krb5_authdata *adc1, krb5_authdata *adc2) {
69
assert(adc1->ad_type == adc2->ad_type);
70
assert(adc1->length == adc2->length);
71
assert(memcmp(adc1->contents, adc2->contents, adc1->length) == 0);
77
krb5_authdata **results;
78
krb5_authdata *container[2];
79
krb5_authdata **container_out;
82
assert(krb5_init_context(&context) == 0);
83
assert(krb5_merge_authdata(context, adseq1, adseq2, &results) == 0);
84
compare_authdata(results[0], &ad1);
85
compare_authdata( results[1], &ad2);
86
compare_authdata(results[2], &ad4);
87
compare_authdata( results[3], &ad3);
88
assert(results[4] == NULL);
89
krb5_free_authdata(context, results);
92
assert(krb5_encode_authdata_container( context, KRB5_AUTHDATA_IF_RELEVANT, container, &container_out) == 0);
93
assert(krb5int_find_authdata(context,
94
adseq1, container_out, 22, &results) == 0);
95
compare_authdata(&ad1, results[0]);
96
compare_authdata( results[1], &ad4);
97
compare_authdata( results[2], &ad3);
98
assert( results[3] == NULL);
99
krb5_free_authdata(context, results);
100
krb5_free_authdata(context, container_out);