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 5bf9e00c authored by Cypres TAC's avatar Cypres TAC
Browse files

js decoder padding update + java test

parent 5b8b1b11
Pipeline #238554 failed with stages
in 7 minutes and 57 seconds
......@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fr.inria.clea</groupId>
<artifactId>clea-crypto</artifactId>
<version>0.0.2-SNAPSHOT</version>
<version>0.3-SNAPSHOT</version>
<dependencies>
<dependency>
......
......@@ -193,6 +193,32 @@ class LocationSpecificPartTest {
MatrixToImageWriter.writeToStream(bitMatrix, imageFormat, fileOutputStream);
fileOutputStream.close();
}
/**
* Testing the decoding of a LSP in base64 (encoded by C lib)
* using several type of padding
*/
@Test
public void testDecodingInBase64withDifferentaPadding() throws Exception {
final String serverAuthoritySecretKey = "3108f08b1485adb6f72cfba1b55c7484c906a2a3a0a027c78dcd991ca64c97bd";
/* message encrypted, from C package with different padding */
String lspBase64Pad0 = "AMSXLACY_zHatRP_ikRhFsR2sQW2hIaN7ZfvfHhYL02sYoxXnk4VAi-nqTeA2f312xVRYHCFgQOviOfT1yOlrBh0Wp7xVAEghYzqwhoCm9dWjMl6G4IM4rEHPmiLOkCxYp75_aIWavRSA-1NB6E";
final int nbPad = 5;
final String[] variousPad = {"=", "%3d", "%3D"};
LocationSpecificPart[] lsp = new LocationSpecificPart[variousPad.length];
LocationSpecificPartDecoder decoder = new LocationSpecificPartDecoder(serverAuthoritySecretKey);
LocationSpecificPart lsp0 = decoder.decrypt(lspBase64Pad0+variousPad[0]);
for (int i = 0; i < variousPad.length; i++) {
lsp[i] = decoder.decrypt(lspBase64Pad0+variousPad[i]);
}
for (int i = 0; i < variousPad.length; i++) {
assertThat(lsp0).isEqualTo(lsp[i]);
}
}
/**
* Testing the decoding of a LSP in base64 (encoded by C lib)
......
......@@ -49,7 +49,7 @@ and Java LSP decoding
# Java executable can encode or decode
# a Clé location Specific Part (LSP)
CMD_JAVA = ['java', '-cp',
'../java/target/clea-crypto-0.0.2-SNAPSHOT-jar-with-dependencies.jar',
'../java/target/clea-crypto-0.3-SNAPSHOT-jar-with-dependencies.jar',
'fr.inria.clea.lsp.LspEncoderDecoder']
# C executable can encode t a Cléa LSP
CMD_C = ['../c/build/test_clea']
......
......@@ -70,35 +70,39 @@ async function got_content(data)
{
$("#qrcode_content").html(data);
var lsp_base64 = data.split("https://tac.gouv.fr?v=0#").join('');
lsp_base64 = lsp_base64.replace(/_/g, '/').replace(/-/g, '+').replace(/={1,2}$/, '');
var lsp = Uint8Array.from(atob(lsp_base64), c => c.charCodeAt(0));
var sk_sa = new Uint8Array($("#sk_sa").val().match(/.{1,2}/g).map(b => parseInt(b, 16)));
var sk_mcta = new Uint8Array($("#sk_mcta").val().match(/.{1,2}/g).map(b => parseInt(b, 16)));
var decoded =
try
{
version: -1,
lspType: -1,
LTId: "",
staff: false,
CRIexp: -1,
venueType: -1,
venueCategory1: -1,
venueCategory2: -1,
periodDuration: -1,
ct_periodStart: -1,
t_qrStart: -1,
LTKey: "",
locationMsg: null
}
var lsp_base64 = data.split("https://tac.gouv.fr?v=0#").join('');
if (data==lsp_base64) {
console.error("Bad url base" );
}
decoded.version = lsp[0] >>> 5;
decoded.lspType = (lsp[0] >>> 2) & 0x7;
decoded.LTId = buf2bn(lsp.slice(1, 17)).toString(16);
lsp_base64 = lsp_base64.replace(/_/g, '/').replace(/-/g, '+').replace(/={1,2}$/, '');
var lsp = Uint8Array.from(atob(lsp_base64), c => c.charCodeAt(0));
var sk_sa = new Uint8Array($("#sk_sa").val().match(/.{1,2}/g).map(b => parseInt(b, 16)));
var sk_mcta = new Uint8Array($("#sk_mcta").val().match(/.{1,2}/g).map(b => parseInt(b, 16)));
var decoded =
{
version: -1,
lspType: -1,
LTId: "",
staff: false,
CRIexp: -1,
venueType: -1,
venueCategory1: -1,
venueCategory2: -1,
periodDuration: -1,
ct_periodStart: -1,
t_qrStart: -1,
LTKey: "",
locationMsg: null
}
decoded.version = lsp[0] >>> 5;
decoded.lspType = (lsp[0] >>> 2) & 0x7;
decoded.LTId = buf2bn(lsp.slice(1, 17)).toString(16);
try
{
var dec = await decode(lsp.slice(0, 17), lsp.slice(17), sk_sa);
decoded.staff = ((dec[0] & 0x80) >>> 7);
......
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