new files
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1329 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
58
lib/krb5/mk_priv.c
Normal file
58
lib/krb5/mk_priv.c
Normal file
@@ -0,0 +1,58 @@
|
||||
#include <krb5_locl.h>
|
||||
|
||||
RCSID("$Id$");
|
||||
|
||||
krb5_error_code
|
||||
krb5_mk_priv(krb5_context context,
|
||||
krb5_auth_context auth_context,
|
||||
const krb5_data *userdata,
|
||||
krb5_data *outbuf,
|
||||
/*krb5_replay_data*/ void *outdata)
|
||||
{
|
||||
krb5_error_code r;
|
||||
KRB_PRIV s;
|
||||
EncKrbPrivPart part;
|
||||
struct timeval tv;
|
||||
unsigned usec;
|
||||
krb5_addresses addr;
|
||||
u_char buf[1024];
|
||||
int len;
|
||||
|
||||
r = krb5_get_all_client_addrs (&addr);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
part.user_data = *userdata;
|
||||
gettimeofday (&tv, NULL);
|
||||
usec = tv.tv_usec;
|
||||
part.timestamp = &tv.tv_sec;
|
||||
part.usec = &usec;
|
||||
part.seq_number = NULL;
|
||||
part.s_address.addr_type = addr.addrs[0].type;
|
||||
part.s_address.address = addr.addrs[0].address;
|
||||
part.r_address = NULL;
|
||||
|
||||
len = encode_EncKrbPrivPart (buf + sizeof(buf) - 1, sizeof(buf), &part);
|
||||
if (len < 0)
|
||||
return ASN1_PARSE_ERROR;
|
||||
|
||||
s.pvno = 5;
|
||||
s.msg_type = krb_priv;
|
||||
s.enc_part.etype = ETYPE_DES_CBC_CRC;
|
||||
s.enc_part.kvno = NULL;
|
||||
|
||||
r = krb5_encrypt (context, buf + sizeof(buf) - len, len,
|
||||
&auth_context->key, &s.enc_part.cipher);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
len = encode_KRB_PRIV (buf + sizeof(buf) - 1, sizeof(buf), &s);
|
||||
if (len < 0)
|
||||
return ASN1_PARSE_ERROR;
|
||||
outbuf->length = len;
|
||||
outbuf->data = malloc (len);
|
||||
if (outbuf->data == NULL)
|
||||
return ENOMEM;
|
||||
memcpy (outbuf->data, buf + sizeof(buf) - len, len);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user