AES encryption

HI,

does anybody know if there is a way to use AES CBC encryption in ST ? I need to encrypt communication via hub action. Any idea how to do it ?

1 Like

You may be able to find ways in Groovy. The ST cloud runs groovy so that’s your starting point. I managed to get MD5 running and I believe there are ways to use SHA too, but these are hashes, not crypto. Look up Groovy AES. Then keep in mind not all classes are permitted in the ST version of Groovy.

1 Like

Last time I checked … no.

There is a very limited “whitelist” of Java Class libraries that can be imported.

And I don’t think the whitelist is published (@jim?)

2 Likes

http://docs.smartthings.com/en/latest/getting-started/groovy-for-smartthings.html#allowed-classes

1 Like

Yay… Thanks, Jim!

But… No crypt, encrypt, (?) Class in the list… I don’t think??

Nope. Nothing like this on a list. Looks like importing Cipher is ok, but due to the fact it is not whitelisted I get SecurityException.

I guess the only way would be to reimplement all logic within groovy script (if possible ) or find a way to add this to whitelist.

1 Like

Or use an external service to do the decrypting for you. When you receive a message from the LAN device, pass it to an https request that decrypts it. When sending a message, first pass it to the https request for encryption. Horrible workaround but still a workaround.

1 Like

Yeah, Was thinking about this but as ultimate goal was to get rid of intermediary device keeping it just for encryption seems pointless.

1 Like

@ady624, @Jim - Is there any new way how AES encryption could be done without any intermediary equipment (either 3rd party service or extra device on the network). As far as I can see, the groovy environment still hasn’t got any white listed cipher. And I am not familiar enough with the new SmartApp/Connected device integration in the new developer workspace.

I am looking for the ability to be able decrypt and encrypt with AES CBC PKCS7 some messages from a LAN connected Smart Air Purifier.
(Cloud integration might be possible too, but I am quite far from that to dig deeper in the subject.)

Any help would be useful!

Are you working on a Midea API devices? Do you already have a working sample using third party service for AES encryption?

@serrano.sandoval, actually I was looking at the Philips air purifiers, or something similar. They have actually connection through CoAP protocol and I have found a working solution to query information from it.