Attention une mise à jour du service Gitlab va être effectuée le mardi 14 décembre entre 13h30 et 14h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes.

Commit 565224f9 authored by Cypres TAC's avatar Cypres TAC
Browse files

Merge branch 'java-enhancements' into 'master'

public qrcode header decoding

See merge request !13
parents 1a571e68 b9e596bf
Pipeline #228261 passed with stage
in 1 minute and 52 seconds
package fr.inria.clea.lsp;
/**
* Generic Clea exception thrown when the layout of the message
* is not respected.
*/
public class CleaEncodingException extends Exception {
private static final long serialVersionUID = 1L;
public CleaEncodingException(String message) {
super(message);
}
}
......@@ -27,16 +27,27 @@ public class LocationSpecificPartDecoder {
/* EC private key in String format used to decrypt the message part */
String serverAuthoritySecretKey;
public LocationSpecificPartDecoder(String servertAuthoritySecretKey) {
/**
* This default constructor should only be used for decoding.
* The server secret key is mandatory to decrypt.
*/
public LocationSpecificPartDecoder() {
this.cleaEciesEncoder = new CleaEciesEncoder();
this.serverAuthoritySecretKey = servertAuthoritySecretKey;
}
public LocationSpecificPartDecoder(String serverAuthoritySecretKey) {
this();
this.serverAuthoritySecretKey = serverAuthoritySecretKey;
}
/**
* Unpack the data decrypted header (binary format):
* | version | LSPtype | pad | LTId | to extract parameters
*/
private EncryptedLocationSpecificPart decodeHeader(byte[] binaryLocationSpecificPart) {
public EncryptedLocationSpecificPart decodeHeader(byte[] binaryLocationSpecificPart) throws CleaEncodingException {
if (binaryLocationSpecificPart.length < CleaEciesEncoder.HEADER_BYTES_SIZE + CleaEciesEncoder.MSG_BYTES_SIZE) {
throw new CleaEncodingException("Bad message length: " + binaryLocationSpecificPart.length);
}
byte[] headerBinary = Arrays.copyOfRange(binaryLocationSpecificPart, 0, CleaEciesEncoder.HEADER_BYTES_SIZE);
BitUtils header = new BitUtils(headerBinary);
......@@ -61,8 +72,9 @@ public class LocationSpecificPartDecoder {
*
* @param lspBase64 Location Specific Part in base64
* @throws CleaEncryptionException
* @throws CleaEncodingException
*/
public EncryptedLocationSpecificPart decrypt(String lspBase64) throws CleaEncryptionException {
public EncryptedLocationSpecificPart decrypt(String lspBase64) throws CleaEncryptionException, CleaEncodingException {
byte[] encryptedLocationSpecificPart = Base64.getDecoder().decode(lspBase64);
log.debug("Base 64 decoded LSP: {}", encryptedLocationSpecificPart);
byte[] binaryLocationSpecificPart;
......
......@@ -37,7 +37,7 @@ public class LocationSpecificPartEncoder {
*
* @return data header in binary format
*/
private byte[] binaryEncodedHeader(LocationSpecificPart locationSpecificPart) {
public byte[] binaryEncodedHeader(LocationSpecificPart locationSpecificPart) {
BitUtils header = new BitUtils(8 * CleaEciesEncoder.HEADER_BYTES_SIZE);
/* version (3 bits) */
header.setNextInteger(locationSpecificPart.getVersion(), 3);
......@@ -62,7 +62,7 @@ public class LocationSpecificPartEncoder {
* @throws CleaEncryptionException
* @throws Exception
*/
private byte[] binaryEncodedMessage(LocationSpecificPart locationSpecificPart) throws CleaEncryptionException {
public byte[] binaryEncodedMessage(LocationSpecificPart locationSpecificPart) throws CleaEncryptionException {
BitUtils message = new BitUtils(8 * CleaEciesEncoder.MSG_BYTES_SIZE);
/* staff (1 bit) */
......
......@@ -27,7 +27,7 @@ public class LspEncoderDecoder {
}
}
protected static void decodeLsp(String[] args) throws CleaEncryptionException {
protected static void decodeLsp(String[] args) throws CleaEncryptionException, CleaEncodingException {
String lspBase64 = args[1];
String serverAuthoritySecretKey = args[2];
String manualContactTracingAuthoritySecretKey = args[3];
......
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