def _jwa(self, name): try: attr = '_jwa_%s' % name.replace('-', '_').replace('+', '_') fn = getattr(self, attr) except (KeyError, AttributeError): raise InvalidJWAAlgorithm() allowed = self._allowed_algs or default_allowed_algs if name not in allowed: raise InvalidJWEOperation('Algorithm not allowed') return fn()
def _jwa(self, name, allowed): if allowed is None: allowed = default_allowed_algs attr = '_jwa_%s' % name try: fn = getattr(self, attr) except (KeyError, AttributeError): raise InvalidJWAAlgorithm() if name not in allowed: raise InvalidJWSOperation('Algorithm not allowed') return fn()
def encryption_alg(cls, name): try: return cls.instantiate_alg(name, use='enc') except KeyError: raise InvalidJWAAlgorithm( '%s is not a valid Encryption algorithm name' % name)
def keymgmt_alg(cls, name): try: return cls.instantiate_alg(name, use='kex') except KeyError: raise InvalidJWAAlgorithm( '%s is not a valid Key Management algorithm name' % name)
def signing_alg(cls, name): try: return cls.instantiate_alg(name, use='sig') except KeyError: raise InvalidJWAAlgorithm( '%s is not a valid Signign algorithm name' % name)