chiark / gitweb /
site: Introduce `pubkey' variable (twice)
[secnet.git] / site.c
diff --git a/site.c b/site.c
index 03d1e06758492c0e18585226bf07f0522d788521..922aa590396e85acef813696aec2764393d05b7a 100644 (file)
--- a/site.c
+++ b/site.c
@@ -650,6 +650,7 @@ static bool_t generate_msg(struct site *st, uint32_t type, cstring_t what,
     if (type_is_msg34(type)) {
        buf_append_uint16(&st->buffer,st->mtu_target);
     }
+    struct sigprivkey_if *privkey=st->privkey;
     append_string_xinfo_done(&st->buffer,&xia);
 
     buf_append_string(&st->buffer,st->remotename);
@@ -670,10 +671,10 @@ static bool_t generate_msg(struct site *st, uint32_t type, cstring_t what,
     buf_append_string(&st->buffer,dhpub);
     free(dhpub);
 
-    bool_t ok=st->privkey->sign(st->privkey->st,
-                               st->buffer.start,
-                               st->buffer.size,
-                               &st->buffer);
+    bool_t ok=privkey->sign(privkey->st,
+                           st->buffer.start,
+                           st->buffer.size,
+                           &st->buffer);
     if (!ok) goto fail;
     return True;
 
@@ -755,8 +756,9 @@ static bool_t unpick_msg(struct site *st, uint32_t type,
     CHECK_AVAIL(msg,m->pklen);
     m->pk=buf_unprepend(msg,m->pklen);
     m->hashlen=msg->start-m->hashstart;
+    struct sigpubkey_if *pubkey=st->pubkey;
 
-    if (!st->pubkey->unpick(st->pubkey->st,msg,&m->sig)) {
+    if (!pubkey->unpick(pubkey->st,msg,&m->sig)) {
        return False;
     }
 
@@ -903,10 +905,12 @@ static bool_t generate_msg3(struct site *st, const struct msg *prompt)
 
 static bool_t process_msg3_msg4(struct site *st, struct msg *m)
 {
+    struct sigpubkey_if *pubkey=st->pubkey;
+
     /* Check signature and store g^x mod m */
-    if (!st->pubkey->check(st->pubkey->st,
-                          m->hashstart,m->hashlen,
-                          &m->sig)) {
+    if (!pubkey->check(pubkey->st,
+                      m->hashstart,m->hashlen,
+                      &m->sig)) {
        slog(st,LOG_SEC,"msg3/msg4 signature failed check!");
        return False;
     }