forked from aws/s2n-tls
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a proof harness for s2n_hmac_update (aws#2531)
* Adds a proof harness for s2n_hmac_update * Avoids unsigned-arithmetic overflow * Updates SAW and SideTrail proofs * Lexicographic order * Removes bounded_malloc from s2n_hmac_update proof * Prevent overflow using s2n_add_overflow Signed-off-by: Felipe R. Monteiro <[email protected]>
- Loading branch information
1 parent
09d182e
commit a1f92e6
Showing
6 changed files
with
97 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use | ||
# this file except in compliance with the License. A copy of the License is | ||
# located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
# implied. See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Expected runtime is less than a minute. | ||
|
||
CBMCFLAGS += | ||
|
||
PROOF_UID = s2n_hmac_update | ||
HARNESS_ENTRY = $(PROOF_UID)_harness | ||
HARNESS_FILE = $(HARNESS_ENTRY).c | ||
|
||
PROOF_SOURCES += $(OPENSSL_SOURCE)/bn_override.c | ||
PROOF_SOURCES += $(OPENSSL_SOURCE)/ec_override.c | ||
PROOF_SOURCES += $(OPENSSL_SOURCE)/evp_override.c | ||
PROOF_SOURCES += $(OPENSSL_SOURCE)/md5_override.c | ||
PROOF_SOURCES += $(OPENSSL_SOURCE)/sha_override.c | ||
PROOF_SOURCES += $(PROOF_SOURCE)/make_common_datastructures.c | ||
PROOF_SOURCES += $(PROOF_SOURCE)/proof_allocators.c | ||
PROOF_SOURCES += $(PROOF_STUB)/s2n_calculate_stacktrace.c | ||
PROOF_SOURCES += $(PROOF_STUB)/s2n_is_in_fips_mode.c | ||
PROOF_SOURCES += $(PROOFDIR)/$(HARNESS_FILE) | ||
|
||
PROJECT_SOURCES += $(SRCDIR)/crypto/s2n_hmac.c | ||
PROJECT_SOURCES += $(SRCDIR)/crypto/s2n_hash.c | ||
PROJECT_SOURCES += $(SRCDIR)/crypto/s2n_evp.c | ||
PROJECT_SOURCES += $(SRCDIR)/utils/s2n_result.c | ||
PROJECT_SOURCES += $(SRCDIR)/utils/s2n_safety.c | ||
|
||
# We abstract these functions because manual inspection demonstrates they are unreachable. | ||
REMOVE_FUNCTION_BODY += __CPROVER_file_local_s2n_hash_c_s2n_evp_hash_digest | ||
REMOVE_FUNCTION_BODY += __CPROVER_file_local_s2n_hash_c_s2n_hash_digest_size | ||
REMOVE_FUNCTION_BODY += __CPROVER_file_local_s2n_hash_c_s2n_low_level_hash_digest | ||
|
||
UNWINDSET += | ||
|
||
include ../Makefile.common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
: | ||
This file marks this directory as containing a CBMC proof. This file | ||
is automatically clobbered in CI and replaced with parameters for | ||
running the proof. |
39 changes: 39 additions & 0 deletions
39
tests/cbmc/proofs/s2n_hmac_update/s2n_hmac_update_harness.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
#include "crypto/s2n_hmac.h" | ||
|
||
#include <cbmc_proof/make_common_datastructures.h> | ||
#include <cbmc_proof/proof_allocators.h> | ||
|
||
void s2n_hmac_update_harness() | ||
{ | ||
/* Non-deterministic inputs. */ | ||
struct s2n_hmac_state *state = cbmc_allocate_s2n_hmac_state(); | ||
uint32_t size; | ||
void *in = malloc(size); | ||
|
||
/* Assumptions. */ | ||
__CPROVER_assume(s2n_result_is_ok(s2n_hmac_state_validate(state))); | ||
__CPROVER_file_local_s2n_hash_c_s2n_hash_set_impl(&state->inner); | ||
|
||
/* Operation under verification. */ | ||
if (s2n_hmac_update(state, in, size) == S2N_SUCCESS) | ||
{ | ||
/* Post-conditions. */ | ||
assert(s2n_result_is_ok(s2n_hmac_state_validate(state))); | ||
assert(state->inner.hash_impl->update != NULL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters