예제 #1
0
 def testRandomMessageDecode(self):
     group = ECGroup(prime192v2)
     for i in range(runs):
         msg_len = group.bitsize()
         s = OpenSSLRand().getRandomBytes(msg_len)
         g = group.encode(s)
         t = group.decode(g)
         assert s == t, "Failed to encode/decode %d properly" % i
예제 #2
0
    def testHybridEnc(self):
        groupObj = ECGroup(prime192v1)
        pkenc = ElGamal(groupObj)
        hyenc = HybridEnc(pkenc, msg_len=groupObj.bitsize())

        (pk, sk) = hyenc.keygen()

        # message len should be group.bitsize() len for prime192v1 (or 20 bytes)
        m = b'the hello world msg1'
        cipher = hyenc.encrypt(pk, m)
        orig_m = hyenc.decrypt(pk, sk, cipher)
        assert m == orig_m, "Failed Decryption"
        if debug: print("Successful Decryption!!")