Permalink
Browse files

NullEncryption and NullHash were broken and somehow EdgeVerification was

removed.  I have fixed them and added EdgeVerification back, testing
locally with P2PNode.
  • Loading branch information...
1 parent 888b643 commit 0c79e78fb0a6e4fbf6579db190a3c4b9bba34a2e David Wolinsky committed Jul 11, 2009
@@ -16,7 +16,7 @@
<Checkpointing>true</Checkpointing>
</NCService>
<Security>
- <Enabled>false</Enabled>
+ <Enabled>true</Enabled>
<SecureEdges>true</SecureEdges>
<TestEnable>true</TestEnable>
<KeyPath>private_key</KeyPath>
@@ -208,6 +208,7 @@ public class BasicNode {
el = new TunnelEdgeListener(_node);
if(_node_config.Security.SecureEdgesEnabled) {
+ Brunet.LinkProtocolState.EdgeVerifyMethod = EdgeVerify.AddressInSubjectAltName;
el = new SecureEdgeListener(el, _bso);
}
_node.AddEdgeListener(el);
@@ -31,14 +31,14 @@ public class NullEncryption : SymmetricAlgorithm {
public NullEncryption()
{
KeySizeValue = 0;
- BlockSizeValue = 1;
+ BlockSizeValue = 8;
FeedbackSizeValue = 0;
LegalKeySizesValue = new KeySizes[1];
LegalKeySizesValue[0] = new KeySizes(0, 0, 0);
LegalBlockSizesValue = new KeySizes[1];
- LegalBlockSizesValue[0] = new KeySizes(1, 1, 0);
+ LegalBlockSizesValue[0] = new KeySizes(8, 8, 0);
}
public override void GenerateIV()
@@ -30,7 +30,7 @@ namespace Brunet.Security {
public class NullHash : HashAlgorithm {
public NullHash()
{
- HashSizeValue = 1;
+ HashSizeValue = 0;
}
protected override void HashCore(byte[] rgb, int start, int size)
@@ -0,0 +1,36 @@
+/*
+Copyright (C) 2008 David Wolinsky <davidiw@ufl.edu>, University of Florida
+
+This program is free software; you can redistribute it and/or
+modify 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.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+using System;
+using Brunet.Security.Transport;
+
+namespace Brunet.Security.Protocol {
+ ///<summary>This provides different methods to verify Secure Edges.</summary>
+ public class EdgeVerify {
+ ///<summary>Verify the edge by comparing the address in the certificate to
+ ///the one provided in the overlay.</summary>
+ public static bool AddressInSubjectAltName(Node node, Edge e, Address addr) {
+ SecureEdge se = e as SecureEdge;
+ if(se == null) {
+ throw new Exception("Invalid edge type!");
+ }
+
+ return se.SA.VerifyCertificateBySubjectAltName(addr.ToString());
+ }
+ }
+}
@@ -1,57 +0,0 @@
-<?xml version="1.0"?>
-<project name="Brunet.Security" default="build">
- <description> Builds Brunet.Security.dll </description>
- <property name="build.dir" value="build"/>
- <property name="lib.dir" value="../../lib"/>
- <property name="bin.dir" value="../../bin"/>
-
- <target name="test" description="Configures a debug build">
- <copy todir="${build.dir}">
- <fileset basedir="${lib.dir}">
- <include name="Mono.Security.dll" />
- <include name="Brunet.dll" />
- <include name="Brunet.Mock.dll" />
- </fileset>
- </copy>
- <csc target="library" define="BRUNET_NUNIT" output="${build.dir}/Brunet.Security.Test.dll">
- <sources failonempty="true">
- <include name="*.cs"/>
- </sources>
- <references basedir="${build.dir}">
- <include name="Mono.Security.dll" />
- <include name="Brunet.dll" />
- <include name="Brunet.Mock.dll" />
- <include name="nunit.framework.dll" />
- </references>
- </csc>
- <nunit2>
- <formatter type="Plain" />
- <test assemblyname="${build.dir}/Brunet.Security.Test.dll"/>
- </nunit2>
- </target>
-
- <target name="build" description="Builds Brunet.Security.dll for release">
- <copy todir="${build.dir}">
- <fileset basedir="${lib.dir}">
- <include name="Brunet.dll" />
- <include name="Mono.Security.dll" />
- </fileset>
- </copy>
- <csc target="library" define="" output="${build.dir}/Brunet.Security.dll">
- <sources failonempty="true">
- <include name="*.cs"/>
- </sources>
- <references basedir="${build.dir}">
- <include name="Mono.Security.dll"/>
- <include name="Brunet.dll" />
- </references>
- </csc>
- <copy todir="${lib.dir}">
- <fileset basedir="${build.dir}">
- <include name="Brunet.Security.dll" />
- </fileset>
- </copy>
-
- <nant buildfile="Utils/default.build" />
- </target>
-</project>
@@ -43,8 +43,7 @@ public class SecurityPolicy {
static SecurityPolicy() {
_ssync = new object();
_splist = new Dictionary<int, SecurityPolicy>();
- new SecurityPolicy(DefaultSPI, DefaultEncryptor, DefaultAuthenticator,
- DefaultPreExchangedKeys);
+ SetDefaultSecurityPolicy(DefaultEncryptor, DefaultAuthenticator, DefaultPreExchangedKeys);
}
public static void SetDefaultSecurityPolicy(string Encryptor, string Authenticator,

0 comments on commit 0c79e78

Please sign in to comment.