parameters: (self, msg_hash, signature)
docstring: Check if the  PKCS#1 v1.5 signature over a message is valid.
  
          This function is also called ``RSASSA-PKCS1-V1_5-VERIFY`` and
          it is specified in
          `section 8.2.2 of RFC8037 <https://tools.ietf.org/html/rfc8017#page-37>`_.
  
          :parameter msg_hash:
              The hash that was carried out over the message. This is an object
              belonging to the :mod:`Crypto.Hash` module.
          :type parameter: hash object
  
          :parameter signature:
              The signature that needs to be validated.
          :type signature: byte string
  
          :raise ValueError: if the signature is not valid.
docstring_summary: Check if the  PKCS#1 v1.5 signature over a message is valid.
docstring_tokens: Check if the PKCS#1 v1 . 5 signature over a message is valid .
function: def verify(self, msg_hash, signature):
          """Check if the  PKCS#1 v1.5 signature over a message is valid.
  
          This function is also called ``RSASSA-PKCS1-V1_5-VERIFY`` and
          it is specified in
          `section 8.2.2 of RFC8037 <https://tools.ietf.org/html/rfc8017#page-37>`_.
  
          :parameter msg_hash:
              The hash that was carried out over the message. This is an object
              belonging to the :mod:`Crypto.Hash` module.
          :type parameter: hash object
  
          :parameter signature:
              The signature that needs to be validated.
          :type signature: byte string
  
          :raise ValueError: if the signature is not valid.
          """
  
          # See 8.2.2 in RFC3447
          modBits = Crypto.Util.number.size(self._key.n)
          k = ceil_div(modBits, 8) # Convert from bits to bytes
  
          # Step 1
          if len(signature) != k:
              raise ValueError("Invalid signature")
          # Step 2a (O2SIP)
          signature_int = bytes_to_long(signature)
          # Step 2b (RSAVP1)
          em_int = self._key._encrypt(signature_int)
          # Step 2c (I2OSP)
          em1 = long_to_bytes(em_int, k)
          # Step 3
          try:
              possible_em1 = [ _EMSA_PKCS1_V1_5_ENCODE(msg_hash, k, True) ]
              # MD2/4/5 hashes always require NULL params in AlgorithmIdentifier.
              # For all others, it is optional.
              try:
                  algorithm_is_md = msg_hash.oid.startswith('1.2.840.113549.2.')
              except AttributeError:
                  algorithm_is_md = False
              if not algorithm_is_md:  # MD2/MD4/MD5
                  possible_em1.append(_EMSA_PKCS1_V1_5_ENCODE(msg_hash, k, False))
          except ValueError:
              raise ValueError("Invalid signature")
          # Step 4
          # By comparing the full encodings (as opposed to checking each
          # of its components one at a time) we avoid attacks to the padding
          # scheme like Bleichenbacher's (see http://www.mail-archive.com/cryptography@metzdowd.com/msg06537).
          #
          if em1 not in possible_em1:
              raise ValueError("Invalid signature")
          pass
function_tokens: def verify ( self , msg_hash , signature ) : # See 8.2.2 in RFC3447 modBits = Crypto . Util . number . size ( self . _key . n ) k = ceil_div ( modBits , 8 ) # Convert from bits to bytes # Step 1 if len ( signature ) != k : raise ValueError ( "Invalid signature" ) # Step 2a (O2SIP) signature_int = bytes_to_long ( signature ) # Step 2b (RSAVP1) em_int = self . _key . _encrypt ( signature_int ) # Step 2c (I2OSP) em1 = long_to_bytes ( em_int , k ) # Step 3 try : possible_em1 = [ _EMSA_PKCS1_V1_5_ENCODE ( msg_hash , k , True ) ] # MD2/4/5 hashes always require NULL params in AlgorithmIdentifier. # For all others, it is optional. try : algorithm_is_md = msg_hash . oid . startswith ( '1.2.840.113549.2.' ) except AttributeError : algorithm_is_md = False if not algorithm_is_md : # MD2/MD4/MD5 possible_em1 . append ( _EMSA_PKCS1_V1_5_ENCODE ( msg_hash , k , False ) ) except ValueError : raise ValueError ( "Invalid signature" ) # Step 4 # By comparing the full encodings (as opposed to checking each # of its components one at a time) we avoid attacks to the padding # scheme like Bleichenbacher's (see http://www.mail-archive.com/cryptography@metzdowd.com/msg06537). # if em1 not in possible_em1 : raise ValueError ( "Invalid signature" ) pass