Example #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_key = "secret.a"
        nacl.generate_key(filename_key)

        strobe = blocks.message_strobe(msg, 100)
        encrypt_secret = nacl.encrypt_secret(filename_key)
        decrypt_secret = nacl.decrypt_secret(filename_key)
        debug = blocks.message_debug()

        self.tb.msg_connect(strobe, "strobe", encrypt_secret, "Msg clear")
        self.tb.msg_connect(encrypt_secret, "Msg encrypted", decrypt_secret,
                            "Msg encrypted")
        self.tb.msg_connect(decrypt_secret, "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])
    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_key = "secret.a"
        nacl.generate_key(filename_key)

        strobe = blocks.message_strobe(msg, 100)
        encrypt_secret = nacl.encrypt_secret(filename_key)
        decrypt_secret = nacl.decrypt_secret(filename_key)
        debug = blocks.message_debug()

        self.tb.msg_connect(strobe, "strobe", encrypt_secret, "Msg clear")
        self.tb.msg_connect(encrypt_secret, "Msg encrypted", decrypt_secret, "Msg encrypted")
        self.tb.msg_connect(decrypt_secret, "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])
Example #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_key = "secret.key"
        nacl.generate_key(filename_key)

        strobe = blocks.message_strobe(msg, 100)
        encrypt_secret = nacl.encrypt_secret(filename_key)
        debug = blocks.message_debug()

        self.tb.msg_connect(strobe, "strobe", encrypt_secret, "Msg clear")
        self.tb.msg_connect(encrypt_secret, "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))
Example #4
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_key = "secret.key"
     nacl.generate_key(filename_key)
     
     strobe = blocks.message_strobe(msg, 100)
     encrypt_secret = nacl.encrypt_secret(filename_key)
     debug = blocks.message_debug()
     
     self.tb.msg_connect(strobe,"strobe",encrypt_secret,"Msg clear")
     self.tb.msg_connect(encrypt_secret,"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))