I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit a756c124 authored by zzz's avatar zzz
Browse files

I2CP: Change format and message type of CreateLeaseSet2 message

to match spec changes
parent ead49256
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@ import net.i2p.crypto.EncType;
import net.i2p.crypto.SigType;
import net.i2p.data.DatabaseEntry;
import net.i2p.data.DataFormatException;
import net.i2p.data.DataHelper;
import net.i2p.data.EncryptedLeaseSet;
import net.i2p.data.LeaseSet;
import net.i2p.data.LeaseSet2;
......@@ -40,7 +41,11 @@ import net.i2p.data.PublicKey;
* @since 0.9.38
*/
public class CreateLeaseSet2Message extends CreateLeaseSetMessage {
public final static int MESSAGE_TYPE = 40;
/**
* NOTE: Preliminary format was type 40 in 0.9.38.
* Format changed as of 0.9.39, changed type to 41.
*/
public final static int MESSAGE_TYPE = 41;
// only used if more than one key, otherwise null
private List<PrivateKey> _privateKeys;
......@@ -118,6 +123,10 @@ public class CreateLeaseSet2Message extends CreateLeaseSetMessage {
EncType etype = pk.getType();
if (etype == null)
throw new I2CPMessageException("Unsupported encryption type");
int encType = (int) DataHelper.readLong(in, 2);
int encLen = (int) DataHelper.readLong(in, 2);
if (encType != etype.getCode() || encLen != etype.getPrivkeyLen())
throw new I2CPMessageException("Enc type mismatch");
PrivateKey priv = new PrivateKey(etype);
priv.readBytes(in);
addPrivateKey(priv);
......@@ -156,6 +165,9 @@ public class CreateLeaseSet2Message extends CreateLeaseSetMessage {
_leaseSet.writeBytes(os);
if (type != DatabaseEntry.KEY_TYPE_META_LS2) {
for (PrivateKey pk : getPrivateKeys()) {
EncType etype = pk.getType();
DataHelper.writeLong(os, 2, etype.getCode());
DataHelper.writeLong(os, 2, pk.length());
pk.writeBytes(os);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment