From 6cf7bc7985dd382728bb6061bbb5ac1827de09f6 Mon Sep 17 00:00:00 2001 From: zzz Date: Sat, 2 Oct 2010 17:20:39 +0000 Subject: [PATCH] * i2ptunnel: - Add hostname DSA signature field, to be used for addkey forms. Experimental, may be commented out later. --- .../src/net/i2p/i2ptunnel/web/EditBean.java | 30 +++++++++++++++++++ apps/i2ptunnel/jsp/editServer.jsp | 11 ++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java index 38bc8b4db..f6c76d7f6 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java @@ -13,6 +13,11 @@ import java.util.List; import java.util.Properties; import java.util.StringTokenizer; +import net.i2p.data.Base64; +import net.i2p.data.Destination; +import net.i2p.data.PrivateKeyFile; +import net.i2p.data.Signature; +import net.i2p.data.SigningPrivateKey; import net.i2p.i2ptunnel.TunnelController; import net.i2p.i2ptunnel.TunnelControllerGroup; @@ -68,6 +73,31 @@ public class EditBean extends IndexBean { return "i2ptunnel" + tunnel + "-privKeys.dat"; } + public String getNameSignature(int tunnel) { + String spoof = getSpoofedHost(tunnel); + if (spoof.length() <= 0) + return ""; + TunnelController tun = getController(tunnel); + if (tun == null) + return ""; + String keyFile = tun.getPrivKeyFile(); + if (keyFile != null && keyFile.trim().length() > 0) { + PrivateKeyFile pkf = new PrivateKeyFile(keyFile); + try { + Destination d = pkf.getDestination(); + if (d == null) + return ""; + SigningPrivateKey privKey = pkf.getSigningPrivKey(); + if (privKey == null) + return ""; + //System.err.println("Signing " + spoof + " with " + Base64.encode(privKey.getData())); + Signature sig = _context.dsa().sign(spoof.getBytes("UTF-8"), privKey); + return Base64.encode(sig.getData()); + } catch (Exception e) {} + } + return ""; + } + public boolean startAutomatically(int tunnel) { TunnelController tun = getController(tunnel); if (tun != null) diff --git a/apps/i2ptunnel/jsp/editServer.jsp b/apps/i2ptunnel/jsp/editServer.jsp index 939ccf520..97a0a93c9 100644 --- a/apps/i2ptunnel/jsp/editServer.jsp +++ b/apps/i2ptunnel/jsp/editServer.jsp @@ -196,7 +196,16 @@ <%=intl._("Add to local addressbook")%> <% } %> - + + <% if (("httpserver".equals(tunnelType)) || ("httpbidirserver".equals(tunnelType))) { + %>
+ + +
+ <% } %> +