Commit a7de0d5f authored by garciay's avatar garciay
Browse files

STF507 week#9:

.  Implement additional TPs
.  Review of the PICS, TSS&TPs & PIXITs documents
.  Start validation using simulation
.      Minor bug fixed in TA
TODO: Logs should be commented later
parent 119e0633
......@@ -297,18 +297,6 @@ public class SecurityHelper {
}
}
signerInfoTypeIndex += (Long.SIZE / Byte.SIZE);
// Check generation location
if (p_headerfields[signerInfoTypeIndex++] != 0x03) { // Header Field: Generation Location (3)
if (p_enforceSecurityCheck) {
// Drop it
System.err.println("SecurityHelper.checkHeaderfields: Drop packet - GenerationTime not found");
return false;
}
}
byte[] threeDLocation = ByteHelper.extract(p_headerfields, signerInfoTypeIndex, (2 * Integer.SIZE + 2 * Byte.SIZE) / Byte.SIZE);
System.out.println("SecurityHelper.checkHeaderfields: threeDLocation=" + threeDLocation);
// TODO Check generation location
signerInfoTypeIndex += threeDLocation.length;
if (signerInfoTypeIndex < p_headerfields.length) {
System.out.println("SecurityHelper.checkHeaderfields: dump #1=" + ByteHelper.byteArrayToString(ByteHelper.extract(p_headerfields, signerInfoTypeIndex, p_headerfields.length - signerInfoTypeIndex)));
......
......@@ -643,12 +643,6 @@ public class GnLayer extends Layer implements Runnable, IEthernetSpecific {
long curtime = System.currentTimeMillis();
byte[] generationTime = ByteHelper.longToByteArray((long)(curtime - 1072915200000L) * 1000L, Long.SIZE / Byte.SIZE); // In microseconds
System.out.println("GnLayer.createSecuredMessage: generationTime=" + ByteHelper.byteArrayToString(generationTime));
byte[] threeDLocation = ByteHelper.concat(
management.getLatitude(),
management.getLongitude(),
new byte[] { 0x00, 0x00 }
);
System.out.println("GnLayer.createSecuredMessage: threeDLocation=" + ByteHelper.byteArrayToString(threeDLocation));
// Build the payload to be signed
byte[] headersField = ByteHelper.concat(
ByteHelper.concat( // SecuredMessage HeaderFields
......@@ -660,11 +654,7 @@ public class GnLayer extends Layer implements Runnable, IEthernetSpecific {
new byte[] {
(byte)0x00, // generationTime
},
generationTime, // Time64 value
new byte[] {
(byte)0x03, // generationLocation
},
threeDLocation // ThreeDLocation
generationTime // Time64 value
)
);
if ((commonHdr[0] & 0xF0) == 0x01) { // Next header = Btp-A
......@@ -709,6 +699,12 @@ public class GnLayer extends Layer implements Runnable, IEthernetSpecific {
}
headersField = ByteHelper.concat(
headersField,
new byte[] {
(byte)0x03 // GenerationLocation
},
management.getLatitude(), // Latitude
management.getLongitude(), // Longitude
new byte[] { (byte)0x00, (byte)0x00 }, // Elevation
new byte[] {
(byte)0x05 // Its-aid
},
......
......@@ -197,6 +197,12 @@ public class GnPort extends ProtocolPort implements Runnable, IEthernetSpecific
}
headersField = ByteHelper.concat(
headersField,
new byte[] {
(byte)0x03 // GenerationLocation
},
management.getLatitude(), // Latitude
management.getLongitude(), // Longitude
new byte[] { (byte)0x00, (byte)0x00 }, // Elevation
new byte[] {
(byte)0x05 // Its-aid
},
......@@ -378,7 +384,7 @@ public class GnPort extends ProtocolPort implements Runnable, IEthernetSpecific
}
private byte[] createSecuredMessage(final byte[] message) {
//System.out.println(">>> GnPort.createSecuredMessage: " + ByteHelper.byteArrayToString(message));
System.out.println(">>> GnPort.createSecuredMessage: " + ByteHelper.byteArrayToString(message));
// Extract and update the basicHeader
byte[] basicHdr = ByteHelper.extract(message, 0, 4);
......@@ -457,6 +463,12 @@ public class GnPort extends ProtocolPort implements Runnable, IEthernetSpecific
}
headersField = ByteHelper.concat(
headersField,
new byte[] {
(byte)0x03 // GenerationLocation
},
management.getLatitude(), // Latitude
management.getLongitude(), // Longitude
new byte[] { (byte)0x00, (byte)0x00 }, // Elevation
new byte[] {
(byte)0x05 // Its-aid
},
......
......@@ -122,7 +122,7 @@ public class UpperTesterPort extends AdapterPort implements IPort, IObservable {
@Override
public boolean send(final byte[] message) {
/* FIXME: For debug only. Uncomment if no UT
/* FIXME: For debug only. Uncomment if no UT*/
try {
Thread.sleep(500);
} catch (InterruptedException e) {
......@@ -158,7 +158,7 @@ public class UpperTesterPort extends AdapterPort implements IPort, IObservable {
notifyObservers(new PortEvent(rsp, getPortName(), getComponentName()));
if(true)
return true;
*/
/**/
try {
ByteArrayOutputStream dataToSent = new ByteArrayOutputStream();
dataToSent.write(message);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment