diff options
Diffstat (limited to 'src/org/noreply/fancydress')
-rw-r--r-- | src/org/noreply/fancydress/type3/SURB.java | 8 | ||||
-rw-r--r-- | src/org/noreply/fancydress/type3/routing/RoutingDestination.java | 17 | ||||
-rw-r--r-- | src/org/noreply/fancydress/type3/routing/RoutingSMTP.java | 5 |
3 files changed, 26 insertions, 4 deletions
diff --git a/src/org/noreply/fancydress/type3/SURB.java b/src/org/noreply/fancydress/type3/SURB.java index 4ef8948..6733909 100644 --- a/src/org/noreply/fancydress/type3/SURB.java +++ b/src/org/noreply/fancydress/type3/SURB.java @@ -25,7 +25,7 @@ public class SURB extends SingleLeg { validateHash = CryptoPrimitives.hash(seed, secret, validate); } while (validateHash[validateHash.length-1] == 0); - byte[] key = Util.slice(CryptoPrimitives.hash(seed, secret, Util.toOctets("Generate")), 0,CryptoPrimitives.KEY_LEN); + byte[] key = Util.slice(CryptoPrimitives.hash(seed, secret, Util.toOctets("Generate")), 0, CryptoPrimitives.KEY_LEN); byte[] stream = CryptoPrimitives.prng(key, CryptoPrimitives.KEY_LEN*(hops.length + 1)); sharedSecret = Util.slice(stream, CryptoPrimitives.KEY_LEN*hops.length, CryptoPrimitives.KEY_LEN); @@ -33,6 +33,7 @@ public class SURB extends SingleLeg { for (int i=0; i<hops.length; i++) sharedKeys[i] = Util.slice(stream, (hops.length-i-1)*CryptoPrimitives.KEY_LEN, CryptoPrimitives.KEY_LEN); + address.setDecodingHandle(seed); makeLeg(hops, sharedKeys, address); }; @@ -50,9 +51,10 @@ public class SURB extends SingleLeg { public String export() { byte[] beginMarker = Util.toOctets("SURB"); int useBy = 1068595200; //FIXME // Y2k36 - byte[] routingInformation = getRoute().getRoutingInformation(); + RoutingForward route = getRoute().asSwap(); + byte[] routingInformation = route.getRoutingInformation(); int routingSize = routingInformation.length; - int routingType = getRoute().getRoutingType(); + int routingType = route.getRoutingType(); byte[] result = new byte[4+2+4+SINGLE_HEADER_LEN+2+2+CryptoPrimitives.KEY_LEN+routingSize]; diff --git a/src/org/noreply/fancydress/type3/routing/RoutingDestination.java b/src/org/noreply/fancydress/type3/routing/RoutingDestination.java index 38a0342..500ebc5 100644 --- a/src/org/noreply/fancydress/type3/routing/RoutingDestination.java +++ b/src/org/noreply/fancydress/type3/routing/RoutingDestination.java @@ -16,12 +16,29 @@ public abstract class RoutingDestination extends Routing { public static final int DECODINGHANDLE_LEN = 20; /** + * A decoding handle as is used in SURBS or forward encrypted messages. + */ + protected byte[] decodingHandle; + + /** * Default constructor. * * @param type The routing type as integer. */ protected RoutingDestination(int type) { super (type); + decodingHandle = null; + } + + /** + * Set a decoding handle as is used in SURBS or forward encrypted messages. + * + * @param decodingHandle decoding handle + */ + public void setDecodingHandle(byte[] decodingHandle) { + if (decodingHandle.length != DECODINGHANDLE_LEN) + throw new Error("Decoding handle is not DECODINGHANDLE_LEN bytes long."); + this.decodingHandle = decodingHandle; } } diff --git a/src/org/noreply/fancydress/type3/routing/RoutingSMTP.java b/src/org/noreply/fancydress/type3/routing/RoutingSMTP.java index 77df42f..b969841 100644 --- a/src/org/noreply/fancydress/type3/routing/RoutingSMTP.java +++ b/src/org/noreply/fancydress/type3/routing/RoutingSMTP.java @@ -50,7 +50,10 @@ public class RoutingSMTP extends RoutingDestination { byte[] result = new byte[length]; int pos = 0; - System.arraycopy(CryptoPrimitives.rand(DECODINGHANDLE_LEN), 0, result, pos, DECODINGHANDLE_LEN); + if (decodingHandle == null) + System.arraycopy(CryptoPrimitives.rand(DECODINGHANDLE_LEN), 0, result, pos, DECODINGHANDLE_LEN); + else + System.err.println("Using set decoding handle for "+mailbox); pos += DECODINGHANDLE_LEN; System.arraycopy(Util.toOctets(mailbox), 0, result, pos, mailbox.length()); pos += mailbox.length(); |