skokov3812 / encrypted-smiley-secure-protocol

Node.JS library Encrypted Smiley ® Secure Protocol (eSSP, SSP)
MIT License
39 stars 32 forks source link

Encrypted smiley secure protocol not working with Linux #2

Closed Kainnan closed 4 years ago

Kainnan commented 4 years ago

Im experiencing some issues with this code on linux based systems.

At first, the randomPrime functions not always returns a prime number, that should be a problem?

Also in the debug mode, my routine always ends with a 232 error, as bellow:

Port opened! COM <- 7f0001116608 SYNC 0 COM -> 7f0001f0200a | RAW COM -> 7f0001f0200a SYNC { success: true, status: 'OK', command: 'SYNC', info: {} } COM <- 7f000206061b94 HOST_PROTOCOL_VERSION 0 COM -> 7f0001f0200a | RAW COM -> 7f0001f0200a HOST_PROTOCOL_VERSION { success: true, status: 'OK', command: 'HOST_PROTOCOL_VERSION', info: {} } COM <- 7f80094a6b000000000000000e36 SET_GENERATOR 0 COM -> 7f8001f02380 | RAW COM -> 7f8001f02380 SET_GENERATOR { success: true, status: 'OK', command: 'SET_GENERATOR', info: {} } COM <- 7f00094b0d0000000000000012f1 SET_MODULUS 0 COM -> 7f0001 | RAW COM -> f0200a | RAW COM -> 7f0001f0200a SET_MODULUS { success: true, status: 'OK', command: 'SET_MODULUS', info: {} } COM <- 7f80094c03000000000000002aa2 REQUEST_KEY_EXCHANGE 0 COM -> 7f8009f0 | RAW COM -> 0300000000000000a392 | RAW COM -> 7f8009f00300000000000000a392 REQUEST_KEY_EXCHANGE { success: true, status: 'OK', command: 'REQUEST_KEY_EXCHANGE', info: { key: [ 3, 0, 0, 0, 0, 0, 0, 0 ] } } AES encrypt key: 0x67452301674523010300000000000000

{ fixedKey: '0123456701234567', generatorKey: 107, modulusKey: 13, hostRandom: 7, hostIntKey: Integer { value: 3n }, slaveIntKey: Integer { value: 3n }, key: Integer { value: 3n } }

COM <- 7f00117e1c9f2e96552714cdfcbee3d62b0467d262b9 GET_SERIAL_NUMBER 0 COM -> 7f00117e9c8eb731 | RAW COM -> 71f6409317861f65722abccfe82e | RAW COM -> 7f00117e9c8eb73171f6409317861f65722abccfe82e GET_SERIAL_NUMBER Decrypted: 0501000000f000022e1c7b7b7b7bf33b { success: true, status: 'OK', command: 'GET_SERIAL_NUMBER', info: { serial_number: 142876 } } SERIAL NUMBER: 142876 COM <- 7f80117e44563706a4c7e4c38bc5dcb9d99948ed8993 ENABLE 1 COM -> 7f | RAW COM -> 80117ed44c63ca38461736407d77 | RAW COM -> fca317c7cf9d94 | RAW COM -> 7f80117ed44c63ca38461736407d77fca317c7cf9d94 ENABLE Decrypted: 0102000000f05f5f5f5f5f5f5f5f807a { success: true, status: 'OK', command: 'ENABLE', info: {} } COM <- 7f00117e5eaea6bfb60caf5371c6a4d4bf33e3751239 POLL 2 GO!!! COM -> 7f00117e | RAW COM -> a2f98eb266c49e27d5570792999d | RAW COM -> 43b255fb | RAW COM -> 7f00117ea2f98eb266c49e27d5570792999d43b255fb POLL Decrypted: 0303000000f0e8e89898989898988bf0 { success: true, status: 'OK', command: 'POLL', info: { code: 232, name: 'DISABLED', description: 'The device is not active and unavailable for normal validation functions.' }

OS: Raspbian/KDE Device: BV20 Interface: FTDI RS232 YP-05

Can you provide me any information that can lead me to find the problem?

skokov3812 commented 4 years ago

I no longer have access to the hardware and can 't tell you what the problem is. Testing was performed on NV200 Payout OS: Windows

nacyil commented 4 years ago

Im experiencing some issues with this code on linux based systems.

At first, the randomPrime functions not always returns a prime number, that should be a problem?

Also in the debug mode, my routine always ends with a 232 error, as bellow:

Port opened! COM <- 7f0001116608 SYNC 0 COM -> 7f0001f0200a | RAW COM -> 7f0001f0200a SYNC { success: true, status: 'OK', command: 'SYNC', info: {} } COM <- 7f000206061b94 HOST_PROTOCOL_VERSION 0 COM -> 7f0001f0200a | RAW COM -> 7f0001f0200a HOST_PROTOCOL_VERSION { success: true, status: 'OK', command: 'HOST_PROTOCOL_VERSION', info: {} } COM <- 7f80094a6b000000000000000e36 SET_GENERATOR 0 COM -> 7f8001f02380 | RAW COM -> 7f8001f02380 SET_GENERATOR { success: true, status: 'OK', command: 'SET_GENERATOR', info: {} } COM <- 7f00094b0d0000000000000012f1 SET_MODULUS 0 COM -> 7f0001 | RAW COM -> f0200a | RAW COM -> 7f0001f0200a SET_MODULUS { success: true, status: 'OK', command: 'SET_MODULUS', info: {} } COM <- 7f80094c03000000000000002aa2 REQUEST_KEY_EXCHANGE 0 COM -> 7f8009f0 | RAW COM -> 0300000000000000a392 | RAW COM -> 7f8009f00300000000000000a392 REQUEST_KEY_EXCHANGE { success: true, status: 'OK', command: 'REQUEST_KEY_EXCHANGE', info: { key: [ 3, 0, 0, 0, 0, 0, 0, 0 ] } } AES encrypt key: 0x67452301674523010300000000000000

{ fixedKey: '0123456701234567', generatorKey: 107, modulusKey: 13, hostRandom: 7, hostIntKey: Integer { value: 3n }, slaveIntKey: Integer { value: 3n }, key: Integer { value: 3n } }

COM <- 7f00117e1c9f2e96552714cdfcbee3d62b0467d262b9 GET_SERIAL_NUMBER 0 COM -> 7f00117e9c8eb731 | RAW COM -> 71f6409317861f65722abccfe82e | RAW COM -> 7f00117e9c8eb73171f6409317861f65722abccfe82e GET_SERIAL_NUMBER Decrypted: 0501000000f000022e1c7b7b7b7bf33b { success: true, status: 'OK', command: 'GET_SERIAL_NUMBER', info: { serial_number: 142876 } } SERIAL NUMBER: 142876 COM <- 7f80117e44563706a4c7e4c38bc5dcb9d99948ed8993 ENABLE 1 COM -> 7f | RAW COM -> 80117ed44c63ca38461736407d77 | RAW COM -> fca317c7cf9d94 | RAW COM -> 7f80117ed44c63ca38461736407d77fca317c7cf9d94 ENABLE Decrypted: 0102000000f05f5f5f5f5f5f5f5f807a { success: true, status: 'OK', command: 'ENABLE', info: {} } COM <- 7f00117e5eaea6bfb60caf5371c6a4d4bf33e3751239 POLL 2 GO!!! COM -> 7f00117e | RAW COM -> a2f98eb266c49e27d5570792999d | RAW COM -> 43b255fb | RAW COM -> 7f00117ea2f98eb266c49e27d5570792999d43b255fb POLL Decrypted: 0303000000f0e8e89898989898988bf0 { success: true, status: 'OK', command: 'POLL', info: { code: 232, name: 'DISABLED', description: 'The device is not active and unavailable for normal validation functions.' }

OS: Raspbian/KDE Device: BV20 Interface: FTDI RS232 YP-05

Can you provide me any information that can lead me to find the problem?

Hello,

I'm trying to run also the library on both windows and debian with a Smart-Hopper, but I have the same problem with random-prime module !!! On my case , I cannot SYNC , I get a TIMEOUT !!

C:\sysd\monnayeur\encrypted-smiley-secure-protocol>node example2.js (node:7728) ExperimentalWarning: The ESM module loader is experimental. (node:7728) UnhandledPromiseRejectionWarning: ReferenceError: module is not defined at file:///C:/sysd/monnayeur/encrypted-smiley-secure-protocol/node_modules/random-prime/index.js:79:1 at ModuleJob.run (internal/modules/esm/module_job.js:137:37) at async Loader.import (internal/modules/esm/loader.js:179:24) (node:7728) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:7728) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. open COM <- 7f0001116608 SYNC 0 TIMEOUT SYNC COM <- 7f0001116608 SYNC 0 TIMEOUT SYNC COM <- 7f0001116608 SYNC 0 ^C C:\sysd\monnayeur\encrypted-smiley-secure-protocol>

Have you found a solution ?? It will be great if you can share it : c.yilmaz@well-pro.com Thanks Can