def verify(self):
if not self.public_key:<EOL><INDENT>self.fetch_public_key()<EOL><DEDENT>data = self.doc.find("<STR_LIT>").text<EOL>sig = self.doc.find("<STR_LIT>").text<EOL>sig_contents = '<STR_LIT:.>'.join([<EOL>data,<EOL>b64encode(b"<STR_LIT>").decode("<STR_LIT:ascii>"),<EOL>b64encode(b"<STR_LIT>").decode("<STR_LIT:ascii>"),<EOL>b64encode(b"<STR_LIT>").decode("<STR_LIT:ascii>")<EOL>])<EOL>sig_hash = SHA256.new(sig_contents.encode("<STR_LIT:ascii>"))<EOL>cipher = PKCS1_v1_5.new(RSA.importKey(self.public_key))<EOL>if not cipher.verify(sig_hash, urlsafe_b64decode(sig)):<EOL><INDENT>raise SignatureVerificationError("<STR_LIT>")<EOL><DEDENT>
Verify Magic Envelope document against public key.