UNPKG

she_encrypt

Version:

Cryptographic function for ciphering SHE commands args (M1-M3/M4-M5)

166 lines (139 loc) 9.42 kB
# SHE_encrypt [TOC] This NodeJS package contains an implementation for ciphering SHE messages (M1/M2/M3-M4/M5) from CID, Keys and channels. It contains several software components: - one NodeJS prototyped instance SHE_encrypt.js - one command using the SHE_encrypt.js instance For using the 'SHE_encrypt.js' component refers to the test.js test file for API. For using the command refers to the test.ts test file for command examples. For running tests use: ```bash $ npm test ``` ## Installing Use : ```bash $ npm install ``` ## SHE messages generation ```bash # First setup the environment for accessing NodeJS a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/export/repos/all_mac/SHE_encrypt$ . ~/.bashrc Use 'WITH_ALL=y . ~/.bashrc' for defining all dev env Use 'export WITH_NODEJS=y' for defining NodeJS env Use 'export WITH_RUST=y' for defining Rust env Use 'export WITH_JAVA=y' for defining Java rt env Use 'export WITH_PERL=y' for defining Python rt env Use 'export WITH_PYTHON=y' for defining Python rt env Use 'export WITH_GCLOUD=y' for defining GCloud Workstations env Use 'export WITH_LLVM=y' for defining LLVM env And source again bash init file with 'source ~/.bashrc' ... # The WITH_NODEJS=y allows to access NodeJS on my setup. Once set, source bashrc again ... a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/export/repos/all_mac/SHE_encrypt$ export WITH_NODEJS=y # And it will provides access with NodeJS a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/export/repos/all_mac/SHE_encrypt$ . ~/.bashrc Use 'WITH_ALL=y . ~/.bashrc' for defining all dev env Setting up NodeJS ... done! Use 'export WITH_RUST=y' for defining Rust env Use 'export WITH_JAVA=y' for defining Java rt env Use 'export WITH_PERL=y' for defining Python rt env Use 'export WITH_PYTHON=y' for defining Python rt env Use 'export WITH_GCLOUD=y' for defining GCloud Workstations env Use 'export WITH_LLVM=y' for defining LLVM env And source again bash init file with 'source ~/.bashrc' ... # Once done, use npm install for setting up the application a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/export/repos/all_mac/SHE_encrypt$ npm install up to date in 10s 32 packages are looking for funding run `npm fund` for details # The first thing to do is verifying unitary tests are OK ... Use 'npm test' for this purpose: a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/export/repos/all_mac/SHE_encrypt$ npm test > she_encrypt@2.1.0 test > jest PASS ./test.js PASS ./test.ts (8.762 s) Test Suites: 2 passed, 2 total Tests: 54 passed, 54 total Snapshots: 0 total Time: 9.972 s Ran all test suites. # Use the generate_she.js command in the bin directory by passing '-h' argument for displaying help ... a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/export/repos/all_mac/SHE_encrypt$ ./bin/generate_she.js -h generate_she.js: Usage: generate_she.js [<OPTIONS>] <COMMAND> [<ARGUMENTS>] This command aims at generating SHE messages for MAC keys provisi- onning. OPTIONS: -v|--verbose be more verbose when running. Use sev- eral times in order to raise verbosity. COMMANDS: -h|--help display this help message. ARGUMENTS: -K|--iskmac generate a Kmac instead of Kmaster. -k|--key[=]<kmac> Kmac to be provisionned. -m|--master[=]<kmaster> Kmaster to be provisionned. -c|--cid[=]<cid> the CID to be used. -C|--channel[=]<channel> the channel to be used for Kmac. Copyright 2023 RENAULT GROUP / Rmi COHEN SCALI <remi.cohen-scali@renault.com> # Then let's start to generate a new master key: A123456789B123456789C123456789D1 with the old one 1F987654321E987654321D987654321C # CID is 0x2000001 a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/export/repos/all_mac/SHE_encrypt$ ./bin/generate_she.js -k A123456789B123456789C123456789D1 -m 1F987654321E987654321D987654321C -c 0x2000001 CID = 33554433 (0x2000001) M1 = 00000000000000000000000000000011 M2 = c44f5059d23ce5fd079a19cc8b1b5804aacc41183dc38b140c392f16a21c2a92 M3 = fff0a3eb96f502d96e64edac0bc338a2 M4 = 00000000000000000000000000000011a7e57c5f614167ee29e745c8777632e4 M5 = 8ceef7c0a4aa4bef36762e0de066d8db M1|M2|M3 = 00000000000000000000000000000011 c44f5059d23ce5fd079a19cc8b1b5804aacc41183dc38b140c392f16a21c2a92 fff0a3eb96f502d96e64edac0bc338a2 M4|M5 = 00000000000000000000000000000011a7e57c5f614167ee29e745c8777632e4 8ceef7c0a4aa4bef36762e0de066d8db # Then generate a Kmac key for channel 1: 123456789B123456789C123456789D12 using the new master key: A123456789B123456789C123456789D1 a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/export/repos/all_mac/SHE_encrypt$ ./bin/generate_she.js -K -k 123456789B123456789C123456789D12 -m A123456789B123456789C123456789D1 -c 0x2000002 -C 1 CID = 33554434 (0x2000002) M1 = 00000000000000000000000000000041 M2 = eeb96ef0669d947bdb5986718728728067125e06117dc0f61318952c008f7e96 M3 = 546a16ca23f1e3b890c74cb7a57840d4 M4 = 0000000000000000000000000000004131c320f97774c22a51d4c1a8da8428f4 M5 = 480aaf9db1b896f1829355f132437802 M1|M2|M3 = 00000000000000000000000000000041 eeb96ef0669d947bdb5986718728728067125e06117dc0f61318952c008f7e96 546a16ca23f1e3b890c74cb7a57840d4 M4|M5 = 0000000000000000000000000000004131c320f97774c22a51d4c1a8da8428f4 480aaf9db1b896f1829355f132437802 # Then generate a Kmac key for channel 2: 23456789B123456789C123456789D123 using the new master key: A123456789B123456789C123456789D1 a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/export/repos/all_mac/SHE_encrypt$ ./bin/generate_she.js -K -k 23456789B123456789C123456789D123 -m A123456789B123456789C123456789D1 -c 0x2000003 -C 2 CID = 33554435 (0x2000003) M1 = 00000000000000000000000000000051 M2 = d719bb4cd7ee7466235668e914c8da40db467e3ab4738cbc0b3e9b4f2e32605b M3 = ce732465323c03b7df4380776c05f6e4 M4 = 000000000000000000000000000000517c7c0878a832a4f20498558698949418 M5 = 4ec5c0f63578cc66e4293bb0761e61f8 M1|M2|M3 = 00000000000000000000000000000051 d719bb4cd7ee7466235668e914c8da40db467e3ab4738cbc0b3e9b4f2e32605b ce732465323c03b7df4380776c05f6e4 M4|M5 = 000000000000000000000000000000517c7c0878a832a4f20498558698949418 4ec5c0f63578cc66e4293bb0761e61f8 # Then generate a Kmac key for channel 3: 3456789B123456789C123456789D1234 using the new master key: A123456789B123456789C123456789D1 a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/export/repos/all_mac/SHE_encrypt$ ./bin/generate_she.js -K -k 3456789B123456789C123456789D1234 -m A123456789B123456789C123456789D1 -c 0x2000004 -C 3 CID = 33554436 (0x2000004) M1 = 00000000000000000000000000000061 M2 = 721fddd669375ee9a4102c756470f45718e8a40ff19995324a33af0b1ed5959d M3 = e73a7ceffb2f30de4f7a94a68826e5b9 M4 = 0000000000000000000000000000006144a2d4841d4e708aeb1c7c7a0848e055 M5 = 3dc7c6cdd676120f71effba929a191cc M1|M2|M3 = 00000000000000000000000000000061 721fddd669375ee9a4102c756470f45718e8a40ff19995324a33af0b1ed5959d e73a7ceffb2f30de4f7a94a68826e5b9 M4|M5 = 0000000000000000000000000000006144a2d4841d4e708aeb1c7c7a0848e055 3dc7c6cdd676120f71effba929a191cc # Then generate a Kmac key for channel 4: 456789B123456789C123456789D12345 using the new master key: A123456789B123456789C123456789D1 a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/export/repos/all_mac/SHE_encrypt$ ./bin/generate_she.js -K -k 456789B123456789C123456789D12345 -m A123456789B123456789C123456789D1 -c 0x2000005 -C 4 CID = 33554437 (0x2000005) M1 = 00000000000000000000000000000071 M2 = d22671dc00fcc446d965a621af39c29aac811e52c989b47307377b9eaa6242dd M3 = a137c4c9c0fdc04daa949bd62c5230a9 M4 = 000000000000000000000000000000717b4b9364cdf0bf0d8959c5a8afe47ba3 M5 = 181a11d0721ce93fa6a8d32e4f1ba57a M1|M2|M3 = 00000000000000000000000000000071 d22671dc00fcc446d965a621af39c29aac811e52c989b47307377b9eaa6242dd a137c4c9c0fdc04daa949bd62c5230a9 M4|M5 = 000000000000000000000000000000717b4b9364cdf0bf0d8959c5a8afe47ba3 181a11d0721ce93fa6a8d32e4f1ba57a # Finally generate a Kmac key for channel 5: 56789B123456789C123456789D123456 using the new master key: A123456789B123456789C123456789D1 a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/export/repos/all_mac/SHE_encrypt$ ./bin/generate_she.js -K -k 56789B123456789C123456789D123456 -m A123456789B123456789C123456789D1 -c 0x2000006 -C 5 CID = 33554438 (0x2000006) M1 = 00000000000000000000000000000081 M2 = 14d7f1abf977ced2a85d1bfbfae1e9f22eea974476f58cec023ca846017df276 M3 = a5cd817929cdec2e64ed3dc4c7e4e974 M4 = 00000000000000000000000000000081139f68c8839f05dbf4867cc5faf21537 M5 = 14cc3f1eab3332d4acef12d55a221601 M1|M2|M3 = 00000000000000000000000000000081 14d7f1abf977ced2a85d1bfbfae1e9f22eea974476f58cec023ca846017df276 a5cd817929cdec2e64ed3dc4c7e4e974 M4|M5 = 00000000000000000000000000000081139f68c8839f05dbf4867cc5faf21537 14cc3f1eab3332d4acef12d55a221601 a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/export/repos/all_mac/SHE_encrypt$ ```