| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#include "crypto/s2n_fips.h" |
| 17 |
#include "crypto/s2n_hash.h" |
| 18 |
|
| 19 |
#include <cbmc_proof/make_common_datastructures.h> |
| 20 |
|
| 21 |
#include <assert.h> |
| 22 |
|
| 23 |
void s2n_hash_free_harness() |
| 24 |
{ |
| 25 |
|
| 26 |
struct s2n_hash_state *state = cbmc_allocate_s2n_hash_state(); |
| 27 |
|
| 28 |
|
| 29 |
__CPROVER_assume(s2n_result_is_ok(s2n_hash_state_validate(state))); |
| 30 |
|
| 31 |
struct rc_keys_from_hash_state saved_hash_state; |
| 32 |
save_rc_keys_from_hash_state(state, &saved_hash_state); |
| 33 |
|
| 34 |
|
| 35 |
assert(s2n_hash_free(state) == S2N_SUCCESS); |
| 36 |
if (state != NULL) { |
| 37 |
assert(state->hash_impl->free != NULL); |
| 38 |
assert(state->digest.high_level.evp.ctx == NULL); |
| 39 |
assert(state->digest.high_level.evp_md5_secondary.ctx == NULL); |
| 40 |
assert_rc_decrement_on_hash_state(&saved_hash_state); |
| 41 |
assert(state->is_ready_for_input == 0); |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
if (state != NULL) { |
| 46 |
|
| 47 |
S2N_EVP_MD_CTX_FREE(state->digest.high_level.evp.ctx); |
| 48 |
S2N_EVP_MD_CTX_FREE(state->digest.high_level.evp_md5_secondary.ctx); |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
free_rc_keys_from_hash_state(&saved_hash_state); |
| 53 |
} |
| 54 |
|
| 55 |
free(state); |
| 56 |
} |