Ejemplo n.º 1
0
    def specification(self):
        tp = self.alloc(alias_ty('struct.t'))
        b = self.fresh_var(i32, "b")
        self.points_to(field(field(tp, "n"), "b"), b)

        self.execute_func(tp)

        self.returns(b)
    def specification(self) -> None:
        instance = self.alloc(alias_ty("struct.signal_type_base"))
        destroy_func = global_var("signal_message_destroy")

        self.execute_func(instance, destroy_func)

        self.points_to(field(instance, "ref_count"), int_to_32_cryptol(1))
        self.points_to(field(instance, "destroy"), destroy_func)
        self.returns(void)
    def specification(self) -> None:
        ref_count = self.fresh_var(i32, "ref_count")
        self.precondition(cryptol(f"{ref_count.name()} > 0"))
        instance = self.alloc(alias_ty("struct.signal_type_base"))
        self.points_to(field(instance, "ref_count"), ref_count)

        self.execute_func(instance)

        self.points_to(field(instance, "ref_count"),
                       cryptol(f"{ref_count.name()} + 1"))
        self.returns(void)
Ejemplo n.º 4
0
    def specification(self) -> None:
        message = self.alloc(alias_ty("struct.signal_message"))
        (_, sender_identity_key_data,
         sender_identity_key) = alloc_ec_public_key(self)
        (_, receiver_identity_key_data,
         receiver_identity_key) = alloc_ec_public_key(self)
        mac_key_data = self.fresh_var(array_ty(self.mac_key_len, i8),
                                      "mac_key_data")
        mac_key = self.alloc(array_ty(self.mac_key_len, i8),
                             points_to=mac_key_data)
        global_context_unused_as_far_as_i_can_tell = self.alloc(
            signal_context_ty, read_only=True)

        base = self.fresh_var(alias_ty("struct.signal_type_base"), "base")
        message_type = self.fresh_var(i32, "message_type")
        global_context = self.alloc(signal_context_ty, read_only=True)
        self.points_to(field(global_context, "crypto_provider"),
                       dummy_signal_crypto_provider)

        serialized_message_len = self.serialized_len - SIGNAL_MESSAGE_MAC_LENGTH
        serialized_message_data = self.fresh_var(
            array_ty(serialized_message_len, i8), "serialized_message_data")

        expected_mac_data = mk_hmac(serialized_message_len,
                                    serialized_message_data,
                                    receiver_identity_key_data,
                                    sender_identity_key_data, self.mac_key_len,
                                    mac_key_data)

        serialized = alloc_buffer_aligned(self, self.serialized_len)
        self.points_to(elem(serialized, 0),
                       int_to_64_cryptol(self.serialized_len),
                       check_target_type=None)
        self.points_to(elem(serialized, 8),
                       serialized_message_data,
                       check_target_type=None)
        self.points_to(elem(serialized, 8 + serialized_message_len),
                       expected_mac_data,
                       check_target_type=None)

        base_message = struct(base, message_type, global_context, serialized)
        self.points_to(field(message, "base_message"), base_message)
        self.points_to(field(message, "message_version"),
                       int_to_8_cryptol(message_version))

        self.execute_func(message, sender_identity_key, receiver_identity_key,
                          mac_key, int_to_64_cryptol(self.mac_key_len),
                          global_context_unused_as_far_as_i_can_tell)

        self.returns(int_to_32_cryptol(1))
Ejemplo n.º 5
0
    def specification(self) -> None:
        context = self.alloc(signal_context_ty, read_only=True)
        hmac_context = self.alloc(i8)
        self.points_to(field(context, "crypto_provider"),
                       dummy_signal_crypto_provider)

        self.execute_func(context, hmac_context)

        self.returns(void)
Ejemplo n.º 6
0
    def specification(self) -> None:
        context = self.alloc(signal_context_ty, read_only=True)
        hmac_context_data = self.fresh_var(array_ty(HMAC_CONTEXT_LENGTH, i8),
                                           "hmac_context_data")
        hmac_context = self.alloc(array_ty(HMAC_CONTEXT_LENGTH, i8),
                                  points_to=hmac_context_data)
        output = self.alloc(ptr_ty(buffer_type(SIGNAL_MESSAGE_MAC_LENGTH)))
        self.points_to(field(context, "crypto_provider"),
                       dummy_signal_crypto_provider)

        self.execute_func(context, hmac_context, output)

        # output_buffer = alloc_buffer_aligned(self, SIGNAL_MESSAGE_MAC_LENGTH)
        # self.points_to(elem(output_buffer, 0), int_to_64_cryptol(SIGNAL_MESSAGE_MAC_LENGTH), check_target_type = i64)
        output_buffer = alloc_pointsto_buffer(
            self, SIGNAL_MESSAGE_MAC_LENGTH,
            cryptol(f"hmac_final {hmac_context_data.name()}"))

        self.points_to(output, output_buffer)
        self.returns(int_to_32_cryptol(0))
Ejemplo n.º 7
0
    def specification(self) -> None:
        context = self.alloc(signal_context_ty, read_only=True)
        hmac_context_data = self.fresh_var(array_ty(HMAC_CONTEXT_LENGTH, i8),
                                           "hmac_context_data")
        hmac_context = self.alloc(array_ty(HMAC_CONTEXT_LENGTH, i8),
                                  points_to=hmac_context_data)
        data_data = self.fresh_var(array_ty(self.data_len, i8), "data_data")
        data = self.alloc(array_ty(self.data_len, i8), points_to=data_data)
        self.points_to(field(context, "crypto_provider"),
                       dummy_signal_crypto_provider)

        self.execute_func(context, hmac_context, data,
                          int_to_64_cryptol(self.data_len))

        # self.points_to(hmac_context, hmac_context_data)
        self.points_to(
            hmac_context,
            cryptol(
                f"hmac_update`{{ {self.data_len} }} {data_data.name()} {hmac_context_data.name()}"
            ))
        self.returns(int_to_32_cryptol(0))
Ejemplo n.º 8
0
    def specification(self) -> None:
        context = self.alloc(signal_context_ty, read_only=True)
        hmac_context_ptr = self.alloc(ptr_ty(array_ty(HMAC_CONTEXT_LENGTH,
                                                      i8)))
        key_data = self.fresh_var(array_ty(self.key_len, i8), "key_data")
        key = self.alloc(array_ty(self.key_len, i8), points_to=key_data)
        self.points_to(field(context, "crypto_provider"),
                       dummy_signal_crypto_provider)

        self.execute_func(context, hmac_context_ptr, key,
                          int_to_64_cryptol(self.key_len))

        dummy_hmac_context = self.alloc(array_ty(HMAC_CONTEXT_LENGTH, i8),
                                        points_to=array(int_to_8_cryptol(42)))
        # self.points_to(hmac_context_ptr, dummy_hmac_context)
        dummy_hmac_context = self.alloc(
            array_ty(HMAC_CONTEXT_LENGTH, i8),
            points_to=cryptol(
                f"hmac_init`{{ {self.key_len} }} {key_data.name()}"))
        self.points_to(hmac_context_ptr, dummy_hmac_context)
        self.returns(int_to_32_cryptol(0))
Ejemplo n.º 9
0
    def specification(self) -> None:
        ec_public_key = alias_ty("struct.ec_public_key")
        buffer_ = self.alloc(ptr_ty(buffer_type(SIGNAL_MESSAGE_MAC_LENGTH)))
        (_, sender_identity_key_data,
         sender_identity_key) = alloc_ec_public_key(self)
        (_, receiver_identity_key_data,
         receiver_identity_key) = alloc_ec_public_key(self)
        mac_key_data = self.fresh_var(array_ty(self.mac_key_len, i8),
                                      "mac_key_data")
        mac_key = self.alloc(array_ty(self.mac_key_len, i8),
                             points_to=mac_key_data)
        serialized_data = self.fresh_var(array_ty(self.serialized_len, i8),
                                         "serialized_data")
        serialized = self.alloc(array_ty(self.serialized_len, i8),
                                points_to=serialized_data)
        global_context = self.alloc(signal_context_ty, read_only=True)
        self.points_to(field(global_context, "crypto_provider"),
                       dummy_signal_crypto_provider)

        self.execute_func(buffer_, int_to_8_cryptol(message_version),
                          sender_identity_key, receiver_identity_key, mac_key,
                          int_to_64_cryptol(self.mac_key_len), serialized,
                          int_to_64_cryptol(self.serialized_len),
                          global_context)

        expected = mk_hmac(self.serialized_len, serialized_data,
                           receiver_identity_key_data,
                           sender_identity_key_data, self.mac_key_len,
                           mac_key_data)

        # buffer_buf = alloc_buffer_aligned(self, SIGNAL_MESSAGE_MAC_LENGTH)
        # self.points_to(elem(buffer_buf, 0), int_to_64_cryptol(SIGNAL_MESSAGE_MAC_LENGTH), check_target_type = i64)
        buffer_buf = alloc_pointsto_buffer(self, SIGNAL_MESSAGE_MAC_LENGTH,
                                           expected)
        self.points_to(buffer_, buffer_buf)
        self.returns(int_to_32_cryptol(0))