I am using M2Crypto's AES for encrypting message, but confused about how to generate a strong random session key and of what length. Does M2Crypto provide any function for generation random key.
If you are encrypting to send to another party then you want to do something like Diffie Hellman or ECDH key exchange to establish a shared secret. If you just want to encrypt for storage, then you need a secure random number generator. I do not believe M2Crypto provides this?
It looks like M2Crypto does support Diffie Hellman.
How to generate strong one time session key for AES in python