1 /*
2 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
5
6
7 /*
8 * Copyright (C) 2001 by the Massachusetts Institute of Technology.
9 * All rights reserved.
10 *
11 * Export of this software from the United States of America may
12 * require a specific license from the United States Government.
13 * It is the responsibility of any person or organization contemplating
14 * export to obtain such a license before exporting.
15 *
16 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
17 * distribute this software and its documentation for any purpose and
18 * without fee is hereby granted, provided that the above copyright
19 * notice appear in all copies and that both that copyright notice and
20 * this permission notice appear in supporting documentation, and that
21 * the name of M.I.T. not be used in advertising or publicity pertaining
22 * to distribution of the software without specific, written prior
23 * permission. Furthermore if you modify this software you must label
24 * your software as modified software and not distribute it in such a
25 * fashion that it might be confused with the original M.I.T. software.
26 * M.I.T. makes no representations about the suitability of
27 * this software for any purpose. It is provided "as is" without express
28 * or implied warranty.
29 *
30 * Section 6 (Encryption) of the Kerberos revisions document defines
31 * cipher states to be used to chain encryptions and decryptions
32 * together. Examples of cipher states include initialization vectors
33 * for CBC encription. Most Kerberos encryption systems can share
34 * code for initializing and freeing cipher states. This file
35 * contains that default code.
36 */
37
38 #include "k5-int.h"
39
40 /* ARGSUSED */
krb5int_des_init_state(krb5_context context,const krb5_keyblock * key,krb5_keyusage usage,krb5_data * new_state)41 krb5_error_code krb5int_des_init_state
42 (krb5_context context, const krb5_keyblock *key,
43 krb5_keyusage usage, krb5_data *new_state )
44 {
45 new_state->length = 8;
46 new_state->data = (void *) MALLOC(8);
47 if (new_state->data) {
48 /* Solaris Kerberos */
49 (void) memset (new_state->data, 0, new_state->length);
50 /* We need to copy in the key for des-cbc-cr--ick, but that's how it works*/
51 if (key->enctype == ENCTYPE_DES_CBC_CRC) {
52 /* Solaris Kerberos */
53 (void) memcpy (new_state->data, key->contents, new_state->length);
54 }
55 } else {
56 return ENOMEM;
57 }
58 return 0;
59 }
60
61 /* ARGSUSED */
krb5int_default_free_state(krb5_context context,krb5_data * state)62 krb5_error_code krb5int_default_free_state
63 (krb5_context context, krb5_data *state)
64 {
65 if (state->data) {
66 FREE (state->data, state->length);
67 state-> data = NULL;
68 state->length = 0;
69 }
70 return 0;
71 }
72
73
74
75