git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1888 ec53bebd-3082-4978-b11e-865c3cabbd6b
		
			
				
	
	
		
			31 lines
		
	
	
		
			616 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			616 B
		
	
	
	
		
			C
		
	
	
	
	
	
#include <krb5_locl.h>
 | 
						|
 | 
						|
RCSID("$Id$");
 | 
						|
 | 
						|
krb5_error_code
 | 
						|
krb5_generate_subkey(krb5_context context,
 | 
						|
		     const krb5_keyblock *key,
 | 
						|
		     krb5_keyblock **subkey)
 | 
						|
{
 | 
						|
    krb5_error_code ret;
 | 
						|
    krb5_keyblock *k;
 | 
						|
 | 
						|
    if (key->keytype != KEYTYPE_DES)
 | 
						|
	abort ();
 | 
						|
    k = malloc(sizeof(**subkey));
 | 
						|
    if (k == NULL)
 | 
						|
	return ENOMEM;
 | 
						|
    k->keytype = key->keytype;
 | 
						|
    k->keyvalue.length = 0;
 | 
						|
    ret = krb5_data_copy (&k->keyvalue,
 | 
						|
			  key->keyvalue.data,
 | 
						|
			  key->keyvalue.length);
 | 
						|
    if (ret) {
 | 
						|
	free(k);
 | 
						|
	return ret;
 | 
						|
    }
 | 
						|
    des_new_random_key ((des_cblock *)k->keyvalue.data);
 | 
						|
    *subkey = k;
 | 
						|
    return 0;
 | 
						|
}
 |