10Sstevel@tonic-gate /*
2*7934SMark.Phalan@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
30Sstevel@tonic-gate * Use is subject to license terms.
40Sstevel@tonic-gate */
50Sstevel@tonic-gate
60Sstevel@tonic-gate
70Sstevel@tonic-gate /*
80Sstevel@tonic-gate * Copyright (C) 2001 by the Massachusetts Institute of Technology.
90Sstevel@tonic-gate * All rights reserved.
100Sstevel@tonic-gate *
110Sstevel@tonic-gate * Export of this software from the United States of America may
120Sstevel@tonic-gate * require a specific license from the United States Government.
130Sstevel@tonic-gate * It is the responsibility of any person or organization contemplating
140Sstevel@tonic-gate * export to obtain such a license before exporting.
150Sstevel@tonic-gate *
160Sstevel@tonic-gate * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
170Sstevel@tonic-gate * distribute this software and its documentation for any purpose and
180Sstevel@tonic-gate * without fee is hereby granted, provided that the above copyright
190Sstevel@tonic-gate * notice appear in all copies and that both that copyright notice and
200Sstevel@tonic-gate * this permission notice appear in supporting documentation, and that
210Sstevel@tonic-gate * the name of M.I.T. not be used in advertising or publicity pertaining
220Sstevel@tonic-gate * to distribution of the software without specific, written prior
230Sstevel@tonic-gate * permission. Furthermore if you modify this software you must label
240Sstevel@tonic-gate * your software as modified software and not distribute it in such a
250Sstevel@tonic-gate * fashion that it might be confused with the original M.I.T. software.
260Sstevel@tonic-gate * M.I.T. makes no representations about the suitability of
270Sstevel@tonic-gate * this software for any purpose. It is provided "as is" without express
280Sstevel@tonic-gate * or implied warranty.
290Sstevel@tonic-gate *
300Sstevel@tonic-gate * Section 6 (Encryption) of the Kerberos revisions document defines
310Sstevel@tonic-gate * cipher states to be used to chain encryptions and decryptions
320Sstevel@tonic-gate * together. Examples of cipher states include initialization vectors
330Sstevel@tonic-gate * for CBC encription. Most Kerberos encryption systems can share
340Sstevel@tonic-gate * code for initializing and freeing cipher states. This file
350Sstevel@tonic-gate * contains that default code.
360Sstevel@tonic-gate */
370Sstevel@tonic-gate
38*7934SMark.Phalan@Sun.COM #include "k5-int.h"
390Sstevel@tonic-gate
400Sstevel@tonic-gate /* ARGSUSED */
krb5int_des_init_state(krb5_context context,const krb5_keyblock * key,krb5_keyusage usage,krb5_data * new_state)41*7934SMark.Phalan@Sun.COM krb5_error_code krb5int_des_init_state
42*7934SMark.Phalan@Sun.COM (krb5_context context, const krb5_keyblock *key,
430Sstevel@tonic-gate krb5_keyusage usage, krb5_data *new_state )
440Sstevel@tonic-gate {
450Sstevel@tonic-gate new_state->length = 8;
460Sstevel@tonic-gate new_state->data = (void *) MALLOC(8);
470Sstevel@tonic-gate if (new_state->data) {
48*7934SMark.Phalan@Sun.COM /* Solaris Kerberos */
490Sstevel@tonic-gate (void) memset (new_state->data, 0, new_state->length);
500Sstevel@tonic-gate /* We need to copy in the key for des-cbc-cr--ick, but that's how it works*/
510Sstevel@tonic-gate if (key->enctype == ENCTYPE_DES_CBC_CRC) {
52*7934SMark.Phalan@Sun.COM /* Solaris Kerberos */
530Sstevel@tonic-gate (void) memcpy (new_state->data, key->contents, new_state->length);
54*7934SMark.Phalan@Sun.COM }
550Sstevel@tonic-gate } else {
560Sstevel@tonic-gate return ENOMEM;
570Sstevel@tonic-gate }
580Sstevel@tonic-gate return 0;
590Sstevel@tonic-gate }
600Sstevel@tonic-gate
610Sstevel@tonic-gate /* ARGSUSED */
krb5int_default_free_state(krb5_context context,krb5_data * state)62*7934SMark.Phalan@Sun.COM krb5_error_code krb5int_default_free_state
63*7934SMark.Phalan@Sun.COM (krb5_context context, krb5_data *state)
640Sstevel@tonic-gate {
650Sstevel@tonic-gate if (state->data) {
660Sstevel@tonic-gate FREE (state->data, state->length);
670Sstevel@tonic-gate state-> data = NULL;
680Sstevel@tonic-gate state->length = 0;
690Sstevel@tonic-gate }
700Sstevel@tonic-gate return 0;
710Sstevel@tonic-gate }
720Sstevel@tonic-gate
73*7934SMark.Phalan@Sun.COM
74*7934SMark.Phalan@Sun.COM
75