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

« back to all changes in this revision

Viewing changes to src/lib/krb4/rd_preauth.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
 
/* rd_preauth.c */
2
 
/* part of Cygnus Network Security */
3
 
/* Copyright 1994 Cygnus Support */
4
 
/*
5
 
 * Permission to use, copy, modify, and
6
 
 * distribute this software and its documentation for any purpose and
7
 
 * without fee is hereby granted, provided that the above copyright
8
 
 * notice appear in all copies and that both that copyright notice and
9
 
 * this permission notice appear in supporting documentation.
10
 
 * Cygnus Support makes no representations about the suitability of
11
 
 * this software for any purpose.  It is provided "as is" without express
12
 
 * or implied warranty.
13
 
 */
14
 
 
15
 
#include "krb.h"
16
 
#include "krb_db.h"
17
 
#include "prot.h"
18
 
#include "des.h"
19
 
#include "krb4int.h"
20
 
#include <string.h>
21
 
 
22
 
/* #define      KERB_ERR_PREAUTH_SHORT          11 */
23
 
/* #define      KERB_ERR_PREAUTH_MISMATCH       12 */
24
 
 
25
 
 
26
 
int
27
 
krb_rd_preauth(pkt, preauth_p, preauth_len, auth_pr, key)
28
 
    KTEXT pkt;
29
 
    char *preauth_p;
30
 
    int preauth_len;
31
 
    Principal *auth_pr;
32
 
    des_cblock key;
33
 
{
34
 
    int st;
35
 
    char *name_p;
36
 
 
37
 
    name_p = auth_pr->name;
38
 
   
39
 
#ifndef NOENCRYPTION
40
 
    /* Decrypt preauth_p using key as the key and initialization vector. */
41
 
    /* check preauth_len */
42
 
    if ((((strlen(name_p) + 1) / 8) + 1) * 8 != preauth_len)
43
 
        return KERB_ERR_PREAUTH_SHORT;
44
 
    else {
45
 
        des_key_schedule key_s;
46
 
 
47
 
        if (des_key_sched(key, key_s)) {
48
 
            return 1;
49
 
        }
50
 
        des_pcbc_encrypt((des_cblock *)preauth_p, (des_cblock *)preauth_p,
51
 
                         (long)preauth_len, key_s, (des_cblock *)key, 
52
 
                         DES_DECRYPT);
53
 
        memset(key_s, 0, sizeof(key_s));
54
 
    }
55
 
#endif /* R3_NO_MODIFICATIONS */
56
 
 
57
 
    /* since the preauth data has the trailing 0, this just works */
58
 
    st = strcmp(preauth_p, name_p);
59
 
    if (st)
60
 
        return KERB_ERR_PREAUTH_MISMATCH;
61
 
    return 0;
62
 
}