Cryptol: The Language of Cryptography
Go to file
2021-10-18 09:47:08 -07:00
.github Migrate Docker images to use what4-solvers builds 2021-09-28 16:23:16 -07:00
bench Fix benchmark suite 2020-04-03 14:47:16 -07:00
cryptol Allow \ line continuation at REPL on Windows 2021-09-22 15:17:25 -07:00
cryptol-remote-api rpc/fix: tweak tests for docker/http to not hang (#1294) 2021-09-29 14:57:00 -07:00
deps feat: timeout for cryptol python client methods (#1282) 2021-09-21 20:23:28 -07:00
docs Disable jekyll, as it ignores files starting with _ 2021-10-18 09:47:08 -07:00
examples Update test suite 2020-05-26 15:33:46 -07:00
helm/cryptol-remote-api Prep CI for upcoming release (#1123) 2021-03-23 15:24:48 -07:00
lib Add primitive toSignedInteger. 2021-09-10 17:05:22 -07:00
src Add rewrite rules to simplify constraints due to generate. 2021-09-27 11:15:43 -07:00
tests Revert "Remove use of \ line continuations in tests" 2021-09-22 15:17:13 -07:00
utils Minor updates to CryHtml.hs 2021-02-12 10:35:42 -08:00
win32 Fix windows installer path (#854) 2020-08-05 12:26:41 -07:00
.dockerignore Add Dockerfile. 2018-07-02 12:29:45 -04:00
.gitignore Adds regression test for dumptests. 2020-11-02 13:59:22 -08:00
.gitmodules feat: initial co-located python client 2021-03-01 15:56:28 -08:00
.gitpod.Dockerfile Support TLS in cryptol-remote-api (#1203) 2021-06-25 14:26:09 -07:00
.gitpod.yml Support TLS in cryptol-remote-api (#1203) 2021-06-25 14:26:09 -07:00
cabal.GHC-8.6.5.config Update to require 0.9.7 which has the callback capability 2021-07-21 10:54:03 -07:00
cabal.GHC-8.8.4.config Update to require 0.9.7 which has the callback capability 2021-07-21 10:54:03 -07:00
cabal.GHC-8.10.2.config Update to require 0.9.7 which has the callback capability 2021-07-21 10:54:03 -07:00
cabal.GHC-8.10.3.config Update to require 0.9.7 which has the callback capability 2021-07-21 10:54:03 -07:00
cabal.project bump argo, minor rpc tweaks 2021-03-01 13:19:00 -08:00
CHANGES.md Update CHANGES.md 2021-10-04 10:24:38 -07:00
CODE_OF_CONDUCT.md Add Code of Conduct 2021-10-04 10:27:42 -07:00
CONTRIBUTING.md Build system and documentation cleanup (#816) 2020-07-14 10:58:38 -07:00
cry Add a check-docs command to the cry script 2021-06-30 10:06:21 -07:00
cryptol.cabal Update copyright year 2021-10-05 10:16:16 -07:00
Dockerfile Migrate Docker images to use what4-solvers builds 2021-09-28 16:23:16 -07:00
LICENSE Build system and documentation cleanup (#816) 2020-07-14 10:58:38 -07:00
LICENSE.rtf Build system and documentation cleanup (#816) 2020-07-14 10:58:38 -07:00
README.md Update solver version references in README.md 2021-10-04 12:58:17 -07:00
Setup.hs Remove obsolete cvs-era $Header$ keywords. 2018-03-22 13:33:12 -07:00

Cryptol Open in Gitpod

Cryptol, version 2

This version of Cryptol is (C) 2013-2020 Galois, Inc., and
distributed under a standard, three-clause BSD license. Please see
the file LICENSE, distributed with this software, for specific
terms and conditions.

What is Cryptol?

The Cryptol specification language was designed by Galois for the NSA Laboratory for Advanced Cybersecurity Research as a public standard for specifying cryptographic algorithms. A Cryptol reference specification can serve as the formal documentation for a cryptographic module. Unlike current specification mechanisms, Cryptol is fully executable, allowing designers to experiment with their programs incrementally as their designs evolve.

This release is an interpreter for version 2 of the Cryptol language. The interpreter includes a :check command, which tests predicates written in Cryptol against randomly-generated test vectors (in the style of QuickCheck). There is also a :prove command, which calls out to SMT solvers, such as Yices, Z3, or CVC4, to prove predicates for all possible inputs.

Getting Cryptol Binaries

Cryptol binaries for Mac OS X, Linux, and Windows are available from the GitHub releases page. Mac OS X and Linux binaries are distributed as a tarball which you can extract to a location of your choice. Windows binaries are distributed both as tarballs and as .msi installer packages which place a shortcut to the Cryptol interpreter in the Start menu.

On Mac OS X, Cryptol is also available via Homebrew. Simply run brew update && brew install cryptol to get the latest stable version.

Getting Z3

Cryptol currently uses Microsoft Research's Z3 SMT solver by default to solve constraints during type checking, and as the default solver for the :sat and :prove commands. Cryptol generally requires the most recent version of Z3, but you can see the specific version tested in CI by looking here.

You can download Z3 binaries for a variety of platforms from their releases page. If you install Cryptol using Homebrew, the appropriate version of Z3 will be installed automatically. If you're using Linux, the package manager for your distribution may include Z3, as well, though sometimes the available versions are somewhat old.

After installation, make sure that z3 (or z3.exe on Windows) is on your PATH.

Note for 64-bit Linux Users

On some 64-bit Linux configurations, 32-bit binaries do not work. This can lead to unhelpful error messages like z3: no such file or directory, even when z3 is clearly present. To fix this, either install 32-bit compatibility packages for your distribution, or download the x64 version of Z3.

Building Cryptol From Source

In addition to the binaries, the Cryptol source is available publicly on GitHub.

Cryptol builds and runs on various flavors of Linux, Mac OS X, and Windows. We regularly build and test it in the following environments:

  • macOS 10.15, 64-bit
  • Ubuntu 20.04, 64-bit
  • Windows Server 2019, 64-bit

Prerequisites

Cryptol is regularly built and tested with the three most recent versions of GHC, which at the time of this writing are 8.6.5, 8.8.4, and 8.10.2. The easiest way to install an approporiate version of GHC is with ghcup.

Some supporting non-Haskell libraries are required to build Cryptol. Most should already be present for your operating system, but you may need to install the following:

You'll also need Z3 installed when running Cryptol.

Building Cryptol

After a fresh checkout of cryptol, be sure to initialize its git submodules:

git submodule update --init

Then, from the Cryptol source directory, run:

./cry build

This will build Cryptol in place. From there, there are additional targets:

  • ./cry run: run Cryptol in the current directory
  • ./cry test: run the regression test suite

Installing Cryptol

If you run cabal v2-install --installdir=DIR in your source directory after running one of the above ./cry command, you will end up with a binary in DIR.

Configuring Cryptol

Cryptol can use several external files to control its operation. Normally, the build process embeds these files into the executable. However, these embedded files can be overwritten with local copies in two ways:

  • Copy the contents of the lib directory into $HOME/.cryptol.

  • Set the CRYPTOLPATH environment variable to name some other directory that contains the files from the lib directory.

Contributing

We believe that anyone who uses Cryptol is making an important contribution toward making Cryptol a better tool. There are many ways to get involved.

Users

If you write Cryptol programs that you think would benefit the community, fork the GitHub repository, and add them to the examples/contrib directory and submit a pull request.

We host a Cryptol mailing list, which you can join here.

If you run into a bug in Cryptol, if something doesn't make sense in the documentation, if you think something could be better, or if you just have a cool use of Cryptol that you'd like to share with us, use the issues page on GitHub, or send email to cryptol@galois.com.

Developers

If you'd like to get involved with Cryptol development, see the list of low-hanging fruit. These are tasks which should be straightforward to implement. Make a fork of this GitHub repository, send along pull requests and we'll be happy to incorporate your changes.

Repository Structure

  • /cryptol: Haskell sources for the front-end cryptol executable and read-eval-print loop
  • /docs: LaTeX and Markdown sources for the Cryptol documentation
  • /examples: Cryptol sources implementing several interesting algorithms
  • /lib: Cryptol standard library sources
  • /src: Haskell sources for the cryptol library (the bulk of the implementation)
  • /tests: Haskell sources for the Cryptol regression test suite, as well as the Cryptol sources and expected outputs that comprise that suite

Where to Look Next

The docs directory of the installation package contains an introductory book, the examples directory contains a number of algorithms specified in Cryptol.

If you are familiar with version 1 of Cryptol, you should read the Version2Changes document in the docs directory.

For a large collection of Cryptol examples, see the cryptol-specs repository.

Cryptol is still under active development at Galois. We are also building tools that consume both Cryptol specifications and implementations in (for example) C or Java, and can (with some amount of work) allow you to verify that an implementation meets its specification. See more information on the SAW website.

Thanks!

We hope that Cryptol is useful as a tool for educators and students, commercial and open source authors of cryptographic implementations, and by cryptographers to

  • specify cryptographic algorithms
  • check or prove properties of algorithms
  • generate test vectors for testing implementations
  • experiment with new algorithms

Acknowledgements

Cryptol has been under development for over a decade with many people contributing to its design and implementation. Those people include (but are not limited to) Aaron Tomb, Adam Foltzer, Adam Wick, Alexander Bakst, Andrew Kent, Andrei Stefanescu, Andrey Chudnov, Andy Gill, Benjamin Barenblat, Ben Jones, Ben Selfridge, Brett Boston, Brian Huffman, Brian Ledger, Chris Phifer, Daniel Wagner, David Thrane Christiansen, David Lazar, Dylan McNamee, Eddy Westbrook, Edward Yang, Eric Mertens, Eric Mullen, Fergus Henderson, Iavor Diatchki, Jared Weakly, Jeff Lewis, Jim Teisher, Joe Hendrix, Joe Hurd, Joe Kiniry, Joel Stanley, Joey Dodds, John Launchbury, John Matthews, Jonathan Daugherty, Kenneth Foner, Kevin Quick, Kyle Carter, Ledah Casburn, Lee Pike, Levent Erkök, Lisanna Dettwyler, Magnus Carlsson, Mark Shields, Mark Tullsen, Matt Sottile, Nathan Collins, Philip Weaver, Robert Dockins, Ryan Scott, Sally Browning, Sam Anklesaria, Sigbjørn Finne, Stephen Magill, Thomas Nordin, Trevor Elliott, and Tristan Ravitch.

Much of the work on Cryptol has been funded by, and lots of design input was provided by, the team at the NSA's Laboratory for Advanced Cybersecurity Research, including Brad Martin, Frank Taylor, and Sean Weaver.

Portions of Cryptol are also based upon work supported by the Office of Naval Research under Contract No. N68335-17-C-0452. Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the Office of Naval Research.