-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate NSym proofs for SHA384/512 with Arm assembly (#122)
This PR adds the proof for SHA384/512 Arm assembly routines. The following is a description of changes that are made to integrate these proofs: 1. A new Dockerfile Dockerfile.saw is written for running the proofs for Arm SHA384 and SHA512 2. Two Cryptol specifications are written for SHA384 and SHA512 3. A set of bash scripts are written for setting up environment, cross-compiling Arm assembly into appropriate micro-architecture, invoking tools for translating Cryptol specifications into Ocaml specifications and run NSym proofs; there are also several scripts for staging relative tooling 4. Two versions of proofs are added, note that the proofs are written in a way to allow both SHA384 and SHA512: * sha512_block_data_order_unbounded.ml for unbounded proof of sha512_block_data_order procedure run on Graviton2 * sha512_block_armv8_unbounded.ml for unbounded proof of sha512_block_armv8 procedure run on Graviton3 --------- Co-authored-by: Yan Peng <yppe@dev-dsk-yppe-2c-7ad218d0.us-west-2.amazon.com>
- Loading branch information
Showing
53 changed files
with
4,748 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: 'AWS-LC Formal Verification NSym Proofs' | ||
description: 'Check NSym proofs to verify AWS-LC against Cryptol specs' | ||
runs: | ||
using: 'docker' | ||
image: '../../../Dockerfile.nsym' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
FROM ubuntu:22.04 | ||
ENV GOROOT=/usr/local/go | ||
ENV PATH="$GOROOT/bin:$PATH" | ||
ARG GO_VERSION=1.20.1 | ||
ARG GO_ARCHIVE="go${GO_VERSION}.linux-amd64.tar.gz" | ||
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections | ||
RUN apt-get update | ||
RUN apt-get install -y curl wget unzip git cmake ninja-build clang llvm g++-aarch64-linux-gnu \ | ||
lld python3-pip file time python3-pkgconfig libgmp-dev opam | ||
|
||
RUN wget "https://dl.google.com/go/${GO_ARCHIVE}" && tar -xvf $GO_ARCHIVE && \ | ||
mkdir $GOROOT && mv go/* $GOROOT && rm $GO_ARCHIVE | ||
|
||
RUN opam init --auto-setup --yes --disable-sandboxing \ | ||
&& opam switch create 4.14.0 \ | ||
&& eval $(opam env --switch=4.14.0) \ | ||
&& opam install -y dune ppxlib ppx_deriving zarith odoc | ||
|
||
# Dependencies for Cryptol-Air-Interface | ||
# ghcup, ghc-8.10.7 | ||
# zlib: libghc-bzlib-dev zlib1g-dev | ||
|
||
ADD ./NSym/scripts /lc/scripts | ||
RUN /lc/scripts/docker_install.sh | ||
ENV CRYPTOLPATH="../../../cryptol-specs:../../spec:./spec:../cryptol-specs" | ||
|
||
# This container expects all files in the directory to be mounted or copied. | ||
# The GitHub action will mount the workspace and set the working directory of the container. | ||
# Another way to mount the files is: docker run -v `pwd`:`pwd` -w `pwd` <name> | ||
|
||
ENTRYPOINT ["./NSym/scripts/docker_entrypoint.sh"] |
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,34 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
DEFAULT_OPTIONS?=-vno -q -vnoosi | ||
|
||
.PHONY: all clean sha512_spec sha384_spec sha2_grav2 sha2_grav3 | ||
|
||
SHA384_SPEC_FILE := \ | ||
sha384rec_spec | ||
|
||
SHA512_SPEC_FILE := \ | ||
sha512rec_spec | ||
|
||
SHA2_GRAVITON2_FILES := \ | ||
sha512_block_data_order_bounded \ | ||
sha512_block_data_order_unbounded | ||
|
||
SHA2_GRAVITON3_FILES := \ | ||
sha512_block_armv8_bounded \ | ||
sha512_block_armv8_unbounded | ||
|
||
all: sha384_spec sha512_spec sha2_grav2 sha2_grav3 | ||
|
||
sha384_spec: $(SHA384_SPEC_FILE) | ||
sha512_spec: $(SHA512_SPEC_FILE) | ||
|
||
sha2_grav2: $(SHA2_GRAVITON2_FILES) | ||
sha2_grav3: $(SHA2_GRAVITON3_FILES) | ||
|
||
$(SHA512_SPEC_FILE) $(SHA384_SPEC_FILE) $(SHA2_GRAVITON2_FILES) $(SHA2_GRAVITON3_FILES): %: proofs/SHA512/%.ml | ||
time -p dune exec -- _build/default/proofs/$(*F).exe $(DEFAULT_OPTIONS) | ||
|
||
clean: | ||
dune clean && rm -f *.opam |
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,13 @@ | ||
# Autospecs | ||
|
||
This dune package contains automatically generated Ocaml specifications and auxiliary Ocaml files associated with the automatically generated specifications. We use Cryptol specifications (for SAW proofs) as input and translate them into Ocaml specifications that work with NSym. Auxiliary Ocaml files contain functions or lemmas that are needed in the NSym proofs. We keep the automatically generated files in the repository to keep a record of them. | ||
|
||
## SHA512 | ||
|
||
The automatically generated specifications include: | ||
1. `SHA384rec.ml`: A translation from NSym/spec/SHA384rec.cry | ||
2. `SHA512rec.ml`: A translation from NSym/spec/SHA512rec.cry | ||
|
||
The auxiliary files are: | ||
1. `sha2.ml`: A parameterization of the NSym proofs to allow both SHA384 and SHA512 | ||
2. `sha512rec_theorems.ml`: Base case and inductive case theorems for the recursive function `air_processBlocks_rec` |
Oops, something went wrong.