K6 and AES encryption


I’ve been using k6 to test backend performance at my company for about a year now, but now as we are nearing production the backend enforces strict encryption in a lot of workflows.

Long story short, I need to be able to encrypt and decrypt payloads using AES256-GCM and RSA. I was planning to use node-forge, as I already had a good implementation for other tests, but I realized that I can’t bundle any node modules that use browser specific objects. Sadly I couldn’t find a pure javascript library that implements AES GCM operation mode anywhere, so I’m stuck.

Could anyone offer some advice as on how to proceed from here with k6? What would be the most performance friendly way to use advanced encryption with k6?

I’ve been thinking about making a shell script that uses openssl or hosting a local server that only does the encryption.

I ran into a similar issues where I couldn’t use the libraries in jmeter so wrote a node.js server to do so. Mine was using sha256 but I suspect the concept is the same, you pass in some text (in my case a device and message id) and return an encrypted string.

Although full disclosure, I’m neither a node or crypto expert. In fact looking at my code I’m sure its wildly inefficient but I wrote it in a hurry and it works :slight_smile:

Downside is you need an external server which needs to be able to handle the load (we’ve got ours running a number of servers behind a load balancer) and in K6 its an extra http call which may interfere with your reporting.

There’s also a k6 extension which you may be able to utilize or extend, I haven’t used this as yet.

Good Luck.