dead
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@838 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
256
d.c
256
d.c
@@ -1,256 +0,0 @@
|
||||
#include <krb5_locl.h>
|
||||
#include <d.h>
|
||||
|
||||
int
|
||||
buf_getbyte (Buffer *b)
|
||||
{
|
||||
if (b->p >= b->buf + b->len)
|
||||
return EOF;
|
||||
return *b->p++;
|
||||
}
|
||||
|
||||
void
|
||||
buf_init (Buffer *b, char *ptr, unsigned len)
|
||||
{
|
||||
b->buf = b->p = ptr;
|
||||
b->len = len;
|
||||
}
|
||||
|
||||
Buffer *
|
||||
buf_derive (Buffer *b, Buffer *tmp, int len)
|
||||
{
|
||||
tmp->buf = tmp->p = b->p;
|
||||
if(len == -1)
|
||||
tmp->len = buf_bytesleft (b);
|
||||
else
|
||||
tmp->len = len;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
int
|
||||
buf_bytesleft (Buffer *b)
|
||||
{
|
||||
return b->len - (b->p - b->buf);
|
||||
}
|
||||
|
||||
void
|
||||
buf_advance (Buffer *b, int n)
|
||||
{
|
||||
b->p += n;
|
||||
}
|
||||
|
||||
int
|
||||
buf_length (Buffer *b)
|
||||
{
|
||||
return b->p - b->buf;
|
||||
}
|
||||
|
||||
Identifier *
|
||||
getid (Buffer *b, Identifier *i)
|
||||
{
|
||||
int c, len;
|
||||
|
||||
c = buf_getbyte (b);
|
||||
if (c == EOF)
|
||||
return NULL;
|
||||
i->class = c >> 6;
|
||||
i->type = (c >> 5) & 1;
|
||||
i->tag = c & 0x1F;
|
||||
if (i->tag == 0x1F) {
|
||||
do {
|
||||
c = buf_getbyte (b);
|
||||
if (c == EOF)
|
||||
return NULL;
|
||||
i->tag = i->tag * 0x80 + (c & 0x7F);
|
||||
} while( c & 0x80);
|
||||
}
|
||||
|
||||
c = buf_getbyte (b);
|
||||
if (c == EOF)
|
||||
return NULL;
|
||||
len = c;
|
||||
if (len < 0x80) {
|
||||
i->len = len;
|
||||
} else if(len > 0x80) {
|
||||
len &= 0x7F;
|
||||
i->len = 0;
|
||||
while (len--) {
|
||||
c = buf_getbyte (b);
|
||||
if (c == EOF)
|
||||
return NULL;
|
||||
i->len = i->len * 0x100 + c;
|
||||
}
|
||||
} else if (len == 0x80)
|
||||
i->len = -1;
|
||||
return i;
|
||||
}
|
||||
|
||||
Identifier *
|
||||
matchid (Buffer *b, Identifier *i)
|
||||
{
|
||||
Identifier tmp;
|
||||
|
||||
if (getid (b, &tmp) == NULL)
|
||||
return NULL;
|
||||
if (tmp.class == i->class && tmp.type == i->type && tmp.tag == i->tag) {
|
||||
i->len = tmp.len;
|
||||
return i;
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Identifier dummy;
|
||||
|
||||
Identifier *
|
||||
matchid3 (Buffer *b, Identifier *i, Der_class class, Der_type type,
|
||||
unsigned tag)
|
||||
{
|
||||
i->class = class;
|
||||
i->type = type;
|
||||
i->tag = tag;
|
||||
return matchid (b, i);
|
||||
}
|
||||
|
||||
Identifier *
|
||||
matchcontextid (Buffer *b, Identifier *i, int tag)
|
||||
{
|
||||
Identifier tmp;
|
||||
|
||||
if (matchid3 (b, &tmp, CONTEXT, CONS, tag) == NULL ||
|
||||
matchid (b, i) == NULL)
|
||||
return NULL;
|
||||
return i;
|
||||
}
|
||||
|
||||
Identifier *
|
||||
matchcontextid3 (Buffer *b, Identifier *i, Der_class class,
|
||||
Der_type dtype,
|
||||
int type,
|
||||
unsigned tag)
|
||||
{
|
||||
i->class = class;
|
||||
i->type = dtype;
|
||||
i->tag = type;
|
||||
return matchcontextid (b, i, tag);
|
||||
}
|
||||
|
||||
int
|
||||
der_get_integer (Buffer *b, void *val)
|
||||
{
|
||||
int c;
|
||||
int res;
|
||||
int len;
|
||||
|
||||
res = len = 0;
|
||||
while ((c = buf_getbyte (b)) != EOF) {
|
||||
res = res * 0x100 + c;
|
||||
++len;
|
||||
}
|
||||
*((int *)val) = res;
|
||||
return len;
|
||||
}
|
||||
|
||||
int
|
||||
der_get_octetstring (Buffer *b, void *val)
|
||||
{
|
||||
krb5_data *str = (krb5_data *)val;
|
||||
int len, c;
|
||||
char *p;
|
||||
|
||||
len = buf_bytesleft (b);
|
||||
str->length = len;
|
||||
str->data = p = malloc (len + 1);
|
||||
while (len && (c = buf_getbyte (b)) != EOF) {
|
||||
*p++ = c;
|
||||
--len;
|
||||
}
|
||||
*p++ = '\0';
|
||||
return len;
|
||||
}
|
||||
|
||||
int
|
||||
der_get_generalizedtime (Buffer *b, void *val)
|
||||
{
|
||||
time_t *t = (time_t *)val;
|
||||
int len;
|
||||
krb5_data str;
|
||||
struct tm tm, *tm2;
|
||||
|
||||
len = der_get_octetstring (b, &str);
|
||||
sscanf (str.data, "%04d%02d%02d%02d%02d%02dZ",
|
||||
&tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour,
|
||||
&tm.tm_min, &tm.tm_sec);
|
||||
tm.tm_year -= 1900;
|
||||
tm.tm_mon -= 1;
|
||||
tm.tm_isdst = 0;
|
||||
|
||||
*t = mktime (&tm);
|
||||
|
||||
tm2 = gmtime (t);
|
||||
|
||||
*t += *t - mktime (tm2);
|
||||
string_free (str);
|
||||
return len;
|
||||
}
|
||||
|
||||
static int (*get_univ_funcs[])(Buffer *, void *val) = {
|
||||
NULL, /* 0 */
|
||||
NULL, /* 1 */
|
||||
der_get_integer, /* 2 */
|
||||
NULL, /* 3 */
|
||||
der_get_octetstring, /* 4 */
|
||||
NULL, /* 5 */
|
||||
NULL, /* 6 */
|
||||
NULL, /* 7 */
|
||||
NULL, /* 8 */
|
||||
NULL, /* 9 */
|
||||
NULL, /* 10 */
|
||||
NULL, /* 11 */
|
||||
NULL, /* 12 */
|
||||
NULL, /* 13 */
|
||||
NULL, /* 14 */
|
||||
NULL, /* 15 */
|
||||
NULL, /* 16 */
|
||||
NULL, /* 17 */
|
||||
NULL, /* 18 */
|
||||
NULL, /* 19 */
|
||||
NULL, /* 20 */
|
||||
NULL, /* 21 */
|
||||
NULL, /* 22 */
|
||||
NULL, /* 23 */
|
||||
der_get_generalizedtime, /* 24 */
|
||||
NULL, /* 25 */
|
||||
NULL, /* 26 */
|
||||
der_get_octetstring, /* 27 */
|
||||
};
|
||||
|
||||
int
|
||||
der_get_val (Buffer *b, int type, void *val)
|
||||
{
|
||||
return (*(get_univ_funcs[type]))(b, val);
|
||||
}
|
||||
|
||||
void
|
||||
getzeros (Buffer *b, int len)
|
||||
{
|
||||
if (len == -1) {
|
||||
buf_getbyte (b);
|
||||
buf_getbyte (b);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
getdata (Buffer *b, Identifier *i, void *arg)
|
||||
{
|
||||
Buffer tmp;
|
||||
int res;
|
||||
|
||||
buf_derive (b, &tmp, i->len);
|
||||
res = der_get_val (&tmp, i->tag, arg);
|
||||
if (i->len == -1) {
|
||||
getzeros (b, i->len);
|
||||
buf_advance (b, res);
|
||||
} else
|
||||
buf_advance (b, i->len);
|
||||
return res;
|
||||
}
|
27
d.h
27
d.h
@@ -1,27 +0,0 @@
|
||||
#include <der.h>
|
||||
|
||||
struct Buffer {
|
||||
unsigned char *buf;
|
||||
unsigned char *p;
|
||||
unsigned len;
|
||||
};
|
||||
|
||||
typedef struct Buffer Buffer;
|
||||
|
||||
int buf_getbyte (Buffer *);
|
||||
void buf_init (Buffer *, char *, unsigned);
|
||||
Buffer *buf_derive (Buffer *, Buffer *, int);
|
||||
int buf_bytesleft (Buffer *b);
|
||||
void buf_advance (Buffer *b, int n);
|
||||
int buf_length (Buffer *b);
|
||||
|
||||
struct Identifier {
|
||||
Der_class class;
|
||||
Der_type type;
|
||||
unsigned tag;
|
||||
int len;
|
||||
};
|
||||
|
||||
typedef struct Identifier Identifier;
|
||||
|
||||
Identifier *getid (Buffer *b, Identifier *i);
|
28
der.c
28
der.c
@@ -1,28 +0,0 @@
|
||||
#include <krb5_locl.h>
|
||||
#include <der.h>
|
||||
|
||||
/*
|
||||
* Type functions
|
||||
*/
|
||||
|
||||
krb5_data
|
||||
string_make_n (int n, char *s)
|
||||
{
|
||||
krb5_data ret;
|
||||
|
||||
ret.length = n;
|
||||
ret.data = s;
|
||||
return ret;
|
||||
}
|
||||
|
||||
krb5_data
|
||||
string_make (char *s)
|
||||
{
|
||||
return string_make_n (strlen (s), s);
|
||||
}
|
||||
|
||||
void
|
||||
string_free (krb5_data s)
|
||||
{
|
||||
free (s.data);
|
||||
}
|
30
der.h
30
der.h
@@ -1,30 +0,0 @@
|
||||
#ifndef DER_H
|
||||
|
||||
#define DER_H
|
||||
|
||||
typedef enum {UNIV = 0, APPL = 1, CONTEXT = 2 , PRIVATE = 3} Der_class;
|
||||
|
||||
typedef enum {PRIM = 0, CONS = 1} Der_type;
|
||||
|
||||
/* Universal tags */
|
||||
|
||||
enum {
|
||||
UT_Integer = 2,
|
||||
UT_BitString = 3,
|
||||
UT_OctetString = 4,
|
||||
UT_Null = 5,
|
||||
UT_ObjID = 6,
|
||||
UT_Sequence = 16,
|
||||
UT_Set = 17,
|
||||
UT_PrintableString = 19,
|
||||
UT_IA5String = 22,
|
||||
UT_UTCTime = 23,
|
||||
UT_GeneralizedTime = 24,
|
||||
UT_GeneralString = 27
|
||||
};
|
||||
|
||||
krb5_data string_make (char *);
|
||||
krb5_data string_make_n (int len, char *);
|
||||
void string_free (krb5_data);
|
||||
|
||||
#endif /* DER_H */
|
395
e.c
395
e.c
@@ -1,395 +0,0 @@
|
||||
#include <krb5_locl.h>
|
||||
#include <d.h>
|
||||
#include <k5_der.h>
|
||||
|
||||
int
|
||||
der_get_principalname (Buffer *b, krb5_principal *p)
|
||||
{
|
||||
Identifier i;
|
||||
int cur, max;
|
||||
char *str;
|
||||
int len;
|
||||
|
||||
*p = malloc(sizeof(**p));
|
||||
if (*p == NULL)
|
||||
return -1;
|
||||
(*p)->ncomp = 0;
|
||||
|
||||
if (matchid3 (b, &i, UNIV, CONS, UT_Sequence) == NULL)
|
||||
return -1;
|
||||
if (matchcontextid3 (b, &i, UNIV, PRIM, UT_Integer, 0) == NULL)
|
||||
return -1;
|
||||
getdata (b, &i, &(*p)->type);
|
||||
if (matchcontextid3 (b, &i, UNIV, CONS, UT_Sequence, 1) == NULL)
|
||||
return -1;
|
||||
cur = 0;
|
||||
max = 1;
|
||||
(*p)->comp = malloc(sizeof(*(*p)->comp) * max);
|
||||
while (matchid3 (b, &i, UNIV, PRIM, UT_GeneralString)) {
|
||||
if (cur >= max) {
|
||||
max *= 2;
|
||||
(*p)->comp = realloc ((*p)->comp, sizeof(*(*p)->comp) * max);
|
||||
}
|
||||
getdata (b, &i, &(*p)->comp[cur++]);
|
||||
}
|
||||
(*p)->ncomp = cur;
|
||||
return buf_length (b);
|
||||
}
|
||||
|
||||
int
|
||||
der_get_encrypteddata (Buffer *b, EncryptedData *e)
|
||||
{
|
||||
Identifier i0, i1, i;
|
||||
int len;
|
||||
|
||||
if (matchid3 (b, &i0, UNIV, CONS, UT_Sequence) == NULL)
|
||||
return -1;
|
||||
if (matchcontextid3 (b, &i, UNIV, PRIM, UT_Integer, 0) == NULL)
|
||||
return -1;
|
||||
getdata (b, &i, &e->etype);
|
||||
getid (b, &i);
|
||||
if (i.tag == 1) {
|
||||
int kvno;
|
||||
|
||||
if (matchid3 (b, &i, UNIV, PRIM, UT_Integer) == NULL)
|
||||
return -1;
|
||||
getdata (b, &i, &kvno);
|
||||
e->kvno = malloc (sizeof (int));
|
||||
*(e->kvno) = kvno;
|
||||
} else
|
||||
e->kvno = NULL;
|
||||
if (matchid3 (b, &i1, CONTEXT, CONS, 2) == NULL)
|
||||
return -1;
|
||||
if (matchid3 (b, &i, UNIV, PRIM, UT_OctetString) == NULL)
|
||||
return -1;
|
||||
getdata (b, &i, &e->cipher);
|
||||
getzeros (b, i1.len);
|
||||
getzeros (b, i0.len);
|
||||
return buf_length (b);
|
||||
}
|
||||
|
||||
int
|
||||
der_get_ticket (Buffer *b, krb5_ticket *t)
|
||||
{
|
||||
Identifier i0, i1, i;
|
||||
EncryptedData e;
|
||||
Buffer tmp;
|
||||
int len;
|
||||
int tkt_vno;
|
||||
|
||||
if (matchid3 (b, &i0, APPL, CONS, APPL_TICKET) == NULL)
|
||||
return -1;
|
||||
if (matchid3 (b, &i1, UNIV, CONS, UT_Sequence) == NULL)
|
||||
return -1;
|
||||
if (matchcontextid3 (b, &i, UNIV, PRIM, UT_Integer, 0) == NULL)
|
||||
return -1;
|
||||
getdata (b, &i, &tkt_vno);
|
||||
if (tkt_vno != 5)
|
||||
return -1;
|
||||
t->sprinc = malloc (sizeof (*t->sprinc));
|
||||
if (t->sprinc == NULL)
|
||||
return -1;
|
||||
if (matchcontextid3 (b, &i, UNIV, PRIM, UT_GeneralString, 1) == NULL)
|
||||
return -1;
|
||||
getdata (b, &i, &t->sprinc->realm);
|
||||
if (matchid3 (b, &i, CONTEXT, CONS, 2) == NULL)
|
||||
return -1;
|
||||
buf_derive(b, &tmp, i.len);
|
||||
len = der_get_principalname (&tmp, &t->sprinc);
|
||||
if (len == -1)
|
||||
return -1;
|
||||
buf_advance (b, len);
|
||||
getzeros (b, i.len);
|
||||
if (matchid3 (b, &i, CONTEXT, CONS, 3) == NULL)
|
||||
return -1;
|
||||
buf_derive (b, &tmp, i.len);
|
||||
len = der_get_encrypteddata (&tmp, &e);
|
||||
if (len == -1)
|
||||
return -1;
|
||||
buf_advance (b, len);
|
||||
getzeros (b, i.len);
|
||||
getzeros (b, i1.len);
|
||||
getzeros (b, i0.len);
|
||||
t->kvno = *e.kvno;
|
||||
t->etype = e.etype;
|
||||
t->enc_part = e.cipher;
|
||||
return buf_length (b);
|
||||
}
|
||||
|
||||
int
|
||||
der_get_kdc_rep (Buffer *b, int msg, krb5_kdc_rep *k)
|
||||
{
|
||||
Identifier i, i0;
|
||||
Buffer tmp;
|
||||
int len;
|
||||
|
||||
if (matchid3 (b, &i0, UNIV, CONS, UT_Sequence) == NULL)
|
||||
return -1;
|
||||
if (matchcontextid3 (b, &i, UNIV, PRIM, UT_Integer, 0) == NULL)
|
||||
return -1;
|
||||
|
||||
getdata (b, &i, &k->pvno);
|
||||
if (matchcontextid3 (b, &i, UNIV, PRIM, UT_Integer, 1) == NULL)
|
||||
return -1;
|
||||
getdata (b, &i, &k->msg_type);
|
||||
if (k->msg_type != msg)
|
||||
return -1;
|
||||
getid (b, &i);
|
||||
if (i.tag == 2)
|
||||
abort (); /* XXX */
|
||||
if (i.tag != 3)
|
||||
return -1;
|
||||
if (matchid3 (b, &i, UNIV, PRIM, UT_GeneralString) == NULL)
|
||||
return -1;
|
||||
getdata (b, &i, &k->realm);
|
||||
if (matchid3 (b, &i, CONTEXT, CONS, 4) == NULL)
|
||||
return -1;
|
||||
buf_derive(b, &tmp, i.len);
|
||||
len = der_get_principalname (&tmp, &k->cname);
|
||||
if (len == -1)
|
||||
return -1;
|
||||
buf_advance (b, len);
|
||||
getzeros (b, i.len);
|
||||
if (matchid3 (b, &i, CONTEXT, CONS, 5) == NULL)
|
||||
return -1;
|
||||
buf_derive(b, &tmp, i.len);
|
||||
len = der_get_ticket (&tmp, &k->ticket);
|
||||
if (len == -1)
|
||||
return -1;
|
||||
buf_advance (b, len);
|
||||
getzeros (b, i.len);
|
||||
if (matchid3 (b, &i, CONTEXT, CONS, 6) == NULL)
|
||||
return -1;
|
||||
buf_derive(b, &tmp, i.len);
|
||||
len = der_get_encrypteddata (&tmp, &k->enc_part);
|
||||
if(len == -1)
|
||||
return -1;
|
||||
buf_advance (b, len);
|
||||
getzeros (b, i.len);
|
||||
getzeros (b, i0.len);
|
||||
return buf_length (b);
|
||||
}
|
||||
|
||||
static int
|
||||
der_get_kdc_rep_msg (Buffer *b, int msg, krb5_kdc_rep *a)
|
||||
{
|
||||
Identifier i;
|
||||
|
||||
if (matchid3(b, &i, APPL, CONS, msg) == NULL)
|
||||
return -1;
|
||||
return der_get_kdc_rep (b, msg, a);
|
||||
}
|
||||
|
||||
int
|
||||
der_get_as_rep (Buffer *b, As_Rep *a)
|
||||
{
|
||||
return der_get_kdc_rep_msg (b, KRB_AS_REP, a);
|
||||
}
|
||||
|
||||
int
|
||||
der_get_tgs_rep (Buffer *b, Tgs_Rep *a)
|
||||
{
|
||||
return der_get_kdc_rep_msg (b, KRB_TGS_REP, a);
|
||||
}
|
||||
|
||||
int
|
||||
der_get_encryptionkey (Buffer *b, krb5_keyblock *k)
|
||||
{
|
||||
Identifier i;
|
||||
|
||||
if (matchid3 (b, &i, UNIV, CONS, UT_Sequence) == NULL)
|
||||
return -1;
|
||||
if (matchcontextid3 (b, &i, UNIV, PRIM, UT_Integer, 0) == NULL)
|
||||
return -1;
|
||||
getdata (b, &i, &k->keytype);
|
||||
if (matchcontextid3 (b, &i, UNIV, PRIM, UT_OctetString, 1) == NULL)
|
||||
return -1;
|
||||
getdata (b, &i, &k->contents);
|
||||
return buf_length (b);
|
||||
}
|
||||
|
||||
int
|
||||
der_get_hostaddresses (Buffer *b, krb5_addresses *h)
|
||||
{
|
||||
Identifier i;
|
||||
int cur, max;
|
||||
|
||||
if (matchid3 (b, &i, UNIV, CONS, UT_Sequence) == NULL)
|
||||
return -1;
|
||||
cur = 0;
|
||||
max = 1;
|
||||
h->addrs = malloc (sizeof (*h->addrs));
|
||||
while (matchid3 (b, &i, UNIV, CONS, UT_Sequence)) {
|
||||
if (cur >= max) {
|
||||
max *= 2;
|
||||
h->addrs = realloc (h->addrs, sizeof(*h->addrs) * max);
|
||||
}
|
||||
if (matchcontextid3 (b, &i, UNIV, PRIM, UT_Integer, 0) == NULL)
|
||||
return -1;
|
||||
getdata (b, &i, &h->addrs[cur].type);
|
||||
if (matchcontextid3 (b, &i, UNIV, PRIM, UT_OctetString, 1) == NULL)
|
||||
return -1;
|
||||
getdata (b, &i, &h->addrs[cur].address);
|
||||
++cur;
|
||||
}
|
||||
h->number = cur;
|
||||
return buf_length (b);
|
||||
}
|
||||
|
||||
int
|
||||
der_get_lastreq (Buffer *b, LastReq *l)
|
||||
{
|
||||
Identifier i;
|
||||
int cur, max;
|
||||
|
||||
if (matchid3 (b, &i, UNIV, CONS, UT_Sequence) == NULL)
|
||||
return -1;
|
||||
cur = 0;
|
||||
max = 1;
|
||||
l->values = malloc (sizeof(*l->values));
|
||||
while (matchid3 (b, &i, UNIV, CONS, UT_Sequence)) {
|
||||
if (cur >= max) {
|
||||
max *= 2;
|
||||
l->values = realloc (l->values, sizeof (*l->values) * max);
|
||||
}
|
||||
if (matchcontextid3 (b, &i, UNIV, PRIM, UT_Integer, 0) == NULL)
|
||||
return -1;
|
||||
getdata (b, &i, &l->values[cur].lr_type);
|
||||
if (matchcontextid3 (b, &i, UNIV, PRIM, UT_GeneralizedTime, 1) == NULL)
|
||||
return -1;
|
||||
getdata (b, &i, &l->values[cur].lr_value);
|
||||
++cur;
|
||||
}
|
||||
l->number = cur;
|
||||
return buf_length (b);
|
||||
}
|
||||
|
||||
int
|
||||
der_get_ticketflags (Buffer *b, TicketFlags *t)
|
||||
{
|
||||
Identifier i;
|
||||
|
||||
return buf_bytesleft (b);
|
||||
}
|
||||
|
||||
int
|
||||
der_get_enckdcreppart (Buffer *b, int msg, EncKdcRepPart *a)
|
||||
{
|
||||
Identifier i;
|
||||
Buffer tmp;
|
||||
int len;
|
||||
|
||||
if (matchid3 (b, &i, UNIV, CONS, UT_Sequence) == NULL)
|
||||
return -1;
|
||||
if (matchid3 (b, &i, CONTEXT, CONS, 0) == NULL)
|
||||
return -1;
|
||||
buf_derive (b, &tmp, i.len);
|
||||
len = der_get_encryptionkey (&tmp, &a->key);
|
||||
if (len == -1)
|
||||
return -1;
|
||||
buf_advance (b, len);
|
||||
getzeros (b, i.len);
|
||||
if (matchid3 (b, &i, CONTEXT, CONS, 1) == NULL)
|
||||
return -1;
|
||||
buf_derive (b, &tmp, i.len);
|
||||
len = der_get_lastreq (&tmp, &a->req);
|
||||
if (len == -1)
|
||||
return -1;
|
||||
buf_advance (b, len);
|
||||
getzeros (b, i.len);
|
||||
if (matchcontextid3 (b, &i, UNIV, PRIM, UT_Integer, 2) == NULL)
|
||||
return -1;
|
||||
getdata (b, &i, &a->nonce);
|
||||
getid (b, &i);
|
||||
if (i.tag == 3) {
|
||||
if (matchid3 (b, &i, UNIV, PRIM, UT_GeneralizedTime) == NULL)
|
||||
return NULL;
|
||||
|
||||
a->key_expiration = malloc (sizeof(*a->key_expiration));
|
||||
getdata (b, &i, a->key_expiration);
|
||||
getid (b, &i);
|
||||
} else
|
||||
a->key_expiration = NULL;
|
||||
if (i.tag != 4)
|
||||
return NULL;
|
||||
buf_derive (b, &tmp, i.len);
|
||||
len = der_get_ticketflags (&tmp, &a->flags);
|
||||
if (len == -1)
|
||||
return -1;
|
||||
buf_advance (b, len);
|
||||
getzeros (b, i.len);
|
||||
if (matchcontextid3 (b, &i, UNIV, PRIM, UT_GeneralizedTime, 5) == NULL)
|
||||
return NULL;
|
||||
getdata (b, &i, &a->authtime);
|
||||
getid (b, &i);
|
||||
if (i.tag == 6) {
|
||||
if (matchid3 (b, &i, UNIV, PRIM, UT_GeneralizedTime) == NULL)
|
||||
return NULL;
|
||||
|
||||
a->starttime = malloc (sizeof(*a->starttime));
|
||||
getdata (b, &i, a->starttime);
|
||||
getid (b, &i);
|
||||
} else
|
||||
a->starttime = NULL;
|
||||
if (i.tag != 7)
|
||||
return NULL;
|
||||
if (matchid3 (b, &i, UNIV, PRIM, UT_GeneralizedTime) == NULL)
|
||||
return NULL;
|
||||
getdata (b, &i, &a->endtime);
|
||||
getid (b, &i);
|
||||
if (i.tag == 8) {
|
||||
if (matchid3 (b, &i, UNIV, PRIM, UT_GeneralizedTime) == NULL)
|
||||
return NULL;
|
||||
|
||||
a->renew_till = malloc (sizeof(*a->renew_till));
|
||||
getdata (b, &i, a->renew_till);
|
||||
getid (b, &i);
|
||||
} else
|
||||
a->renew_till = NULL;
|
||||
if (i.tag != 9)
|
||||
return NULL;
|
||||
if (matchid3 (b, &i, UNIV, PRIM, UT_GeneralString) == NULL)
|
||||
return NULL;
|
||||
getdata (b, &i, &a->srealm);
|
||||
if (matchid3 (b, &i, CONTEXT, CONS, 10) == NULL)
|
||||
return NULL;
|
||||
buf_derive(b, &tmp, i.len);
|
||||
len = der_get_principalname (&tmp, &a->sname);
|
||||
if (len == -1)
|
||||
return -1;
|
||||
buf_advance (b, len);
|
||||
getzeros (b, i.len);
|
||||
getid (b, &i);
|
||||
if (i.tag == 11) {
|
||||
buf_derive (b, &tmp, i.len);
|
||||
len = der_get_hostaddresses (&tmp, &a->caddr);
|
||||
if (len == -1)
|
||||
return -1;
|
||||
buf_advance (b, len);
|
||||
getzeros (b, i.len);
|
||||
} else
|
||||
a->caddr.number = 0;
|
||||
return buf_length (b);
|
||||
}
|
||||
|
||||
static int
|
||||
der_get_enckdcreppart_msg (Buffer *b, int msg, EncKdcRepPart *a)
|
||||
{
|
||||
Identifier i;
|
||||
|
||||
if (matchid3 (b, &i, APPL, CONS, msg) == NULL)
|
||||
return -1;
|
||||
return der_get_enckdcreppart (b, msg, a);
|
||||
}
|
||||
|
||||
int
|
||||
der_get_encasreppart (Buffer *b, EncASRepPart *a)
|
||||
{
|
||||
return der_get_enckdcreppart_msg (b, KRB_ENCASREPPART, a);
|
||||
}
|
||||
|
||||
int
|
||||
der_get_enctgsreppart (Buffer *b, EncTGSRepPart *a)
|
||||
{
|
||||
return der_get_enckdcreppart_msg (b, KRB_ENCKDCREPPART, a);
|
||||
}
|
Reference in New Issue
Block a user