Update of /cvsroot/freenet/freenet/src/freenet In directory sc8-pr-cvs1:/tmp/cvs-serv27675/src/freenet
Modified Files: Key.java Log Message: Strip signum bit during BigInteger to Key conversion Index: Key.java =================================================================== RCS file: /cvsroot/freenet/freenet/src/freenet/Key.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -w -r1.11 -r1.12 --- Key.java 12 Nov 2003 12:07:14 -0000 1.11 +++ Key.java 12 Nov 2003 15:22:06 -0000 1.12 @@ -180,8 +180,13 @@ /** * General constructor - just interprets the supplied BigInteger as an byte array. */ - public Key(BigInteger val) { - this.val = val.toByteArray(); + public Key(BigInteger theInteger) { + byte[] b = theInteger.toByteArray(); + if(b.length>KEYBYTES){ + this.val = new byte[KEYBYTES]; + System.arraycopy(b, b.length-KEYBYTES,val, 0, KEYBYTES); //Strip the byte containing the signum bit + }else + this.val = b; } // Interpret key as value between 0 and 2^183. public BigInteger toBigInteger() { @@ -195,6 +200,7 @@ Core.logger.log(this, "Very long key detected!: " + this, new Exception("debug"), Logger.NORMAL); byte[] ob = new byte[KEYBYTES]; System.arraycopy(b, 0, ob, 0, KEYBYTES); + b = ob; } return new BigInteger(1, b); } _______________________________________________ cvs mailing list [EMAIL PROTECTED] http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs