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

« back to all changes in this revision

Viewing changes to src/lib/krb4/mk_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
 
/* mk_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 <string.h>
17
 
 
18
 
#include "autoconf.h"
19
 
#ifdef HAVE_STDLIB_H
20
 
#include <stdlib.h>
21
 
#else
22
 
extern char *malloc(), *calloc(), *realloc();
23
 
#endif
24
 
 
25
 
int
26
 
krb_mk_preauth(preauth_p, preauth_len,
27
 
               key_proc, aname, inst, realm, password, key)
28
 
    char **preauth_p;
29
 
    int  *preauth_len;
30
 
    key_proc_type key_proc;
31
 
    char *aname;
32
 
    char *inst;
33
 
    char *realm;
34
 
    char *password;
35
 
    C_Block key;
36
 
{
37
 
#ifdef NOENCRYPTION
38
 
    *preauth_len = strlen(aname) + 1; /* include the trailing 0 */
39
 
    *preauth_p = malloc(*preauth_len);
40
 
    strcpy(*preauth_p, aname);  /* this will copy the trailing 0 */
41
 
#else
42
 
    des_key_schedule key_s;
43
 
    int sl = strlen(aname);
44
 
#endif
45
 
 
46
 
    (*key_proc)(aname, inst, realm, password, key);
47
 
 
48
 
#ifndef NOENCRYPTION
49
 
    /* 
50
 
     * preauth_len is set to a length greater than sl + 1 
51
 
     * and a multpile of 8
52
 
     */
53
 
    *preauth_len = (((sl + 1) / 8) + 1) * 8;
54
 
    /* allocate memory for preauth_p and fill it with 0 */
55
 
    *preauth_p = malloc((size_t)*preauth_len);
56
 
    /* create the key schedule */
57
 
    if (des_key_sched(key, key_s)) {
58
 
        return 1;
59
 
    }
60
 
    /* 
61
 
     * encrypt aname using key_s as the key schedule and key as the
62
 
     * initialization vector.
63
 
     */
64
 
    des_pcbc_encrypt((des_cblock *)aname, (des_cblock *)*preauth_p,
65
 
                     (long)(sl + 1), key_s, (des_cblock *)key, DES_ENCRYPT);
66
 
    memset(key_s, 0, sizeof(key_s));
67
 
#endif
68
 
    return 0;
69
 
}
70
 
 
71
 
void
72
 
krb_free_preauth(preauth_p, preauth_len)
73
 
     char *preauth_p;
74
 
     int preauth_len;
75
 
{
76
 
    free(preauth_p);
77
 
    return;
78
 
}