refactored BIGNUM code to use BN_CTX_get()