Hi
Is it misstyped?
mcrypt_decrypt(
MCRYPT_RIJNDAEL_128
You use 128bit at PHP function call, but -aes-256-ecb in command line?
What Lua SSL library do you use?
2014-04-24 21:06 GMT+03:00 <luis...@interactive3g.com>:
> Hi,
>
> We are porting part of our back-end from PHP to openresty and I am having
> some problems decrypting a AES encrypted string.
>
> This is the PHP code
>
> function aes_decrypt($sStr, $sKey) {
> return mcrypt_decrypt(
> MCRYPT_RIJNDAEL_128,
> $sKey,
> base64_decode($sStr),
> MCRYPT_MODE_ECB
> );
> }
>
> echo aes_decrypt("tkKbFgvUw39xxwKswwRt9w==","our256bitskey");
>
> Using openssl command line client, I am able to decrypt it with the
> following command
>
> echo -ne "tkKbFgvUw39xxwKswwRt9w==" | base64 -d | openssl enc -d
> -aes-256-ecb -nosalt -nopad -A -K our256bitskeyHEXencoded
>
> And here is the lua code we are using:
>
> local m = "tkKbFgvUw39xxwKswwRt9w=="
> local aes_256_ecb = aes:new("our256bitskey",nil,aes.cipher(256,"ecb"))
> local dm = ngx.decode_base64(m)
> local msisdn = aes_256_ecb:decrypt(dm)
> return msisdn
>
> decrypt is returning nil in the C.EVP_DecryptFinal_ex call
>
> Any hint ?
>
> Thanks,
> Luis.
--
My best wishes.
Alexandr Ogurtsov.
Linux is very friendly it is just picky who its friends are