Author: toad
Date: 2008-07-18 21:15:20 +0000 (Fri, 18 Jul 2008)
New Revision: 21219
Modified:
branches/db4o/freenet/src/freenet/keys/ClientCHK.java
branches/db4o/freenet/src/freenet/keys/ClientKey.java
branches/db4o/freenet/src/freenet/keys/ClientSSK.java
Log:
ClientKey.cloneKey(). Creates a copy of the key.
We will use this to ensure that the keys inside PersistentChosenRequests don't
get deactivated.
Modified: branches/db4o/freenet/src/freenet/keys/ClientCHK.java
===================================================================
--- branches/db4o/freenet/src/freenet/keys/ClientCHK.java 2008-07-18
21:14:23 UTC (rev 21218)
+++ branches/db4o/freenet/src/freenet/keys/ClientCHK.java 2008-07-18
21:15:20 UTC (rev 21219)
@@ -37,6 +37,17 @@
/** The length of the decryption key */
static final short CRYPTO_KEY_LENGTH = 32;
+ private ClientCHK(ClientCHK key) {
+ this.routingKey = new byte[key.routingKey.length];
+ System.arraycopy(key.routingKey, 0, routingKey, 0,
key.routingKey.length);
+ this.nodeKey = (NodeCHK) key.nodeKey.cloneKey();
+ this.cryptoKey = new byte[key.cryptoKey.length];
+ System.arraycopy(key.cryptoKey, 0, cryptoKey, 0, key.cryptoKey.length);
+ this.controlDocument = key.controlDocument;
+ this.cryptoAlgorithm = key.cryptoAlgorithm;
+ this.compressionAlgorithm = key.compressionAlgorithm;
+ }
+
/**
* @param routingKey The routing key. This is the overall hash of the
* header and content of the key.
@@ -165,4 +176,8 @@
public boolean isCompressed() {
return compressionAlgorithm >= 0;
}
+
+ public ClientKey cloneKey() {
+ return new ClientCHK(this);
+ }
}
Modified: branches/db4o/freenet/src/freenet/keys/ClientKey.java
===================================================================
--- branches/db4o/freenet/src/freenet/keys/ClientKey.java 2008-07-18
21:14:23 UTC (rev 21218)
+++ branches/db4o/freenet/src/freenet/keys/ClientKey.java 2008-07-18
21:15:20 UTC (rev 21219)
@@ -12,4 +12,6 @@
*/
public abstract Key getNodeKey();
+ public abstract ClientKey cloneKey();
+
}
Modified: branches/db4o/freenet/src/freenet/keys/ClientSSK.java
===================================================================
--- branches/db4o/freenet/src/freenet/keys/ClientSSK.java 2008-07-18
21:14:23 UTC (rev 21218)
+++ branches/db4o/freenet/src/freenet/keys/ClientSSK.java 2008-07-18
21:15:20 UTC (rev 21219)
@@ -33,6 +33,21 @@
static final int CRYPTO_KEY_LENGTH = 32;
public static final int EXTRA_LENGTH = 5;
+ private ClientSSK(ClientSSK key) {
+ this.cryptoAlgorithm = key.cryptoAlgorithm;
+ this.docName = new String(key.docName);
+ if(pubKey != null)
+ this.pubKey = key.pubKey.cloneKey();
+ else
+ this.pubKey = null;
+ pubKeyHash = new byte[key.pubKeyHash.length];
+ System.arraycopy(key.pubKeyHash, 0, pubKeyHash, 0,
pubKeyHash.length);
+ cryptoKey = new byte[key.cryptoKey.length];
+ System.arraycopy(key.cryptoKey, 0, cryptoKey, 0,
key.cryptoKey.length);
+ ehDocname = new byte[key.ehDocname.length];
+ System.arraycopy(key.ehDocname, 0, ehDocname, 0,
key.ehDocname.length);
+ }
+
public ClientSSK(String docName, byte[] pubKeyHash, byte[] extras,
DSAPublicKey pubKey, byte[] cryptoKey) throws MalformedURLException {
this.docName = docName;
this.pubKey = pubKey;
@@ -132,4 +147,8 @@
public String toString() {
return "ClientSSK:"+getURI().toString();
}
+
+ public ClientKey cloneKey() {
+ return new ClientSSK(this);
+ }
}