Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

roEVPCipher : Setup working for blowfish, but not for aes

I am trying to use roEVPCipher method to encrypt my data using aes-128-ecb cipher,
But Its failing in initial setup only, Setup returns error code as -1


cipher_obj = CreateObject("roEVPCipher")
ret = cipher_obj.Setup(true, "aes-128-ecb", "0123456789abcdef", "", 0)
if ret <> 0
print "Setup Error" ; ret
end if


The similar code is working properly for blowfish cipher encryption


cipher_obj = CreateObject("roEVPCipher")
ret = cipher_obj.Setup(true, "bf", "7B1CB530521E7554D623E1412A2CF29F", "785BC65A9D7850FD", 0)
if ret <> 0
print "Setup Error" ; ret
end if


Please suggest me, how to use aes-128-ecb cipher encryption
0 Kudos
5 REPLIES 5
kc8pql
Visitor

Re: roEVPCipher : Setup working for blowfish, but not for ae

You may want to post this to the developer forum rather than here on the general user forum.
____________________________________________________________________________________________________________
No, I don't work for Roku.
Netflix Player N1000X, XDS 2100X (premature death by lightning)
Roku2 XD 3050X, Roku2 XS 3100R, Roku2 4210R
0 Kudos
RokuChris
Roku Employee
Roku Employee

Re: roEVPCipher : Setup working for blowfish, but not for ae

The problem is with the key you're trying to use. When using aes-128, you need to use a 128 bit hex encoded key.
0 Kudos

Re: roEVPCipher : Setup working for blowfish, but not for ae

Thanks Guys, Now its working fine with 128 bit hex encoded key
0 Kudos
mjames
Visitor

Re: roEVPCipher : Setup working for blowfish, but not for ae

I am unable to figure out how to use AES 128 encryption. Roku box keeps rebooting in most of the attempts. Otherwise, setup call returns -1. It is working perfectly fine if I use "bf".

Appreciate your help.

here is my code snippet:

  
alg = "aes-128-cbc"
'alg = "bf"
pad = 1
encryptKey = "10a58869d74be5a374cf867cfb473859"
IV = "00000000000000000000000000000000"
plainText = "00000000000000000000000000000000"

encResult = crypto_encrypt(alg, encryptKey, IV, plainText, pad)


Function crypto_encrypt(alg as String, encryptKey As String, IV As String, text As String, pad as Integer) As String

crypto = CreateObject("roEVPCipher")
res = crypto.Setup(true, alg,encryptKey,IV,pad)
print res

ba = CreateObject("roByteArray")
ba.FromAsciiString(text)

enc = crypto.Process(ba)

return (enc.ToHexString())

End function
0 Kudos
jsleuth
Visitor

Re: roEVPCipher : Setup working for blowfish, but not for ae

"manuthepassion" wrote:
Thanks Guys, Now its working fine with 128 bit hex encoded key


How were you able to encode your ascii string to a 128-bit hex key? I've been creating a roByteArray from ascii and then outputting a hex string, but I'm not getting my roEVPCipher setup yet...
0 Kudos