Skip to content

Commit

Permalink
salt-channel-2.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
franslundberg committed Oct 25, 2017
1 parent 3cb440b commit fcdffb2
Show file tree
Hide file tree
Showing 20 changed files with 163 additions and 107 deletions.
4 changes: 2 additions & 2 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ NOTE: compile with Java 7! (mainly due to Android).
</tstamp>

<!-- VERSION, first line below is for DEV build, second for _RELEASE build. -->
<property name="version" value="2.1.${date}"/>
<!-- <property name="version" value="2.1"/> -->
<!-- <property name="version" value="2.2.${date}"/> -->
<property name="version" value="2.2"/>

<property name="time" value="${dateAndMinute}"/>

Expand Down
Binary file added files/releases/salt-channel-2.2-javadoc.jar
Binary file not shown.
Binary file not shown.
Binary file removed files/releases/salt-channel-x-2.0.jar
Binary file not shown.
16 changes: 14 additions & 2 deletions release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,25 @@ Release history. The implementation started in 2016, but formal
releases starts with release 2.0.


Release v2.1, 2017-11-17

Release v2.2, 2017-10-25
========================

Implements salt-channel-v2-draft8.md. No known bugs.

* ApplicationChannel now available to lib users. Includes
information about last flag and multi app packet.



Release v2.1, 2017-10-17
========================

This release implements Salt Channel v2, draft8.


Release v2.0, 2017-11-17

Release v2.0, 2017-10-17
========================

Implements Salt Channel v2, draft7 (spec-salt-channel-v2-draft7.md).
File renamed without changes.
57 changes: 37 additions & 20 deletions src-test/saltchannel/v2/ApplicationChannelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.junit.Assert;
import org.junit.Test;
import saltaa.SaltLib;
import saltchannel.TimeException;
import saltchannel.Tunnel;
import saltchannel.util.TimeChecker;
Expand Down Expand Up @@ -47,37 +48,53 @@ public void testAvailable() {
c1.write(false, new byte[]{0x10}, new byte[]{0x20, 0x21});
c2.read();

Assert.assertEquals(1, c2.available());
Assert.assertEquals(1, c2.availableFromMultiAppPacket());
}

// TODO D. implement tests for lastFlag.
//@Test
@Test
public void testLastFlag1() {
// Note, the lastFlag is implemented in EncryptedChannelV2, so it must
// be included when testing this.

Tunnel tunnel = new Tunnel();
ApplicationChannel c1 = new ApplicationChannel(tunnel.channel1(), TimeKeeper.NULL, TimeChecker.NULL);
ApplicationChannel c2 = new ApplicationChannel(tunnel.channel2(), TimeKeeper.NULL, TimeChecker.NULL);
byte[] sharedKey = new byte[SaltLib.crypto_box_SHAREDKEYBYTES];
sharedKey[9] = 0x09;
EncryptedChannelV2 c1e = new EncryptedChannelV2(tunnel.channel1(), sharedKey, EncryptedChannelV2.Role.CLIENT);
EncryptedChannelV2 c2e = new EncryptedChannelV2(tunnel.channel2(), sharedKey, EncryptedChannelV2.Role.SERVER);

c1.write(false, new byte[]{0x10});
c1.write(true, new byte[]{0x20}, new byte[]{0x30});
ApplicationChannel c1a = new ApplicationChannel(c1e, TimeKeeper.NULL, TimeChecker.NULL);
ApplicationChannel c2a = new ApplicationChannel(c2e, TimeKeeper.NULL, TimeChecker.NULL);

c2.read();
Assert.assertEquals("isLast1", false, c2.isLast());
c2.read();
Assert.assertEquals("isLast2", false, c2.isLast());
c2.read();
Assert.assertEquals("isLast3", true, c2.isLast());
c1a.write(true, new byte[]{0x10});

Assert.assertEquals("lastFlag1", false, c2a.lastFlag());
c2a.read();
Assert.assertEquals("lastFlag2", true, c2a.lastFlag());
}

@Test
public void testLastFlag2() {
Tunnel tunnel = new Tunnel();
ApplicationChannel c1 = new ApplicationChannel(tunnel.channel1(), TimeKeeper.NULL, TimeChecker.NULL);
ApplicationChannel c2 = new ApplicationChannel(tunnel.channel2(), TimeKeeper.NULL, TimeChecker.NULL);
// Note, the lastFlag is implemented in EncryptedChannelV2, so it must
// be included when testing this.

c1.write(false, new byte[]{0x10});
c2.read();

Assert.assertEquals(false, c2.isLast());
Tunnel tunnel = new Tunnel();
byte[] sharedKey = new byte[SaltLib.crypto_box_SHAREDKEYBYTES];
sharedKey[9] = 0x09;
EncryptedChannelV2 c1e = new EncryptedChannelV2(tunnel.channel1(), sharedKey, EncryptedChannelV2.Role.CLIENT);
EncryptedChannelV2 c2e = new EncryptedChannelV2(tunnel.channel2(), sharedKey, EncryptedChannelV2.Role.SERVER);

ApplicationChannel c1a = new ApplicationChannel(c1e, TimeKeeper.NULL, TimeChecker.NULL);
ApplicationChannel c2a = new ApplicationChannel(c2e, TimeKeeper.NULL, TimeChecker.NULL);

c1a.write(false, new byte[]{0x10});
c1a.write(true, new byte[]{0x20}, new byte[]{0x30});

c2a.read();
Assert.assertEquals("lastFlag1", false, c2a.lastFlag());
c2a.read();
Assert.assertEquals("lastFlag2", true, c2a.lastFlag());
c2a.read();
Assert.assertEquals("lastFlag3", true, c2a.lastFlag());
}


Expand Down
21 changes: 10 additions & 11 deletions src-test/saltchannel/v2/EncryptedChannelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void testChannel() throws ComException, UnsupportedEncodingException {
EncryptedChannelV2.Role.SERVER);

byte[] clear1 = "AAAA".getBytes("UTF-8");
e1.write(clear1);
e1.write(false, clear1);
byte[] clear2 = e2.read();

Assert.assertArrayEquals(clear1, clear2);
Expand All @@ -63,8 +63,8 @@ public void testMultipleWrites() {
byte[] m1 = new byte[]{1};
byte[] m2 = new byte[]{2};

e1.write(m1);
e1.write(m2);
e1.write(false, m1);
e1.write(false, m2);

byte[] m1b = e2.read();
byte[] m2b = e2.read();
Expand All @@ -85,7 +85,7 @@ public void testMultipleMessageInOneWrite() {
byte[] m1 = new byte[]{1};
byte[] m2 = new byte[]{2};

e1.write(m1, m2);
e1.write(false, m1, m2);

byte[] m1b = e2.read();
byte[] m2b = e2.read();
Expand All @@ -110,24 +110,23 @@ public void testBothWays() {
byte[] m3 = new byte[]{1};
byte[] m4 = new byte[]{2};

e1.write(m1);
e1.write(false, m1);
byte[] m1b = e2.read();
Assert.assertArrayEquals(m1, m1b);

e2.write(m2);
e2.write(false, m2);
byte[] m2b = e1.read();
Assert.assertArrayEquals(m2, m2b);

e1.write(m3);
e1.write(false, m3);
byte[] m3b = e2.read();
Assert.assertArrayEquals(m3, m3b);

e2.write(m4);
e2.write(false, m4);
byte[] m4b = e1.read();
Assert.assertArrayEquals(m4, m4b);
}


@Test
public void testFirstMessageFromClient() {
byte[] key = key2();
Expand All @@ -140,11 +139,11 @@ public void testFirstMessageFromClient() {
byte[] m1 = new byte[]{1};
byte[] m2 = new byte[]{2};

e2.write(m1);
e2.write(false, m1);
byte[] m1b = e1.read();
Assert.assertArrayEquals(m1, m1b);

e1.write(m2);
e1.write(false, m2);
byte[] m2b = e2.read();
Assert.assertArrayEquals(m2, m2b);
}
Expand Down
12 changes: 6 additions & 6 deletions src-test/saltchannel/v2/packets/M1PacketTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,45 @@ public class M1PacketTest {

@Test
public void testSanity() {
M1Packet p = new M1Packet();
M1Message p = new M1Message();
p.clientEncKey = new byte[32];
p.serverSigKey = null;

byte[] bytes1 = new byte[p.getSize()];
p.toBytes(bytes1, 0);
byte[] bytes2 = new byte[bytes1.length];
M1Packet.fromBytes(bytes1, 0).toBytes(bytes2, 0);
M1Message.fromBytes(bytes1, 0).toBytes(bytes2, 0);

Assert.assertArrayEquals(bytes1, bytes2);
}

@Test
public void testWithTicket() {
M1Packet p = new M1Packet();
M1Message p = new M1Message();
p.clientEncKey = new byte[32];
p.serverSigKey = null;
p.ticket = new byte[20]; // dummy data

byte[] bytes1 = new byte[p.getSize()];
p.toBytes(bytes1, 0);
byte[] bytes2 = new byte[bytes1.length];
M1Packet.fromBytes(bytes1, 0).toBytes(bytes2, 0);
M1Message.fromBytes(bytes1, 0).toBytes(bytes2, 0);

Assert.assertArrayEquals(bytes1, bytes2);
}


@Test
public void testWithTicketRequested() {
M1Packet p = new M1Packet();
M1Message p = new M1Message();
p.clientEncKey = new byte[32];
p.serverSigKey = null;
p.ticketRequested = true;

byte[] bytes1 = new byte[p.getSize()];
p.toBytes(bytes1, 0);
byte[] bytes2 = new byte[bytes1.length];
M1Packet.fromBytes(bytes1, 0).toBytes(bytes2, 0);
M1Message.fromBytes(bytes1, 0).toBytes(bytes2, 0);

Assert.assertArrayEquals(bytes1, bytes2);
}
Expand Down
8 changes: 4 additions & 4 deletions src-test/saltchannel/v2/packets/M2PacketTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ public class M2PacketTest {

@Test
public void testSanity() {
M2Packet p = new M2Packet();
M2Message p = new M2Message();
p.noSuchServer = false;
p.serverEncKey = new byte[32];

byte[] bytes1 = new byte[p.getSize()];
p.toBytes(bytes1, 0);

M2Packet p2 = M2Packet.fromBytes(bytes1, 0);
M2Message p2 = M2Message.fromBytes(bytes1, 0);

byte[] bytes2 = new byte[bytes1.length];
p2.toBytes(bytes2, 0);
Expand All @@ -24,15 +24,15 @@ public void testSanity() {

@Test
public void testResumeSupported() {
M2Packet p = new M2Packet();
M2Message p = new M2Message();
p.noSuchServer = false;
p.resumeSupported = true;
p.serverEncKey = new byte[32];

byte[] bytes1 = new byte[p.getSize()];
p.toBytes(bytes1, 0);

M2Packet p2 = M2Packet.fromBytes(bytes1, 0);
M2Message p2 = M2Message.fromBytes(bytes1, 0);

byte[] bytes2 = new byte[bytes1.length];
p2.toBytes(bytes2, 0);
Expand Down
4 changes: 2 additions & 2 deletions src/saltchannel/dev/BuildInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ public class BuildInfo {

private BuildInfo() {}

public static final String VERSION = identity("2.1.20171024");
public static final String VERSION = identity("2.2");

/**
* Build time, for example: "160508.1435".
*/
public static final String TIME = identity("20171024.1233");
public static final String TIME = identity("20171025.0815");

/**
* Returns 's'; useful for avoiding compiler inlining of a final field.
Expand Down
3 changes: 0 additions & 3 deletions src/saltchannel/dev/Dev.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package saltchannel.dev;

// TODO D. document and improve testing for AppChannelV2 etc; now exposed to application layer.
// Expose multi app message and lastFlag to application layer.

/**
* Development stuff.
*/
Expand Down
18 changes: 9 additions & 9 deletions src/saltchannel/dev/ExamplePacketDump.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static void main(String[] args) {
public ExamplePacketDump() {
}

private void m1_print(int case_id, M1Packet m1) {
private void m1_print(int case_id, M1Message m1) {
String sigkey_str = m1.serverSigKey != null? "+" : "null";
String tik_str = m1.ticket != null? Hex.create(m1.ticket) : "null";
System.out.println(String.format("-------------\nM1 CASE: %d -> time: 0x%x, serverSigKey: %s, ticket: %s, ticketRequested: %b ",
Expand All @@ -25,10 +25,10 @@ private void m1_print(int case_id, M1Packet m1) {
}

private void M1() {
M1Packet m1;
M1Message m1;

// CASE 1 - NO ticket, NO server sig key, NO ticketRequested
m1 = new M1Packet();
m1 = new M1Message();
m1.time = 0xdeadbeef;
m1.clientEncKey = CryptoTestData.aEnc.pub();
m1.serverSigKey = null;
Expand All @@ -39,7 +39,7 @@ private void M1() {
m1 = null;

// CASE 2 - NO ticket, + server sig key, + ticketRequested
m1 = new M1Packet();
m1 = new M1Message();
m1.time = 0xdeadbeef;
m1.clientEncKey = CryptoTestData.aEnc.pub();
m1.serverSigKey = CryptoTestData.bSig.pub();
Expand All @@ -50,7 +50,7 @@ private void M1() {
m1 = null;

// CASE 3 - + Ticket, NO server sig key: + ticketRequested
m1 = new M1Packet();
m1 = new M1Message();
m1.time = 0xdeadbeef;
m1.clientEncKey = CryptoTestData.aEnc.pub();
m1.serverSigKey = null;
Expand All @@ -63,7 +63,7 @@ private void M1() {
m1 = null;

// CASE 4 - + Ticket, + server sig key: + ticketRequested
m1 = new M1Packet();
m1 = new M1Message();
m1.time = 0xdeadbeef;
m1.clientEncKey = CryptoTestData.aEnc.pub();
m1.serverSigKey = CryptoTestData.bSig.pub();
Expand All @@ -76,17 +76,17 @@ private void M1() {
m1 = null;
}

private void m2_print(int case_id, M2Packet m2) {
private void m2_print(int case_id, M2Message m2) {
String enckey_str = m2.serverEncKey != null? "+" : "null";
System.out.println(String.format("-------------\nM2 CASE: %d -> time: 0x%x, ServerEncKey: %s, resumeSupported: %b ",
case_id, m2.time, enckey_str, m2.resumeSupported));
System.out.println("\nsizeof(M2): " + m2.getSize() + ", M2: '" + Hex.create(m2.toBytes())+"'\n");
}

private void M2() {
M2Packet m2;
M2Message m2;

m2 = new M2Packet();
m2 = new M2Message();
m2.time = 0xdeadbeef;
m2.resumeSupported = true;
m2.serverEncKey = CryptoTestData.bEnc.pub();
Expand Down
Loading

0 comments on commit fcdffb2

Please sign in to comment.