UNPKG

she_decrypt

Version:

Pure JavaScript implementation for deciphering SHE arguments (M1, M2, etc)

1,240 lines (1,167 loc) 52.7 kB
#!/usr/bin/env node /**@FileInfo * * nominal.test.ts * * Tests for the she_decrypt script. This file contains the nominal tests for * testing the she_decrypt command behaviour. */ ((root) => { "use strict"; const FS = require('fs'); const SHE = require('../SHE_decrypt.js'); const helpstring1 = "she_decrypt: usage: she_decrypt [OPTIONS] [ARGUMENTS] \n"+ " This script allows to parse CAN frames trace log file and extract from \n"+ " it the provisionning UDS frames, then extracting the SHE messages from \n"+ " it. \n"+ " OPTIONS: \n"+ " [-v|--verbose=[<integer>]] be more verbose when running. \n"+ " [-h|--help] display this help message. \n"+ " [-c|--cid] display the CID of the SHE message. \n"+ " [-f|--fid] display the FID of the SHE message. \n"+ " [-C|--channel] display the channel of the SHE message. \n"+ " \n"+ " ARGUMENTS: \n"+ " [-m|--msg=[<SHEmsg>]] SHE message to process and decipher. \n"+ " [-M|--msg-file=[<SHEfile>]] file containing the SHE message to \n"+ " decipher. If filename provided is set to \n"+ " '-' the STDIN is used for reading the \n"+ " SHE message. This is the default. \n"+ " [-K|--Kmaster=[<key>]] Kmaster to use to decipher the SHE msg. \n"+ " By default the Kmaster key has value: \n"+ " 0153F7000099ED9F320451AA8A7D9707 \n"+ " [-4|--m4=[<M4>]] Verify the provided M4 value. \n"+ " [-5|--m5=[<M5>]] Verify the provided M5 value. \n"+ " \n"+ "Copyright ©2023-2024 RENAULT GROUP / Rémi COHEN SCALI <remi.cohen-scali@renault.com> \n" /** * TSDECNom001: * Nominal test for help message display with short option */ test('TSDECNom001: Nominal test for displaying help message (-h)', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "-h" ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe(helpstring1); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom002: * Nominal test for help message display with long option */ test('TSDECNom002: Nominal test for displaying help message (--help)', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "--help" ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe(helpstring1); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom003: * Nominal test for SHE message on STDIN from tests/msg.txt decipher with default key * * $ cat tests/msg.txt | ./bin/she_decrypt */ test('TSDECNom003: Nominal test for deciphering SHE message provided on STDIN (from tests/msg.txt)', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt" ], { stdio: [ FS.openSync("tests/msg.txt", "r"), 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("Kmaster: 0f90af60245edfd794c4e606202371ae\n"+ "Kmac: ed28a6fbae79f25c17112917711a54ad\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom004: * Nominal test for SHE message on STDIN from tests/msg2.txt decipher with default key * * $ cat tests/msg2.txt | ./bin/she_decrypt */ test('TSDECNom004: Nominal test for deciphering SHE message provided on STDIN (from tests/msg2.txt)', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt" ], { stdio: [ FS.openSync("tests/msg2.txt", "r"), 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("Kmaster: c85c499d7ed56116302371372834c3ae\n"+ "Kmac: 99900b0679387f91ea4db0119e07979a\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom005: * Nominal test for SHE message on STDIN from tests/msg.txt decipher with default key with CID & FID * * $ cat tests/msg.txt | ./bin/she_decrypt -cf */ test('TSDECNom005: Nominal test for deciphering SHE message provided on STDIN (from tests/msg.txt) with CID/FID', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "-cf" ], { stdio: [ FS.openSync("tests/msg.txt", "r"), 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("CID = 33554565 (0x2000085)\n"+ "FID = 0\n"+ "Kmaster: 0f90af60245edfd794c4e606202371ae\n"+ "CID = 33554567 (0x2000087)\n"+ "FID = 2\n"+ "Kmac: ed28a6fbae79f25c17112917711a54ad\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom006: * Nominal test for SHE message on STDIN from tests/msg2.txt decipher with default key with CID & FID * * $ cat tests/msg2.txt | ./bin/she_decrypt -cf */ test('TSDECNom006: Nominal test for deciphering SHE message provided on STDIN (from tests/msg2.txt)', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "-cf" ], { stdio: [ FS.openSync("tests/msg2.txt", "r"), 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("CID = 33554462 (0x200001e)\n"+ "FID = 0\n"+ "Kmaster: c85c499d7ed56116302371372834c3ae\n"+ "CID = 33554464 (0x2000020)\n"+ "FID = 2\n"+ "Kmac: 99900b0679387f91ea4db0119e07979a\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom007: * Nominal test for SHE message on STDIN from tests/msg2.txt decipher with default key with CID & FID * * $ cat tests/msg2.txt | ./bin/she_decrypt --cid --fid */ test('TSDECNom007: Nominal test for deciphering SHE message provided on STDIN (from tests/msg2.txt)', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "--cid", "--fid" ], { stdio: [ FS.openSync("tests/msg2.txt", "r"), 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("CID = 33554462 (0x200001e)\n"+ "FID = 0\n"+ "Kmaster: c85c499d7ed56116302371372834c3ae\n"+ "CID = 33554464 (0x2000020)\n"+ "FID = 2\n"+ "Kmac: 99900b0679387f91ea4db0119e07979a\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom008: * Nominal test for SHE message in tests/msg.txt decipher with default key * * $ ./bin/she_decrypt -M tests/msg.txt */ test('TSDECNom008: Nominal test for deciphering SHE message provided from tests/msg.txt', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "-M", "tests/msg.txt" ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("Kmaster: 0f90af60245edfd794c4e606202371ae\n"+ "Kmac: ed28a6fbae79f25c17112917711a54ad\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom009: * Nominal test for SHE message in tests/msg2.txt decipher with default key * * $ ./bin/she_decrypt -M tests/msg2.txt */ test('TSDECNom009: Nominal test for deciphering SHE message provided from tests/msg2.txt', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "-M", "tests/msg2.txt" ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("Kmaster: c85c499d7ed56116302371372834c3ae\n"+ "Kmac: 99900b0679387f91ea4db0119e07979a\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom010: * Nominal test for SHE message in tests/msg.txt decipher with default key * * $ ./bin/she_decrypt -cf -M tests/msg.txt */ test('TSDECNom010: Nominal test for deciphering SHE message provided on STDIN (from tests/msg.txt) with CID/FID', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "-cf", "-M", "tests/msg.txt" ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("CID = 33554565 (0x2000085)\n"+ "FID = 0\n"+ "Kmaster: 0f90af60245edfd794c4e606202371ae\n"+ "CID = 33554567 (0x2000087)\n"+ "FID = 2\n"+ "Kmac: ed28a6fbae79f25c17112917711a54ad\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom011: * Nominal test for SHE message in tests/msg2.txt decipher with default key * * $ ./bin/she_decrypt -cf -M tests/msg2.txt */ test('TSDECNom011: Nominal test for deciphering SHE message provided from tests/msg2.txt) with CID/FID', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "-cf", "-M", "tests/msg2.txt" ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("CID = 33554462 (0x200001e)\n"+ "FID = 0\n"+ "Kmaster: c85c499d7ed56116302371372834c3ae\n"+ "CID = 33554464 (0x2000020)\n"+ "FID = 2\n"+ "Kmac: 99900b0679387f91ea4db0119e07979a\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom012: * Nominal test for SHE message in tests/msg.txt decipher with default key * * $ ./bin/she_decrypt --cid --fid --msg-file tests/msg.txt */ test('TSDECNom012: Nominal test for deciphering SHE message provided on STDIN (from tests/msg.txt) with CID/FID (long)', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "--cid", "--fid", "--msg-file", "tests/msg.txt" ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("CID = 33554565 (0x2000085)\n"+ "FID = 0\n"+ "Kmaster: 0f90af60245edfd794c4e606202371ae\n"+ "CID = 33554567 (0x2000087)\n"+ "FID = 2\n"+ "Kmac: ed28a6fbae79f25c17112917711a54ad\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom013: * Nominal test for SHE message in tests/msg2.txt decipher with default key * * $ ./bin/she_decrypt -cf -M tests/msg2.txt */ test('TSDECNom013: Nominal test for deciphering SHE message provided from tests/msg2.txt) with CID/FID (long)', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "--cid", "--fid", "--msg-file", "tests/msg2.txt" ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("CID = 33554462 (0x200001e)\n"+ "FID = 0\n"+ "Kmaster: c85c499d7ed56116302371372834c3ae\n"+ "CID = 33554464 (0x2000020)\n"+ "FID = 2\n"+ "Kmac: 99900b0679387f91ea4db0119e07979a\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom014: * Nominal test for help message display with short option (verbose) */ test('TSDECNom014: Nominal test for displaying help message (-h) verbose', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "-vh" ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("she_decrypt: info: verbosity (-v) increased to 1\n"+ "she_decrypt: info: Help requested.\n"+ helpstring1); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom015: * Nominal test for help message display with long option (verbose) */ test('TSDECNom015: Nominal test for displaying help message (--help) verbose', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "--verbose", "--help" ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("she_decrypt: info: verbosity (-v) increased to 1\n"+ "she_decrypt: info: Help requested.\n"+ helpstring1); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom016: * Nominal test for SHE message on STDIN from tests/msg.txt decipher with default key (verbose) * * $ cat tests/msg.txt | ./bin/she_decrypt -v */ test('TSDECNom016: Nominal test for deciphering SHE message provided on STDIN (from tests/msg.txt) verbose', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "-v" ], { stdio: [ FS.openSync("tests/msg.txt", "r"), 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("she_decrypt: info: verbosity (-v) increased to 1\n"+ "she_decrypt: info: new message read from file '-' = '00000000000000000000000000000011e9550f568a7cb43c8e82fc97f09ea71d63ca54eeaff2963a95fa68d64833950a17ad655772b0c644632c855c0da059aa'\n"+ "she_decrypt: info: new message read from file '-' = '00000000000000000000000000000041f2d9f8203a15339a63f8d3a649c687b397f25c4d4c84c3800daa5fc684e081979469a496ea1908b9a643e036f50176b6'\n"+ "Kmaster: 0f90af60245edfd794c4e606202371ae\n"+ "Kmac: ed28a6fbae79f25c17112917711a54ad\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom017: * Nominal test for SHE message on STDIN from tests/msg2.txt decipher with default key (verbose) * * $ cat tests/msg2.txt | ./bin/she_decrypt -v */ test('TSDECNom017: Nominal test for deciphering SHE message provided on STDIN (from tests/msg2.txt) verbose', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "-v" ], { stdio: [ FS.openSync("tests/msg2.txt", "r"), 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("she_decrypt: info: verbosity (-v) increased to 1\nshe_decrypt: info: new message read from file '-' = '0000000000000000000000000000001114c192927bf31676d3d63a2575b5f84e8a8be9da158e3711b4e602ba068af1fe4ae3eff29ec6c613cb03c4fd42680750'\n"+ "she_decrypt: info: new message read from file '-' = '00000000000000000000000000000041d0712612d44d059fd935ade25c1425dd8f6ff806fb9977181489902088883a5d7283f224c7e7df8f6c5a906ba932131a'\n"+ "Kmaster: c85c499d7ed56116302371372834c3ae\n"+ "Kmac: 99900b0679387f91ea4db0119e07979a\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom018: * Nominal test for SHE message on STDIN from tests/msg.txt decipher with default key with CID & FID (verbose) * * $ cat tests/msg.txt | ./bin/she_decrypt -vcf */ test('TSDECNom018: Nominal test for deciphering SHE message provided on STDIN (from tests/msg.txt) with CID/FID verbose', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "-vcf" ], { stdio: [ FS.openSync("tests/msg.txt", "r"), 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("she_decrypt: info: verbosity (-v) increased to 1\n"+ "she_decrypt: info: CID display (-c) requested.\n"+ "she_decrypt: info: FID display (-c) requested.\n"+ "she_decrypt: info: new message read from file '-' = '00000000000000000000000000000011e9550f568a7cb43c8e82fc97f09ea71d63ca54eeaff2963a95fa68d64833950a17ad655772b0c644632c855c0da059aa'\n"+ "she_decrypt: info: new message read from file '-' = '00000000000000000000000000000041f2d9f8203a15339a63f8d3a649c687b397f25c4d4c84c3800daa5fc684e081979469a496ea1908b9a643e036f50176b6'\n"+ "CID = 33554565 (0x2000085)\n"+ "FID = 0\n"+ "Kmaster: 0f90af60245edfd794c4e606202371ae\n"+ "CID = 33554567 (0x2000087)\n"+ "FID = 2\n"+ "Kmac: ed28a6fbae79f25c17112917711a54ad\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom019: * Nominal test for SHE message on STDIN from tests/msg2.txt decipher with default key with CID & FID (verbose) * * $ cat tests/msg2.txt | ./bin/she_decrypt -vcf */ test('TSDECNom019: Nominal test for deciphering SHE message provided on STDIN (from tests/msg2.txt) verbose', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "-vcf" ], { stdio: [ FS.openSync("tests/msg2.txt", "r"), 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("she_decrypt: info: verbosity (-v) increased to 1\n"+ "she_decrypt: info: CID display (-c) requested.\n"+ "she_decrypt: info: FID display (-c) requested.\n"+ "she_decrypt: info: new message read from file '-' = '0000000000000000000000000000001114c192927bf31676d3d63a2575b5f84e8a8be9da158e3711b4e602ba068af1fe4ae3eff29ec6c613cb03c4fd42680750'\n"+ "she_decrypt: info: new message read from file '-' = '00000000000000000000000000000041d0712612d44d059fd935ade25c1425dd8f6ff806fb9977181489902088883a5d7283f224c7e7df8f6c5a906ba932131a'\n"+ "CID = 33554462 (0x200001e)\n"+ "FID = 0\n"+ "Kmaster: c85c499d7ed56116302371372834c3ae\n"+ "CID = 33554464 (0x2000020)\n"+ "FID = 2\n"+ "Kmac: 99900b0679387f91ea4db0119e07979a\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom020: * Nominal test for SHE message on STDIN from tests/msg2.txt decipher with default key with CID & FID (verbose) * * $ cat tests/msg2.txt | ./bin/she_decrypt --verbose --cid --fid */ test('TSDECNom020: Nominal test for deciphering SHE message provided on STDIN (from tests/msg2.txt) verbose', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "--verbose", "--cid", "--fid" ], { stdio: [ FS.openSync("tests/msg2.txt", "r"), 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("she_decrypt: info: verbosity (-v) increased to 1\n"+ "she_decrypt: info: CID display (-c) requested.\n"+ "she_decrypt: info: FID display (-c) requested.\n"+ "she_decrypt: info: new message read from file '-' = '0000000000000000000000000000001114c192927bf31676d3d63a2575b5f84e8a8be9da158e3711b4e602ba068af1fe4ae3eff29ec6c613cb03c4fd42680750'\n"+ "she_decrypt: info: new message read from file '-' = '00000000000000000000000000000041d0712612d44d059fd935ade25c1425dd8f6ff806fb9977181489902088883a5d7283f224c7e7df8f6c5a906ba932131a'\n"+ "CID = 33554462 (0x200001e)\n"+ "FID = 0\n"+ "Kmaster: c85c499d7ed56116302371372834c3ae\n"+ "CID = 33554464 (0x2000020)\n"+ "FID = 2\n"+ "Kmac: 99900b0679387f91ea4db0119e07979a\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom021: * Nominal test for SHE message in tests/msg.txt decipher with default key (verbose) * * $ ./bin/she_decrypt -v -M tests/msg.txt */ test('TSDECNom021: Nominal test for deciphering SHE message provided from tests/msg.txt (verbose)', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "-v", "-M", "tests/msg.txt" ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("she_decrypt: info: verbosity (-v) increased to 1\n"+ "she_decrypt: info: message file (-M) set to 'tests/msg.txt'\n"+ "she_decrypt: info: new message read from file 'tests/msg.txt' = '00000000000000000000000000000011e9550f568a7cb43c8e82fc97f09ea71d63ca54eeaff2963a95fa68d64833950a17ad655772b0c644632c855c0da059aa'\n"+ "she_decrypt: info: new message read from file 'tests/msg.txt' = '00000000000000000000000000000041f2d9f8203a15339a63f8d3a649c687b397f25c4d4c84c3800daa5fc684e081979469a496ea1908b9a643e036f50176b6'\n"+ "Kmaster: 0f90af60245edfd794c4e606202371ae\n"+ "Kmac: ed28a6fbae79f25c17112917711a54ad\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom022: * Nominal test for SHE message in tests/msg2.txt decipher with default key (verbose) * * $ ./bin/she_decrypt -v -M tests/msg2.txt */ test('TSDECNom022: Nominal test for deciphering SHE message provided from tests/msg2.txt (verbose)', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "-v", "-M", "tests/msg2.txt" ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("she_decrypt: info: verbosity (-v) increased to 1\n"+ "she_decrypt: info: message file (-M) set to 'tests/msg2.txt'\n"+ "she_decrypt: info: new message read from file 'tests/msg2.txt' = '0000000000000000000000000000001114c192927bf31676d3d63a2575b5f84e8a8be9da158e3711b4e602ba068af1fe4ae3eff29ec6c613cb03c4fd42680750'\n"+ "she_decrypt: info: new message read from file 'tests/msg2.txt' = '00000000000000000000000000000041d0712612d44d059fd935ade25c1425dd8f6ff806fb9977181489902088883a5d7283f224c7e7df8f6c5a906ba932131a'\n"+ "Kmaster: c85c499d7ed56116302371372834c3ae\n"+ "Kmac: 99900b0679387f91ea4db0119e07979a\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom023: * Nominal test for SHE message in tests/msg.txt decipher with default key (verbose) * * $ ./bin/she_decrypt -vcf -M tests/msg.txt */ test('TSDECNom023: Nominal test for deciphering SHE message provided on STDIN (from tests/msg.txt) with CID/FID verbose', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "-vcf", "-M", "tests/msg.txt" ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("she_decrypt: info: verbosity (-v) increased to 1\n"+ "she_decrypt: info: CID display (-c) requested.\n"+ "she_decrypt: info: FID display (-c) requested.\n"+ "she_decrypt: info: message file (-M) set to 'tests/msg.txt'\n"+ "she_decrypt: info: new message read from file 'tests/msg.txt' = '00000000000000000000000000000011e9550f568a7cb43c8e82fc97f09ea71d63ca54eeaff2963a95fa68d64833950a17ad655772b0c644632c855c0da059aa'\n"+ "she_decrypt: info: new message read from file 'tests/msg.txt' = '00000000000000000000000000000041f2d9f8203a15339a63f8d3a649c687b397f25c4d4c84c3800daa5fc684e081979469a496ea1908b9a643e036f50176b6'\n"+ "CID = 33554565 (0x2000085)\n"+ "FID = 0\n"+ "Kmaster: 0f90af60245edfd794c4e606202371ae\n"+ "CID = 33554567 (0x2000087)\n"+ "FID = 2\n"+ "Kmac: ed28a6fbae79f25c17112917711a54ad\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom024: * Nominal test for SHE message in tests/msg2.txt decipher with default key (verbose) * * $ ./bin/she_decrypt -vcf -M tests/msg2.txt */ test('TSDECNom024: Nominal test for deciphering SHE message provided from tests/msg2.txt) with CID/FID', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "-vcf", "-M", "tests/msg2.txt" ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("she_decrypt: info: verbosity (-v) increased to 1\n"+ "she_decrypt: info: CID display (-c) requested.\n"+ "she_decrypt: info: FID display (-c) requested.\n"+ "she_decrypt: info: message file (-M) set to 'tests/msg2.txt'\n"+ "she_decrypt: info: new message read from file 'tests/msg2.txt' = '0000000000000000000000000000001114c192927bf31676d3d63a2575b5f84e8a8be9da158e3711b4e602ba068af1fe4ae3eff29ec6c613cb03c4fd42680750'\n"+ "she_decrypt: info: new message read from file 'tests/msg2.txt' = '00000000000000000000000000000041d0712612d44d059fd935ade25c1425dd8f6ff806fb9977181489902088883a5d7283f224c7e7df8f6c5a906ba932131a'\n"+ "CID = 33554462 (0x200001e)\n"+ "FID = 0\n"+ "Kmaster: c85c499d7ed56116302371372834c3ae\n"+ "CID = 33554464 (0x2000020)\n"+ "FID = 2\n"+ "Kmac: 99900b0679387f91ea4db0119e07979a\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom025: * Nominal test for SHE message in tests/msg.txt decipher with default key (verbose) * * $ ./bin/she_decrypt --verbose --cid --fid --msg-file tests/msg.txt */ test('TSDECNom025: Nominal test for deciphering SHE message provided on STDIN (from tests/msg.txt) with CID/FID (long verbose)', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "--verbose", "--cid", "--fid", "--msg-file", "tests/msg.txt" ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("she_decrypt: info: verbosity (-v) increased to 1\n"+ "she_decrypt: info: CID display (-c) requested.\n"+ "she_decrypt: info: FID display (-c) requested.\n"+ "she_decrypt: info: message file (-M) set to 'tests/msg.txt'\n"+ "she_decrypt: info: new message read from file 'tests/msg.txt' = '00000000000000000000000000000011e9550f568a7cb43c8e82fc97f09ea71d63ca54eeaff2963a95fa68d64833950a17ad655772b0c644632c855c0da059aa'\n"+ "she_decrypt: info: new message read from file 'tests/msg.txt' = '00000000000000000000000000000041f2d9f8203a15339a63f8d3a649c687b397f25c4d4c84c3800daa5fc684e081979469a496ea1908b9a643e036f50176b6'\n"+ "CID = 33554565 (0x2000085)\n"+ "FID = 0\n"+ "Kmaster: 0f90af60245edfd794c4e606202371ae\n"+ "CID = 33554567 (0x2000087)\n"+ "FID = 2\n"+ "Kmac: ed28a6fbae79f25c17112917711a54ad\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom026: * Nominal test for SHE message in tests/msg2.txt decipher with default key (verbose) * * $ ./bin/she_decrypt --verbose --cid --fid --msg-file tests/msg2.txt */ test('TSDECNom026: Nominal test for deciphering SHE message provided from tests/msg2.txt) with CID/FID (long verbose)', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "--verbose", "--cid", "--fid", "--msg-file", "tests/msg2.txt" ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("she_decrypt: info: verbosity (-v) increased to 1\n"+ "she_decrypt: info: CID display (-c) requested.\n"+ "she_decrypt: info: FID display (-c) requested.\n"+ "she_decrypt: info: message file (-M) set to 'tests/msg2.txt'\n"+ "she_decrypt: info: new message read from file 'tests/msg2.txt' = '0000000000000000000000000000001114c192927bf31676d3d63a2575b5f84e8a8be9da158e3711b4e602ba068af1fe4ae3eff29ec6c613cb03c4fd42680750'\n"+ "she_decrypt: info: new message read from file 'tests/msg2.txt' = '00000000000000000000000000000041d0712612d44d059fd935ade25c1425dd8f6ff806fb9977181489902088883a5d7283f224c7e7df8f6c5a906ba932131a'\n"+ "CID = 33554462 (0x200001e)\n"+ "FID = 0\n"+ "Kmaster: c85c499d7ed56116302371372834c3ae\n"+ "CID = 33554464 (0x2000020)\n"+ "FID = 2\n"+ "Kmac: 99900b0679387f91ea4db0119e07979a\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom027: * Nominal test for SHE message in tests/msg2.txt decipher with default key * * $ ./bin/she_decrypt -cfC -M tests/msg2.txt */ test('TSDECNom027: Nominal test for deciphering SHE message provided from tests/msg2.txt) with CID/FID (long)', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "--cid", "--fid", "--channel", "--msg-file", "tests/msg2.txt" ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("CID = 33554462 (0x200001e)\n"+ "FID = 0\n"+ "Kmaster: c85c499d7ed56116302371372834c3ae\n"+ "CID = 33554464 (0x2000020)\n"+ "FID = 2\n"+ "Channel = 1\n"+ "Kmac: 99900b0679387f91ea4db0119e07979a\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom028: * Nominal test for valid M4 SHE message deciphered with default key * * $ ./bin/she_decrypt --cid --fid --channel --msg 0000000000000000000000000000001114c192927bf31676d3d63a2575b5f84e8a8be9da158e3711b4e602ba068af1fe4ae3eff29ec6c613cb03c4fd42680750 --m4 00000000000000000000000000000011ef6e5504e37f5b686959e17b0563c665 */ test('TSDECNom028: Error test for valid M4 deciphering SHE message) with CID/FID/Channel (long)', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "--cid", "--fid", "--channel", "--msg", "0000000000000000000000000000001114c192927bf31676d3d63a2575b5f84e8a8be9da158e3711b4e602ba068af1fe4ae3eff29ec6c613cb03c4fd42680750", "--m4", "00000000000000000000000000000011ef6e5504e37f5b686959e17b0563c665" ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("CID = 33554462 (0x200001e)\n"+ "FID = 0\n"+ "Kmaster: c85c499d7ed56116302371372834c3ae\n"+ "M4: \x1b[1;32mValid\x1b[m (00000000000000000000000000000011ef6e5504e37f5b686959e17b0563c665)\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom029: * Nominal test for valid M4 SHE message deciphered with default key * * $ ./bin/she_decrypt -cfCm 0000000000000000000000000000001114c192927bf31676d3d63a2575b5f84e8a8be9da158e3711b4e602ba068af1fe4ae3eff29ec6c613cb03c4fd42680750 -4 00000000000000000000000000000011ef6e5504e37f5b686959e17b0563c665 */ test('TSDECNom029: Nominal test for valid M4 deciphering SHE message) with CID/FID/Channel (short)', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "-cfCm", "0000000000000000000000000000001114c192927bf31676d3d63a2575b5f84e8a8be9da158e3711b4e602ba068af1fe4ae3eff29ec6c613cb03c4fd42680750", "-4", "00000000000000000000000000000011ef6e5504e37f5b686959e17b0563c665" ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("CID = 33554462 (0x200001e)\n"+ "FID = 0\n"+ "Kmaster: c85c499d7ed56116302371372834c3ae\n"+ "M4: \x1b[1;32mValid\x1b[m (00000000000000000000000000000011ef6e5504e37f5b686959e17b0563c665)\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom030: * Nominal test for valid M4/M5 SHE messages from msg2.txt deciphered with default key * * $ ./bin/she_decrypt -cfCM tests/msg2.txt -4 00000000000000000000000000000011ef6e5504e37f5b686959e17b0563c665 -4 00000000000000000000000000000041a54c939fa273c1f8b452585ec7f616b9 -5 970c6d07e6ac7408bd0ffcaf71d6ffb1 -5 45d3d4b4f8338051137d57af68d9d8f8 */ test('TSDECNom030: Nominal test for valid M4/M5 deciphering SHE messages from msg2.txt) with CID/FID/Channel (short)', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "-cfCM", "tests/msg2.txt", "-4", "00000000000000000000000000000011ef6e5504e37f5b686959e17b0563c665", "-4", "00000000000000000000000000000041a54c939fa273c1f8b452585ec7f616b9", "-5", "970c6d07e6ac7408bd0ffcaf71d6ffb1", "-5", "45d3d4b4f8338051137d57af68d9d8f8", ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("CID = 33554462 (0x200001e)\n"+ "FID = 0\n"+ "Kmaster: c85c499d7ed56116302371372834c3ae\n"+ "M4: \x1b[1;32mValid\x1b[m (00000000000000000000000000000011ef6e5504e37f5b686959e17b0563c665)\n"+ "M5: \x1b[1;32mValid\x1b[m (970c6d07e6ac7408bd0ffcaf71d6ffb1)\n"+ "CID = 33554464 (0x2000020)\n"+ "FID = 2\n"+ "Channel = 1\n"+ "Kmac: 99900b0679387f91ea4db0119e07979a\n"+ "M4: \x1b[1;32mValid\x1b[m (00000000000000000000000000000041a54c939fa273c1f8b452585ec7f616b9)\n"+ "M5: \x1b[1;32mValid\x1b[m (45d3d4b4f8338051137d57af68d9d8f8)\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom031: * Nominal test for valid M4/M5 SHE messages from msg2.txt deciphered with default key * * $ ./bin/she_decrypt --cid --fid --channel --msd-file tests/msg2.txt --m4 00000000000000000000000000000011ef6e5504e37f5b686959e17b0563c665 --m4 00000000000000000000000000000041a54c939fa273c1f8b452585ec7f616b9 --m5 970c6d07e6ac7408bd0ffcaf71d6ffb1 --m5 45d3d4b4f8338051137d57af68d9d8f8 */ test('TSDECNom030: Nominal test for valid M4/M5 deciphering SHE messages from msg2.txt) with CID/FID/Channel (long)', () => { const {spawnSync} = require('node:child_process'); const subproc = spawnSync( "node", [ "./bin/she_decrypt", "--cid", "--fid", "--channel", "--msg-file", "tests/msg2.txt", "--m4", "00000000000000000000000000000011ef6e5504e37f5b686959e17b0563c665", "--m4", "00000000000000000000000000000041a54c939fa273c1f8b452585ec7f616b9", "--m5", "970c6d07e6ac7408bd0ffcaf71d6ffb1", "--m5", "45d3d4b4f8338051137d57af68d9d8f8", ], { stdio: [ 'ignore', 'pipe', 'pipe' ] } ); expect(subproc.status).toBe(0x00); expect(subproc.stdout.toString()).toBe("CID = 33554462 (0x200001e)\n"+ "FID = 0\n"+ "Kmaster: c85c499d7ed56116302371372834c3ae\n"+ "M4: \x1b[1;32mValid\x1b[m (00000000000000000000000000000011ef6e5504e37f5b686959e17b0563c665)\n"+ "M5: \x1b[1;32mValid\x1b[m (970c6d07e6ac7408bd0ffcaf71d6ffb1)\n"+ "CID = 33554464 (0x2000020)\n"+ "FID = 2\n"+ "Channel = 1\n"+ "Kmac: 99900b0679387f91ea4db0119e07979a\n"+ "M4: \x1b[1;32mValid\x1b[m (00000000000000000000000000000041a54c939fa273c1f8b452585ec7f616b9)\n"+ "M5: \x1b[1;32mValid\x1b[m (45d3d4b4f8338051137d57af68d9d8f8)\n"); expect(subproc.stderr.toString()).toBe(""); } ); /** * TSDECNom032: * Nominal test for valid M5 SHE message deciphered with default key * * $ ./bin/she_decrypt --cid --fid --channel --msg 0000000000000000000000000000001114c192927bf31676d3d63a2575b5f84e8a8be9da158e3711b4e602ba068af1fe4ae3eff29ec6c613cb03c4fd42680750 --m5 970c6d07e6ac7408bd0ffcaf71d6ffb1 */ test('TSDECNom032: Error test for valid M5 deciphering SHE message) with CID/FID/Channel (long)', () => { const {spawnSync} = require('node:child_process'); const subproc =