From 9fe002edfab58aac700bb3b5a8ada0f38e3ac5ea Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 3 Dec 2019 22:57:15 +0000 Subject: [PATCH] secnet: loadpub interface: Return a closure_t too We are going to want this for the `make-public' verb. In principle we could just return the closure and the call site that wants the ops could fish it out, but given that we have both this seems nicer. (The secnet closure interface paradigm is not particularly pretty but I don't fancy reworking it now...) We will want this for loadpriv, too. That will come (considerably) later. Signed-off-by: Ian Jackson --- pubkeys.fl.pl | 3 ++- rsa.c | 2 ++ secnet.h | 7 ++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pubkeys.fl.pl b/pubkeys.fl.pl index ec1cba6..d163e37 100755 --- a/pubkeys.fl.pl +++ b/pubkeys.fl.pl @@ -228,8 +228,9 @@ 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; if (pubkey->sethash) { if (!c->defhash) { diff --git a/rsa.c b/rsa.c index 9cd12ba..8fc976b 100644 --- a/rsa.c +++ b/rsa.c @@ -404,6 +404,7 @@ static list_t *rsapub_apply(closure_t *self, struct cloc loc, dict_t *context, bool_t rsa1_loadpub(const struct sigscheme_info *algo, struct buffer_if *pubkeydata, struct sigpubkey_if **sigpub_r, + closure_t **closure_r, struct log_if *log, struct cloc loc) { struct rsapub *st=0; @@ -434,6 +435,7 @@ bool_t rsa1_loadpub(const struct sigscheme_info *algo, if (!st) goto error_out; *sigpub_r=&st->ops; + *closure_r=&st->cl; return True; error_out: diff --git a/secnet.h b/secnet.h index 30a171d..057d399 100644 --- a/secnet.h +++ b/secnet.h @@ -404,10 +404,15 @@ struct sigscheme_info; typedef bool_t sigscheme_loadpub(const struct sigscheme_info *algo, struct buffer_if *pubkeydata, struct sigpubkey_if **sigpub_r, + closure_t **closure_r, struct log_if *log, struct cloc loc); /* pubkeydata is (supposedly) for this algorithm. * loadpub should log an error if it fails. - * pubkeydata may be modified (but not freed) */ + * pubkeydata may be modified (but not freed). + * both *sigpub_r and *closure_r must always be written and must + * refer to the same object, so on successful return + * (*closure_r)->type==CL_SIGPUBKEY + * and (*closure_r)->interface==*sigpub_r */ typedef bool_t sigscheme_loadpriv(const struct sigscheme_info *algo, struct buffer_if *privkeydata, -- 2.30.2