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

« back to all changes in this revision

Viewing changes to src/lib/krb5/asn.1/asn1_get.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
/* -*- mode: c; indent-tabs-mode: nil -*- */
1
2
/*
2
3
 * src/lib/krb5/asn.1/asn1_get.c
3
 
 * 
 
4
 *
4
5
 * Copyright 1994 by the Massachusetts Institute of Technology.
5
6
 * All Rights Reserved.
6
7
 *
8
9
 *   require a specific license from the United States Government.
9
10
 *   It is the responsibility of any person or organization contemplating
10
11
 *   export to obtain such a license before exporting.
11
 
 * 
 
12
 *
12
13
 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13
14
 * distribute this software and its documentation for any purpose and
14
15
 * without fee is hereby granted, provided that the above copyright
32
33
    asn1_error_code retval;
33
34
 
34
35
    if (buf == NULL || buf->base == NULL ||
35
 
        buf->bound - buf->next + 1 <= 0) {
36
 
        t->tagnum = ASN1_TAGNUM_CEILING; /* emphatically not an EOC tag */
37
 
        t->asn1class = UNIVERSAL;
38
 
        t->construction = PRIMITIVE;
39
 
        t->length = 0;
40
 
        t->indef = 0;
41
 
        return 0;
 
36
        buf->bound - buf->next + 1 <= 0) {
 
37
        t->tagnum = ASN1_TAGNUM_CEILING; /* emphatically not an EOC tag */
 
38
        t->asn1class = UNIVERSAL;
 
39
        t->construction = PRIMITIVE;
 
40
        t->length = 0;
 
41
        t->indef = 0;
 
42
        return 0;
42
43
    }
43
44
    {
44
 
        /* asn1_get_id(buf, t) */
45
 
        asn1_tagnum tn=0;
46
 
        asn1_octet o;
 
45
        /* asn1_get_id(buf, t) */
 
46
        asn1_tagnum tn=0;
 
47
        asn1_octet o;
47
48
 
48
49
#define ASN1_CLASS_MASK 0xC0
49
50
#define ASN1_CONSTRUCTION_MASK 0x20
50
51
#define ASN1_TAG_NUMBER_MASK 0x1F
51
52
 
52
 
        retval = asn1buf_remove_octet(buf,&o);
53
 
        if (retval)
54
 
            return retval;
 
53
        retval = asn1buf_remove_octet(buf,&o);
 
54
        if (retval)
 
55
            return retval;
55
56
 
56
 
        t->asn1class = (asn1_class)(o&ASN1_CLASS_MASK);
57
 
        t->construction = (asn1_construction)(o&ASN1_CONSTRUCTION_MASK);
58
 
        if ((o&ASN1_TAG_NUMBER_MASK) != ASN1_TAG_NUMBER_MASK){
59
 
            /* low-tag-number form */
60
 
            t->tagnum = (asn1_tagnum)(o&ASN1_TAG_NUMBER_MASK);
61
 
        } else {
62
 
            /* high-tag-number form */
63
 
            do {
64
 
                retval = asn1buf_remove_octet(buf,&o);
65
 
                if (retval) return retval;
66
 
                tn = (tn<<7) + (asn1_tagnum)(o&0x7F);
67
 
            }while(o&0x80);
68
 
            t->tagnum = tn;
69
 
        }
 
57
        t->asn1class = (asn1_class)(o&ASN1_CLASS_MASK);
 
58
        t->construction = (asn1_construction)(o&ASN1_CONSTRUCTION_MASK);
 
59
        if ((o&ASN1_TAG_NUMBER_MASK) != ASN1_TAG_NUMBER_MASK) {
 
60
            /* low-tag-number form */
 
61
            t->tagnum = (asn1_tagnum)(o&ASN1_TAG_NUMBER_MASK);
 
62
        } else {
 
63
            /* high-tag-number form */
 
64
            do {
 
65
                retval = asn1buf_remove_octet(buf,&o);
 
66
                if (retval) return retval;
 
67
                tn = (tn<<7) + (asn1_tagnum)(o&0x7F);
 
68
            } while (o&0x80);
 
69
            t->tagnum = tn;
 
70
        }
70
71
    }
71
72
 
72
73
    {
73
 
        /* asn1_get_length(buf, t) */
74
 
        asn1_octet o;
75
 
 
76
 
        t->indef = 0;
77
 
        retval = asn1buf_remove_octet(buf,&o);
78
 
        if (retval) return retval;
79
 
        if ((o&0x80) == 0) {
80
 
            t->length = (int)(o&0x7F);
81
 
        } else {
82
 
            int num;
83
 
            int len=0;
84
 
    
85
 
            for (num = (int)(o&0x7F); num>0; num--) {
86
 
                retval = asn1buf_remove_octet(buf,&o);
87
 
                if(retval) return retval;
88
 
                len = (len<<8) + (int)o;
89
 
            }
90
 
            if (len < 0)
91
 
                return ASN1_OVERRUN;
92
 
            if (!len)
93
 
                t->indef = 1;
94
 
            t->length = len;
95
 
        }
 
74
        /* asn1_get_length(buf, t) */
 
75
        asn1_octet o;
 
76
 
 
77
        t->indef = 0;
 
78
        retval = asn1buf_remove_octet(buf,&o);
 
79
        if (retval) return retval;
 
80
        if ((o&0x80) == 0) {
 
81
            t->length = (int)(o&0x7F);
 
82
        } else {
 
83
            int num;
 
84
            int len=0;
 
85
 
 
86
            for (num = (int)(o&0x7F); num>0; num--) {
 
87
                retval = asn1buf_remove_octet(buf,&o);
 
88
                if (retval) return retval;
 
89
                len = (len<<8) + (int)o;
 
90
            }
 
91
            if (len < 0)
 
92
                return ASN1_OVERRUN;
 
93
            if (!len)
 
94
                t->indef = 1;
 
95
            t->length = len;
 
96
        }
96
97
    }
97
98
    if (t->indef && t->construction != CONSTRUCTED)
98
 
        return ASN1_MISMATCH_INDEF;
 
99
        return ASN1_MISMATCH_INDEF;
99
100
    return 0;
100
101
}
101
102
 
106
107
 
107
108
    retval = asn1_get_tag_2(buf, &t);
108
109
    if (retval)
109
 
        return retval;
 
110
        return retval;
110
111
    if (t.asn1class != UNIVERSAL || t.construction != CONSTRUCTED ||
111
 
        t.tagnum != ASN1_SEQUENCE)
112
 
        return ASN1_BAD_ID;
 
112
        t.tagnum != ASN1_SEQUENCE)
 
113
        return ASN1_BAD_ID;
113
114
    if (retlen)
114
 
        *retlen = t.length;
 
115
        *retlen = t.length;
115
116
    if (indef)
116
 
        *indef = t.indef;
 
117
        *indef = t.indef;
117
118
    return 0;
118
119
}