Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1430582 - Add Cryptol/SAW runs to Taskcluster r=franziskus
Reviewers: franziskus Reviewed By: franziskus Bug #: 1430582 Differential Revision: https://phabricator.services.mozilla.com/D388
- Loading branch information
Tim Taubert
committed
Jan 16, 2018
1 parent
16344e3
commit 4f63687
Showing
13 changed files
with
564 additions
and
3 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 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
bmul : {n,m} (fin n, n >= 1, m == n*2 - 1) => [n] -> [n] -> ([n], [n]) | ||
bmul a b = (take`{n} prod, drop`{n} prod) | ||
where prod = pad (pmult a b : [m]) | ||
pad x = zero # x |
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,26 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
import "bmul.cry"; | ||
|
||
print "Loading LLVM bitcode..."; | ||
m <- llvm_load_module "../../../dist/Debug/lib/libfreeblpriv3.so.bc"; | ||
|
||
let SpecBinaryMul n = do { | ||
x <- llvm_var "x" (llvm_int n); | ||
y <- llvm_var "y" (llvm_int n); | ||
llvm_ptr "r_high" (llvm_int n); | ||
r_high <- llvm_var "*r_high" (llvm_int n); | ||
llvm_ptr "r_low" (llvm_int n); | ||
r_low <- llvm_var "*r_low" (llvm_int n); | ||
|
||
let res = {{ bmul x y }}; | ||
llvm_ensure_eq "*r_high" {{ res.0 }}; | ||
llvm_ensure_eq "*r_low" {{ res.1 }}; | ||
|
||
llvm_verify_tactic abc; | ||
}; | ||
|
||
print "Proving equality for 32-bit bmul()..."; | ||
time (llvm_verify m "bmul32" [] (SpecBinaryMul 32)); |
Large diffs are not rendered by default.
Oops, something went wrong.
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,40 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
import "chacha20.cry" as chacha20; | ||
|
||
print "Proving ChaCha20 spec..."; | ||
prove_print abc {{ chacha20::allTestsPass }}; | ||
|
||
print "Loading LLVM bitcode..."; | ||
m <- llvm_load_module "../../../dist/Debug/lib/libfreeblpriv3.so.bc"; | ||
|
||
let SpecChaCha20 n = do { | ||
llvm_ptr "output" (llvm_array n (llvm_int 8)); | ||
output <- llvm_var "*output" (llvm_array n (llvm_int 8)); | ||
|
||
llvm_ptr "plain" (llvm_array n (llvm_int 8)); | ||
plain <- llvm_var "*plain" (llvm_array n (llvm_int 8)); | ||
|
||
len <- llvm_var "len" (llvm_int 32); | ||
llvm_assert_eq "len" {{ `n : [32] }}; | ||
|
||
llvm_ptr "k" (llvm_array 32 (llvm_int 8)); | ||
k <- llvm_var "*k" (llvm_array 32 (llvm_int 8)); | ||
|
||
llvm_ptr "n1" (llvm_array 12 (llvm_int 8)); | ||
n1 <- llvm_var "*n1" (llvm_array 12 (llvm_int 8)); | ||
|
||
ctr <- llvm_var "ctr" (llvm_int 32); | ||
|
||
llvm_ensure_eq "*output" {{ chacha20::encrypt k ctr n1 plain }}; | ||
|
||
llvm_verify_tactic abc; | ||
}; | ||
|
||
print "Proving equality for a single block..."; | ||
time (llvm_verify m "Hacl_Chacha20_chacha20" [] (SpecChaCha20 64)); | ||
|
||
print "Proving equality for multiple blocks..."; | ||
time (llvm_verify m "Hacl_Chacha20_chacha20" [] (SpecChaCha20 256)); |
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 @@ | ||
FROM ubuntu:17.04 | ||
MAINTAINER Tim Taubert <ttaubert@mozilla.com> | ||
|
||
RUN useradd -d /home/worker -s /bin/bash -m worker | ||
WORKDIR /home/worker | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
binutils \ | ||
build-essential \ | ||
bzip2 \ | ||
clang-3.8 \ | ||
curl \ | ||
gcc-multilib \ | ||
g++-multilib \ | ||
gyp \ | ||
lib32z1-dev \ | ||
mercurial \ | ||
ninja-build \ | ||
unzip \ | ||
zlib1g-dev | ||
|
||
# Install SAW/Cryptol. | ||
RUN curl -LO https://saw.galois.com/builds/nightly/saw-0.2-2018-01-14-Ubuntu14.04-64.tar.gz && \ | ||
tar xzvf saw-*.tar.gz -C /usr/local --strip-components=1 && \ | ||
rm saw-*.tar.gz | ||
|
||
# Install Z3. | ||
RUN curl -LO https://github.com/Z3Prover/z3/releases/download/z3-4.6.0/z3-4.6.0-x64-ubuntu-16.04.zip && \ | ||
unzip z3*.zip && \ | ||
cp -r z3*/* /usr/local/ && \ | ||
rm -fr z3* | ||
|
||
ADD bin /home/worker/bin | ||
RUN chmod +x /home/worker/bin/* | ||
|
||
# Change user. | ||
USER worker | ||
|
||
# Set a default command useful for debugging | ||
CMD ["/bin/bash", "--login"] |
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,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -v -e -x | ||
|
||
# Default values for testing. | ||
REVISION=${NSS_HEAD_REVISION:-default} | ||
REPOSITORY=${NSS_HEAD_REPOSITORY:-https://hg.mozilla.org/projects/nss} | ||
|
||
# Clone NSS. | ||
for i in 0 2 5; do | ||
sleep $i | ||
hg clone -r $REVISION $REPOSITORY nss && exit 0 | ||
rm -rf nss | ||
done | ||
exit 1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
source $(dirname "$0")/tools.sh | ||
|
||
# Fetch artifact if needed. | ||
fetch_dist | ||
|
||
# Run SAW. | ||
saw "nss/automation/saw/$1.saw" |
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