summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2003-10-27 21:30:00 +0000
committerPeter Palfrader <peter@palfrader.org>2003-10-27 21:30:00 +0000
commitbf0ee8eb55de61e98a745d5ea13087c733d4b4b0 (patch)
tree121fe629258856cd41fe2a5c138bb4a87ad4097e /src
parent6ee27b4e16c9478762516bb90ac49e64317b6e57 (diff)
Make sure we use the same instance of routing information in both makeSHS calls
Diffstat (limited to 'src')
-rw-r--r--src/org/noreply/fancydress/type3/SingleLeg.java16
1 files 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() {