2
/* part of Cygnus Network Security */
3
/* Copyright 1994 Cygnus Support */
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.
22
extern char *malloc(), *calloc(), *realloc();
26
krb_mk_preauth(preauth_p, preauth_len,
27
key_proc, aname, inst, realm, password, key)
30
key_proc_type key_proc;
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 */
42
des_key_schedule key_s;
43
int sl = strlen(aname);
46
(*key_proc)(aname, inst, realm, password, key);
50
* preauth_len is set to a length greater than sl + 1
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)) {
61
* encrypt aname using key_s as the key schedule and key as the
62
* initialization vector.
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));
72
krb_free_preauth(preauth_p, preauth_len)