'Check the consistency of an RSA private key.
:return: True if key is consistent.
:raise Error: if the key is inconsistent.
:raise TypeError: if the key is of a type which cannot be checked.
Only RSA keys can currently be checked.'

def check(self):

    if self._only_public:
        raise TypeError('public    key    only')
    if (_lib.EVP_PKEY_type(self._pkey.type) != _lib.EVP_PKEY_RSA):
        raise TypeError('key    type    unsupported')
    rsa = _lib.EVP_PKEY_get1_RSA(self._pkey)
    rsa = _ffi.gc(rsa, _lib.RSA_free)
    result = _lib.RSA_check_key(rsa)
    if result:
        return True
    _raise_current_error()
