Closed Saeedsaeb closed 3 years ago
hi , and thanks for the library i am having some issues regarding decrypt for a message from NodeJS
this is the information i have recieved form NodeJs developer :
IV: 3b698860538401cdd146504278aeecc9 KEY: df4f66809bafe58fe16aba7f4cb3e8bc DATA: 560d5ecae14404f4d143931d6d4e4705
and i am supposed to decrypt the data , this is the code i am trying to do the job with , its the simple example which i chanaged some thing but it dose not work :
unsigned char data[]={0X56 , 0X0d , 0X5e , 0Xca , 0Xe1 , 0X44 , 0X04 , 0Xf4 , 0Xd1 , 0X43 , 0X93 , 0X1d , 0X6d , 0X4e , 0X47 , 0X05 }; /* Simple buffer example for low-memory conditions (Arduino) */ #include "AESLib.h" #define BAUD 9600 AESLib aesLib; #define INPUT_BUFFER_LIMIT (256 + 1) // designed for Arduino UNO, not stress-tested anymore (this works with readBuffer[129]) unsigned char cleartext[INPUT_BUFFER_LIMIT] = {0}; // THIS IS INPUT BUFFER (FOR TEXT) // AES Encryption Key (same as in node-js example) byte aes_key[] = { 0xdf, 0x4f, 0x66, 0x80, 0x9b, 0xaf, 0xe5, 0x8f, 0xe1 , 0x6a , 0xba , 0x7f , 0x4c , 0xb3 , 0xe8, 0xbc }; byte aes_iv[N_BLOCK] = { 0x3b , 0x69 , 0x88 , 0x60 , 0x53 , 0x84 , 0x01 , 0xcd , 0xd1 , 0x46 , 0x50 , 0x42 , 0x78 , 0xae, 0xec , 0xc9}; uint16_t decrypt_to_cleartext(byte msg[], uint16_t msgLen, byte iv[]) { Serial.print("Calling decrypt...; "); uint16_t dec_bytes = aesLib.decrypt(msg, msgLen, (char*)cleartext, aes_key, sizeof(aes_key), iv); Serial.print("Decrypted bytes: "); Serial.println(dec_bytes); return dec_bytes; } void setup() { Serial.begin(BAUD); Serial.setTimeout(60000); delay(2000); } /* non-blocking wait function */ void wait(unsigned long milliseconds) { unsigned long timeout = millis() + milliseconds; while (millis() < timeout) { yield(); } } unsigned long loopcount = 0; byte enc_iv[N_BLOCK] = { 0x3b , 0x69 , 0x88 , 0x60 , 0x53 , 0x84 , 0x01 , 0xcd , 0xd1 , 0x46 , 0x50 , 0x42 , 0x78 , 0xae, 0xec , 0xc9}; byte enc_iv_to[N_BLOCK] = { 0x3b , 0x69 , 0x88 , 0x60 , 0x53 , 0x84 , 0x01 , 0xcd , 0xd1 , 0x46 , 0x50 , 0x42 , 0x78 , 0xae, 0xec , 0xc9}; byte enc_iv_from[N_BLOCK] = { 0x3b , 0x69 , 0x88 , 0x60 , 0x53 , 0x84 , 0x01 , 0xcd , 0xd1 , 0x46 , 0x50 , 0x42 , 0x78 , 0xae, 0xec , 0xc9}; void loop() { memcpy(enc_iv, enc_iv_from, sizeof(enc_iv_from)); uint16_t decLen = decrypt_to_cleartext(data, sizeof(data), enc_iv); Serial.print("Decrypted cleartext of length: "); Serial.println(decLen); Serial.print("Decrypted cleartext:\n"); Serial.println((char*)cleartext); Serial.println("---"); delay(5000); }
Thanks for reporting. This is due to a decryption bug in <2.2.0. Fixed in 2.2.1.
hi , and thanks for the library i am having some issues regarding decrypt for a message from NodeJS
this is the information i have recieved form NodeJs developer :
IV: 3b698860538401cdd146504278aeecc9 KEY: df4f66809bafe58fe16aba7f4cb3e8bc DATA: 560d5ecae14404f4d143931d6d4e4705
and i am supposed to decrypt the data , this is the code i am trying to do the job with , its the simple example which i chanaged some thing but it dose not work :