Skip to content

Commit 22a9f04

Browse files
committed
Merge branch 'release/2.2'
2 parents 908061a + a7ff06b commit 22a9f04

20 files changed

+980
-70
lines changed

README.md

Lines changed: 69 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ When not supplied at creation time, the following parameters are defined based o
2828
### Using the TRS V2 additions
2929
As of release 2.0, two additional provisions were added to the .trs format: Trace Set Parameters and Trace Parameters. Note that TRS V2 is backwards compatible with TRS V1. However, as can be expected, the additional information will not be available when using a pre-V2 reader.
3030
#### Trace Set Parameters
31-
Trace Set Parameters are user-defined key value pairs that can be used to save global information about the trace set. The following types of data can be used (also found in com.riscure.trs.parameter.ParameterTypes):
31+
Trace Set Parameters are user-defined key value pairs that can be used to save global information about the trace set. The following types of data can be used (also found in com.riscure.trs.enums.ParameterType):
3232

3333
BYTE: 1 byte integer
3434
SHORT: 2 byte integer
@@ -39,11 +39,11 @@ Trace Set Parameters are user-defined key value pairs that can be used to save g
3939
STRING: UTF-8 encoded string value
4040
Each type also supports array creation. Please note that there is no provision for arrays of length 1. An array of length 1 will always be saved and loaded as a single value.
4141
##### Using Trace Set Parameters
42-
Global parameters can be added by creating a `TraceSetParameters` object when creating a trace set. The following java code shows an example:
42+
Global parameters can be added by creating a `TraceSetParameterMap` object when creating a trace set. The following java code shows an example:
4343
```java
4444
TRSMetaData metaData = new TRSMetaData();
4545
metaData.put(TRSTag.TRS_VERSION, 2);
46-
TraceSetParameters parameters = new TraceSetParameters();
46+
TraceSetParameterMap parameters = new TraceSetParameterMap();
4747
parameters.put("BYTE", (byte)1);
4848
parameters.put("SHORT", (short)2);
4949
parameters.put("INT", 3);
@@ -64,19 +64,15 @@ ts.close();
6464
```
6565

6666
#### Trace Parameters
67-
TraceParameters behave very similar to Trace Set Parameters from a user perspective. They are values that can be added to _every_ trace, describing specific values that can vary between traces. The data types that can be used are the same as for Trace Set Parameters. However, there are several details that are different:
67+
Trace Parameters behave very similar to Trace Set Parameters from a user perspective. They are values that can be added to _every_ trace, describing specific values that can vary between traces. The data types that can be used are the same as for Trace Set Parameters. However, there are several details that are different:
6868

6969
1. The length of the added information *must* be the same for every trace. This means that the first trace added to the trace set dictates the length of both arrays _and_ strings. If a longer string is added later, it will be truncated.
70-
2. The length of every parameter is saved in the header at creation time, in a structure called `TraceParameterDefinitions`. This structure is used when reading out the traces to determine the structure of the included data. This information is _not_ added to the individual traces themselves.
70+
2. The length of every parameter is saved in the header at creation time, in a structure called `TraceParameterDefinitionMap`. This structure is used when reading out the traces to determine the structure of the included data. This information is _not_ added to the individual traces themselves.
7171
3. Going forward, there will be pre-defined tags used to mark important information:
7272
SAMPLES: An alternative for saving the samples of a trace. This may in the future replace the predefined trace structure of title-data-samples.
7373
TITLE: An alternative for saving the title of a trace. This may in the future replace the predefined trace structure of title-data-samples.
7474

75-
Any additional tags can be added based on the application. Riscure Inspector will have its own definitions. We will try to keep a list here of standardized known tags as best we can.
76-
77-
- INPUT: (BYTE ARRAY): the value used as input for a cryptographic operation
78-
- OUTPUT: (BYTE ARRAY): the value returned by a cryptographic operation
79-
- KEY: (BYTE ARRAY): the value used as key for a cryptographic operation
75+
Any additional tags can be added based on the application.
8076

8177
##### Using Trace Parameters
8278
Local parameters can be added by creating a `TraceParameters` object when creating a trace. The following java code shows an example:
@@ -97,7 +93,7 @@ parameters.put("LONGARRAY", new long[]{3L, 4L, 5L});
9793
parameters.put("DOUBLEARRAY", new double[]{6.0, 7.0, 8.0});
9894
Trace.create("trace title", new float[0], parameters);
9995
```
100-
Note that the previously mentioned `TraceParameterDefinitions` are created automatically when adding the first trace.
96+
Note that the previously mentioned `TraceParameterDefinitionMap` are created automatically when adding the first trace.
10197

10298
### Reading `.trs` files
10399
```java
@@ -146,6 +142,68 @@ traceSet.add(com.riscure.trs.Trace("Trace 0 ", [0x0, 0x0f, 0xA, 0x3C], [0
146142
traceSet.close();
147143
```
148144

145+
## Riscure Inspector use
146+
147+
Riscure Inspector has its own definitions that are used to tag specific types of data. Note that many of the type are namespaced; The ':' character is interpreted as a namespace separator for the purpose of grouping values together.
148+
We will try to keep a list here of standardized known tags as best we can.
149+
150+
### Trace Set Parameters
151+
152+
Name | Type | Description |
153+
---- | ---- | ----------- |
154+
KEY | BYTE ARRAY | The value used as key for a cryptographic operation (applicable to the entire set)
155+
SETUP:OSCILLOSCOPE:RANGE | FLOAT | The range (V) of the oscilloscope used for this measurement
156+
SETUP:OSCILLOSCOPE:COUPLING | INTEGER | The coupling of the oscilloscope used for this measurement. Currently encoded as 0 for AC and 1 for DC
157+
SETUP:OSCILLOSCOPE:OFFSET | FLOAT | The offset (V) of the oscilloscope used for this measurement
158+
SETUP:OSCILLOSCOPE:INPUT_IMPEDANCE | FLOAT | The input impedance (Ω) of the oscilloscope used for this measurement
159+
SETUP:OSCILLOSCOPE:DEVICE_ID | STRING | The device ID of the oscilloscope used for this measurement. This is commonly the name, type, and/or serial number
160+
SETUP:OSCILLOSCOPE:ACTIVE_CHANNEL_COUNT | INTEGER | The number of active channels of the oscilloscope used for this measurement
161+
SETUP:OSCILLOSCOPE:COUNT | INTEGER | The number of oscilloscopes used for this measurement
162+
SETUP:ICWAVES:FILTER:TYPE | INTEGER | The type of filter used by the icWaves during this measurement: 0 = None, 1 = Lowpass, 2 = Highpass, 3 = Narrow Baseband
163+
SETUP:ICWAVES:FILTER:FREQUENCY | INTEGER | The center frequency of the filter used by the icWaves during this measurement
164+
SETUP:ICWAVES:FILTER:RANGE | INTEGER | The range of the filter used by the icWaves during this measurement
165+
SETUP:ICWAVES:EXT_CLK:ENABLED | BOOLEAN | Whether the external clock input of the icWaves was used during this measurement
166+
SETUP:ICWAVES:EXT_CLK:THRESHOLD | FLOAT | The threshold of the external clock used by the icWaves during this measurement. This dictates the minimum voltage level that will be recognized as a logical '1'
167+
SETUP:ICWAVES:EXT_CLK:FREQUENCY | FLOAT | The input frequency of the external clock used by the icWaves during this measurement
168+
SETUP:ICWAVES:EXT_CLK:TIMEBASE | INTEGER | The divider applied to the external clock before multiplication. The value (n) should be in the range [0, 15], indicating a division by 2^n. i.e. '0' divides by 1, '1' divides by 2, '2' divides by 4, etc
169+
SETUP:ICWAVES:EXT_CLK:MULTIPLIER | INTEGER | The multiplier applied to the external clock used by the icWaves during this measurement. The multiplier must fall in the range [1, 20]. After multiplication, the resulting clock signal must fall in the range [10MHz, 200MHz]
170+
SETUP:ICWAVES:EXT_CLK:PHASE_SHIFT | INTEGER | The phase shift applied to the multiplied external clock used by the icWaves during this measurement
171+
SETUP:ICWAVES:EXT_CLK:RESAMPLER_MASK_ENABLED | BOOLEAN | Whether the external clock resampler mask of the icWaves was used during this measurement
172+
SETUP:ICWAVES:EXT_CLK:RESAMPLER_MASK | INTEGER | How the resampling was applied. '1' means 'multiple samples were combined into one', '0' means 'first sample was picked, the rest was discarded'
173+
SETUP:XYZ:GRID_COUNT_X | INTEGER | The number of steps in the X direction in the XYZ scanning grid
174+
SETUP:XYZ:GRID_COUNT_Y | INTEGER | The number of steps in the Y direction in the XYZ scanning grid
175+
SETUP:XYZ:MEASUREMENTS_PER_SPOT | INTEGER | The number of measurements performed in every location before proceeding to the next location
176+
SETUP:XYZ:REFERENCE_POINTS | DOUBLE ARRAY | The set of locations that define the scanning grid. This is formatted as a set of locations [NE, NW, SW], where each location is represented by 3 doubles [X, Y, Z]
177+
X_OFFSET | INTEGER | The offset of the x-axis relative to the origin
178+
X_SCALE | FLOAT | The value of the x-axis unit represented by the distance between two consecutive sample points. The sampling frequency can be calculated by computing '1 / X_SCALE'
179+
Y_SCALE | FLOAT | The value of the y-axis unit represented by the distance between two consecutive sample values. This is normally only used if the encoding of a sample is an integer type. For float and double encoding, this value is set to 1.
180+
TRACE_OFFSET | INTEGER | The index of the first trace to appear in this set
181+
DISPLAY_HINT:X_LABEL | STRING | The label of the x-axis (commonly used to denote the axis unit)
182+
DISPLAY_HINT:Y_LABEL | STRING | The label of the y-axis (commonly used to denote the axis unit)
183+
DISPLAY_HINT:USE_LOG_SCALE | BOOLEAN | Whether the traces in this trace set are best displayed using a logarithmic Y scale
184+
DISPLAY_HINT:NUM_TRACES_SHOWN | INTEGER | An indication of how many traces should be displayed at the same time to best represent the information in this trace set
185+
DISPLAY_HINT:TRACES_OVERLAP | BOOLEAN | Whether traces should be overlapped in the same window if more than 1 is displayed
186+
TVLA:SETn | STRING | Used to save the names of the TVLA sets represented in this trace set, where 'n' should be replaced by the set index. e.g. a trace set containing two sets 'RANDOM' and 'FIXED' would define 'TVLA:SET0 = RANDOM' and TVLA:SET1 = FIXED'. The value stored per trace in 'TVLA_SET_INDEX' should correspond to the value of n.
187+
TVLA:CIPHER | STRING | The string definition of the target cipher of this TVLA set
188+
189+
### Trace Parameters
190+
191+
Name | Type | Description |
192+
---- | ---- | ----------- |
193+
INPUT | BYTE ARRAY | The value used as input for a cryptographic operation
194+
OUTPUT | BYTE ARRAY | The value returned by a cryptographic operation
195+
KEY | BYTE ARRAY | The value used as key for a cryptographic operation (in case different keys are used during the acquisition campaign)
196+
TIMEOUT | BOOLEAN ARRAY | Whether the measurement encountered a time out
197+
OSCILLOSCOPE:CHANNEL_INDEX | BYTE | The index of the channel used to measure this trace
198+
PATTERN_TYPE | BYTE | The id of the attacked pattern of a public key attack
199+
TVLA_SET_INDEX | SHORT | The index of TVLA set (defined in the set parameters) that this trace belongs to
200+
SOURCE_TRACE_INDEX | INTEGER | The index of the corresponding trace in the source trace set. This can be used in cases where the trace set is re-ordered in any way to keep track of the original location.
201+
SOURCE_TRACE_SAMPLE_INDEX | INTEGER | The index of the corresponding sample in the source trace. This can be used in cases where the samples are shifted or re-ordered in any way to keep track of the original sample index.
202+
FILTER:LOW_BOUND | FLOAT | The lower bound of the frequency filter applied to this trace
203+
FILTER:HIGH_BOUND | FLOAT | The upper bound of the frequency filter applied to this trace
204+
FILTER:SEGMENTS:VALUES | FLOAT ARRAY | The values describing the filter segments
205+
FILTER:SEGMENTS:COUNT | INTEGER | The number of value segments in the filter
206+
XYZ:RELATIVE_POSITION | DOUBLE ARRAY | The XYZ position where this trace was measured relative to the origin specified in the set parameters
149207

150208
## Documentation
151209
TODO

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.riscure</groupId>
88
<artifactId>trsfile</artifactId>
9-
<version>2.1</version>
9+
<version>2.2</version>
1010
<packaging>jar</packaging>
1111

1212
<name>${project.groupId}:${project.artifactId}</name>

src/main/java/com/riscure/trs/TRSMetaDataUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.riscure.trs;
22

33
import com.riscure.trs.enums.TRSTag;
4+
import com.riscure.trs.io.LittleEndianInputStream;
45
import com.riscure.trs.parameter.trace.definition.TraceParameterDefinitionMap;
56
import com.riscure.trs.parameter.traceset.TraceSetParameterMap;
67

7-
import java.io.DataInputStream;
88
import java.io.FileOutputStream;
99
import java.io.IOException;
1010
import java.nio.ByteBuffer;
@@ -112,7 +112,7 @@ public static TRSMetaData readTRSMetaData(ByteBuffer buffer) throws TRSFormatExc
112112
return trs;
113113
}
114114

115-
public static String readName(DataInputStream dis) throws IOException {
115+
public static String readName(LittleEndianInputStream dis) throws IOException {
116116
//Read NL
117117
short nameLength = dis.readShort();
118118
byte[] nameBytes = new byte[nameLength];

0 commit comments

Comments
 (0)