X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=pubkeys.fl.pl;h=d163e3747ecadf61e9d8a763670403cbf624ecd2;hb=31c89500dd7755b13880409d4edc441ff06ffd37;hp=f0e8d58c3364f7702117635a009377e1a96080b1;hpb=8edfb13017ffb9706dfec817743d6227c300d540;p=secnet.git diff --git a/pubkeys.fl.pl b/pubkeys.fl.pl index f0e8d58..d163e37 100755 --- a/pubkeys.fl.pl +++ b/pubkeys.fl.pl @@ -134,6 +134,7 @@ L [ \t]* S [ \t]+ BASE91S []-~!#-&(-[]+ %x SKIPNL +%x SYNTAXERR %option yylineno %option noyywrap @@ -160,6 +161,7 @@ struct pubkeyset_context { /* filled in during setup: */ struct cloc loc; /* line is runtime */ struct log_if *log; + struct hash_if *defhash; struct buffer_if *data_buf; struct peer_keyset *building; /* runtime: */ @@ -226,16 +228,23 @@ static struct pubkeyset_context c[1]; !FINAL { if (c->building->nkeys >= MAX_SIG_KEYS) DOSKIP("too many public keys"); struct sigpubkey_if *pubkey; + closure_t *cl; bool_t ok=c->scheme->loadpub(c->scheme,c->data_buf, - &pubkey,c->log,c->loc); + &pubkey,&cl,c->log,c->loc); if (!ok) break; - memcpy(c->building->keys[c->building->nkeys].id.b, - c->grpid, - GRPIDSZ); + if (pubkey->sethash) { + if (!c->defhash) { + pubkey->dispose(pubkey->st); + DOSKIP("public key requires default hash to load"); + } + pubkey->sethash(pubkey->st,c->defhash); + } + struct peer_pubkey *fill=&c->building->keys[c->building->nkeys]; + memcpy(fill->id.b,c->grpid,GRPIDSZ); assert(ALGIDSZ==1); /* otherwise need htons or htonl or something */ - c->building->keys[c->building->nkeys].id.b[GRPIDSZ]= - c->scheme->algid; - c->building->keys[c->building->nkeys++].pubkey=pubkey; + fill->id.b[GRPIDSZ]=c->scheme->algid; + fill->pubkey=pubkey; + c->building->nkeys++; !} !KEYWORD serial @@ -267,7 +276,14 @@ static struct pubkeyset_context c[1]; <> { return 0; } -<*>. { FAIL("syntax error"); } +<*>. { + yymore(); + BEGIN(SYNTAXERR); +} +.* { + slilog(LI,M_DEBUG,"pubkeys syntax error at `%s'", yytext); + FAIL("syntax error"); +} <*>\n { FAIL("syntax error - unexpected newline"); } <> { FAIL("syntax error - unexpected eof"); } @@ -275,15 +291,18 @@ static struct pubkeyset_context c[1]; extern struct peer_keyset * keyset_load(const char *path, struct buffer_if *data_buf, - struct log_if *log, int logcl_enoent) { + struct log_if *log, int logcl_enoent, + struct hash_if *defhash) { assert(!c->building); c->log=log; + c->defhash=defhash; c->loc.file=path; pkyyin = fopen(path, "r"); if (!pkyyin) { slilog(LI, errno==ENOENT ? logcl_enoent : M_ERR, - "could not open keyset file %s: %s", + "%scould not open keyset file %s: %s", + logcl_enoent==M_DEBUG && errno==ENOENT ? "expectedly " : "", path,strerror(errno)); goto err; } @@ -302,10 +321,6 @@ keyset_load(const char *path, struct buffer_if *data_buf, int r=pkyylex(); if (r) goto err_bad; - if (!c->had_serial) { - slilog(LI,M_ERR,"missing serial number in %s",path); - goto err_bad; - } if (!c->building->nkeys) { slilog(LI,M_ERR,"no useable keys in %s",path); goto err_bad;