예제 #1
0
 def test_001_t (self):
     data = [ord('a'),ord('b'),ord('c'),ord('d')]
     msg = pmt.list1(pmt.list2(pmt.string_to_symbol("msg_clear"),pmt.init_u8vector(len(data),data)))
     filename_sk_a = "secret.a"
     filename_pk_a = "public.a"
     nacl.generate_keypair(filename_sk_a,filename_pk_a)
     filename_sk_b = "secret.b"
     filename_pk_b = "public.b"
     nacl.generate_keypair(filename_sk_b,filename_pk_b)
     
     strobe = blocks.message_strobe(msg, 100)
     encrypt_public = nacl.encrypt_public(filename_pk_b,filename_sk_a)
     decrypt_public = nacl.decrypt_public(filename_pk_a,filename_sk_b)
     debug = blocks.message_debug()
     
     self.tb.msg_connect(strobe,"strobe",encrypt_public,"Msg clear")
     self.tb.msg_connect(encrypt_public,"Msg encrypted",decrypt_public,"Msg encrypted")
     self.tb.msg_connect(decrypt_public,"Msg decrypted",debug,"store")
     
     self.tb.start()
     sleep(0.15)
     self.tb.stop()
     self.tb.wait()
     
     # check results
     msg_out = debug.get_message(0)
     msg_symbol = pmt.symbol_to_string(pmt.nth(0,pmt.nth(0,msg_out)))
     msg_decrypted = pmt.u8vector_elements(pmt.nth(1,pmt.nth(0,msg_out)))
     print msg_symbol, msg_decrypted
     print "msg_clear", data
     
     for k in range(len(data)):
         self.assertEqual(data[k],msg_decrypted[k])
예제 #2
0
 def test_001_t (self):
     data = [ord('t'),ord('e'),ord('s'),ord('t')]
     msg = pmt.list1(pmt.list2(pmt.string_to_symbol("msg_clear"),pmt.init_u8vector(len(data),data)))
     filename_sk = "secret.key"
     filename_pk = "public.key"
     nacl.generate_keypair(filename_sk,filename_pk)
     
     strobe = blocks.message_strobe(msg, 100)
     encrypt_public = nacl.encrypt_public(filename_pk,filename_sk)
     debug = blocks.message_debug()
     
     self.tb.msg_connect(strobe,"strobe",encrypt_public,"Msg clear")
     self.tb.msg_connect(encrypt_public,"Msg encrypted",debug,"store")
     
     self.tb.start()
     sleep(0.15)
     self.tb.stop()
     self.tb.wait()
     
     # check results
     msg_stored = debug.get_message(0)
     nonce = pmt.nth(0,msg_stored)
     msg_encrypted = pmt.nth(1,msg_stored)
     print pmt.symbol_to_string(pmt.nth(0,nonce)), pmt.u8vector_elements(pmt.nth(1,nonce))
     print pmt.symbol_to_string(pmt.nth(0,msg_encrypted)), pmt.u8vector_elements(pmt.nth(1,msg_encrypted))
예제 #3
0
    def test_001_t(self):
        data = [ord('t'), ord('e'), ord('s'), ord('t')]
        msg = pmt.list1(
            pmt.list2(pmt.string_to_symbol("msg_clear"),
                      pmt.init_u8vector(len(data), data)))
        filename_sk = "secret.key"
        filename_pk = "public.key"
        nacl.generate_keypair(filename_sk, filename_pk)

        strobe = blocks.message_strobe(msg, 100)
        encrypt_public = nacl.encrypt_public(filename_pk, filename_sk)
        debug = blocks.message_debug()

        self.tb.msg_connect(strobe, "strobe", encrypt_public, "Msg clear")
        self.tb.msg_connect(encrypt_public, "Msg encrypted", debug, "store")

        self.tb.start()
        sleep(0.15)
        self.tb.stop()
        self.tb.wait()

        # check results
        msg_stored = debug.get_message(0)
        nonce = pmt.nth(0, msg_stored)
        msg_encrypted = pmt.nth(1, msg_stored)
        print pmt.symbol_to_string(pmt.nth(0, nonce)), pmt.u8vector_elements(
            pmt.nth(1, nonce))
        print pmt.symbol_to_string(pmt.nth(
            0,
            msg_encrypted)), pmt.u8vector_elements(pmt.nth(1, msg_encrypted))
예제 #4
0
    def test_001_t(self):
        data = [ord('a'), ord('b'), ord('c'), ord('d')]
        msg = pmt.list1(
            pmt.list2(pmt.string_to_symbol("msg_clear"),
                      pmt.init_u8vector(len(data), data)))
        filename_sk_a = "secret.a"
        filename_pk_a = "public.a"
        nacl.generate_keypair(filename_sk_a, filename_pk_a)
        filename_sk_b = "secret.b"
        filename_pk_b = "public.b"
        nacl.generate_keypair(filename_sk_b, filename_pk_b)

        strobe = blocks.message_strobe(msg, 100)
        encrypt_public = nacl.encrypt_public(filename_pk_b, filename_sk_a)
        decrypt_public = nacl.decrypt_public(filename_pk_a, filename_sk_b)
        debug = blocks.message_debug()

        self.tb.msg_connect(strobe, "strobe", encrypt_public, "Msg clear")
        self.tb.msg_connect(encrypt_public, "Msg encrypted", decrypt_public,
                            "Msg encrypted")
        self.tb.msg_connect(decrypt_public, "Msg decrypted", debug, "store")

        self.tb.start()
        sleep(0.15)
        self.tb.stop()
        self.tb.wait()

        # check results
        msg_out = debug.get_message(0)
        msg_symbol = pmt.symbol_to_string(pmt.nth(0, pmt.nth(0, msg_out)))
        msg_decrypted = pmt.u8vector_elements(pmt.nth(1, pmt.nth(0, msg_out)))
        print msg_symbol, msg_decrypted
        print "msg_clear", data

        for k in range(len(data)):
            self.assertEqual(data[k], msg_decrypted[k])