Skip to content

Commit 09484af

Browse files
authored
fix: type inconsistencies in CBMC proof harnesses (#772)
These changes add necessary forward declarations (or system headers includes) and address inconsistencies in how we invoke functions from CBMC proof harnesses as compared to their original signatures.
1 parent 6174f83 commit 09484af

File tree

30 files changed

+118
-33
lines changed

30 files changed

+118
-33
lines changed

verification/cbmc/include/make_common_data_structures.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <aws/cryptosdk/materials.h>
2020
#include <aws/cryptosdk/private/framefmt.h>
2121
#include <aws/cryptosdk/private/header.h>
22+
#include <aws/cryptosdk/private/hkdf.h>
2223
#include <proof_helpers/make_common_data_structures.h>
2324
#include <proof_helpers/proof_allocators.h>
2425
#include <proof_helpers/utils.h>
@@ -114,4 +115,5 @@ struct aws_cryptosdk_enc_request *ensure_enc_request_attempt_allocation(const si
114115
struct aws_cryptosdk_enc_materials *ensure_enc_materials_attempt_allocation();
115116

116117
/* Allocates the members of the default_cmm and ensures that internal pointers are pointing to the correct objects. */
117-
struct aws_cryptosdk_cmm *ensure_default_cmm_attempt_allocation(const struct aws_cryptosdk_keyring_vt *vtable);
118+
struct aws_cryptosdk_cmm *ensure_default_cmm_attempt_allocation(
119+
const struct aws_cryptosdk_cmm_vt *cmm_vtable, const struct aws_cryptosdk_keyring_vt *vtable);

verification/cbmc/include/openssl/evp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ EVP_MD_CTX *EVP_MD_CTX_new(void);
6262
int EVP_MD_CTX_size(const EVP_MD_CTX *ctx);
6363
void EVP_MD_CTX_free(EVP_MD_CTX *ctx);
6464
int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
65+
int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
6566
int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt);
6667
int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s);
6768
int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s);

verification/cbmc/include/openssl/rand.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
* permissions and limitations under the License.
1515
*/
1616

17-
/* Empty header. Necessary just because it is included in cipher.c */
17+
int RAND_bytes(unsigned char *buf, int num);

verification/cbmc/proofs/aws_cryptosdk_cmm_decrypt_materials/aws_cryptosdk_cmm_decrypt_materials_harness.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void aws_cryptosdk_cmm_decrypt_materials_harness() {
120120
*/
121121
__CPROVER_assume(aws_cryptosdk_dec_request_is_valid(request));
122122

123-
struct aws_cryptosdk_enc_materials **output = can_fail_malloc(sizeof(*output));
123+
struct aws_cryptosdk_dec_materials **output = can_fail_malloc(sizeof(*output));
124124
__CPROVER_assume(output);
125125

126126
// Run the function under test.

verification/cbmc/proofs/aws_cryptosdk_edk_list_copy_all/aws_cryptosdk_edk_list_copy_all_harness.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include <aws/cryptosdk/edk.h>
20+
#include <aws/cryptosdk/list_utils.h>
2021
#include <make_common_data_structures.h>
2122
#include <proof_helpers/make_common_data_structures.h>
2223
#include <proof_helpers/proof_allocators.h>
@@ -65,14 +66,15 @@ const size_t g_item_size = sizeof(struct aws_cryptosdk_edk);
6566
* These stubs capture the key aspect of checking that the element is allocated.
6667
* It writes/reads a magic constant to ensure that we only ever _clean_up() data that we cloned
6768
*/
68-
int aws_cryptosdk_edk_init_clone(struct aws_allocator *alloc, void *dest, void *src) {
69+
int aws_cryptosdk_edk_init_clone(
70+
struct aws_allocator *alloc, struct aws_cryptosdk_edk *dest, const struct aws_cryptosdk_edk *src) {
6971
assert(AWS_MEM_IS_READABLE(src, g_item_size));
7072
uint8_t *d = (uint8_t *)dest;
7173
*d = 0xab;
7274
return nondet_int();
7375
}
7476

75-
void aws_cryptosdk_edk_clean_up(void *p) {
77+
void aws_cryptosdk_edk_clean_up(struct aws_cryptosdk_edk *p) {
7678
uint8_t *d = (uint8_t *)p;
7779
assert(*d == 0xab);
7880
}

verification/cbmc/proofs/aws_cryptosdk_enc_ctx_clear/aws_cryptosdk_enc_ctx_clear_harness.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ void aws_cryptosdk_enc_ctx_clear_harness() {
3131
aws_cryptosdk_enc_ctx_clear(&map);
3232
assert(aws_hash_table_is_valid(&map));
3333
struct hash_table_state *impl = map.p_impl;
34-
assert_all_zeroes(&impl->slots[0], impl->size * sizeof(impl->slots[0]));
34+
assert_all_zeroes((const uint8_t *)&impl->slots[0], impl->size * sizeof(impl->slots[0]));
3535
}

verification/cbmc/proofs/aws_cryptosdk_enc_ctx_deserialize/aws_cryptosdk_enc_ctx_deserialize_harness.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <aws/common/hash_table.h>
1717
#include <aws/common/private/hash_table_impl.h>
1818
#include <aws/cryptosdk/enc_ctx.h>
19+
#include <aws/cryptosdk/private/enc_ctx.h>
1920
#include <proof_helpers/make_common_data_structures.h>
2021
#include <proof_helpers/proof_allocators.h>
2122
#include <proof_helpers/utils.h>

verification/cbmc/proofs/aws_cryptosdk_enc_ctx_serialize/aws_cryptosdk_enc_ctx_serialize_harness.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <aws/common/hash_table.h>
1717
#include <aws/common/private/hash_table_impl.h>
1818
#include <aws/cryptosdk/enc_ctx.h>
19+
#include <aws/cryptosdk/private/enc_ctx.h>
1920
#include <proof_helpers/make_common_data_structures.h>
2021
#include <proof_helpers/proof_allocators.h>
2122
#include <proof_helpers/utils.h>

verification/cbmc/proofs/aws_cryptosdk_enc_ctx_size/aws_cryptosdk_enc_ctx_size_harness.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <aws/common/hash_table.h>
1717
#include <aws/common/private/hash_table_impl.h>
1818
#include <aws/cryptosdk/enc_ctx.h>
19+
#include <aws/cryptosdk/private/enc_ctx.h>
1920
#include <proof_helpers/make_common_data_structures.h>
2021
#include <proof_helpers/proof_allocators.h>
2122
#include <proof_helpers/utils.h>

verification/cbmc/proofs/aws_cryptosdk_enc_materials_new/aws_cryptosdk_enc_materials_new_harness.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void aws_cryptosdk_enc_materials_new_harness() {
3232
__CPROVER_assume(aws_allocator_is_valid(alloc));
3333

3434
/* Operation under verification. */
35-
struct aws_cryptosdk_dec_materials *enc_mat = aws_cryptosdk_enc_materials_new(alloc, alg);
35+
struct aws_cryptosdk_enc_materials *enc_mat = aws_cryptosdk_enc_materials_new(alloc, alg);
3636

3737
/* Post-conditions. */
3838
if (enc_mat != NULL) {

0 commit comments

Comments
 (0)