chiark / gitweb /
server/tun-unet: Fix stupidity in t_create.
[tripe] / server / keyexch.c
index ae8c9c5d433563858fc36de41a503952e4c3c619..396ecaede13b83c5f430014637c7e2f01b700764 100644 (file)
@@ -7,7 +7,7 @@
  * (c) 2001 Straylight/Edgeware
  */
 
-/*----- Licensing notice --------------------------------------------------* 
+/*----- Licensing notice --------------------------------------------------*
  *
  * This file is part of Trivial IP Encryption (TrIPE).
  *
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * TrIPE is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with TrIPE; if not, write to the Free Software Foundation,
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  * %$r_A = g^{\rho_A}$%                        Alice's challenge
  * %$c_A = H(\cookie{cookie}, r_A)$%   Alice's cookie
  * %$v_A = \rho_A \xor H(\cookie{expected-reply}, a, r_A, r_B, b^{\rho_A})$%
- *                                     Alice's challenge check value
+ *                                     Alice's challenge check value
  * %$r_B^\alpha = a^{\rho_B}$%         Alice's reply
  * %$K = r_B^{\rho_A} = r_B^{\rho_A} = g^{\rho_A\rho_B}$%
- *                                     Alice and Bob's shared secret key
+ *                                     Alice and Bob's shared secret key
  * %$w_A = H(\cookie{switch-request}, c_A, c_B)$%
- *                                     Alice's switch request value
+ *                                     Alice's switch request value
  * %$u_A = H(\cookie{switch-confirm}, c_A, c_B)$%
- *                                     Alice's switch confirm value
+ *                                     Alice's switch confirm value
  *
  * The messages are then:
  *
@@ -75,7 +75,7 @@
  *
  * %$\cookie{kx-switch-ok}, E_K(u_A))$%
  *     Switch received.  Committed; send data; move to @KXS_SWITCH@.
- */ 
+ */
 
 /*----- Tunable parameters ------------------------------------------------*/
 
@@ -563,7 +563,7 @@ static kxchal *respond(keyexch *kx, unsigned msg, buf *b)
   /* --- Discard a packet with an invalid cookie --- */
 
   if (hc && memcmp(hc, kx->hc, algs.hashsz) != 0) {
-    a_warn("KX", "?PEER", "incorrect", "cookie", A_END);
+    a_warn("KX", "?PEER", kx->p, "incorrect", "cookie", A_END);
     goto bad;
   }
 
@@ -598,7 +598,7 @@ static kxchal *respond(keyexch *kx, unsigned msg, buf *b)
       goto badcheck;
 
     /* --- Fill in a new challenge block --- */
-    
+
     kxc = kxc_new(kx);
     G_COPY(gg, kxc->c, c);
     G_COPY(gg, kxc->r, r);
@@ -678,7 +678,7 @@ bad:
   G_DESTROY(gg, cc);
   G_DESTROY(gg, r);
   mp_drop(cv);
-  return (0);  
+  return (0);
 }
 
 /* --- @dochallenge@ --- *
@@ -857,7 +857,7 @@ static void commit(keyexch *kx, kxchal *kxc)
   kx->r[0] = kxc;
   kx->nr = 1;
   kxc_stoptimer(kxc);
-  ksl_link(kx->ks, kxc->ks);  
+  ksl_link(kx->ks, kxc->ks);
 }
 
 /* --- @doreply@ --- *
@@ -886,7 +886,7 @@ static int doreply(keyexch *kx, buf *b)
   if (BLEFT(b)) {
     a_warn("KX", "?PEER", kx->p, "invalid", "reply", A_END);
     goto bad;
-  }    
+  }
   if (kx->s == KXS_CHAL) {
     commit(kx, kxc);
     kx->s = KXS_COMMIT;
@@ -950,7 +950,7 @@ static int doswitch(keyexch *kx, buf *b)
       checkresponse(kx, KX_SWITCH, b))
     goto bad;
   if ((hswrq = buf_get(b, algs.hashsz)) == 0 || BLEFT(b)) {
-    a_warn("KX", "?PEER", "invalid", "switch-rq", A_END);
+    a_warn("KX", "?PEER", kx->p, "invalid", "switch-rq", A_END);
     goto bad;
   }
   IF_TRACING(T_KEYEXCH, {
@@ -996,7 +996,7 @@ static int doswitchok(keyexch *kx, buf *b)
   if (decryptrest(kx, kxc, KX_SWITCHOK, b))
     goto bad;
   if ((hswok = buf_get(b, algs.hashsz)) == 0 || BLEFT(b)) {
-    a_warn("KX", "?PEER", "invalid", "switch-ok", A_END);
+    a_warn("KX", "?PEER", kx->p, "invalid", "switch-ok", A_END);
     goto bad;
   }
   IF_TRACING(T_KEYEXCH, {
@@ -1012,7 +1012,7 @@ static int doswitchok(keyexch *kx, buf *b)
   return (0);
 
 bad:
-  return (-1);  
+  return (-1);
 }
 
 /*----- Main code ---------------------------------------------------------*/