def _verify_signature(payload, signing_input, header, signature, key='', algorithms=None): alg = header.get('alg') if not alg: raise JWSError('No algorithm was specified in the JWS header.') if algorithms is not None and alg not in algorithms: raise JWSError('The specified alg value is not allowed') try: alg_obj = get_algorithm_object(alg) key = alg_obj.prepare_key(key) if not alg_obj.verify(signing_input, key, signature): raise JWSSignatureError() except JWSSignatureError: raise JWSError('Signature verification failed.') except JWSError: raise JWSError('Invalid or unsupported algorithm: %s' % alg)
def _verify_signature(signing_input, header, signature, key="", algorithms=None): alg = header.get("alg") if not alg: raise JWSError("No algorithm was specified in the JWS header.") if algorithms is not None and alg not in algorithms: raise JWSError("The specified alg value is not allowed") keys = _get_keys(key) try: if not _sig_matches_keys(keys, signing_input, signature, alg): raise JWSSignatureError() except JWSSignatureError: raise JWSError("Signature verification failed.") except JWSError: raise JWSError("Invalid or unsupported algorithm: %s" % alg)
def _verify_signature(signing_input, header, signature, key='', algorithms=None): alg = header.get('alg') if not alg: raise JWSError('No algorithm was specified in the JWS header.') if algorithms is not None and alg not in algorithms: raise JWSError('The specified alg value is not allowed') try: key = jwk.construct(key, alg) if not key.verify(signing_input, signature): raise JWSSignatureError() except JWSSignatureError: raise JWSError('Signature verification failed.') except JWSError: raise JWSError('Invalid or unsupported algorithm: %s' % alg)
def _verify_signature(signing_input, header, signature, key='', algorithms=None): alg = header.get('alg') if not alg: raise JWSError('No algorithm was specified in the JWS header.') if algorithms is not None and alg not in algorithms: raise JWSError('The specified alg value is not allowed') logger.info(f'00. key: {key}') keys = _get_keys(key) logger.info(f'01. keys: {keys}') try: if not _sig_matches_keys(keys, signing_input, signature, alg): raise JWSSignatureError() except JWSSignatureError: raise JWSError('Signature verification failed.') except JWSError: raise JWSError('Invalid or unsupported algorithm: %s' % alg)