finally got it working. used malloc to allocate decrypted bytes