Payload decrypttion AES CTR 128

Hello :slight_smile:

I am trying to decrypt payload from frames. In device documentation I can see, that I need to use 3 thinks to decode data encrypted in AES CTR128:

→dataencrypted (of course encrypted datas)
→InitializationVector (I have this)
→Key_Data_Enc (Also I have this)

I really do not know how to write function in JavaScript which will be able to decode this payload.
On the network I found CryptoJS code, but I do not know how to implement this module to Chirpstack to work with this.

Could someone help me?
Thank you a lot

There exist many tools and libraries available for this.


I know how to decode and parse data to readable form and fetching necessary information from payloads.
The problem is that payloads are encrypted by base64 and after that by AES CTR 128 bit.
So in Decode window in Chirpstack I need to first use some function to decrypt AES and finall use Decode function to grab bytes and parse.

Can anybody help? I need to resolve it.

So these are LoRa payloads that have been AES-encrypted prior to sending, such that they are twice encrypted? Why?

I don’t spend much time in JavaScript, but it looks like there are a number of libraries that support AES decryption:

The main problem is that every samples use CryptoJS or aes-js modules/libraries.
I do not know how to implement this in Chirpstack.

Those modules are implement in Chirpstack? How to use them? I tried to install it on Linux but Chirpstack still does not See it in decode window.

Chirpstack use some VM of JavaScript?

Yes, ChirpStack does use a JavaScript VM, but my understanding is it is limited to ES5.

I think you would be better off writing code to pull the payloads from MQTT (or other integration of your choice) and do what you need in your own service.

1 Like

I am working on production env. Unfortunetelly I can’t modyfie existing MQTT.
In this project we are using pure LoRa devices and gateways. Between Gateway and NS we have only RabbitMQ que system.
It is important taht only possible to implement AES decyrption in Decoder code. :frowning:

Ho can I install CryptoJS to VM of JavaScript? Or maybe how can I decrypt frames without external librarys.