Exemple #1
0
    def specification(self) -> None:
        x = self.fresh_var(ty.array(2, ty.i32), "x")
        p = self.alloc(ty.array(4, ty.i32))
        self.points_to(p, x, check_target_type=self.check_x_type)

        self.execute_func(p)

        self.points_to(p, cryptol("{x} # {x}".format(x=x.name())))
        self.returns(void)
    def specification(self):
        array_ty = ty.array(2, ty.array(4, ty.i32))
        i = self.fresh_var(array_ty, "w.i")
        pw = self.alloc(ty.struct_type(array_ty), points_to=struct(i))

        self.execute_func(pw)

        self.points_to(pw, struct(cryptol('zero:[2][4][32]')))
        self.returns(void)
    def specification(self):
        (x, x_p) = ptr_to_fresh(self, ty.array(2, ty.i32), "x")
        p = self.alloc(ty.alias('struct.s'), points_to=struct(x_p))

        self.execute_func(p)

        self.returns(p)
Exemple #4
0
    def specification(self) -> None:
        data = self.fresh_var(array(self.length, i8), "data")
        buf = alloc_pointsto_buffer_readonly(self, self.length, data)

        self.execute_func(buf)

        new_buf = alloc_pointsto_buffer(self, self.length, data)
        self.returns(new_buf)
    def specification(self):
        (_, x_p) = ptr_to_fresh(self, ty.array(2, ty.i32), "x")
        p = self.alloc(ty.alias('struct.s'), points_to=struct(x_p))

        self.execute_func(p)

        self.points_to(p, struct(x_p))
        self.points_to(x_p, cryptol('[0, 0] : [2][32]'))
        self.returns(void)
Exemple #6
0
    def test_points_to_at_type(self):
        connect()
        if __name__ == "__main__": view(LogResults())
        bcname = str(Path('tests', 'saw', 'test-files',
                          'points_to_at_type.bc'))
        mod = llvm_load_module(bcname)

        result = llvm_verify(mod, "f", FPointsToContract(None))
        self.assertIs(result.is_success(), True)

        result = llvm_verify(mod, "f", FPointsToContract(ty.array(2, ty.i32)))
        self.assertIs(result.is_success(), True)

        with self.assertRaises(VerificationError):
            llvm_verify(mod, "f", FPointsToContract(PointerType()))

        with self.assertRaises(VerificationError):
            llvm_verify(mod, "f", FPointsToContract(ty.array(3, ty.i32)))
Exemple #7
0
def setup_hash_state(c: Contract, pstate: SetupVal) -> Tuple[Any, FreshVar]:
    alg0 = c.fresh_var(ty.i32, "alg")
    h0 = c.fresh_var(ty.array(8, ty.i64), "h0")
    Nl0 = c.fresh_var(ty.i64, "Nl")
    Nh0 = c.fresh_var(ty.i64, "Nh")
    u0 = c.fresh_var(ty.array(16, ty.i64), "u")
    num0 = c.fresh_var(ty.i32, "h0")
    is_ready_for_input0 = c.fresh_var(ty.i8, "is_ready_for_input")
    currently_in_hash0 = c.fresh_var(ty.i64, "currently_in_hash")
    md_len0 = c.fresh_var(ty.i32, "md_len")
    (_, pimpl) = ptr_to_fresh(c,
                              ty.alias('struct.s2n_hash'),
                              "impl",
                              read_only=True)
    c.points_to(
        pstate,
        struct(pimpl, alg0, is_ready_for_input0, currently_in_hash0,
               struct(struct(struct(h0, Nl0, Nh0, struct(u0), num0,
                                    md_len0)))))
Exemple #8
0
def buffer_type(length: int) -> LLVMType:
    return array(8 + length, i8)