@@ -387,17 +387,53 @@ def _is_compact_jws(self, jws):
387387 return True
388388
389389 def alg2keytype (self , alg ):
390+ """
391+ Translate a signing algorithm into a specific key type.
392+
393+ :param alg: The signing algorithm
394+ :return: A key type or None if there is no key type matching the
395+ algorithm
396+ """
390397 return alg2keytype (alg )
391398
392399 def set_header_claim (self , key , value ):
400+ """
401+ Set a specific claim in the header to a specific value.
402+
403+ :param key: The name of the claim
404+ :param value: The value of the claim
405+ """
393406 self ._header [key ] = value
394407
395408 def verify_alg (self , alg ):
409+ """
410+ Specifically check that the 'alg' claim has a specific value
411+
412+ :param alg: The expected alg value
413+ :raises: KeyError if the 'alg' is not present in the header
414+ :return: True if the alg value in the header is the same as the one
415+ given.
416+ """
396417 if alg == self .jwt .headers ['alg' ]:
397418 return True
398419 else :
399420 return False
400421
422+ def verify_header (self , key , val ):
423+ """
424+ Check that a particular header claim is present as a has specific value
425+
426+ :param key: The claim
427+ :param val: The value of the claim
428+ :raises: KeyError if the claim is not present in the header
429+ :return: True if the claim exists in the header and has the prescribed
430+ value
431+ """
432+ if val == self .jwt .headers [key ]:
433+ return True
434+ else :
435+ return False
436+
401437
402438def factory (token , ** kwargs ):
403439 _jw = JWS (** kwargs )
0 commit comments