From fda04ff4b5c1f55ed1bb9ea8a50fc36322a81441 Mon Sep 17 00:00:00 2001 From: John Kohl Date: Tue, 9 Oct 1990 16:46:48 +0000 Subject: [PATCH] changes for draft 3 ASN.1 definitions git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1175 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/asn.1/ekrp2kekrp.c | 30 ++++----- src/lib/krb5/asn.1/enck2kkey.c | 12 ++-- src/lib/krb5/asn.1/err2kerr.c | 37 +++++++---- src/lib/krb5/asn.1/kaprp2aprp.c | 4 +- src/lib/krb5/asn.1/kdcr2kkdcr.c | 7 +- src/lib/krb5/asn.1/kekrp2ekrp.c | 36 +++++------ src/lib/krb5/asn.1/kerr2err.c | 29 ++++++--- src/lib/krb5/asn.1/kkdcr2kdcr.c | 8 +-- src/lib/krb5/asn.1/kkey2enck.c | 2 +- src/lib/krb5/asn.1/klsrq2lsrq.c | 9 ++- src/lib/krb5/asn.1/kpriv2priv.c | 8 +-- src/lib/krb5/asn.1/ktgrq2tgrq.c | 104 +++++++++++++++++++++++++++--- src/lib/krb5/asn.1/ktkt2tkt.c | 11 ++-- src/lib/krb5/asn.1/lsrq2klsrq.c | 8 ++- src/lib/krb5/asn.1/priv2kpriv.c | 6 +- src/lib/krb5/asn.1/tgrq2ktgrq.c | 109 ++++++++++++++++++++++++++------ src/lib/krb5/asn.1/tkt2ktkt.c | 8 +-- 17 files changed, 305 insertions(+), 123 deletions(-) diff --git a/src/lib/krb5/asn.1/ekrp2kekrp.c b/src/lib/krb5/asn.1/ekrp2kekrp.c index d3f432230..65474dc80 100644 --- a/src/lib/krb5/asn.1/ekrp2kekrp.c +++ b/src/lib/krb5/asn.1/ekrp2kekrp.c @@ -29,8 +29,8 @@ static char rcsid_ekrp2kekrp_c[] = /* ISODE defines max(a,b) */ krb5_enc_kdc_rep_part * -KRB5_EncKDCRepPart2krb5_enc_kdc_rep_part(val, error) -const register struct type_KRB5_EncKDCRepPart *val; +KRB5_EncTGSRepPart2krb5_enc_kdc_rep_part(val, error) +const register struct type_KRB5_EncTGSRepPart *val; register int *error; { register krb5_enc_kdc_rep_part *retval; @@ -42,7 +42,6 @@ register int *error; } xbzero(retval, sizeof(*retval)); - retval->confounder = val->confounder; retval->session = KRB5_EncryptionKey2krb5_keyblock(val->key, error); if (!retval->session) { xfree(retval); @@ -56,15 +55,14 @@ register int *error; return(0); } - retval->ctime = gentime2unix(val->ctime, error); - if (*error) { - goto errout; - } - retval->key_exp = gentime2unix(val->key__exp, error); - if (*error) { - goto errout; - } + retval->nonce = val->nonce; + if (val->key__expiration) { + retval->key_exp = gentime2unix(val->key__expiration, error); + if (*error) { + goto errout; + } + } retval->flags = KRB5_TicketFlags2krb5_flags(val->flags, error); if (*error) { goto errout; @@ -73,9 +71,11 @@ register int *error; if (*error) { goto errout; } - retval->times.starttime = gentime2unix(val->starttime, error); - if (*error) { - goto errout; + if (val->starttime) { + retval->times.starttime = gentime2unix(val->starttime, error); + if (*error) { + goto errout; + } } retval->times.endtime = gentime2unix(val->endtime, error); if (retval->flags & TKT_FLG_RENEWABLE) { @@ -85,7 +85,7 @@ register int *error; } } retval->server = KRB5_PrincipalName2krb5_principal(val->sname, - val->srealm, + val->realm, error); if (!retval->server) { goto errout; diff --git a/src/lib/krb5/asn.1/enck2kkey.c b/src/lib/krb5/asn.1/enck2kkey.c index deb389702..a23852584 100644 --- a/src/lib/krb5/asn.1/enck2kkey.c +++ b/src/lib/krb5/asn.1/enck2kkey.c @@ -36,13 +36,13 @@ register int *error; { krb5_keyblock *retval; - if (!val->session) { + if (!val->keyvalue) { *error = EINVAL; return(0); } else *error = 0; /* pull up, then play with the single string */ - if (qb_pullup(val->session) != OK) { + if (qb_pullup(val->keyvalue) != OK) { nomem: *error = ENOMEM; return(0); @@ -51,15 +51,15 @@ register int *error; if (!retval) { goto nomem; } - retval->contents = (unsigned char *) xmalloc(val->session->qb_forw->qb_len); + retval->contents = (unsigned char *) xmalloc(val->keyvalue->qb_forw->qb_len); if (!retval->contents) { xfree(retval); goto nomem; } retval->keytype = val->keytype; - retval->length = val->session->qb_forw->qb_len; - xbcopy(val->session->qb_forw->qb_data, retval->contents, - val->session->qb_forw->qb_len); + retval->length = val->keyvalue->qb_forw->qb_len; + xbcopy(val->keyvalue->qb_forw->qb_data, retval->contents, + val->keyvalue->qb_forw->qb_len); return(retval); } diff --git a/src/lib/krb5/asn.1/err2kerr.c b/src/lib/krb5/asn.1/err2kerr.c index 1355cddba..655021af0 100644 --- a/src/lib/krb5/asn.1/err2kerr.c +++ b/src/lib/krb5/asn.1/err2kerr.c @@ -44,20 +44,26 @@ register int *error; xbzero(retval, sizeof(*retval)); - retval->ctime = gentime2unix(val->ctime, error); - if (*error) { - errout: - krb5_free_error(retval); - return(0); - } - retval->cmsec = val->cmsec; + if (val->ctime) { + retval->ctime = gentime2unix(val->ctime, error); + if (*error) { + errout: + krb5_free_error(retval); + return(0); + } + } + if (val->optionals & opt_KRB5_KRB__ERROR_cmsec) + retval->cmsec = val->cmsec; + else + retval->cmsec = 0; + retval->stime = gentime2unix(val->stime, error); if (*error) { goto errout; } retval->smsec = val->smsec; - retval->error = val->error; - if (val->crealm) { + retval->error = val->error__code; + if (val->crealm && val->cname) { retval->client = KRB5_PrincipalName2krb5_principal(val->cname, val->crealm, error); @@ -65,9 +71,9 @@ register int *error; goto errout; } } - if (val->sname) { + if (val->sname && val->realm) { retval->server = KRB5_PrincipalName2krb5_principal(val->sname, - val->srealm, + val->realm, error); if (!retval->server) { goto errout; @@ -82,5 +88,14 @@ register int *error; goto errout; } } + if (val->e__data) { + temp = qbuf2krb5_data(val->e__text, error); + if (temp) { + retval->text = *temp; + xfree(temp); + } else { + goto errout; + } + } return(retval); } diff --git a/src/lib/krb5/asn.1/kaprp2aprp.c b/src/lib/krb5/asn.1/kaprp2aprp.c index 14bc90f7a..074a26ba7 100644 --- a/src/lib/krb5/asn.1/kaprp2aprp.c +++ b/src/lib/krb5/asn.1/kaprp2aprp.c @@ -44,10 +44,10 @@ register int *error; retval->pvno = KRB5_PVNO; retval->msg__type = KRB5_AP_REP; - retval->enc__part = krb5_data2qbuf(&(val->enc_part)); + retval->enc__part = krb5_enc_data2KRB5_EncryptedData(&(val->enc_part), + error); if (!retval->enc__part) { xfree(retval); - *error = ENOMEM; return(0); } return(retval); diff --git a/src/lib/krb5/asn.1/kdcr2kkdcr.c b/src/lib/krb5/asn.1/kdcr2kkdcr.c index 4e8ee5686..002ee2e6e 100644 --- a/src/lib/krb5/asn.1/kdcr2kkdcr.c +++ b/src/lib/krb5/asn.1/kdcr2kkdcr.c @@ -35,7 +35,7 @@ krb5_msgtype *type; register int *error; { register krb5_kdc_rep *retval; - krb5_data *temp; + krb5_enc_data *temp; retval = (krb5_kdc_rep *)xmalloc(sizeof(*retval)); if (!retval) { @@ -54,15 +54,12 @@ register int *error; return(0); } - retval->etype = val->etype; - retval->ckvno = val->ckvno; - retval->ticket = KRB5_Ticket2krb5_ticket(val->ticket, error); if (!retval->ticket) { krb5_free_kdc_rep(retval); return(0); } - temp = qbuf2krb5_data(val->enc__part, error); + temp = KRB5_EncryptedData2krb5_enc_data(val->enc__part, error); if (temp) { retval->enc_part = *temp; xfree(temp); diff --git a/src/lib/krb5/asn.1/kekrp2ekrp.c b/src/lib/krb5/asn.1/kekrp2ekrp.c index ca1429046..16585a2b3 100644 --- a/src/lib/krb5/asn.1/kekrp2ekrp.c +++ b/src/lib/krb5/asn.1/kekrp2ekrp.c @@ -28,21 +28,20 @@ static char rcsid_kekrp2ekrp_c[] = /* ISODE defines max(a,b) */ -struct type_KRB5_EncKDCRepPart * -krb5_enc_kdc_rep_part2KRB5_EncKDCRepPart(val, error) +struct type_KRB5_EncTGSRepPart * +krb5_enc_kdc_rep_part2KRB5_EncTGSRepPart(val, error) const register krb5_enc_kdc_rep_part *val; register int *error; { - register struct type_KRB5_EncKDCRepPart *retval; + register struct type_KRB5_EncTGSRepPart *retval; - retval = (struct type_KRB5_EncKDCRepPart *)xmalloc(sizeof(*retval)); + retval = (struct type_KRB5_EncTGSRepPart *)xmalloc(sizeof(*retval)); if (!retval) { *error = ENOMEM; return(0); } xbzero(retval, sizeof(*retval)); - retval->confounder = val->confounder; retval->key = krb5_keyblock2KRB5_EncryptionKey(val->session, error); if (!retval->key) { xfree(retval); @@ -51,16 +50,15 @@ register int *error; retval->last__req = krb5_last_req2KRB5_LastReq(val->last_req, error); if (!retval->last__req) { errout: - free_KRB5_EncKDCRepPart(retval); + free_KRB5_EncTGSRepPart(retval); return(0); } - retval->ctime = unix2gentime(val->ctime, error); - if (!retval->ctime) { - goto errout; - } - retval->key__exp = unix2gentime(val->key_exp, error); - if (!retval->key__exp) { - goto errout; + retval->nonce = val->nonce; + if (val->key_exp) { + retval->key__expiration = unix2gentime(val->key_exp, error); + if (!retval->key__expiration) { + goto errout; + } } retval->flags = krb5_flags2KRB5_TicketFlags(val->flags, error); if (!retval->flags) { @@ -70,9 +68,11 @@ register int *error; if (!retval->authtime) { goto errout; } - retval->starttime = unix2gentime(val->times.starttime, error); - if (!retval->starttime) { - goto errout; + if (val->times.starttime) { + retval->starttime = unix2gentime(val->times.starttime, error); + if (!retval->starttime) { + goto errout; + } } retval->endtime = unix2gentime(val->times.endtime, error); if (!retval->endtime) { @@ -84,8 +84,8 @@ register int *error; goto errout; } } - retval->srealm = krb5_data2qbuf(val->server[0]); - if (!retval->srealm) { + retval->realm = krb5_data2qbuf(val->server[0]); + if (!retval->realm) { *error = ENOMEM; goto errout; } diff --git a/src/lib/krb5/asn.1/kerr2err.c b/src/lib/krb5/asn.1/kerr2err.c index 44fca6acc..8eaf0aecb 100644 --- a/src/lib/krb5/asn.1/kerr2err.c +++ b/src/lib/krb5/asn.1/kerr2err.c @@ -45,12 +45,17 @@ register int *error; retval->pvno = KRB5_PVNO; retval->msg__type = KRB5_ERROR; - retval->ctime = unix2gentime(val->ctime, error); - if (!retval->ctime) { - xfree(retval); - return(0); + if (val->ctime) { + retval->ctime = unix2gentime(val->ctime, error); + if (!retval->ctime) { + xfree(retval); + return(0); + } + } + if (val->cmsec) { + retval->cmsec = val->cmsec; + retval->optionals = opt_KRB5_KRB__ERROR_cmsec; } - retval->cmsec = val->cmsec; retval->stime = unix2gentime(val->stime, error); if (!retval->stime) { @@ -59,7 +64,7 @@ register int *error; return(0); } retval->smsec = val->smsec; - retval->error = val->error; + retval->error__code = val->error; if (val->client) { retval->crealm = krb5_data2qbuf(val->client[0]); @@ -73,9 +78,10 @@ register int *error; } } + /* server is technically not optional, but... */ if (val->server) { - retval->srealm = krb5_data2qbuf(val->server[0]); - if (!retval->srealm) { + retval->realm = krb5_data2qbuf(val->server[0]); + if (!retval->realm) { *error = ENOMEM; goto errout; } @@ -91,5 +97,12 @@ register int *error; goto errout; } } + if (val->e_data.data) { + retval->e__data = krb5_data2qbuf(&val->e_data); + if (!retval->e__data) { + *error = ENOMEM; + goto errout; + } + } return(retval); } diff --git a/src/lib/krb5/asn.1/kkdcr2kdcr.c b/src/lib/krb5/asn.1/kkdcr2kdcr.c index 350340f61..0315f9da4 100644 --- a/src/lib/krb5/asn.1/kkdcr2kdcr.c +++ b/src/lib/krb5/asn.1/kkdcr2kdcr.c @@ -18,7 +18,6 @@ static char rcsid_kkdcr2kdcr_c[] = #include #include -/*#include */ #include #include "KRB5-types.h" #include "asn1glue.h" @@ -59,16 +58,13 @@ OLDDECLARG(register int *,error) if (!retval->cname) { goto errout; } - retval->etype = val->etype; - retval->ckvno = val->ckvno; - retval->ticket = krb5_ticket2KRB5_Ticket(val->ticket, error); if (!retval->ticket) { goto errout; } - retval->enc__part = krb5_data2qbuf(&(val->enc_part)); + retval->enc__part = krb5_enc_data2KRB5_EncryptedData(&(val->enc_part), + error); if (!retval->enc__part) { - *error = ENOMEM; goto errout; } return(retval); diff --git a/src/lib/krb5/asn.1/kkey2enck.c b/src/lib/krb5/asn.1/kkey2enck.c index cc611909f..11a55d482 100644 --- a/src/lib/krb5/asn.1/kkey2enck.c +++ b/src/lib/krb5/asn.1/kkey2enck.c @@ -59,7 +59,7 @@ register int *error; } retval->keytype = val->keytype; - retval->session = temp; + retval->keyvalue = temp; return(retval); } diff --git a/src/lib/krb5/asn.1/klsrq2lsrq.c b/src/lib/krb5/asn.1/klsrq2lsrq.c index 3a6cd0d9f..3e63086db 100644 --- a/src/lib/krb5/asn.1/klsrq2lsrq.c +++ b/src/lib/krb5/asn.1/klsrq2lsrq.c @@ -52,13 +52,18 @@ register int *error; retval->element_KRB5_4[i] = (struct element_KRB5_5 *) xmalloc(sizeof(*(retval->element_KRB5_4[i]))); if (!retval->element_KRB5_4[i]) { + *error = ENOMEM; + errout: retval->nelem = i; free_KRB5_LastReq(retval); - *error = ENOMEM; return(0); } retval->element_KRB5_4[i]->lr__type = val[i]->lr_type; - retval->element_KRB5_4[i]->lr__value = val[i]->value; + retval->element_KRB5_4[i]->lr__value = unix2gentime(val[i]->value, + error); + if (!retval->element_KRB5_4[i]->lr__value) { + goto errout; + } } return(retval); } diff --git a/src/lib/krb5/asn.1/kpriv2priv.c b/src/lib/krb5/asn.1/kpriv2priv.c index 6226aa254..21749d4c5 100644 --- a/src/lib/krb5/asn.1/kpriv2priv.c +++ b/src/lib/krb5/asn.1/kpriv2priv.c @@ -45,12 +45,10 @@ register int *error; retval->pvno = KRB5_PVNO; retval->msg__type = KRB5_PRIV; - retval->etype = val->etype; - - retval->enc__part = krb5_data2qbuf(&(val->enc_part)); + retval->enc__part = krb5_enc_data2KRB5_EncryptedData(&(val->enc_part), + error); if (!retval->enc__part) { - free_KRB5_KRB__PRIV(retval); - *error = ENOMEM; + xfree(retval); return(0); } return(retval); diff --git a/src/lib/krb5/asn.1/ktgrq2tgrq.c b/src/lib/krb5/asn.1/ktgrq2tgrq.c index f85c207ad..0bd1ffc64 100644 --- a/src/lib/krb5/asn.1/ktgrq2tgrq.c +++ b/src/lib/krb5/asn.1/ktgrq2tgrq.c @@ -29,8 +29,8 @@ static char rcsid_ktgrq2tgrq_c[] = /* ISODE defines max(a,b) */ struct type_KRB5_TGS__REQ * -krb5_tgs_req2KRB5_TGS__REQ(val, error) -const register krb5_tgs_req *val; +krb5_kdc_req2KRB5_TGS__REQ(val, error) +const register krb5_kdc_req *val; register int *error; { register struct type_KRB5_TGS__REQ *retval; @@ -42,18 +42,104 @@ register int *error; } xbzero(retval, sizeof(*retval)); - retval->header = krb5_data2qbuf(&(val->header)); - if (!retval->header) { + retval->pvno = KRB5_PVNO; + retval->msg__type = val->msg_type; + retval->padata__type = val->padata_type; + retval->padata = krb5_data2qbuf(&(val->padata)); + if (!retval->padata) { xfree(retval); *error = ENOMEM; return(0); } - retval->tgs__request = krb5_data2qbuf(&(val->tgs_request)); - if (!retval->tgs__request) { - xfree(retval->header); - xfree(retval); - *error = ENOMEM; + retval->req__body->kdc__options = + krb5_kdcoptions2KRB5_KDCOptions(val->kdc_options, + error); + if (!retval->req__body->kdc__options) { + errout: + free_KRB5_TGS__REQ(retval); return(0); } + if (val->client) { + retval->req__body->cname = + krb5_principal2KRB5_PrincipalName(val->client, error); + if (!retval->req__body->cname) { + goto errout; + } + } + retval->req__body->realm = krb5_data2qbuf(val->server[0]); + if (!retval->req__body->realm) { + *error = ENOMEM; + goto errout; + } + retval->req__body->sname = krb5_principal2KRB5_PrincipalName(val->server, + error); + if (!retval->req__body->sname) { + goto errout; + } + retval->req__body->from = unix2gentime(val->from, error); + if (!retval->req__body->from) { + goto errout; + } + retval->req__body->till = unix2gentime(val->till, error); + if (!retval->req__body->till) { + goto errout; + } + if (val->kdc_options & KDC_OPT_RENEWABLE) { + retval->req__body->rtime = unix2gentime(val->rtime, error); + if (!retval->req__body->rtime) { + goto errout; + } + } + retval->req__body->ctime = unix2gentime(val->ctime, error); + if (!retval->req__body->ctime) { + goto errout; + } + retval->req__body->nonce = val->nonce; + retval->req__body->etype = val->etype; + + if (val->addresses) { + retval->req__body->addresses = + krb5_address2KRB5_HostAddresses(val->addresses, error); + if (!retval->req__body->addresses) { + goto errout; + } + } + if (val->authorization_data) { + retval->req__body->authorization__data = + krb5_authdata2KRB5_AuthorizationData(val->authorization_data, + error); + if (!retval->req__body->authorization__data) + goto errout; + } + if (val->second_ticket) { + struct element_KRB5_9 *adtk; + krb5_ticket * const *temp; + register int i; + + /* count elements */ + for (i = 0, temp = val->second_ticket; *temp; temp++,i++); + + adtk = (struct element_KRB5_9 *)xmalloc(sizeof(*retval) + + max(0,i-1)*sizeof(adtk->Ticket)); + if (!adtk) { + *error = ENOMEM; + goto errout; + } + xbzero(adtk, sizeof(adtk)); + adtk->nelem = i; + for (i = 0; i < adtk->nelem; i++) { + adtk->Ticket[i] = krb5_ticket2KRB5_Ticket(val->second_ticket[i], + error); + if (!adtk->Ticket[i]) { + while (i >= 0) { + free_KRB5_Ticket(adtk->Ticket[i]); + i--; + } + xfree(adtk); + goto errout; + } + } + retval->req__body->additional__tickets = adtk; + } return(retval); } diff --git a/src/lib/krb5/asn.1/ktkt2tkt.c b/src/lib/krb5/asn.1/ktkt2tkt.c index fecff7ddd..f368ee0b0 100644 --- a/src/lib/krb5/asn.1/ktkt2tkt.c +++ b/src/lib/krb5/asn.1/ktkt2tkt.c @@ -43,8 +43,8 @@ register int *error; xbzero(retval, sizeof(*retval)); retval->tkt__vno = KRB5_PVNO; - retval->srealm = krb5_data2qbuf(val->server[0]); - if (!retval->srealm) { + retval->realm = krb5_data2qbuf(val->server[0]); + if (!retval->realm) { *error = ENOMEM; errout: free_KRB5_Ticket(retval); @@ -55,12 +55,9 @@ register int *error; goto errout; } - retval->etype = val->etype; - - retval->skvno = val->skvno; - retval->enc__part = krb5_data2qbuf(&(val->enc_part)); + retval->enc__part = krb5_enc_data2KRB5_EncryptedData(&(val->enc_part), + error); if (!retval->enc__part) { - *error = ENOMEM; goto errout; } return(retval); diff --git a/src/lib/krb5/asn.1/lsrq2klsrq.c b/src/lib/krb5/asn.1/lsrq2klsrq.c index 23f7becfc..81fb27c2f 100644 --- a/src/lib/krb5/asn.1/lsrq2klsrq.c +++ b/src/lib/krb5/asn.1/lsrq2klsrq.c @@ -50,7 +50,13 @@ register int *error; *error = ENOMEM; return(0); } - retval[i]->value = val->element_KRB5_4[i]->lr__value; + retval[i]->value = gentime2unix(val->element_KRB5_4[i]->lr__value, + error); + if (*error) { + /* value is zero if error, so it won't get freed... */ + krb5_free_last_req(retval); + return(0); + } retval[i]->lr_type = val->element_KRB5_4[i]->lr__type; } retval[i] = 0; diff --git a/src/lib/krb5/asn.1/priv2kpriv.c b/src/lib/krb5/asn.1/priv2kpriv.c index e7d0acd9d..793e033d8 100644 --- a/src/lib/krb5/asn.1/priv2kpriv.c +++ b/src/lib/krb5/asn.1/priv2kpriv.c @@ -34,7 +34,7 @@ const register struct type_KRB5_KRB__PRIV *val; register int *error; { register krb5_priv *retval; - krb5_data *temp; + krb5_enc_data *temp; retval = (krb5_priv *)xmalloc(sizeof(*retval)); if (!retval) { @@ -43,9 +43,7 @@ register int *error; } xbzero(retval, sizeof(*retval)); - retval->etype = val->etype; - - temp = qbuf2krb5_data(val->enc__part, error); + temp = KRB5_EncryptedData2krb5_enc_data(val->enc__part, error); if (temp) { retval->enc_part = *temp; xfree(temp); diff --git a/src/lib/krb5/asn.1/tgrq2ktgrq.c b/src/lib/krb5/asn.1/tgrq2ktgrq.c index 20de5b8f6..e9f464196 100644 --- a/src/lib/krb5/asn.1/tgrq2ktgrq.c +++ b/src/lib/krb5/asn.1/tgrq2ktgrq.c @@ -28,37 +28,110 @@ static char rcsid_tgrq2ktgrq_c[] = /* ISODE defines max(a,b) */ -krb5_tgs_req * -KRB5_TGS__REQ2krb5_tgs_req(val, error) +krb5_kdc_req * +KRB5_TGS__REQ2krb5_kdc_req(val, error) const register struct type_KRB5_TGS__REQ *val; register int *error; { - register krb5_tgs_req *retval; + register krb5_kdc_req *retval; krb5_data *temp; - retval = (krb5_tgs_req *)xmalloc(sizeof(*retval)); + retval = (krb5_kdc_req *)xmalloc(sizeof(*retval)); if (!retval) { *error = ENOMEM; return(0); } xbzero(retval, sizeof(*retval)); - temp = qbuf2krb5_data(val->header, error); - if (temp) { - retval->header = *temp; - xfree(temp); - } else { - xfree(retval); + retval->msg_type = val->msg__type; + retval->padata_type = val->padata__type; + if (val->padata) { + temp = qbuf2krb5_data(val->padata, error); + if (temp) { + retval->padata = *temp; + xfree(temp); + } else { + goto errout; + } + } + + retval->kdc_options = + KRB5_KDCOptions2krb5_kdcoptions(val->req__body->kdc__options, + error); + if (*error) { + errout: + krb5_free_kdc_req(retval); return(0); } - temp = qbuf2krb5_data(val->tgs__request, error); - if (temp) { - retval->tgs_request = *temp; - xfree(temp); - } else { - xfree(retval->header.data); - xfree(retval); - return(0); + if (val->req__body->cname) + retval->client = + KRB5_PrincipalName2krb5_principal(val->req__body->cname, + val->req__body->realm, + error); + retval->server = KRB5_PrincipalName2krb5_principal(val->req__body->sname, + val->req__body->realm, + error); + if (!retval->server) { + goto errout; + } + retval->from = gentime2unix(val->req__body->from, error); + if (*error) { + goto errout; + } + retval->till = gentime2unix(val->req__body->till, error); + if (*error) { + goto errout; + } + if (retval->kdc_options & KDC_OPT_RENEWABLE) { + retval->rtime = gentime2unix(val->req__body->rtime, error); + if (*error) { + goto errout; + } + } + retval->ctime = gentime2unix(val->req__body->ctime, error); + if (*error) { + goto errout; + } + retval->nonce = val->req__body->nonce; + + retval->etype = val->req__body->etype; + + + if (val->req__body->addresses) { + retval->addresses = + KRB5_HostAddresses2krb5_address(val->req__body->addresses, error); + if (!retval->addresses) { + goto errout; + } + } + if (val->req__body->authorization__data) { + retval->authorization_data = + KRB5_AuthorizationData2krb5_authdata(val->req__body-> + authorization__data, + error); + if (*error) + goto errout; + } + if (val->req__body->additional__tickets) { + register krb5_ticket **aticks; + register struct element_KRB5_9 *tptr; + register int i; + + tptr = val->req__body->additional__tickets; + /* plus one for null terminator */ + aticks = (krb5_ticket **) xcalloc(tptr->nelem + 1, + sizeof(*aticks)); + for (i = 0; i < tptr->nelem; i++) { + aticks[i] = KRB5_Ticket2krb5_ticket(tptr->Ticket[i], error); + if (!aticks[i]) { + while (i >= 0) { + krb5_free_ticket(aticks[i]); + i--; + } + goto errout; + } + } + retval->second_ticket = aticks; } return(retval); } diff --git a/src/lib/krb5/asn.1/tkt2ktkt.c b/src/lib/krb5/asn.1/tkt2ktkt.c index 68ef43ef5..cda06a550 100644 --- a/src/lib/krb5/asn.1/tkt2ktkt.c +++ b/src/lib/krb5/asn.1/tkt2ktkt.c @@ -34,7 +34,7 @@ const register struct type_KRB5_Ticket *val; register int *error; { register krb5_ticket *retval; - krb5_data *temp; + krb5_enc_data *temp; retval = (krb5_ticket *)xmalloc(sizeof(*retval)); if (!retval) { @@ -45,16 +45,14 @@ register int *error; retval->server = KRB5_PrincipalName2krb5_principal(val->sname, - val->srealm, + val->realm, error); if (!retval->server) { xfree(retval); return(0); } - retval->etype = val->etype; - retval->skvno = val->skvno; - temp = qbuf2krb5_data(val->enc__part, error); + temp = KRB5_EncryptedData2krb5_enc_data(val->enc__part, error); if (temp) { retval->enc_part = *temp; xfree(temp); -- 2.26.2