1 #pragma ident "%Z%%M% %I% %E% SMI" 2 3 /* 4 * Copyright 1993 by OpenVision Technologies, Inc. 5 * 6 * Permission to use, copy, modify, distribute, and sell this software 7 * and its documentation for any purpose is hereby granted without fee, 8 * provided that the above copyright notice appears in all copies and 9 * that both that copyright notice and this permission notice appear in 10 * supporting documentation, and that the name of OpenVision not be used 11 * in advertising or publicity pertaining to distribution of the software 12 * without specific, written prior permission. OpenVision makes no 13 * representations about the suitability of this software for any 14 * purpose. It is provided "as is" without express or implied warranty. 15 * 16 * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 18 * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR 19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 20 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 21 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 22 * PERFORMANCE OF THIS SOFTWARE. 23 */ 24 25 #include "gssapiP_krb5.h" 26 #ifdef HAVE_MEMORY_H 27 #include <memory.h> 28 #endif 29 30 static unsigned char zeros[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}; 31 32 krb5_error_code 33 kg_make_seed(context, key, seed) 34 krb5_context context; 35 krb5_keyblock *key; 36 unsigned char *seed; 37 { 38 krb5_error_code code; 39 krb5_keyblock *tmpkey; 40 int i; 41 42 code = krb5_copy_keyblock(context, key, &tmpkey); 43 if (code) 44 return(code); 45 46 /* reverse the key bytes, as per spec */ 47 48 for (i=0; i<tmpkey->length; i++) 49 tmpkey->contents[i] = key->contents[key->length - 1 - i]; 50 51 code = kg_encrypt(context, tmpkey, KG_USAGE_SEAL, NULL, zeros, seed, 16); 52 53 krb5_free_keyblock(context, tmpkey); 54 55 return(code); 56 } 57