def testC04CreateArmoredSigned(self):
     "armory: apply_armor() signed, uncompressed message"
     gpg_d = read_test_file(['pgpfiles','sig','sig.DSAELG1.onepass.gpg'])
     msg = list_msgs(list_pkts(gpg_d))[0]
     armored_d = apply_armor(msg)
     armored = list_armored(armored_d)[0]
     newmsg = list_msgs(list_pkts(armored.data))[0]
     self.assertEqual('MESSAGE', armored.title)
     self.assertEqual(msg.rawstr(), newmsg.rawstr())
 def __testC05CreateArmoredClearSigned(self):
     "armory: apply_armor() clearsigned message"
     gpg_d = read_test_file(['pgpfiles','sig','sig.DSAELG1.onepass.gpg'])
     msg = list_msgs(list_pkts(gpg_d))[0]
     armored_d = apply_armor(msg, clearsign=True)
     armored = list_armored(armored_d)[0]
     newmsg = list_msgs(list_pkts(armored.data))[0]
     self.assertEqual('SIGNED MESSAGE', armored.title)
     self.assertEqual(msg.rawstr(), newmsg.rawstr())
 def testC01CreateArmoredPublicKey(self):
     "armory: apply_armor() DSA/ElGamal public key"
     gpg_d = read_test_file(['pgpfiles','key','DSAELG1.pub.gpg'])
     msg = list_msgs(list_pkts(gpg_d))[0]
     armored_d = apply_armor(msg)
     armored = list_armored(armored_d)[0]
     newmsg = list_msgs(list_pkts(armored.data))[0]
     self.assertEqual('PUBLIC KEY BLOCK', armored.title)
     self.assertEqual(msg.rawstr(), newmsg.rawstr())
 def __testC05CreateArmoredClearSigned(self):
     "armory: apply_armor() clearsigned message"
     gpg_d = read_test_file(['pgpfiles', 'sig', 'sig.DSAELG1.onepass.gpg'])
     msg = list_msgs(list_pkts(gpg_d))[0]
     armored_d = apply_armor(msg, clearsign=True)
     armored = list_armored(armored_d)[0]
     newmsg = list_msgs(list_pkts(armored.data))[0]
     self.assertEqual('SIGNED MESSAGE', armored.title)
     self.assertEqual(msg.rawstr(), newmsg.rawstr())
 def testC04CreateArmoredSigned(self):
     "armory: apply_armor() signed, uncompressed message"
     gpg_d = read_test_file(['pgpfiles', 'sig', 'sig.DSAELG1.onepass.gpg'])
     msg = list_msgs(list_pkts(gpg_d))[0]
     armored_d = apply_armor(msg)
     armored = list_armored(armored_d)[0]
     newmsg = list_msgs(list_pkts(armored.data))[0]
     self.assertEqual('MESSAGE', armored.title)
     self.assertEqual(msg.rawstr(), newmsg.rawstr())
 def testC01CreateArmoredPublicKey(self):
     "armory: apply_armor() DSA/ElGamal public key"
     gpg_d = read_test_file(['pgpfiles', 'key', 'DSAELG1.pub.gpg'])
     msg = list_msgs(list_pkts(gpg_d))[0]
     armored_d = apply_armor(msg)
     armored = list_armored(armored_d)[0]
     newmsg = list_msgs(list_pkts(armored.data))[0]
     self.assertEqual('PUBLIC KEY BLOCK', armored.title)
     self.assertEqual(msg.rawstr(), newmsg.rawstr())
 def testC02CreateArmoredEncrypted(self):
     "armory: apply_armor() ElGamal/CAST encrypted message"
     gpg_d = read_test_file(['pgpfiles','enc','pub.elg.aes256.clrtxt.gpg'])
     msg = list_msgs(list_pkts(gpg_d))[0]
     armored_d = apply_armor(msg)
     #f = file('pgpfiles/enc/sap.pub.elg.aes256.clrtxt.asc', 'w')
     #f.write(armored_d)
     #f.close()
     armored = list_armored(armored_d)[0]
     newmsg = list_msgs(list_pkts(armored.data))[0]
     self.assertEqual('MESSAGE', armored.title)
     self.assertEqual(msg.rawstr(), newmsg.rawstr())
 def testC02CreateArmoredEncrypted(self):
     "armory: apply_armor() ElGamal/CAST encrypted message"
     gpg_d = read_test_file(
         ['pgpfiles', 'enc', 'pub.elg.aes256.clrtxt.gpg'])
     msg = list_msgs(list_pkts(gpg_d))[0]
     armored_d = apply_armor(msg)
     #f = file('pgpfiles/enc/sap.pub.elg.aes256.clrtxt.asc', 'w')
     #f.write(armored_d)
     #f.close()
     armored = list_armored(armored_d)[0]
     newmsg = list_msgs(list_pkts(armored.data))[0]
     self.assertEqual('MESSAGE', armored.title)
     self.assertEqual(msg.rawstr(), newmsg.rawstr())
Esempio n. 9
0
def cat_pkt_str(pkt_str_list, armor=False):
    """Concatenate all the packets found in a list of strings.

    :Parameters:
        - `pkt_str_list`: list of OpenPGP strings (native or ASCII-armored)

    :Keywords:
        - `armor`: set to True to return an armored string

    :Returns: string of packets

    :note: ASCII-armored blocks are OK. Native OpenPGP packets are OK. Just
        make sure that both aren't present in a single element in
        `pkt_str_list`.
    """
    from openpgp.sap.armory import looks_armored, list_armored, apply_armor

    saplog.info("Concatenating packets from %s chunks." % len(pkt_str_list))
    pkts = []

    for pkt_d in pkt_str_list:

        if looks_armored(pkt_d):
            pgp_d = ''.join([a.data for a in list_armored(pkt_d)])

        else:
            pgp_d = pkt_d

        pkts.extend(list_pkts(pgp_d))

    if armor:
        s = apply_armor(pkts)

    else:
        s = ''.join([p.rawstr() for p in pkts])

    return s
Esempio n. 10
0
def cat_pkt_str(pkt_str_list, armor=False):
    """Concatenate all the packets found in a list of strings.

    :Parameters:
        - `pkt_str_list`: list of OpenPGP strings (native or ASCII-armored)

    :Keywords:
        - `armor`: set to True to return an armored string

    :Returns: string of packets

    :note: ASCII-armored blocks are OK. Native OpenPGP packets are OK. Just
        make sure that both aren't present in a single element in
        `pkt_str_list`.
    """
    from openpgp.sap.armory import looks_armored, list_armored, apply_armor

    saplog.info("Concatenating packets from %s chunks." % len(pkt_str_list))
    pkts = []

    for pkt_d in pkt_str_list:

        if looks_armored(pkt_d):
            pgp_d = ''.join([a.data for a in list_armored(pkt_d)])

        else:
            pgp_d = pkt_d

        pkts.extend(list_pkts(pgp_d))

    if armor:
        s = apply_armor(pkts)

    else:
        s = ''.join([p.rawstr() for p in pkts])

    return s