Optional: crypto backend object from the "cryptography" python library

def load_verifying_key(verifying_key, crypto_backend=default_backend()):
    """ Optional: crypto backend object from the "cryptography" python library
    """
    if isinstance(verifying_key, EllipticCurvePublicKey):
        return verifying_key

    elif isinstance(verifying_key, (str, unicode)):
        if is_hex(verifying_key):
            try:
                public_key_pem = ECPublicKey(verifying_key).to_pem()
            except:
                pass
            else:
                try:
                    return load_pem_public_key(
                        public_key_pem, backend=crypto_backend)
                except Exception as e:
                    traceback.print_exc()
                    raise InvalidPublicKeyError()

            try:
                return load_der_public_key(
                    verifying_key, backend=crypto_backend)
            except:
                raise InvalidPublicKeyError()
        else:
            try:
                return load_pem_public_key(
                    verifying_key, backend=crypto_backend)
            except Exception as e:
                raise InvalidPublicKeyError()
    else:
        raise ValueError('Verifying key must be in string or unicode format.')