Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils: continued result migration #1891

Merged
merged 9 commits into from
May 21, 2020
Merged

Conversation

camshaft
Copy link
Contributor

@camshaft camshaft commented May 14, 2020

Please note that while we are transitioning from travis-ci to AWS CodeBuild, some tests are run on each platform. Non-AWS contributors will temporarily be unable to see CodeBuild results. We apologize for the inconvenience.

Resolved issues:

This is a continuation of the work started in #1872.

Description of changes:

s2n_ensure is introduced as a low-level definition for safety check helpers. This is intended to make it easier for static analyzers and verifiers to hook in and add additional checks.

s2n_safety has been updated to use the definitions provided by s2n_ensure. I also added a short description of what each macro does. A family of ENSURE macros are added to hopefully make the check macro names a little more consistent.

Several otherutils modules have been migrated to use s2n_result, notably:

  • s2n_array
  • s2n_asn1_time
  • s2n_random
  • s2n_rfc5952
  • s2n_set
  • s2n_timer

The interface change cause all caller locations to be updated.

Call-outs:

There is still quite a bit left to migrate but this changeset was already big enough :)

Testing:

It is unlikely that additional unit tests are needed beyond what is there, as most of the changes are caught by the compiler due to naming and type changes.

I had to update a couple of the SAW proofs to reflect the new function signatures.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@camshaft camshaft force-pushed the utils-result-misc branch 2 times, most recently from 1fd895d to 831c225 Compare May 14, 2020 23:46
@codecov-io
Copy link

codecov-io commented May 15, 2020

Codecov Report

Merging #1891 into master will increase coverage by 1.04%.
The diff coverage is 88.80%.

@@            Coverage Diff             @@
##           master    #1891      +/-   ##
==========================================
+ Coverage   80.06%   81.10%   +1.04%     
==========================================
  Files         229      233       +4     
  Lines       17014    17312     +298     
==========================================
+ Hits        13622    14041     +419     
+ Misses       3392     3271     -121     

Impacted file tree graph

@zaherd zaherd added this to Code Review in TLS 1.3 Part II May 15, 2020
@camshaft camshaft force-pushed the utils-result-misc branch 7 times, most recently from 2c0d3db to c80e7e5 Compare May 15, 2020 20:20
@camshaft camshaft marked this pull request as ready for review May 15, 2020 20:42
Copy link
Contributor

@danielsn danielsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of int,

  1. create a new typedef int POSIX_INT_ERRORCODE, and use that for external functions.
  2. Add a check in "grep simple mistakes" that checks for any naked uses of int. I'd say that all ints should either be defined types: uint32_t, uint64_t, size_t, or they should be POSIX_INT_ERRORCODE. That makes it very clear what's going on.

utils/s2n_set.c Outdated Show resolved Hide resolved
@camshaft
Copy link
Contributor Author

Instead of int,

  1. create a new typedef int POSIX_INT_ERRORCODE, and use that for external functions.

  2. Add a check in "grep simple mistakes" that checks for any naked uses of int. I'd say that all ints should either be defined types: uint32_t, uint64_t, size_t, or they should be POSIX_INT_ERRORCODE. That makes it very clear what's going on.

I think that's a great idea. We discussed offline and it's probably best to do it in another PR.

danielsn
danielsn previously approved these changes May 18, 2020
@codecov-commenter
Copy link

codecov-commenter commented May 19, 2020

Codecov Report

Merging #1891 into master will increase coverage by 1.48%.
The diff coverage is 89.41%.

@@            Coverage Diff             @@
##           master    #1891      +/-   ##
==========================================
+ Coverage   79.38%   80.86%   +1.48%     
==========================================
  Files         229      231       +2     
  Lines       17152    17510     +358     
==========================================
+ Hits        13616    14160     +544     
+ Misses       3536     3350     -186     

Impacted file tree graph

pq-crypto/sike_r2/sidh.c Outdated Show resolved Hide resolved
@danielsn
Copy link
Contributor

the array -> vec thing feels like a separate PR.

#else
S2N_ERROR(S2N_ERR_UNSUPPORTED_CPU);
BAIL(S2N_ERR_UNSUPPORTED_CPU);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we OK with this? Or should it be S2N_BAIL

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to be consistent with GUARD and not prefix it. The same question goes for ENSURE and friends.

Since they're all private macros I think we're ok to go without the prefix.

Copy link
Contributor

@danielsn danielsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should really update the dev guide at the same time as the code changes.

@camshaft camshaft requested a review from danielsn May 19, 2020 21:01
danielsn
danielsn previously approved these changes May 20, 2020
Copy link
Contributor

@baldwinmatt baldwinmatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all nits - the only thing i see is that we have uint32_t lengths for arrays, then iterate over it using an int.

tests/unit/s2n_vec_test.c Outdated Show resolved Hide resolved
crypto/s2n_certificate.c Outdated Show resolved Hide resolved
crypto/s2n_certificate.c Outdated Show resolved Hide resolved
crypto/s2n_certificate.c Outdated Show resolved Hide resolved
crypto/s2n_certificate.c Outdated Show resolved Hide resolved
tls/s2n_config.c Outdated Show resolved Hide resolved
tls/s2n_resume.c Outdated Show resolved Hide resolved
tls/s2n_resume.c Outdated Show resolved Hide resolved
tls/s2n_resume.c Outdated Show resolved Hide resolved
tls/s2n_resume.c Outdated Show resolved Hide resolved
baldwinmatt
baldwinmatt previously approved these changes May 20, 2020
Copy link
Contributor

@baldwinmatt baldwinmatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woot! thanks for iterating and fixing so many things!

danielsn
danielsn previously approved these changes May 20, 2020
@camshaft camshaft dismissed stale reviews from danielsn and baldwinmatt via 220f39c May 21, 2020 15:47
@zaherd zaherd merged commit ecbf2b1 into aws:master May 21, 2020
TLS 1.3 Part II automation moved this from Code Review to Done May 21, 2020
@camshaft camshaft deleted the utils-result-misc branch May 21, 2020 17:01
@zaherd zaherd moved this from Done to Closed in TLS 1.3 Part II Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
TLS 1.3 Part II
  
Closed
Development

Successfully merging this pull request may close these issues.

None yet

6 participants