summaryrefslogtreecommitdiff
path: root/src/org/noreply/fancydress/type3/routing
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/noreply/fancydress/type3/routing')
-rw-r--r--src/org/noreply/fancydress/type3/routing/RoutingDestination.java17
-rw-r--r--src/org/noreply/fancydress/type3/routing/RoutingSMTP.java5
2 files changed, 21 insertions, 1 deletions
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();