Open fu-raz opened 7 months ago
From what I debugged so far is that it happens in the unpad function. In this example it calculates nPaddingBytes = 198
, which it then strips from the WordArray, leaving only 15 bytes.
Removing the padding.unpad(finalProcessedBlocks);
from BlockCipher.js worked, but I don't know if this now messes up other encryption modes
I know you're probably not working on this anymore, but I'm hoping you'll at least see this message and might have an idea where I can look.
I'm trying to decrypt data using AES GCM. I can do this in node js perfectly fine and I've almost got it working in your library. I can authenticate the data and key using the AAD and tag, which works great. Then I can decrypt the payload, but it never decrypts the whole message, only a small part.
Full disclosure, I'm trying to decrypt the broadcast messages from Tuya devices, so I can (eventually) use them in an app called SignalRGB. I know how to do this in NodeJS, but their app only supports limited JS. So that's why I'm here. Your library is the only one so far that has been able to decrypt at least part of the data.
Here's a test script, assuming you import
AES, MD5, GCM, Hex and Base64
This is a 213 byte long encrypted json message. If I decrypt it in node js, it gives me exactly that. A 213 byte decrypted json message. When I use your library it gives me, in this case, 15 bytes of the decrypted json message. So it does decrypt correctly, it just stops randomly.
I have other examples where the library decrypts more, but never the full message. Do you have any clue where I should look?
Best regards, Rick