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.
Created draft proof for s2n_constant_time_equals (aws#2072)
* Created patrial proof for s2n_constant_time_equals * Incorporated comments. * Updated return type of s2n_constant_time_equals definitions. * Added disambiguating parentheses. * Incorporated additional comments.
- Loading branch information
Showing
9 changed files
with
85 additions
and
6 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
tests/cbmc/proofs/s2n_safety_constant_time_equals/Makefile
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,31 @@ | ||
# 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 40 seconds. | ||
MAX_ARR_LEN = 10 | ||
DEFINES += -DMAX_ARR_LEN=$(MAX_ARR_LEN) | ||
|
||
CBMCFLAGS += | ||
|
||
HARNESS_ENTRY = s2n_safety_constant_time_equals_harness | ||
HARNESS_FILE = $(HARNESS_ENTRY).c | ||
|
||
PROOF_SOURCES += $(HARNESS_FILE) | ||
PROOF_SOURCES += $(PROOF_SOURCE)/proof_allocators.c | ||
|
||
PROJECT_SOURCES += $(SRCDIR)/utils/s2n_safety.c | ||
|
||
UNWINDSET += s2n_constant_time_equals.0:$(call addone,$(MAX_ARR_LEN)) | ||
|
||
include ../Makefile.common |
4 changes: 4 additions & 0 deletions
4
tests/cbmc/proofs/s2n_safety_constant_time_equals/cbmc-batch.yaml
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. |
42 changes: 42 additions & 0 deletions
42
tests/cbmc/proofs/s2n_safety_constant_time_equals/s2n_safety_constant_time_equals_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,42 @@ | ||
/* | ||
* 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 "api/s2n.h" | ||
#include "utils/s2n_safety.h" | ||
|
||
#include <sys/param.h> | ||
#include <assert.h> | ||
|
||
#include <cbmc_proof/proof_allocators.h> | ||
|
||
void s2n_safety_constant_time_equals_harness() { | ||
/* Non-deterministic inputs. */ | ||
uint32_t len; | ||
uint32_t alen; | ||
uint32_t blen; | ||
__CPROVER_assume(len < MAX_ARR_LEN); | ||
__CPROVER_assume(alen >= len); | ||
__CPROVER_assume(blen >= len); | ||
uint8_t * a = can_fail_malloc(alen); | ||
uint8_t * b = can_fail_malloc(blen); | ||
|
||
/* Pre-conditions. */ | ||
__CPROVER_assume(S2N_IMPLIES(len != 0, a != NULL && b != NULL)); | ||
|
||
/* Check logical equivalence of s2n_constant_time_equals against element equality */ | ||
if(s2n_constant_time_equals(a, b, len)) { | ||
assert(__CPROVER_forall {size_t i; (i >=0 && i < len) ==> (a[i] == b[i])}); | ||
} | ||
} |
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
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
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