Commit 705dfb3c authored by Fabio Utzig's avatar Fabio Utzig Committed by Fabio Utzig
Browse files

Add third_party/fiat from boringssl

This adds the boringssl version of fiat-crypto. The version bundled here
had most if its non-used code removed, like signing, X25519 curve
operations not required by verification, etc.

Under boringssl tree, fiat can be found in third_party/fiat. The version
included here comes from a boringssl tree where the last commit is
f109f2087349712d3ac717d15fab48e130618110.

Signed-off-by: default avatarFabio Utzig <utzig@apache.org>
parent 8101d1fa
Loading
Loading
Loading
Loading
+22
Changes for ext/fiat/LICENSE: 22 added lines, 0 removed lines.
Original line number Diff line number Diff line
The MIT License (MIT)

Copyright (c) 2015-2016 the fiat-crypto authors (see
https://github.com/mit-plv/fiat-crypto/blob/master/AUTHORS).

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+13
Changes for ext/fiat/METADATA: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
name: "fiat"
description: "Fiat-Crypto: Synthesizing Correct-by-Construction Code for Cryptographic Primitives."

third_party {
  url {
    type: GIT
    value: "https://github.com/mit-plv/fiat-crypto"
  }
  version: "4441785fb44b88bb6943ddbf639d872c8c903281"
  last_upgrade_date { year: 2019 month: 1 day: 16 }

  local_modifications: "Fiat-generated code has been integrated into existing BoringSSL code"
}
+10
Changes for ext/fiat/README.chromium: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
Name: Fiat-Crypto: Synthesizing Correct-by-Construction Code for Cryptographic Primitives
Short Name: fiat-crypto
URL: https://github.com/mit-plv/fiat-crypto
Version: git (see METADATA)
License: MIT
License File: LICENSE
Security Critical: yes

Description:
See README.md and METADATA.
+47
Changes for ext/fiat/README.md: 47 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Fiat

Some of the code in this directory is generated by
[Fiat](https://github.com/mit-plv/fiat-crypto) and thus these files are
licensed under the MIT license. (See LICENSE file.)

## Curve25519

To generate the field arithmetic procedures in `curve25519.c` from a fiat-crypto
checkout (as of `7892c66d5e0e5770c79463ce551193ceef870641`), run
`make src/Specific/solinas32_2e255m19_10limbs/femul.c` (replacing `femul` with
the desired field operation). The "source" file specifying the finite field and
referencing the desired implementation strategy is
`src/Specific/solinas32_2e255m19_10limbs/CurveParameters.v`, specifying roughly
"unsaturated arithmetic modulo 2^255-19 using 10 limbs of radix 2^25.5 in 32-bit
unsigned integers with a single carry chain and two wraparound carries" where
only the prime is considered normative and everything else is treated as
"compiler hints".

The 64-bit implementation uses 5 limbs of radix 2^51 with instruction scheduling
taken from curve25519-donna-c64. It is found in
`src/Specific/solinas64_2e255m19_5limbs_donna`.

## P256

To generate the field arithmetic procedures in `p256.c` from a fiat-crypto
checkout, run
`make src/Specific/montgomery64_2e256m2e224p2e192p2e96m1_4limbs/femul.c`.
The corresponding "source" file is
`src/Specific/montgomery64_2e256m2e224p2e192p2e96m1_4limbs/CurveParameters.v`,
specifying roughly "64-bit saturated word-by-word Montgomery reduction modulo
2^256 - 2^224 + 2^192 + 2^96 - 1". Again, everything except for the prime is
untrusted. There is currently a known issue where `fesub.c` for p256 does not
manage to complete the build (specialization) within a week on Coq 8.7.0.
<https://github.com/JasonGross/fiat-crypto/tree/3e6851ddecaac70d0feb484a75360d57f6e41244/src/Specific/montgomery64_2e256m2e224p2e192p2e96m1_4limbs>
does manage to build that file, but the work on that branch was never finished
(the correctness proofs of implementation templates still apply, but the
now abandoned prototype specialization facilities there are unverified).

## Working With Fiat Crypto Field Arithmetic

The fiat-crypto readme <https://github.com/mit-plv/fiat-crypto#arithmetic-core>
contains an overview of the implementation templates followed by a tour of the
specialization machinery. It may be helpful to first read about the less messy
parts of the system from chapter 3 of <http://adam.chlipala.net/theses/andreser.pdf>.
There is work ongoing to replace the entire specialization mechanism with
something much more principled <https://github.com/mit-plv/fiat-crypto/projects/4>.
+1104

File added.

Preview size limit exceeded, changes collapsed.

Loading