(init_tgs_req): re-structure a little bit
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@5940 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -117,6 +117,60 @@ out:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the `enc-authorization-data' in `req_body' based on `authdata'
|
||||||
|
*/
|
||||||
|
|
||||||
|
static krb5_error_code
|
||||||
|
set_auth_data (krb5_context context,
|
||||||
|
KDC_REQ_BODY *req_body,
|
||||||
|
krb5_authdata *authdata,
|
||||||
|
krb5_keyblock *key)
|
||||||
|
{
|
||||||
|
if(authdata->len) {
|
||||||
|
size_t len;
|
||||||
|
unsigned char *buf;
|
||||||
|
krb5_crypto crypto;
|
||||||
|
krb5_error_code ret;
|
||||||
|
|
||||||
|
len = length_AuthorizationData(authdata);
|
||||||
|
buf = malloc(len);
|
||||||
|
if (buf == NULL)
|
||||||
|
return ENOMEM;
|
||||||
|
ret = encode_AuthorizationData(buf + len - 1,
|
||||||
|
len, authdata, &len);
|
||||||
|
if (ret) {
|
||||||
|
free (buf);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ALLOC(req_body->enc_authorization_data, 1);
|
||||||
|
if (req_body->enc_authorization_data == NULL) {
|
||||||
|
free (buf);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
ret = krb5_crypto_init(context, key, 0, &crypto);
|
||||||
|
if (ret) {
|
||||||
|
free (buf);
|
||||||
|
free (req_body->enc_authorization_data);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
krb5_encrypt_EncryptedData(context,
|
||||||
|
crypto,
|
||||||
|
KRB5_KU_TGS_REQ_AUTH_DAT_SUBKEY,
|
||||||
|
/* KRB5_KU_TGS_REQ_AUTH_DAT_SESSION? */
|
||||||
|
buf,
|
||||||
|
len,
|
||||||
|
0,
|
||||||
|
req_body->enc_authorization_data);
|
||||||
|
free (buf);
|
||||||
|
krb5_crypto_destroy(context, crypto);
|
||||||
|
} else {
|
||||||
|
req_body->enc_authorization_data = NULL;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a tgs-req in `t' with `addresses', `flags', `second_ticket'
|
* Create a tgs-req in `t' with `addresses', `flags', `second_ticket'
|
||||||
* (if not-NULL), `in_creds', `krbtgt', and returning the generated
|
* (if not-NULL), `in_creds', `krbtgt', and returning the generated
|
||||||
@@ -226,35 +280,20 @@ init_tgs_req (krb5_context context,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(in_creds->authdata.len) {
|
ret = set_auth_data (context, &t->req_body, &in_creds->authdata, key);
|
||||||
size_t len;
|
if (ret) {
|
||||||
unsigned char *buf;
|
krb5_free_keyblock (context, key);
|
||||||
krb5_crypto crypto;
|
krb5_auth_con_free (context, ac);
|
||||||
len = length_AuthorizationData(&in_creds->authdata);
|
goto fail;
|
||||||
buf = malloc(len);
|
|
||||||
ret = encode_AuthorizationData(buf + len - 1,
|
|
||||||
len, &in_creds->authdata, &len);
|
|
||||||
ALLOC(t->req_body.enc_authorization_data, 1);
|
|
||||||
ret = krb5_crypto_init(context, key, 0, &crypto);
|
|
||||||
krb5_encrypt_EncryptedData(context,
|
|
||||||
crypto,
|
|
||||||
KRB5_KU_TGS_REQ_AUTH_DAT_SUBKEY,
|
|
||||||
/* KRB5_KU_TGS_REQ_AUTH_DAT_SESSION? */
|
|
||||||
buf,
|
|
||||||
len,
|
|
||||||
0,
|
|
||||||
t->req_body.enc_authorization_data);
|
|
||||||
krb5_crypto_destroy(context, crypto);
|
|
||||||
} else {
|
|
||||||
t->req_body.enc_authorization_data = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = make_pa_tgs_req(context,
|
ret = make_pa_tgs_req(context,
|
||||||
ac,
|
ac,
|
||||||
&t->req_body,
|
&t->req_body,
|
||||||
t->padata->val,
|
t->padata->val,
|
||||||
krbtgt);
|
krbtgt);
|
||||||
if(ret) {
|
if(ret) {
|
||||||
|
krb5_free_keyblock (context, key);
|
||||||
krb5_auth_con_free(context, ac);
|
krb5_auth_con_free(context, ac);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user