Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update harness for aws_cryptosdk_enc_ctx_clone #611

Merged
merged 10 commits into from
Oct 21, 2020
12 changes: 6 additions & 6 deletions .cbmc-batch/jobs/aws_cryptosdk_enc_ctx_clone/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ include ../Makefile.local_default

#########
# Local vars
MAX_NUM_ELEMS = 4
# Time on my laptop: 4m50s
MAX_TABLE_SIZE ?= 4
# Time on my laptop: 5m10s
#########
#if we don't include the hash_table.c, we don't need to remove their function bodies
ABSTRACTIONS += $(SRCDIR)/c-common-helper-stubs/aws_hash_table_no_slots_override.c
Expand All @@ -35,13 +35,14 @@ CBMCFLAGS +=

DEFINES += -DHASH_ITER_ELEMENT_GENERATOR=hash_iterator_string_string_generator
DEFINES += -DHASH_TABLE_FIND_ELEMENT_GENERATOR=hash_find_string_string_generator
DEFINES += -DMAX_NUM_ELEMS=$(MAX_NUM_ELEMS)
DEFINES += -DMAX_TABLE_SIZE=$(MAX_TABLE_SIZE)

DEPENDENCIES += $(SRCDIR)/c-common-helper-src/make_common_data_structures.c
DEPENDENCIES += $(SRCDIR)/c-common-helper-src/proof_allocators.c
DEPENDENCIES += $(SRCDIR)/c-common-helper-src/utils.c
DEPENDENCIES += $(SRCDIR)/c-common-src/byte_buf.c
DEPENDENCIES += $(SRCDIR)/c-common-src/common.c
DEPENDENCIES += $(SRCDIR)/c-common-src/hash_table.c
DEPENDENCIES += $(SRCDIR)/c-common-src/math.c
DEPENDENCIES += $(SRCDIR)/c-common-src/string.c
DEPENDENCIES += $(SRCDIR)/c-enc-sdk-src/enc_ctx.c
Expand All @@ -51,8 +52,7 @@ ENTRY = aws_cryptosdk_enc_ctx_clone_harness
REMOVE_FUNCTION_BODIES += --remove-function-body aws_string_destroy
REMOVE_FUNCTION_BODIES += --remove-function-body aws_string_new_from_array

UNWINDSET += aws_cryptosdk_enc_ctx_clone.0:$(shell echo $$(($(MAX_NUM_ELEMS) + 1)))
UNWINDSET += aws_cryptosdk_enc_ctx_clone.1:$(shell echo $$(($(MAX_NUM_ELEMS) + 1)))

UNWINDSET += aws_cryptosdk_enc_ctx_clone.0:$(shell echo $$((1 + $(MAX_TABLE_SIZE))))
UNWINDSET += aws_cryptosdk_enc_ctx_clone.1:$(shell echo $$((1 + $(MAX_TABLE_SIZE))))
###########
include ../Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,22 @@
#include <proof_helpers/proof_allocators.h>
#include <proof_helpers/utils.h>

void make_hash_table_with_no_backing_store(struct aws_hash_table *map, size_t max_table_entries);

/**
* The actual proof
*/
void aws_cryptosdk_enc_ctx_clone_harness() {
struct aws_hash_table dest;
make_hash_table_with_no_backing_store(&dest, MAX_NUM_ELEMS);
__CPROVER_assume(aws_hash_table_is_valid(&dest));
/* Nondet Input */
struct aws_hash_table *dest = malloc(sizeof(*dest));
struct aws_hash_table *src = malloc(sizeof(*src));

/* Assumptions */
ensure_allocated_hash_table(dest, MAX_TABLE_SIZE);
__CPROVER_assume(aws_hash_table_is_valid(dest));
__CPROVER_assume(dest->p_impl->entry_count <= MAX_TABLE_SIZE);
ensure_hash_table_has_valid_destroy_functions(dest);

struct aws_hash_table src;
make_hash_table_with_no_backing_store(&src, MAX_NUM_ELEMS);
__CPROVER_assume(aws_hash_table_is_valid(&src));
ensure_allocated_hash_table(src, MAX_TABLE_SIZE);
__CPROVER_assume(aws_hash_table_is_valid(src));
__CPROVER_assume(src->p_impl->entry_count <= MAX_TABLE_SIZE);
ensure_hash_table_has_valid_destroy_functions(src);

int rval = aws_cryptosdk_enc_ctx_clone(can_fail_allocator(), &dest, &src);
/* Operation under verification */
int rval = aws_cryptosdk_enc_ctx_clone(can_fail_allocator(), dest, src);
danielsn marked this conversation as resolved.
Show resolved Hide resolved
}