• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python support.read_test_file函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中support.read_test_file函数的典型用法代码示例。如果您正苦于以下问题:Python read_test_file函数的具体用法?Python read_test_file怎么用?Python read_test_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了read_test_file函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: testF02EncryptPublicArmor

 def testF02EncryptPublicArmor(self):
     "encrypt_str()/decrypt_str() ElGamal via user ID (armored)"
     pubkey_d = read_test_file(['pgpfiles','key','DSAELG1.pub.asc'])
     seckey_d = read_test_file(['pgpfiles','key','DSAELG1.sec.asc'])
     cphtxt = encrypt_str(self.lit_data,keys=pubkey_d,
                          use_userid=[(None,"Tester")], armor=True)
     self.assertEqual(True, looks_armored(cphtxt))
开发者ID:BackupTheBerlios,项目名称:pgpyp-svn,代码行数:7,代码来源:test_16_api_str.py


示例2: testI01EncryptPublicElGamalDES3ZIP

 def testI01EncryptPublicElGamalDES3ZIP(self):
     """crypto.cipher: encrypt()/decrypt() ElGamal, DES3 w/ integrity, & ZIP"""
     key_d = read_test_file(['pgpfiles','key','DSAELG3.pub.gpg'])
     keypkt = list_pkts(key_d)[3] # ElGamal encrypting key
     d = "My secret message."
     # literal data packet
     litbody = create_LiteralDataBody(data=d, modified=0, format='b',
                                          filename='outfile')
     litpkt = create_Packet(PKT_LITERAL, litbody._d)
     # compressed data packet
     compbody = create_CompressedDataBody(COMP_ZIP, litpkt.rawstr())
     comppkt = create_Packet(PKT_COMPRESSED, compbody._d)
     # session key
     key = gen_random(_keysize(SYM_DES3))
     sespkt = encrypt_public_session(keypkt, key, SYM_DES3)
     # encrypted data
     encpkt = encrypt_integrity(SYM_DES3, key, comppkt.rawstr())
     # decryption
     seckey_d = read_test_file(['pgpfiles','key','DSAELG3.sec.nopass.gpg'])
     seckeypkt = list_pkts(seckey_d)[2]
     clrtxt = decrypt(encpkt, None, sespkt, seckeypkt)
     # got compressed
     comppkt_out = list_pkts(clrtxt)[0]
     # got literal
     litpkt_out = list_pkts(comppkt_out.body.data)[0]
     self.assertEqual(d, litpkt_out.body.data)
     self.assertEqual('outfile', litpkt_out.body.filename)
     self.assertEqual(0, litpkt_out.body.modified)
     self.assertEqual('b', litpkt_out.body.format)
开发者ID:BackupTheBerlios,项目名称:pgpyp-svn,代码行数:29,代码来源:test_14_cipher.py


示例3: testC02DecryptDSA_decompression

 def testC02DecryptDSA_decompression(self):
     "decrypt_str() DSA AES256 w/integrity (decompressed)"
     enc_d = read_test_file(['pgpfiles','enc','pub.elg.aes256.clrtxt.gpg'])
     key_d = read_test_file(['pgpfiles','key','DSAELG1.sec.asc'])
     clrtxt = decrypt_str(enc_d, passphrase='test', keys=key_d,
                                  decompress=True)
     litmsg = list_as_signed(clrtxt)[0] # no compressed msg to go through
     self.assertEqual(self.lit_data, litmsg.literals[0].body.data)
开发者ID:BackupTheBerlios,项目名称:pgpyp-svn,代码行数:8,代码来源:test_16_api_str.py


示例4: testC01DecryptDSA

 def testC01DecryptDSA(self):
     "decrypt_str() DSA AES256 w/integrity"
     enc_d = read_test_file(['pgpfiles','enc','pub.elg.aes256.clrtxt.gpg'])
     key_d = read_test_file(['pgpfiles','key','DSAELG1.sec.asc'])
     clrtxt = decrypt_str(enc_d, passphrase='test', keys=key_d)
     compmsg = list_as_signed(clrtxt)[0]
     literal_pkt = list_pkts(compmsg.compressed.body.data)[0]
     self.assertEqual(self.lit_data, literal_pkt.body.data)
开发者ID:BackupTheBerlios,项目名称:pgpyp-svn,代码行数:8,代码来源:test_16_api_str.py


示例5: testF03EncryptPublicKeyID

 def testF03EncryptPublicKeyID(self):
     "encrypt_str()/decrypt_str() ElGamal via key ID"
     pubkey_d = read_test_file(['pgpfiles','key','DSAELG1.pub.asc'])
     seckey_d = read_test_file(['pgpfiles','key','DSAELG1.sec.asc'])
     cphtxt = encrypt_str(self.lit_data, keys=pubkey_d, use_key=[(None,"CB7D6980A1F2BEF6")])
     clrtxt = decrypt_str(cphtxt, passphrase="test", keys=seckey_d, decompress=True)
     litmsg = list_as_signed(clrtxt)[0] # auto-decompressed above
     self.assertEqual(self.lit_data, litmsg.literals[0].body.data)
开发者ID:BackupTheBerlios,项目名称:pgpyp-svn,代码行数:8,代码来源:test_16_api_str.py


示例6: testC04DecryptRSA

 def testC04DecryptRSA(self):
     "decrypt_str() RSA w/integrity"
     lit_data = "My secret message."
     enc_d = read_test_file(['pgpfiles','enc','sap.2DSAELG1RSA.nocomp.gpg'])
     key_d = read_test_file(['pgpfiles','key','RSA1.sec.asc'])
     clrtxt = decrypt_str(enc_d, passphrase='test', keys=key_d)
     clrmsgs = list_as_signed(clrtxt)
     literal_pkt = clrmsgs[0].literals[0]
     self.assertEqual(lit_data, literal_pkt.body.data)
开发者ID:BackupTheBerlios,项目名称:pgpyp-svn,代码行数:9,代码来源:test_16_api_str.py


示例7: testC03DecryptDSA_armor

 def testC03DecryptDSA_armor(self):
     "decrypt_str() DSA AES256 w/integrity (armored, decompressed)"
     enc_d = read_test_file(['pgpfiles','enc','pub.elg.aes256.clrtxt.gpg'])
     key_d = read_test_file(['pgpfiles','key','DSAELG1.sec.asc'])
     clrtxt = decrypt_str(enc_d, passphrase='test', keys=key_d,
                                  decompress=True, armor=True)
     self.assertEqual(True, looks_armored(clrtxt)) # check armoring
     litmsg = list_as_signed(clrtxt)[0]
     self.assertEqual(self.lit_data, litmsg.literals[0].body.data)
开发者ID:BackupTheBerlios,项目名称:pgpyp-svn,代码行数:9,代码来源:test_16_api_str.py


示例8: testD08CertificationRevocation

 def testD08CertificationRevocation(self):
     "crypto.signature: verify() foreign user ID certification"
     key_d = read_test_file(['pgpfiles','key','DSAELG2.pub.foreign_uid_cert.gpg'])
     sigkey_d = read_test_file(['pgpfiles','key','RSA1.pub.gpg'])
     sigpkt = list_pkts(sigkey_d)[0]
     pkts = list_pkts(key_d)
     primary_key, uid, cert = pkts[0], pkts[1], pkts[3]
     opts = {'primary':primary_key}
     verified = verify(cert, uid, sigpkt, **opts)
     self.assertEqual(True, verified)
开发者ID:BackupTheBerlios,项目名称:pgpyp-svn,代码行数:10,代码来源:test_12_signing.py


示例9: testG05Decrypt5

 def testG05Decrypt5(self):
     """crypto.cipher: decrypt() symmetric (CAST) compressed"""
     enc_d = read_test_file(['pgpfiles','enc','sym.cast.cleartext.txt.gpg'])
     clr_d = read_test_file(['pgpfiles','cleartext.txt'])
     sespkt, encpkt = list_pkts(enc_d)
     passphrase = 'test'
     msg_d = decrypt(encpkt, passphrase, sespkt)
     compmsg = list_msgs(list_pkts(msg_d))[0]
     litpkt = list_pkts(compmsg.compressed.body.data)[0]
     self.assertEqual(clr_d, litpkt.body.data)
开发者ID:BackupTheBerlios,项目名称:pgpyp-svn,代码行数:10,代码来源:test_14_cipher.py


示例10: testF04EncryptPublicKeyIDNoTarget

 def testF04EncryptPublicKeyIDNoTarget(self):
     "encrypt_str()/decrypt_str() no specified encryption key"
     pubkey_d = read_test_file(['pgpfiles','key','DSAELG1.pub.asc'])
     seckey_d = read_test_file(['pgpfiles','key','DSAELG1.sec.asc'])
     try:
         cphtxt = encrypt_str(self.lit_data, keys=pubkey_d) # missing target
     except PGPError:
         pass
     else:
         self.fail()
开发者ID:BackupTheBerlios,项目名称:pgpyp-svn,代码行数:10,代码来源:test_16_api_str.py


示例11: testE01SignBinaryAsMsgViaUID

 def testE01SignBinaryAsMsgViaUID(self):
     "sign_str()/verify_str() binary (0x00) using user ID"
     lit_d = read_test_file(['pgpfiles','cleartext.txt'])
     seckey_d = read_test_file(['pgpfiles','key','DSAELG1.sec.asc'])
     pubkey_d = read_test_file(['pgpfiles','key','DSAELG1.pub.asc'])
     signed = sign_str(0x00, seckey_d, target=lit_d,
                       use_userid=(None,'Tester'),
                       passphrase='test')
     verified = verify_str(signed, pubkey_d)
     self.assertEqual(lit_d, list_pkts(verified)[0].body.data)
开发者ID:BackupTheBerlios,项目名称:pgpyp-svn,代码行数:10,代码来源:test_16_api_str.py


示例12: testE02SignTextKeyID

 def testE02SignTextKeyID(self):
     "sign_str()/verify_str() text (0x01) using key ID"
     lit_d = read_test_file(['pgpfiles','cleartext.txt'])
     seckey_d = read_test_file(['pgpfiles','key','DSAELG1.sec.asc'])
     pubkey_d = read_test_file(['pgpfiles','key','DSAELG1.pub.asc'])
     signed = sign_str(0x01, seckey_d, target=lit_d,
                       use_key=(None, '0CFC2B6DCC079DF3'),
                       passphrase='test')
     verified = verify_str(signed, pubkey_d)
     self.assertEqual(lit_d, list_pkts(verified)[0].body.data)
开发者ID:BackupTheBerlios,项目名称:pgpyp-svn,代码行数:10,代码来源:test_16_api_str.py


示例13: testD01DSASecretKey

 def testD01DSASecretKey(self):
     """crypto.cipher: decrypt_symmetric() v4 DSA secret key (DSA_x)"""
     dsasec_d = read_test_file(['pgpfiles','key','DSAELG1.sec.gpg'])
     dsasecnopass_d = read_test_file(['pgpfiles','key','DSAELG1.sec.nopass.gpg'])
     pkts, nopasspkts = list_pkts(dsasec_d), list_pkts(dsasecnopass_d)
     secretkey_pkt, nopasskey_pkt = pkts[0], nopasspkts[0]
     secretkey, nopasskey = secretkey_pkt.body, nopasskey_pkt.body
     passphrase = 'test'
     key = string2key(secretkey.s2k, secretkey.alg_sym, passphrase)
     result = decrypt_symmetric(secretkey.alg_sym, key, secretkey._enc_d, secretkey.iv)
     self.assertEqual(nopasskey.DSA_x._d, result[:22])
开发者ID:BackupTheBerlios,项目名称:pgpyp-svn,代码行数:11,代码来源:test_14_cipher.py


示例14: testH01EncryptPublicElGamalDES3

 def testH01EncryptPublicElGamalDES3(self):
     """crypto.cipher: encrypt()/decrypt() ElGamal, DES3 w/ integrity"""
     key_d = read_test_file(['pgpfiles','key','DSAELG3.pub.gpg'])
     keypkt = list_pkts(key_d)[3] # ElGamal encrypting key
     msg = "My secret message."
     key = gen_random(_keysize(SYM_DES3))
     sespkt = encrypt_public_session(keypkt, key, SYM_DES3)
     encpkt = encrypt_integrity(SYM_DES3, key, msg)
     seckey_d = read_test_file(['pgpfiles','key','DSAELG3.sec.nopass.gpg'])
     seckeypkt = list_pkts(seckey_d)[2]
     clrtxt = decrypt(encpkt, None, sespkt, seckeypkt)
     self.assertEqual(msg, clrtxt)
开发者ID:BackupTheBerlios,项目名称:pgpyp-svn,代码行数:12,代码来源:test_14_cipher.py


示例15: testD03RSA

 def testD03RSA(self):
     """crypto.cipher: decrypt_symmetric() v3 RSA secret key (RSA_d,p,q,u)"""
     rsasec_armored = read_test_file(['pgpfiles','interop','pgp6.5.3','RSA1','key.pgp6.5.3.RSA1.sec.asc'])
     rsanopass_armored = read_test_file(['pgpfiles','interop','pgp6.5.3','RSA1','key.pgp6.5.3.RSA1.sec.nopass.asc'])
     rsasec_d, rsanopass_d = list_armored(rsasec_armored)[0].data, list_armored(rsanopass_armored)[0].data
     pkts, nopasspkts = list_pkts(rsasec_d), list_pkts(rsanopass_d)
     secretkey_pkt, nopasskey_pkt = pkts[0], nopasspkts[0]
     secretkey, nopasskey = secretkey_pkt.body, nopasskey_pkt.body
     passphrase = 'test'
     # for the future..
     if secretkey.s2k_usg in [254, 255]: # we have an s2k
         key = string2key(secretkey.s2k, secretkey.alg_sym, passphrase)
     else:
         import md5
         key = md5.new(passphrase).digest()
     # Just comparing bytes, not integer values. The funky notation
     # 'enc_RSA_d_d', 'enc_RSA_p_d' means "the encrypted *integer*
     # data from the RSA d and p # MPIs, respectively.
     # 'len_RSA_d_d' means "the octet length of the integer portion
     # of the RSA d MPI."
     idx = 0
     # RSA_d
     len_RSA_d_d = mpilen2int(secretkey._enc_d[idx:idx+2])
     idx = idx + 2
     enc_RSA_d_d = secretkey._enc_d[idx:idx+len_RSA_d_d]
     idx = idx + len_RSA_d_d
     iv = secretkey.iv # iv provided
     RSA_d_d = decrypt_symmetric(secretkey.alg_sym, key, enc_RSA_d_d, iv)
     self.assertEqual(RSA_d_d, nopasskey.RSA_d._int_d)
     # RSA_p
     len_RSA_p_d = mpilen2int(secretkey._enc_d[idx:idx+2])
     idx = idx + 2
     enc_RSA_p_d = secretkey._enc_d[idx:idx+len_RSA_p_d]
     idx = idx + len_RSA_p_d
     iv = enc_RSA_d_d[-8:] # last 8 octets from "pre-sync" instream
     RSA_p_d = decrypt_symmetric(secretkey.alg_sym, key, enc_RSA_p_d, iv)
     self.assertEqual(RSA_p_d, nopasskey.RSA_p._int_d)
     # RSA_q
     len_RSA_q_d = mpilen2int(secretkey._enc_d[idx:idx+2])
     idx = idx + 2
     enc_RSA_q_d = secretkey._enc_d[idx:idx+len_RSA_q_d]
     idx = idx + len_RSA_q_d
     iv = enc_RSA_p_d[-8:] # last 8 octets from "pre-sync" instream
     RSA_q_d = decrypt_symmetric(secretkey.alg_sym, key, enc_RSA_q_d, iv)
     self.assertEqual(RSA_q_d, nopasskey.RSA_q._int_d)
     # RSA_u
     len_RSA_u_d = mpilen2int(secretkey._enc_d[idx:idx+2])
     idx = idx + 2
     enc_RSA_u_d = secretkey._enc_d[idx:idx+len_RSA_u_d]
     idx = idx + len_RSA_u_d
     iv = enc_RSA_q_d[-8:] # last 8 octets from "pre-sync" instream
     RSA_u_d = decrypt_symmetric(secretkey.alg_sym, key, enc_RSA_u_d, iv)
     self.assertEqual(RSA_u_d, nopasskey.RSA_u._int_d)
开发者ID:BackupTheBerlios,项目名称:pgpyp-svn,代码行数:53,代码来源:test_14_cipher.py


示例16: testF03DSADirectForeign

 def testF03DSADirectForeign(self):
     "crypto.signature: sign() v4 DSA direct on foreign primary key"
     targetkey_d = read_test_file(['pgpfiles','key','DSAELG3.pub.gpg'])
     seckey_d = read_test_file(['pgpfiles','key','DSAELG1.sec.gpg'])
     targetkeypkt = list_pkts(targetkey_d)[0]
     seckeypkt = list_pkts(seckey_d)[0]
     sigtype = SIG_DIRECT
     opts = {'passphrase':'test', 'primary':targetkeypkt}
     sigpkt = sign(sigtype, targetkeypkt, seckeypkt, **opts)
     verified = verify(sigpkt, targetkeypkt, seckeypkt,
                           primary=targetkeypkt)
     self.assertEqual(1, verified)
开发者ID:BackupTheBerlios,项目名称:pgpyp-svn,代码行数:12,代码来源:test_12_signing.py


示例17: testD02RSASecretKey

 def testD02RSASecretKey(self):
     """crypto.cipher: decrypt_symmetric() v4 RSA secret key (RSA_d,p,q,u)"""
     rsasec_d = read_test_file(['pgpfiles','key','RSA1.sec.gpg'])
     rsasecnopass_d = read_test_file(['pgpfiles','key','RSA1.sec.nopass.gpg'])
     pkts, nopasspkts = list_pkts(rsasec_d), list_pkts(rsasecnopass_d)
     secretkey_pkt, nopasskey_pkt = pkts[0], nopasspkts[0]
     secretkey, nopasskey = secretkey_pkt.body, nopasskey_pkt.body
     passphrase = 'test'
     key = string2key(secretkey.s2k, secretkey.alg_sym, passphrase)
     result = decrypt_symmetric(secretkey.alg_sym, key, secretkey._enc_d, secretkey.iv)
     good_mpi_d = nopasskey.RSA_d._d + nopasskey.RSA_p._d + nopasskey.RSA_q._d + nopasskey.RSA_u._d
     self.assertEqual(good_mpi_d, result[:328])
开发者ID:BackupTheBerlios,项目名称:pgpyp-svn,代码行数:12,代码来源:test_14_cipher.py


示例18: testE08SignSubkeyBadSigner

 def testE08SignSubkeyBadSigner(self):
     "sign_str() subkey direct (0x1F) target not found"
     seckey_d = read_test_file(['pgpfiles','key','DSAELG1.sec.asc'])
     pubkey_d = read_test_file(['pgpfiles','key','DSAELG1.pub.asc'])
     try:
         sigpkt = sign_str(0x1F, seckey_d, target=pubkey_d,
                           use_key=(None, "0CFC2B6DCC079xxx"), # munged
                           target_key=(None,"CB7D6980A1F2BEF6"),
                           passphrase='test')
     except PGPError: # signing key is specified so it must be used
         pass
     else:
         self.fail()
开发者ID:BackupTheBerlios,项目名称:pgpyp-svn,代码行数:13,代码来源:test_16_api_str.py


示例19: testG03Decrypt3

 def testG03Decrypt3(self):
     """crypto.cipher: decrypt() v3 public (RSA nopass) 3DES compressed"""
     enc_d = read_test_file(['pgpfiles','enc','pub.pgp653rsa.clrtxt.gpg'])
     key_d = read_test_file(['pgpfiles','key','pgp653rsa.sec.nopass.gpg'])
     clr_d = read_test_file(['pgpfiles','cleartext.txt'])
     sespkt, encpkt = list_pkts(enc_d)
     passphrase = 'test'
     sespkt, encpkt = list_pkts(enc_d)
     keypkt = list_pkts(key_d)[0]
     msg_d = decrypt(encpkt, passphrase, sespkt, keypkt)
     compmsg = list_msgs(list_pkts(msg_d))[0]
     litpkt = list_pkts(compmsg.compressed.body.data)[0]
     self.assertEqual(clr_d, litpkt.body.data)
开发者ID:BackupTheBerlios,项目名称:pgpyp-svn,代码行数:13,代码来源:test_14_cipher.py


示例20: testE03SignDetached

 def testE03SignDetached(self):
     "sign_str()/verify_str() detached binary (0x00) using key ID"
     lit_d = read_test_file(['pgpfiles','cleartext.txt'])
     seckey_d = read_test_file(['pgpfiles','key','DSAELG1.sec.asc'])
     pubkey_d = read_test_file(['pgpfiles','key','DSAELG1.pub.asc'])
     sigtype = 0x01
     keyid_d = "0CFC2B6DCC079DF3"
     passphrase = "test"
     sigpkt = sign_str(0x01, seckey_d, target=lit_d,
                       use_key=(None, '0CFC2B6DCC079DF3'),
                       passphrase='test',
                       detach=True)
     verified = verify_str(sigpkt, pubkey_d, detached=lit_d)
     self.assertEqual(lit_d, verified)
开发者ID:BackupTheBerlios,项目名称:pgpyp-svn,代码行数:14,代码来源:test_16_api_str.py



注:本文中的support.read_test_file函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python support.root_deiconify函数代码示例发布时间:2022-05-27
下一篇:
Python support.pack_single_uint32函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap