summaryrefslogtreecommitdiffstats
path: root/src/test/java/org/uic/barcode
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2021-11-23 15:39:05 +0100
committerCGantert345 <57003061+CGantert345@users.noreply.github.com>2021-11-23 15:39:05 +0100
commit12ca8d77e0a0d63ce03886d38c079c686122253a (patch)
tree6703a1676aac7406401694a8d2e6a33c07fce497 /src/test/java/org/uic/barcode
parentadditional tests for DOSIPAS (diff)
downloadUIC-barcode-12ca8d77e0a0d63ce03886d38c079c686122253a.tar
UIC-barcode-12ca8d77e0a0d63ce03886d38c079c686122253a.tar.gz
UIC-barcode-12ca8d77e0a0d63ce03886d38c079c686122253a.tar.bz2
UIC-barcode-12ca8d77e0a0d63ce03886d38c079c686122253a.tar.lz
UIC-barcode-12ca8d77e0a0d63ce03886d38c079c686122253a.tar.xz
UIC-barcode-12ca8d77e0a0d63ce03886d38c079c686122253a.tar.zst
UIC-barcode-12ca8d77e0a0d63ce03886d38c079c686122253a.zip
Diffstat (limited to 'src/test/java/org/uic/barcode')
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java
index 93ecdfb..53b6af8 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java
@@ -10,6 +10,11 @@ import java.security.NoSuchProviderException;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.temporal.ChronoUnit;
+import java.util.Arrays;
+import java.util.Date;
import java.util.zip.DataFormatException;
import org.bouncycastle.jce.ECNamedCurveTable;
@@ -19,6 +24,7 @@ import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.Decoder;
import org.uic.barcode.Encoder;
+import org.uic.barcode.dynamicContent.fdc1.TimeStamp;
import org.uic.barcode.dynamicContent.fdc1.UicDynamicContentDataFDC1;
import org.uic.barcode.dynamicFrame.Constants;
import org.uic.barcode.test.utils.SimpleUICTestTicket;
@@ -34,6 +40,11 @@ public class DynamicFrameDynamicContentTest {
public KeyPair keyPairLevel1 = null;
public KeyPair keyPairLevel2 = null;
+ public byte[] passIdHash = "PassId".getBytes();
+ public byte[] phoneIdHash = "myPhone".getBytes();
+
+ ZonedDateTime originalTimeStamp = ZonedDateTime.now(ZoneId.of("UTC"));
+
public IUicRailTicket testFCBticket = null;
@@ -87,6 +98,12 @@ public class DynamicFrameDynamicContentTest {
UicDynamicContentDataFDC1 dcd = new UicDynamicContentDataFDC1();
dcd.setChallengeString("CHALLENGE");
dcd.setAppId("MyApp");
+ dcd.setPhoneIdHash(phoneIdHash);
+ dcd.setPassIdHash(passIdHash);
+ TimeStamp ts = new TimeStamp();
+ ts.setDateTime(Date.from(originalTimeStamp.toInstant()));
+ dcd.setTimeStamp(ts);
+
enc.setDynamicContentDataUIC1(dcd);
enc.signLevel2(keyPairLevel2.getPrivate());
} catch (Exception e) {
@@ -133,6 +150,12 @@ public class DynamicFrameDynamicContentTest {
UicDynamicContentDataFDC1 dcd = new UicDynamicContentDataFDC1();
dcd.setChallengeString("CHALLENGE");
dcd.setAppId("MyApp");
+ dcd.setPhoneIdHash(phoneIdHash);
+ dcd.setPassIdHash(passIdHash);
+ TimeStamp ts = new TimeStamp();
+ ts.setDateTime(Date.from(originalTimeStamp.toInstant()));
+ dcd.setTimeStamp(ts);
+
enc.setDynamicContentDataUIC1(dcd);
enc.signLevel2(keyPairLevel2.getPrivate());
} catch (Exception e) {
@@ -182,10 +205,21 @@ public class DynamicFrameDynamicContentTest {
assert(level2check == Constants.LEVEL2_VALIDATION_OK);
- assert(dec.getDynamicHeader().getDynamicDataFDC1().getChallengeString().equals("CHALLENGE"));
+ UicDynamicContentDataFDC1 dynamicData = dec.getDynamicHeader().getDynamicDataFDC1();
+
+ assert(dynamicData.getChallengeString().equals("CHALLENGE"));
+
+ assert(dynamicData.getAppId().equals("MyApp"));
+
+ assert(Arrays.equals(dynamicData.getPassIdHash(),passIdHash));
- assert(dec.getDynamicHeader().getDynamicDataFDC1().getAppId().equals("MyApp"));
+ assert(Arrays.equals(dynamicData.getPhoneIdHash(),phoneIdHash));
+ Date timeStamp = dynamicData.getTimeStamp().getTimeAsDate();
+ ZonedDateTime retrievedTimeStamp = timeStamp.toInstant().atZone(ZoneId.of("UTC"));
+ long diff = ChronoUnit.SECONDS.between(originalTimeStamp, retrievedTimeStamp);
+
+ assert(diff == 0);
}
public KeyPair generateECDSAKeys(String keyAlgorithmName, String paramName) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException{