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
Loading
Loading
Loading
Loading
+0 −12
Original line number Original line Diff line number Diff line
@@ -297,18 +297,6 @@ public class SecurityHelper {
            }
            }
        }
        }
        signerInfoTypeIndex += (Long.SIZE / Byte.SIZE);
        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) { 
        if (signerInfoTypeIndex < p_headerfields.length) { 
            System.out.println("SecurityHelper.checkHeaderfields: dump #1=" + ByteHelper.byteArrayToString(ByteHelper.extract(p_headerfields, signerInfoTypeIndex, p_headerfields.length - signerInfoTypeIndex)));
            System.out.println("SecurityHelper.checkHeaderfields: dump #1=" + ByteHelper.byteArrayToString(ByteHelper.extract(p_headerfields, signerInfoTypeIndex, p_headerfields.length - signerInfoTypeIndex)));
+7 −11
Original line number Original line Diff line number Diff line
@@ -643,12 +643,6 @@ public class GnLayer extends Layer implements Runnable, IEthernetSpecific {
        long curtime = System.currentTimeMillis();
        long curtime = System.currentTimeMillis();
        byte[] generationTime = ByteHelper.longToByteArray((long)(curtime - 1072915200000L) * 1000L, Long.SIZE / Byte.SIZE); // In microseconds
        byte[] generationTime = ByteHelper.longToByteArray((long)(curtime - 1072915200000L) * 1000L, Long.SIZE / Byte.SIZE); // In microseconds
        System.out.println("GnLayer.createSecuredMessage: generationTime=" + ByteHelper.byteArrayToString(generationTime));
        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
        // Build the payload to be signed
        byte[] headersField = ByteHelper.concat(
        byte[] headersField = ByteHelper.concat(
            ByteHelper.concat(                                // SecuredMessage HeaderFields
            ByteHelper.concat(                                // SecuredMessage HeaderFields
@@ -660,11 +654,7 @@ public class GnLayer extends Layer implements Runnable, IEthernetSpecific {
                new byte[] {
                new byte[] {
                    (byte)0x00,                               // generationTime
                    (byte)0x00,                               // generationTime
                },
                },
                generationTime,                               //    Time64 value
                generationTime                               //    Time64 value
                new byte[] {
                    (byte)0x03,                               // generationLocation
                },
                threeDLocation                                //    ThreeDLocation
            )
            )
        );
        );
        if ((commonHdr[0] & 0xF0) == 0x01) { // Next header = Btp-A
        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 = ByteHelper.concat(
                headersField,
                headersField,
                new byte[] { 
                        (byte)0x03                                // GenerationLocation
                    },
                    management.getLatitude(),                     //     Latitude
                    management.getLongitude(),                    //     Longitude
                    new byte[] { (byte)0x00, (byte)0x00 },        //     Elevation
                new byte[] { 
                new byte[] { 
                    (byte)0x05                                // Its-aid
                    (byte)0x05                                // Its-aid
                },
                },
+13 −1
Original line number Original line Diff line number Diff line
@@ -197,6 +197,12 @@ public class GnPort extends ProtocolPort implements Runnable, IEthernetSpecific
        }
        }
        headersField = ByteHelper.concat(
        headersField = ByteHelper.concat(
            headersField,
            headersField,
            new byte[] { 
                    (byte)0x03                                // GenerationLocation
                },
                management.getLatitude(),                     //     Latitude
                management.getLongitude(),                    //     Longitude
                new byte[] { (byte)0x00, (byte)0x00 },        //     Elevation
            new byte[] { 
            new byte[] { 
                (byte)0x05                                // Its-aid
                (byte)0x05                                // Its-aid
            },
            },
@@ -378,7 +384,7 @@ public class GnPort extends ProtocolPort implements Runnable, IEthernetSpecific
    }
    }
    
    
    private byte[] createSecuredMessage(final byte[] message) {
    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
        // Extract and update the basicHeader
        byte[] basicHdr = ByteHelper.extract(message, 0, 4);
        byte[] basicHdr = ByteHelper.extract(message, 0, 4);
@@ -457,6 +463,12 @@ public class GnPort extends ProtocolPort implements Runnable, IEthernetSpecific
            }
            }
            headersField = ByteHelper.concat(
            headersField = ByteHelper.concat(
                headersField,
                headersField,
                new byte[] { 
                    (byte)0x03                                // GenerationLocation
                },
                management.getLatitude(),                     //     Latitude
                management.getLongitude(),                    //     Longitude
                new byte[] { (byte)0x00, (byte)0x00 },        //     Elevation
                new byte[] { 
                new byte[] { 
                    (byte)0x05                                // Its-aid
                    (byte)0x05                                // Its-aid
                },
                },
+2 −2
Original line number Original line Diff line number Diff line
@@ -122,7 +122,7 @@ public class UpperTesterPort extends AdapterPort implements IPort, IObservable {
    
    
    @Override
    @Override
    public boolean send(final byte[] message) {
    public boolean send(final byte[] message) {
/* FIXME: For debug only. Uncomment if no UT
/* FIXME: For debug only. Uncomment if no UT*/
        try {
        try {
            Thread.sleep(500);
            Thread.sleep(500);
        } catch (InterruptedException e) {
        } catch (InterruptedException e) {
@@ -158,7 +158,7 @@ public class UpperTesterPort extends AdapterPort implements IPort, IObservable {
        notifyObservers(new PortEvent(rsp, getPortName(), getComponentName()));
        notifyObservers(new PortEvent(rsp, getPortName(), getComponentName()));
        if(true)
        if(true)
            return true;
            return true;
*/
/**/
        try {
        try {
            ByteArrayOutputStream dataToSent = new ByteArrayOutputStream();
            ByteArrayOutputStream dataToSent = new ByteArrayOutputStream();
            dataToSent.write(message);
            dataToSent.write(message);