Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Commit 3865c2c3 authored by Cypres TAC's avatar Cypres TAC
Browse files

Merge branch 'feature/lsp-constants' into 'master'

Feature/lsp constants

See merge request !42
parents 31c02da2 aaccdfe0
Pipeline #245667 passed with stages
in 8 minutes and 29 seconds
......@@ -15,3 +15,5 @@ c/build
/CLEA-lib/js/dist
/CLEA-lib/js/.cache
/CLEA-lib/js/node_modules
CLEA-lib/java/.idea/
*.iml
......@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fr.inria.clea</groupId>
<artifactId>clea-crypto</artifactId>
<version>1.0.1</version>
<version>1.1-SNAPSHOT</version>
<dependencies>
<dependency>
......
......@@ -34,6 +34,9 @@ import lombok.extern.slf4j.Slf4j;
@ToString
@Slf4j
public class LocationSpecificPart {
public static final int UNLIMITED_PERIOD_DURATION = 255;
public static final int QRCODE_NO_RENEWAL = 0x1F;
public static final short LOCATION_TEMPORARY_SECRET_KEY_SIZE = 32; // 256 bits
public static final String VERSION_VALIDATION_MESSAGE = "Version should have a value between 0 and 8 (included)";
public static final String TYPE_VALIDATION_MESSAGE = "Type should have a value between 0 and 8 (included)";
......@@ -47,7 +50,7 @@ public class LocationSpecificPart {
public static final String QR_CODE_VALIDITY_START_TIME_VALIDATION_MESSAGE = "QR-code validity start time must not be null";
public static final String LOCATION_TEMPORARY_SECRET_KEY_VALIDATION_MESSAGE = "Location temporary secret key must not be null";
public static final String LOCATION_TEMPORARY_SECRET_KEY_SIZE_VALIDATION_MESSAGE = "Location temporary secret key must have a size of " + LOCATION_TEMPORARY_SECRET_KEY_SIZE + " bytes";
/* Clea protocol version number */
@Builder.Default
@Min(value = 0, message = VERSION_VALIDATION_MESSAGE)
......@@ -99,7 +102,7 @@ public class LocationSpecificPart {
/* Duration, in terms of number of hours, of the period */
@Min(value = 0, message = PERIOD_DURATION_VALIDATION_MESSAGE)
@Max(value = 255, message = PERIOD_DURATION_VALIDATION_MESSAGE)
@Max(value = UNLIMITED_PERIOD_DURATION, message = PERIOD_DURATION_VALIDATION_MESSAGE)
protected int periodDuration;
/* Starting time of the period in a compressed manner (round hour) */
......@@ -146,7 +149,7 @@ public class LocationSpecificPart {
* @return the number of seconds between a new QR code generation.
*/
public int getQrCodeRenewalInterval() {
if (this.qrCodeRenewalIntervalExponentCompact == 0x1F) {
if (this.qrCodeRenewalIntervalExponentCompact == QRCODE_NO_RENEWAL) {
return 0;
}
return (int) Math.pow(2, this.qrCodeRenewalIntervalExponentCompact);
......
......@@ -218,7 +218,7 @@ public class LocationSpecificPartValidationTest {
}
@Test
public void testWhenPeriodDurationIsGreaterThan255ThenValidationFails() {
public void testWhenPeriodDurationIsGreaterThanMaxValueThenValidationFails() {
LocationSpecificPart lsp = locationSpecificPartBuilder.periodDuration(256).build();
CleaInvalidLocationMessageException exception = assertThrows(CleaInvalidLocationMessageException.class, () -> {
......
......@@ -68,7 +68,7 @@ public class LocationTest {
@Test
public void testWhenSettingQrCodeValidityStartTimeWithNoQrCodeRenewalIntervalThenQrValidityStartTimeNotUpdated() {
int qrCodeRenewalIntervalExponentCompact = 0x1F;
int qrCodeRenewalIntervalExponentCompact = LocationSpecificPart.QRCODE_NO_RENEWAL;
int periodDuration = 3;
lsp = newLocationSpecificPart(qrCodeRenewalIntervalExponentCompact, periodDuration);
......@@ -84,7 +84,7 @@ public class LocationTest {
@Test
public void testWhenSettingQrCodeValidityStartTimeWithNoQrCodeRenewalIntervalThenQrValidityStartTimeUpdatedWhenNewPeriod() throws CleaEncryptionException {
int qrCodeRenewalIntervalExponentCompact = 0x1F;
int qrCodeRenewalIntervalExponentCompact = LocationSpecificPart.QRCODE_NO_RENEWAL;
int periodDuration = 3;
lsp = newLocationSpecificPart(qrCodeRenewalIntervalExponentCompact, periodDuration);
......
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