ndb/dns: implement RFC6844 certificate authority authorization record type
This commit is contained in:
parent
5fd4fa912e
commit
b5690a5ae7
6 changed files with 69 additions and 8 deletions
|
@ -299,6 +299,11 @@ convRR2M(RR *rp, uchar *p, uchar *ep, Dict *dp)
|
||||||
UCHAR(rp->cert->alg);
|
UCHAR(rp->cert->alg);
|
||||||
BYTES(rp->cert->data, rp->cert->dlen);
|
BYTES(rp->cert->data, rp->cert->dlen);
|
||||||
break;
|
break;
|
||||||
|
case Tcaa:
|
||||||
|
UCHAR(rp->caa->flags);
|
||||||
|
SYMBOL(rp->caa->tag->name);
|
||||||
|
BYTES(rp->caa->data, rp->caa->dlen);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* stuff in the rdata section length */
|
/* stuff in the rdata section length */
|
||||||
|
|
|
@ -472,6 +472,11 @@ retry:
|
||||||
UCHAR(rp->cert->alg);
|
UCHAR(rp->cert->alg);
|
||||||
BYTES(rp->cert->data, rp->cert->dlen);
|
BYTES(rp->cert->data, rp->cert->dlen);
|
||||||
break;
|
break;
|
||||||
|
case Tcaa:
|
||||||
|
UCHAR(rp->caa->flags);
|
||||||
|
SYMBOL(rp->caa->tag);
|
||||||
|
BYTES(rp->caa->data, rp->caa->dlen);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if(sp->p - data != len) {
|
if(sp->p - data != len) {
|
||||||
char ptype[64];
|
char ptype[64];
|
||||||
|
|
|
@ -40,7 +40,7 @@ static RR* soarr(Ndbtuple*, Ndbtuple*);
|
||||||
static RR* srvrr(Ndbtuple*, Ndbtuple*);
|
static RR* srvrr(Ndbtuple*, Ndbtuple*);
|
||||||
static RR* txtrr(Ndbtuple*, Ndbtuple*);
|
static RR* txtrr(Ndbtuple*, Ndbtuple*);
|
||||||
|
|
||||||
static int implemented[Tall] =
|
static int implemented[] =
|
||||||
{
|
{
|
||||||
[Ta] 1,
|
[Ta] 1,
|
||||||
[Taaaa] 1,
|
[Taaaa] 1,
|
||||||
|
@ -118,7 +118,7 @@ dblookup(char *name, int class, int type, int auth, int ttl)
|
||||||
rp = nil;
|
rp = nil;
|
||||||
|
|
||||||
if(type == Tall){
|
if(type == Tall){
|
||||||
for (type = Ta; type < Tall; type++)
|
for (type = 0; type < nelem(implemented); type++)
|
||||||
if(implemented[type])
|
if(implemented[type])
|
||||||
rrcat(&rp, dblookup(name, class, type, auth, ttl));
|
rrcat(&rp, dblookup(name, class, type, auth, ttl));
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ static struct {
|
||||||
} dnvars;
|
} dnvars;
|
||||||
|
|
||||||
/* names of RR types */
|
/* names of RR types */
|
||||||
char *rrtname[] =
|
static char *rrtname[] =
|
||||||
{
|
{
|
||||||
[Ta] "ip",
|
[Ta] "ip",
|
||||||
[Tns] "ns",
|
[Tns] "ns",
|
||||||
|
@ -97,7 +97,7 @@ char *rrtname[] =
|
||||||
[Tmailb] "mailb",
|
[Tmailb] "mailb",
|
||||||
[Tmaila] "maila",
|
[Tmaila] "maila",
|
||||||
[Tall] "all",
|
[Tall] "all",
|
||||||
0,
|
[Tcaa] "caa",
|
||||||
};
|
};
|
||||||
|
|
||||||
/* names of response codes */
|
/* names of response codes */
|
||||||
|
@ -462,6 +462,9 @@ dnagenever(DN *dp)
|
||||||
case Tsig:
|
case Tsig:
|
||||||
MARK(rp->sig->signer);
|
MARK(rp->sig->signer);
|
||||||
break;
|
break;
|
||||||
|
case Tcaa:
|
||||||
|
MARK(rp->caa->tag);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -872,6 +875,7 @@ rrcopy(RR *rp, RR **last)
|
||||||
SOA *soa;
|
SOA *soa;
|
||||||
Srv *srv;
|
Srv *srv;
|
||||||
Key *key;
|
Key *key;
|
||||||
|
Caa *caa;
|
||||||
Cert *cert;
|
Cert *cert;
|
||||||
Sig *sig;
|
Sig *sig;
|
||||||
Null *null;
|
Null *null;
|
||||||
|
@ -902,6 +906,14 @@ rrcopy(RR *rp, RR **last)
|
||||||
key->data = emalloc(key->dlen);
|
key->data = emalloc(key->dlen);
|
||||||
memmove(key->data, rp->key->data, rp->key->dlen);
|
memmove(key->data, rp->key->data, rp->key->dlen);
|
||||||
break;
|
break;
|
||||||
|
case Tcaa:
|
||||||
|
caa = nrp->caa;
|
||||||
|
*nrp = *rp;
|
||||||
|
nrp->caa = caa;
|
||||||
|
*caa = *rp->caa;
|
||||||
|
caa->data = emalloc(caa->dlen);
|
||||||
|
memmove(caa->data, rp->caa->data, rp->caa->dlen);
|
||||||
|
break;
|
||||||
case Tcert:
|
case Tcert:
|
||||||
cert = nrp->cert;
|
cert = nrp->cert;
|
||||||
*nrp = *rp;
|
*nrp = *rp;
|
||||||
|
@ -1043,7 +1055,7 @@ rrtype(char *atype)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i <= Tall; i++)
|
for(i = 0; i < nelem(rrtname); i++)
|
||||||
if(rrtname[i] && strcmp(rrtname[i], atype) == 0)
|
if(rrtname[i] && strcmp(rrtname[i], atype) == 0)
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
|
@ -1062,7 +1074,7 @@ rrtype(char *atype)
|
||||||
int
|
int
|
||||||
rrsupported(int type)
|
rrsupported(int type)
|
||||||
{
|
{
|
||||||
if(type < 0 || type >Tall)
|
if(type < 0 || type >= nelem(rrtname))
|
||||||
return 0;
|
return 0;
|
||||||
return rrtname[type] != nil;
|
return rrtname[type] != nil;
|
||||||
}
|
}
|
||||||
|
@ -1299,6 +1311,14 @@ rrfmt(Fmt *f)
|
||||||
fmtprint(&fstr, "\t%d %d %d",
|
fmtprint(&fstr, "\t%d %d %d",
|
||||||
rp->cert->type, rp->cert->tag, rp->cert->alg);
|
rp->cert->type, rp->cert->tag, rp->cert->alg);
|
||||||
break;
|
break;
|
||||||
|
case Tcaa:
|
||||||
|
if (rp->caa == nil)
|
||||||
|
fmtprint(&fstr, "\t<null> <null> <null>");
|
||||||
|
else
|
||||||
|
fmtprint(&fstr, "\t%d %s %.*s",
|
||||||
|
rp->caa->flags, dnname(rp->caa->tag),
|
||||||
|
rp->caa->dlen, (char*)rp->caa->data);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
strp = fmtstrflush(&fstr);
|
strp = fmtstrflush(&fstr);
|
||||||
|
@ -1441,6 +1461,14 @@ rravfmt(Fmt *f)
|
||||||
fmtprint(&fstr, " type=%d tag=%d alg=%d",
|
fmtprint(&fstr, " type=%d tag=%d alg=%d",
|
||||||
rp->cert->type, rp->cert->tag, rp->cert->alg);
|
rp->cert->type, rp->cert->tag, rp->cert->alg);
|
||||||
break;
|
break;
|
||||||
|
case Tcaa:
|
||||||
|
if (rp->caa == nil)
|
||||||
|
fmtprint(&fstr, " flags=<null> tag=<null> value=<null>");
|
||||||
|
else
|
||||||
|
fmtprint(&fstr, " flags=%d tag=%s value=%.*s",
|
||||||
|
rp->caa->flags, dnname(rp->caa->tag),
|
||||||
|
rp->caa->dlen, (char*)rp->caa->data);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
strp = fmtstrflush(&fstr);
|
strp = fmtstrflush(&fstr);
|
||||||
|
@ -1596,6 +1624,8 @@ rrequiv(RR *r1, RR *r2)
|
||||||
return blockequiv(r1->null, r2->null);
|
return blockequiv(r1->null, r2->null);
|
||||||
case Ttxt:
|
case Ttxt:
|
||||||
return txtequiv(r1->txt, r2->txt);
|
return txtequiv(r1->txt, r2->txt);
|
||||||
|
case Tcaa:
|
||||||
|
return r1->caa->flags == r2->caa->flags && r1->caa->tag == r2->caa->tag && blockequiv(r1->caa, r2->caa);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1894,7 +1924,7 @@ rrname(int type, char *buf, int len)
|
||||||
char *t;
|
char *t;
|
||||||
|
|
||||||
t = nil;
|
t = nil;
|
||||||
if(type >= 0 && type <= Tall)
|
if(type >= 0 && type < nelem(rrtname))
|
||||||
t = rrtname[type];
|
t = rrtname[type];
|
||||||
if(t==nil){
|
if(t==nil){
|
||||||
snprint(buf, len, "%d", type);
|
snprint(buf, len, "%d", type);
|
||||||
|
@ -1959,6 +1989,10 @@ rralloc(int type)
|
||||||
rp->key = emalloc(sizeof(*rp->key));
|
rp->key = emalloc(sizeof(*rp->key));
|
||||||
setmalloctag(rp->key, rp->pc);
|
setmalloctag(rp->key, rp->pc);
|
||||||
break;
|
break;
|
||||||
|
case Tcaa:
|
||||||
|
rp->caa = emalloc(sizeof(*rp->caa));
|
||||||
|
setmalloctag(rp->caa, rp->pc);
|
||||||
|
break;
|
||||||
case Tcert:
|
case Tcert:
|
||||||
rp->cert = emalloc(sizeof(*rp->cert));
|
rp->cert = emalloc(sizeof(*rp->cert));
|
||||||
setmalloctag(rp->cert, rp->pc);
|
setmalloctag(rp->cert, rp->pc);
|
||||||
|
@ -2019,6 +2053,10 @@ rrfree(RR *rp)
|
||||||
memset(rp->null, 0, sizeof *rp->null); /* cause trouble */
|
memset(rp->null, 0, sizeof *rp->null); /* cause trouble */
|
||||||
free(rp->null);
|
free(rp->null);
|
||||||
break;
|
break;
|
||||||
|
case Tcaa:
|
||||||
|
free(rp->caa->data);
|
||||||
|
memset(rp->caa, 0, sizeof *rp->caa); /* cause trouble */
|
||||||
|
break;
|
||||||
case Ttxt:
|
case Ttxt:
|
||||||
while(t = rp->txt){
|
while(t = rp->txt){
|
||||||
rp->txt = t->next;
|
rp->txt = t->next;
|
||||||
|
|
|
@ -71,6 +71,7 @@ enum
|
||||||
Tmailb= 253, /* { Tmb, Tmg, Tmr } */
|
Tmailb= 253, /* { Tmb, Tmg, Tmr } */
|
||||||
Tmaila= 254, /* obsolete */
|
Tmaila= 254, /* obsolete */
|
||||||
Tall= 255, /* all records */
|
Tall= 255, /* all records */
|
||||||
|
Tcaa= 257, /* certification authority authorization */
|
||||||
|
|
||||||
/* classes */
|
/* classes */
|
||||||
Csym= 0, /* internal symbols */
|
Csym= 0, /* internal symbols */
|
||||||
|
@ -171,6 +172,7 @@ typedef struct Server Server;
|
||||||
typedef struct Sig Sig;
|
typedef struct Sig Sig;
|
||||||
typedef struct Srv Srv;
|
typedef struct Srv Srv;
|
||||||
typedef struct Txt Txt;
|
typedef struct Txt Txt;
|
||||||
|
typedef struct Caa Caa;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* a structure to track a request and any slave process handling it
|
* a structure to track a request and any slave process handling it
|
||||||
|
@ -216,6 +218,12 @@ struct Key
|
||||||
int alg;
|
int alg;
|
||||||
Block;
|
Block;
|
||||||
};
|
};
|
||||||
|
struct Caa
|
||||||
|
{
|
||||||
|
int flags;
|
||||||
|
DN *tag;
|
||||||
|
Block;
|
||||||
|
};
|
||||||
struct Cert
|
struct Cert
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
|
@ -288,6 +296,7 @@ struct RR
|
||||||
SOA *soa; /* soa timers - soa */
|
SOA *soa; /* soa timers - soa */
|
||||||
Srv *srv;
|
Srv *srv;
|
||||||
Key *key;
|
Key *key;
|
||||||
|
Caa *caa;
|
||||||
Cert *cert;
|
Cert *cert;
|
||||||
Sig *sig;
|
Sig *sig;
|
||||||
Null *null;
|
Null *null;
|
||||||
|
@ -432,7 +441,6 @@ extern char *zonerefreshprogram;
|
||||||
|
|
||||||
|
|
||||||
/* dn.c */
|
/* dn.c */
|
||||||
extern char *rrtname[];
|
|
||||||
extern char *rname[];
|
extern char *rname[];
|
||||||
extern unsigned nrname;
|
extern unsigned nrname;
|
||||||
extern char *opname[];
|
extern char *opname[];
|
||||||
|
|
|
@ -243,6 +243,11 @@ prettyrrfmt(Fmt *f)
|
||||||
seprint(p, e, "\t%d %d %d",
|
seprint(p, e, "\t%d %d %d",
|
||||||
rp->sig->type, rp->sig->tag, rp->sig->alg);
|
rp->sig->type, rp->sig->tag, rp->sig->alg);
|
||||||
break;
|
break;
|
||||||
|
case Tcaa:
|
||||||
|
seprint(p, e, "\t%d %s %.*s",
|
||||||
|
rp->caa->flags, rp->caa->tag->name,
|
||||||
|
rp->caa->dlen, (char*)rp->caa->data);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
return fmtstrcpy(f, buf);
|
return fmtstrcpy(f, buf);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue