GithubHelp home page GithubHelp logo

heisenbugltd / saatana Goto Github PK

View Code? Open in Web Editor NEW
13.0 4.0 0.0 3.55 MB

A cryptographic framework, proven for correctness in SPARK

Home Page: https://github.heisenbug.eu/Saatana

License: Do What The F*ck You Want To Public License

Ada 100.00%
ada formal-verification cryptographic-framework cryptography ada2012 spark2014 encryption spark-ada ada-language

saatana's Introduction

SPARK/Ada Algorithms Targeting Advanced Network Applications

A cryptographic framework, proven for correctness in SPARK

Alire

Requires GNAT Community 2020, as we are making use of SPARK's Relaxed_Initialization.

Algorithms contained

  • Phelix - Fast Encryption and Authentication in a Single Cryptographic Primitive

    Doug Whiting, Bruce Schneier, Stefan Lucks, and Frédéric Muller

    ECRYPT Stream Cipher Project Report 2005/027, 2005.

    ABSTRACT: Phelix¹ is a high-speed stream cipher with a built-in MAC functionality. It is efficient in both hardware and software. On current Pentium CPUs, Phelix has a per-packet overhead of less than 900 clocks, plus a per-byte cost well under 8 clocks per byte, comparing very favorably with the best AES (encryption-only) implementations, even for small packets.

    ¹ Pronounced "felix" (rhymes with "helix").

saatana's People

Contributors

jellix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

saatana's Issues

Wrong Assume pragmas

As pointed out by Piotr Trojanek in the SPARK discussion mailing list, the Assume pragmas were wrong and not correctly catering for the fact that an empty input array with rather "interesting" bound could be passed to Encrypt/Decrypt_Bytes and Process_AAD, This is a rather serious bug as it would have opened the door to a DoS attack on the implementation if runtime checks were enabled.

The prover was right, after all.

Performance test

We should include a performance test, preferably with different optimization options and a comparison between run-time checks enabled and disabled (as we prove there will be none).

Upload gnatprove results upon CI run

If we're running the prover on the CI runs, we could upload the prove results for further analysis.

Right now there are some "might not be initialized" warnings which should be investigated. Most likely cause is that we run a different set of provers than on my local machine (where Z3 and CVC4 are also installed).

Split workflows into build and proof

Proof takes quite some time, especially if this project ever gets larger, so it seems impractical to run the full proof at each repository push.

Instead, we could just do a build (including running the KAT(s)), and do a proof run once or twice a day.

Prove bijectivity of conversion functions

After these declarations in saatana-crypto.ads we should do something like:

pragma Assert (for all W in Word_32'Range =>
                 To_Unsigned (To_Stream (W)) = W);
   --  Prove bijectivity of conversion subprograms.

We cannot do this directly in Saatana.Crypto:

non-static call not allowed in preelaborated unit

as the package is supposed to be Pure and shall remain so.

An idea might be to introduce private proof property child packages for the specific purpose of proving such kind of properties.

Improve readability of post condition

The post condition on Crypto.Phelix.H isn't very readable, this should be improved.

It would be nice to have it expressed in a form that side-by-side comparison with the algorithm specification would be possible.

Manual proof run

This issue is a placeholder for manual triggers of proof runs.

If you add the special 'run_proof' label, a proof run on the master branch should be triggered.

Upload KAT results

We should upload the full results of the Known Answers Test run. These are important artifacts supporting our proof of functional correctness.

Implement more encryption algorithms

Candidates:

Block Ciphers:

  • Blowfish
  • Twofish
  • Threefish, this one is based on Skein, so the SPARKSkein implementation would be a good start
  • AES (PDF)
  • IDEA (the patent expired in 2012, so it should be free to use now, but proper documentation seems scarce)

Stream ciphers:

And then there's the thing that any proper encryption needs a cryptographically secure random number generator, be it for nonce, key, or random seed initializations.

Precondition not proved in Decrypt/Encrypt_Packet

The currently used provers can prove all assertions which have been added prior to calling De/Encrypt_Bytes, yet for some unexplained reason, the actual precondition can not be proven by the tools.

Lemmas package not run through SPARK

Apparently the (unused and private) Lemmas child package is ignored by gnatprove ATM. Probably, because the package is not in any closure of a main subprogram.

Run gnat check automatically

Heaving recently fixed all the coding standards violations (unnamed block statements etc.) I figured that a gnat check run should be done automatically, either as part of the build process or even a commit trigger.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.