Esempio n. 1
0
  def Verify(self, data, sig, decoder=util.Base64WSDecode):
    """
    Verifies whether the signature corresponds to the given data.

    @param data: message that has been signed with sig
    @type data: string

    @param sig: Base64 string formatted as Header|Signature
    @type sig: string

    @return: True if sig corresponds to data, False otherwise.
    @rtype: boolean
    """
    sig_bytes = decoder(sig) if decoder else sig
    if len(sig_bytes) < HEADER_SIZE:
      raise errors.ShortSignatureError(len(sig_bytes))
    return self.__InternalVerify(sig_bytes[:HEADER_SIZE], sig_bytes[HEADER_SIZE:], data)
Esempio n. 2
0
    def Verify(self, data, sig):
        """
    Verifies whether the signature corresponds to the given data.

    @param data: message that has been signed with sig
    @type data: string

    @param sig: Base64 string formatted as Header|Signature
    @type sig: string

    @return: True if sig corresponds to data, False otherwise.
    @rtype: boolean
    """
        sig_bytes = util.Decode(sig)
        if len(sig_bytes) < HEADER_SIZE:
            raise errors.ShortSignatureError(len(sig_bytes))
        key = self._ParseHeader(sig_bytes[:HEADER_SIZE])
        return key.Verify(data + VERSION_BYTE, sig_bytes[HEADER_SIZE:])