~ubuntu-branches/ubuntu/precise/krb5/precise-updates

« back to all changes in this revision

Viewing changes to src/lib/crypto/krb/prf/des_prf.c

  • Committer: Package Import Robot
  • Author(s): Sam Hartman
  • Date: 2011-12-01 19:34:41 UTC
  • mfrom: (28.1.14 sid)
  • Revision ID: package-import@ubuntu.com-20111201193441-9tipg3aru1jsidyv
Tags: 1.10+dfsg~alpha1-6
* Fix segfault with unknown hostnames in krb5_sname_to_principal,
  Closes: #650671
* Indicate that this library breaks libsmbclient versions that depend on
  krb5_locate_kdc, Closes: #650603, #650611

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
 
/*
3
 
 * lib/crypto/krb/prf//des_prf.c
4
 
 *
5
 
 * Copyright (C) 2004, 2009  by the Massachusetts Institute of Technology.
6
 
 * All rights reserved.
7
 
 *
8
 
 * Export of this software from the United States of America may
9
 
 *   require a specific license from the United States Government.
10
 
 *   It is the responsibility of any person or organization contemplating
11
 
 *   export to obtain such a license before exporting.
12
 
 *
13
 
 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
14
 
 * distribute this software and its documentation for any purpose and
15
 
 * without fee is hereby granted, provided that the above copyright
16
 
 * notice appear in all copies and that both that copyright notice and
17
 
 * this permission notice appear in supporting documentation, and that
18
 
 * the name of M.I.T. not be used in advertising or publicity pertaining
19
 
 * to distribution of the software without specific, written prior
20
 
 * permission.  Furthermore if you modify this software you must label
21
 
 * your software as modified software and not distribute it in such a
22
 
 * fashion that it might be confused with the original M.I.T. software.
23
 
 * M.I.T. makes no representations about the suitability of
24
 
 * this software for any purpose.  It is provided "as is" without express
25
 
 * or implied warranty.
26
 
 *
27
 
 *
28
 
 *
29
 
 * This file contains an implementation of the RFC 3961 PRF for
30
 
 * des-cbc-crc, des-cbc-md4, and des-cbc-md5 enctypes.
31
 
 */
32
 
 
33
 
#include "prf_int.h"
34
 
#include "hash_provider/hash_provider.h"
35
 
 
36
 
krb5_error_code
37
 
krb5int_des_prf(const struct krb5_keytypes *ktp, krb5_key key,
38
 
                const krb5_data *in, krb5_data *out)
39
 
{
40
 
    const struct krb5_hash_provider *hash = &krb5int_hash_md5;
41
 
    krb5_crypto_iov iov;
42
 
    krb5_error_code ret;
43
 
 
44
 
    /* Compute a hash of the input, storing into the output buffer. */
45
 
    iov.flags = KRB5_CRYPTO_TYPE_DATA;
46
 
    iov.data = *in;
47
 
    ret = hash->hash(&iov, 1, out);
48
 
    if (ret != 0)
49
 
        return ret;
50
 
 
51
 
    /* Encrypt the hash in place. */
52
 
    iov.data = *out;
53
 
    return ktp->enc->encrypt(key, NULL, &iov, 1);
54
 
}