From bf0ee8eb55de61e98a745d5ea13087c733d4b4b0 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Mon, 27 Oct 2003 21:30:00 +0000 Subject: Make sure we use the same instance of routing information in both makeSHS calls --- src/org/noreply/fancydress/type3/SingleLeg.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/org/noreply/fancydress/type3/SingleLeg.java b/src/org/noreply/fancydress/type3/SingleLeg.java index 0da3a1e..ec2a022 100644 --- a/src/org/noreply/fancydress/type3/SingleLeg.java +++ b/src/org/noreply/fancydress/type3/SingleLeg.java @@ -73,7 +73,10 @@ public abstract class SingleLeg { for (int i=n-1; i>=0; i--) { Routing routing = i == n-1 ? finalRouting : hops[i+1].getRouting(); - byte[] sh0 = makeSHS(sharedKeys[i], CryptoPrimitives.zero(CryptoPrimitives.HASH_LEN), routing); + byte[] routingInformation = routing.getRoutingInformation(); + int routingType = routing.getRoutingType(); + + byte[] sh0 = makeSHS(sharedKeys[i], CryptoPrimitives.zero(CryptoPrimitives.HASH_LEN), routingType, routingInformation); int shLength = sh0.length; byte[] h0 = Util.concat( sh0, subHeader[i+1] ); @@ -82,7 +85,7 @@ public abstract class SingleLeg { byte[] digest = CryptoPrimitives.hash( i == 0 ? encryptedRest : Util.concat(encryptedRest, junk[i-1])); - byte[] sh = makeSHS(sharedKeys[i], digest, routing); + byte[] sh = makeSHS(sharedKeys[i], digest, routingType, routingInformation); int underflow = Util.max(RSAPublicKey.PK_MAX_DATA_LEN - shLength, 0); byte[] rsaPart = Util.concat( sh, Util.slice(h0, RSAPublicKey.PK_MAX_DATA_LEN - underflow, underflow)); @@ -104,16 +107,15 @@ public abstract class SingleLeg { static private byte[] makeSHS( byte[] sharedSecret, byte[] digest, - Routing routing) + int routingType, + byte[] routingInformation) { if (sharedSecret.length != CryptoPrimitives.KEY_LEN) throw new IllegalArgumentException("sharedSecret must be KEY_LEN bytes long."); if (digest.length != CryptoPrimitives.HASH_LEN) throw new IllegalArgumentException("digest must be HASH_LEN bytes long."); byte[] fixedPart = new byte[MIN_SH]; - byte[] dynamicPart = routing.getRoutingInformation(); - int routingSize = dynamicPart.length; - int routingType = routing.getRoutingType(); + int routingSize = routingInformation.length; int pos = 0; fixedPart[pos] = MAJOR_VERSION; @@ -136,7 +138,7 @@ public abstract class SingleLeg { if (pos != MIN_SH) throw new Error("Did not fill in MIN_SH bytes!"); - return Util.concat(fixedPart, dynamicPart); + return Util.concat(fixedPart, routingInformation); } public RoutingForward getRoute() { -- cgit v1.2.3