17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * Copyright 1993 by OpenVision Technologies, Inc.
3*55fea89dSDan Cross  *
47c478bd9Sstevel@tonic-gate  * Permission to use, copy, modify, distribute, and sell this software
57c478bd9Sstevel@tonic-gate  * and its documentation for any purpose is hereby granted without fee,
67c478bd9Sstevel@tonic-gate  * provided that the above copyright notice appears in all copies and
77c478bd9Sstevel@tonic-gate  * that both that copyright notice and this permission notice appear in
87c478bd9Sstevel@tonic-gate  * supporting documentation, and that the name of OpenVision not be used
97c478bd9Sstevel@tonic-gate  * in advertising or publicity pertaining to distribution of the software
107c478bd9Sstevel@tonic-gate  * without specific, written prior permission. OpenVision makes no
117c478bd9Sstevel@tonic-gate  * representations about the suitability of this software for any
127c478bd9Sstevel@tonic-gate  * purpose.  It is provided "as is" without express or implied warranty.
13*55fea89dSDan Cross  *
147c478bd9Sstevel@tonic-gate  * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
157c478bd9Sstevel@tonic-gate  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
167c478bd9Sstevel@tonic-gate  * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
177c478bd9Sstevel@tonic-gate  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
187c478bd9Sstevel@tonic-gate  * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
197c478bd9Sstevel@tonic-gate  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
207c478bd9Sstevel@tonic-gate  * PERFORMANCE OF THIS SOFTWARE.
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate 
23ab9b2e15Sgtb #include "gssapiP_krb5.h"
24ab9b2e15Sgtb #ifdef HAVE_MEMORY_H
25ab9b2e15Sgtb #include <memory.h>
26ab9b2e15Sgtb #endif
277c478bd9Sstevel@tonic-gate 
28159d09a2SMark Phalan static const unsigned char zeros[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate krb5_error_code
kg_make_seed(context,key,seed)317c478bd9Sstevel@tonic-gate kg_make_seed(context, key, seed)
327c478bd9Sstevel@tonic-gate      krb5_context context;
337c478bd9Sstevel@tonic-gate      krb5_keyblock *key;
347c478bd9Sstevel@tonic-gate      unsigned char *seed;
357c478bd9Sstevel@tonic-gate {
367c478bd9Sstevel@tonic-gate    krb5_error_code code;
377c478bd9Sstevel@tonic-gate    krb5_keyblock *tmpkey;
387c478bd9Sstevel@tonic-gate    int i;
397c478bd9Sstevel@tonic-gate 
40ab9b2e15Sgtb    code = krb5_copy_keyblock(context, key, &tmpkey);
41ab9b2e15Sgtb    if (code)
427c478bd9Sstevel@tonic-gate       return(code);
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate    /* reverse the key bytes, as per spec */
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate    for (i=0; i<tmpkey->length; i++)
477c478bd9Sstevel@tonic-gate       tmpkey->contents[i] = key->contents[key->length - 1 - i];
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate    code = kg_encrypt(context, tmpkey, KG_USAGE_SEAL, NULL, zeros, seed, 16);
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate    krb5_free_keyblock(context, tmpkey);
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate    return(code);
547c478bd9Sstevel@tonic-gate }
55