| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#include <assert.h> |
| 17 |
#include <cbmc_proof/cbmc_utils.h> |
| 18 |
#include <cbmc_proof/make_common_datastructures.h> |
| 19 |
|
| 20 |
#include "api/s2n.h" |
| 21 |
#include "utils/s2n_blob.h" |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
void s2n_dup_harness() |
| 31 |
{ |
| 32 |
struct s2n_blob *from = cbmc_allocate_s2n_blob(); |
| 33 |
struct s2n_blob *to = cbmc_allocate_s2n_blob(); |
| 34 |
__CPROVER_assume(s2n_result_is_ok(s2n_blob_validate(from))); |
| 35 |
__CPROVER_assume(s2n_result_is_ok(s2n_blob_validate(to))); |
| 36 |
const struct s2n_blob old_from = *from; |
| 37 |
const struct s2n_blob old_to = *to; |
| 38 |
struct store_byte_from_buffer old_byte; |
| 39 |
save_byte_from_blob(from, &old_byte); |
| 40 |
|
| 41 |
nondet_s2n_mem_init(); |
| 42 |
|
| 43 |
if (s2n_dup(from, to) == S2N_SUCCESS) { |
| 44 |
assert(old_from.size != 0); |
| 45 |
assert(old_from.data != NULL); |
| 46 |
assert(old_to.size == 0); |
| 47 |
assert(old_to.data == NULL); |
| 48 |
assert(to->size == from->size); |
| 49 |
|
| 50 |
uint32_t idx; |
| 51 |
__CPROVER_assume(idx < from->size); |
| 52 |
assert(from->data[ idx ] == to->data[ idx ]); |
| 53 |
} |
| 54 |
assert(s2n_result_is_ok(s2n_blob_validate(from))); |
| 55 |
assert(s2n_result_is_ok(s2n_blob_validate(to))); |
| 56 |
assert_blob_equivalence(from, &old_from, &old_byte); |
| 57 |
} |