chiark / gitweb /
secnet: loadpub interface: Return a closure_t too
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 3 Dec 2019 22:57:15 +0000 (22:57 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 15 Feb 2020 21:56:51 +0000 (21:56 +0000)
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 <ijackson@chiark.greenend.org.uk>
pubkeys.fl.pl
rsa.c
secnet.h

index ec1cba60610dcbe5edd996059c9eaac1f51faeba..d163e3747ecadf61e9d8a763670403cbf624ecd2 100755 (executable)
@@ -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 9cd12ba4ee0a069967733413e1f0559c5b00ed0b..8fc976b9fdc4c964d600cd88bd0f7e7bc520b320 100644 (file)
--- 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:
index 30a171d4da262160443b9029c1c137fe8f69e027..057d399cfe1bf144d763637da43635a4ae0a132a 100644 (file)
--- 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,