Exemplo n.º 1
0
    def parse_asn1_message(self, asn1_message):
        msg_content = asn1_message.getComponentByName("content")

        self.version = msg_content.getComponentByName("version")
        self.digest_algorithms = self._extract_used_digest_algs(msg_content)
        self.message = msg_content.getComponentByName("content").getComponentByName("signed_content").getContentValue()
        self.certificates = [
            CertificateManager.get_certificate(cert) for cert in msg_content.getComponentByName("certificates")
        ]
        self.signer_infos = [SignerInfo(si) for si in msg_content.getComponentByName("signerInfos")]
Exemplo n.º 2
0

#import properties.properties as p
#print p.Properties.VERIFY_MESSAGE
#p.Properties.load_from_file("properties/security.properties")

'''
subory v test_msgs obsahuju binarnu formu prijatych podpisanych sprav
t.j. odpoved na getSignedXXX obsahovala element dmSignature. Jeho obsah
je base64 dekodovany a zapisany do danych suborov (podpisana prijata a odoslana 
sprava, podpisana dorucenka).
'''

from certs.cert_manager import CertificateManager

CertificateManager.read_trusted_certificates_from_dir("trusted_certificates")
#f = open(os.path.join("test_msgs","signedSentMessage"), "rb")
#f = open("test_msgs/signedReceivedMessage", "r")
f = open("test_msgs/srm2", "r")
#f = open("test_msgs/sigDeliveryInfo", "r")
coded = f.read()

decoded_msg = pkcs7.pkcs7_decoder.decode_msg(coded)
verification_result = pkcs7.verifier.verify_msg(decoded_msg)

#print decoded_msg.getComponentByName("signedData")

if verification_result:
    logger.info("Message verified - ok")
else:
    logger.warning("Verification of pkcs7 message failed")