Added bug fixes and new functions to openssl.py

It seems that PyBitmessage has also added some new functions and fixed some bugs within the file openssl.py. I've tried to quickly commit most of these over, although I might have missed some. 

A (potential) security issue has been discovered in your implementation of the OpenSSL random function, so I strongly recommend that even if you do not merge this pull request, you add a fix for the security issue. See line #397 of PyBitmessage's modified source code for a full explanation of the security issue: https://github.com/Bitmessage/PyBitmessage/blob/master/src/pyelliptic/openssl.py