~ubuntu-branches/ubuntu/maverick/krb5/maverick

« back to all changes in this revision

Viewing changes to src/lib/krb5/krb/t_authdata.c

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hartman
  • Date: 2009-05-07 16:16:34 UTC
  • mfrom: (13.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20090507161634-xqyk0s9na0le4flj
Tags: 1.7dfsg~beta1-4
When  decrypting the TGS response fails with the subkey, try with the
session key to work around Heimdal bug, Closes: #527353 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * lib/krb5/krb/t_authdata.c
 
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
 *
 
28
 * Test authorization data search
 
29
 */
 
30
 
 
31
#include <k5-int.h>
 
32
#include <krb5.h>
 
33
#include <assert.h>
 
34
#include <memory.h>
 
35
 
 
36
krb5_authdata ad1 = {
 
37
  KV5M_AUTHDATA,
 
38
  22,
 
39
  4,
 
40
  (unsigned char *) "abcd"};
 
41
krb5_authdata ad2 = {
 
42
  KV5M_AUTHDATA,
 
43
  23,
 
44
  5,
 
45
  (unsigned char *) "abcde"
 
46
};
 
47
 
 
48
krb5_authdata ad3= {
 
49
  KV5M_AUTHDATA,
 
50
  22,
 
51
  3,
 
52
  (unsigned char *) "ab"
 
53
};
 
54
/* we want three results in the return from krb5int_find_authdata so
 
55
it has to grow its list.
 
56
*/
 
57
krb5_authdata ad4 = {
 
58
    KV5M_AUTHDATA,
 
59
    22,
 
60
    5,
 
61
    (unsigned char *)"abcd"
 
62
};
 
63
 
 
64
krb5_authdata *adseq1[] = {&ad1, &ad2, &ad4, NULL};
 
65
 
 
66
krb5_authdata *adseq2[] = {&ad3, NULL};
 
67
 
 
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);
 
72
}
 
73
 
 
74
int main() 
 
75
{
 
76
    krb5_context context;
 
77
    krb5_authdata **results;
 
78
    krb5_authdata *container[2];
 
79
    krb5_authdata **container_out;
 
80
  
 
81
 
 
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);
 
90
    container[0] = &ad3;
 
91
    container[1] = NULL;
 
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);
 
101
    return 0;
 
102
}