def _verify_signature(self):
        """Verify existing signature.

        Overwrite the method if you need more than one signature.
        """
        if not self.signature:  # fail if object has no signature attribute
            self.validation_text = "No signature found."
            return False
        message = crypto.get_bytes(self._get_information_for_hashing())
        result = crypto.verify(message, self.signature,
                               key_utils.bytes_to_rsa(self.sender_pubkey))
        if not result:
            self.validation_text = "Signature not valid"
            return False
        self.validation_text = "valid"
        return True
    def _create_patient_signature(self, private_key):
        if self.patient_signature:
            logger.debug("Patient signature exists. Quit signing process.")
            return

        print(str(self))
        print("Patient, do you want to sign the vaccination? (Y/N): ")
        reply = sys.stdin.read(1)
        reply = str(reply).lower()

        if reply == "n":
            print("Aborting...")
            return None
        elif reply == "y":
            message = crypto.get_bytes(
                self._get_information_for_hashing(False))
            return crypto.sign(message, private_key)
        else:
            print("No valid input. Abort...")
            return None
 def _create_signature(self, private_key):
     message = crypto.get_bytes(self._get_information_for_hashing())
     return crypto.sign(message, private_key)
 def _create_doctor_signature(self, private_key):
     if self.doctor_signature:
         logger.debug("Doctor signature exists. Quit signing process.")
         return
     message = crypto.get_bytes(self._get_information_for_hashing(True))
     return crypto.sign(message, private_key)
 def _verify_patient_signature(self, pub_key):
     message = crypto.get_bytes(self._get_information_for_hashing(False))
     return crypto.verify(message, self.patient_signature, pub_key)
 def _verify_doctor_signature(self, pub_key):
     message = crypto.get_bytes(self._get_information_for_hashing(True))
     return crypto.verify(message, self.doctor_signature, pub_key)