Commit fa7a4c27 authored by Cypres TAC's avatar Cypres TAC
Browse files

countrycode reserved js

parent 3cbf0da1
Pipeline #235937 failed with stages
in 0 seconds
......@@ -71,18 +71,6 @@
<option value="4">C25</option>
</select>
</div>
<div>
<label for="countryCode">Country code:</label>
<select id="countryCode">
<option value="056">Belgium</option>
<option value="250">France</option>
<option value="274">Germany</option>
<option value="380">Italy</option>
<option value="724">Spain</option>
<option value="826">United Kindom of Great Britain and Northern Ireland</option>
<option value="840">United States of America</option>
</select>
</div>
<div>
<label for="periodDuration">Period duration (in h):</label>
<input type="number" id="periodDuration" name="periodDuration" required min=0 max=255
......
......@@ -26,7 +26,7 @@ let verbose = false;
* @param {conf} config user configuration
* conf = {SK_L, PK_SA, PK_MCTA,
* staff, CRIexp, venueType, venueCategory1, venueCategory2,
* countryCode, periodDuration, locContactMsg}
* periodDuration, locContactMsg}
*
* @return
*/
......@@ -66,7 +66,7 @@ export async function cleaStartNewPeriod(config) {
* @param {conf} config user configuration
* conf = {SK_L, PK_SA, PK_MCTA,
* staff, CRIexp, venueType, venueCategory1, venueCategory2,
* countryCode, periodDuration, locContactMsg}
* periodDuration, locContactMsg}
*
* @return {string} encoded LSP in Base64 format
*/
......@@ -88,8 +88,9 @@ export async function cleaRenewLSP(config) {
header.set(gConf.LTId, 1);
// Fill message
msg[0] = ((config.staff & 0x1) << 7) | (config.locContactMsg ? 0x40 : 0) | ((config.countryCode & 0xFC0) >>> 6);
msg[1] = ((config.countryCode & 0x3F) << 2) | ((config.CRIexp & 0x18) >> 3);
let reserved = 0x0; // reserved for specification evolution
msg[0] = ((config.staff & 0x1) << 7) | (config.locContactMsg ? 0x40 : 0) | ((reserved & 0xFC0) >>> 6);
msg[1] = ((reserved & 0x3F) << 2) | ((config.CRIexp & 0x18) >> 3);
msg[2] = ((config.CRIexp & 0x7) << 5) | (config.venueType & 0x1F);
msg[3] = ((config.venueCategory1 & 0xF) << 4) | (config.venueCategory2 & 0xF);
msg[4] = config.periodDuration;
......
......@@ -37,7 +37,6 @@ import {cleaStartNewPeriod} from './clea'
venueType: parseInt($("#venueType").val()),
venueCategory1: parseInt($("#venueCategory1").val()),
venueCategory2: parseInt($("#venueCategory2").val()),
countryCode: parseInt($("#countryCode").val()),
periodDuration: parseInt($("#periodDuration").val()),
locContactMsg: null
};
......
......@@ -17,7 +17,6 @@ function logEncodingDataAndResult(conf, result) {
+conf.venueType+","
+conf.venueCategory1+","
+conf.venueCategory2+","
+conf.countryCode+","
+conf.periodDuration;
message += ",\"" +navigator.userAgent+"\"";
if (typeof conf.locContactMsg !== 'undefined') {
......
......@@ -5,7 +5,7 @@ const glob = require("glob");
// setup : load cvs file
let cryptoList;
csv({noheader: true,
headers:['sk_l','sk_mcta','sk_sa','result','staff','CRIexp','venueType','venueCategory1','venueCategory2','countryCode','periodDuration','browser', 'locationPhone', 'locationRegion', 'locationPIN']})
headers:['sk_l','sk_mcta','sk_sa','result','staff','CRIexp','venueType','venueCategory1','venueCategory2','periodDuration','browser', 'locationPhone', 'locationRegion', 'locationPIN']})
.fromFile('./crypto.csv')
.then((jsonObj)=> {
cryptoList = jsonObj;
......@@ -22,7 +22,7 @@ setTimeout(function() {
cryptoList.forEach(function (cryptoItem) {
it('test on [' + cryptoItem.browser + '] with ' + cryptoItem.staff + ' ' + cryptoItem.CRIexp + ' ' + cryptoItem.venueType + ' ' + cryptoItem.venueCategory1
+ ' ' + cryptoItem.venueCategory2 + ' ' + cryptoItem.countryCode + ' ' + cryptoItem.periodDuration , async () => {
+ ' ' + cryptoItem.venueCategory2 + ' ' + cryptoItem.periodDuration , async () => {
await new Promise((resolve) => {
let result = '';
const javaproc = spawn('java', ['-cp', cleaCryptoJarPath,
......@@ -47,22 +47,21 @@ setTimeout(function() {
javaproc.on('exit', (code) => {
console.log(`Child exited with code ${code}`);
expect(code).to.equal(0);
expect([10, 13]).to.include(result.length);
expect([9, 12]).to.include(result.length);
expect(result[0]).to.equal(cryptoItem.staff);
expect(result[1]).to.equal(cryptoItem.countryCode);
expect(result[2]).to.equal(cryptoItem.CRIexp);
expect(result[3]).to.equal(cryptoItem.venueType);
expect(result[4]).to.equal(cryptoItem.venueCategory1);
expect(result[5]).to.equal(cryptoItem.venueCategory2);
expect(result[6]).to.equal(cryptoItem.periodDuration);
// result[7] LTId
// result[8] ct_periodStart
// result[9] t_qrStart
if (result.length == 13) {
expect(result[1]).to.equal(cryptoItem.CRIexp);
expect(result[2]).to.equal(cryptoItem.venueType);
expect(result[3]).to.equal(cryptoItem.venueCategory1);
expect(result[4]).to.equal(cryptoItem.venueCategory2);
expect(result[5]).to.equal(cryptoItem.periodDuration);
// result[6] LTId
// result[7] ct_periodStart
// result[8] t_qrStart
if (result.length == 12) {
console.log('checking location');
expect(result[10]).to.equal(cryptoItem.locationPhone);
expect(result[11]).to.equal(cryptoItem.locationRegion);
expect(result[12]).to.equal(cryptoItem.locationPIN);
expect(result[9]).to.equal(cryptoItem.locationPhone);
expect(result[10]).to.equal(cryptoItem.locationRegion);
expect(result[11]).to.equal(cryptoItem.locationPIN);
}
resolve();
});
......
......@@ -51,7 +51,7 @@ function start_decoder()
function show_result(msg)
{
var key = ["version", "lspType", "LTId", "staff", "CRIexp", "venueType", "venueCategory1", "venueCategory2", "countryCode", "periodDuration", "ct_periodStart", "t_qrStart", "LTKey"];
var key = ["version", "lspType", "LTId", "staff", "CRIexp", "venueType", "venueCategory1", "venueCategory2", "periodDuration", "ct_periodStart", "t_qrStart", "LTKey"];
for(i in key)
{
......@@ -86,7 +86,6 @@ async function got_content(data)
venueType: -1,
venueCategory1: -1,
venueCategory2: -1,
countryCode: -1,
periodDuration: -1,
ct_periodStart: -1,
t_qrStart: -1,
......@@ -103,7 +102,6 @@ async function got_content(data)
var dec = await decode(lsp.slice(0, 17), lsp.slice(17), sk_sa);
decoded.staff = ((dec[0] & 0x80) >>> 7);
decoded.countryCode = ((dec[0] & 0x3F) << 6) | (dec[1] >>> 2);
decoded.CRIexp = ((dec[1] & 0x3) << 3) | (dec[2] >>> 5);
decoded.venueType = dec[2] & 0x1F;
decoded.venueCategory1 = dec[3] >>> 4;
......
......@@ -35,11 +35,9 @@
<tr><td>staff:</td><td id="staff">N/A</td>
<td>CRIexp:</td><td id="CRIexp">N/A</td></tr>
<tr><td>venueType:</td><td id="venueType">N/A</td>
<td></td><td></td></tr>
<td>periodDuration:</td><td id="periodDuration">N/A</td></tr>
<tr><td>venueCategory1:</td><td id="venueCategory1">N/A</td>
<td>venueCategory2:</td><td id="venueCategory2">N/A</td></tr>
<tr><td>countryCode:</td><td id="countryCode">N/A</td>
<td>periodDuration:</td><td id="periodDuration">N/A</td></tr>
<tr><td>ct_periodStart:</td><td id="ct_periodStart">N/A</td>
<td>t_qrStart:</td><td id="t_qrStart">N/A</td></tr>
<tr><td>locationPhone:</td><td id="locationPhone">N/A</td>
......
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