blob: 3f3c8b09fa31df4d7dfce3833ff19f0adf5973ca [file] [log] [blame]
Paul Kehrer1681a692014-02-11 23:43:51 -06001Test Vectors
2============
3
4Testing the correctness of the primitives implemented in each ``cryptography``
5backend requires trusted test vectors. Where possible these vectors are obtained
6from official sources such as `NIST`_ or `IETF`_ RFCs. When this is not possible
7``cryptography`` has chosen to create a set of custom vectors using an official
8vector file as input to verify consistency between implemented backends.
9
10Sources
11-------
12
13Asymmetric Ciphers
14~~~~~~~~~~~~~~~~~~
15
16* RSA PKCS1 from the RSA FTP site (ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/
17 and ftp://ftp.rsa.com/pub/rsalabs/tmp/).
Alex Stapleton52e40482014-02-15 21:33:46 +000018* OpenSSL PEM serialization vectors from the `OpenSSL`_ and `GnuTLS`_ test
19 suites.
Paul Kehrer1681a692014-02-11 23:43:51 -060020
21Hashes
22~~~~~~
23
24* MD5 from :rfc:`1321`.
25* RIPEMD160 from the `RIPEMD website`_.
26* SHA1 from `NIST CAVP`_.
27* SHA2 (224, 256, 384, 512) from `NIST CAVP`_.
28* Whirlpool from the `Whirlpool website`_.
29
30HMAC
31~~~~
32
33* HMAC-MD5 from :rfc:`2202`.
34* HMAC-SHA1 from :rfc:`2202`.
35* HMAC-RIPEMD160 from :rfc:`2286`.
36* HMAC-SHA2 (224, 256, 384, 512) from :rfc:`4231`.
37
38Key Derivation Functions
39~~~~~~~~~~~~~~~~~~~~~~~~
40
41* HKDF (SHA1, SHA256) from :rfc:`5869`.
42* PBKDF2 (HMAC-SHA1) from :rfc:`6070`.
43
44Recipes
45~~~~~~~
46
47* Fernet from its `specification repository`_.
48
49Symmetric Ciphers
50~~~~~~~~~~~~~~~~~
51
Paul Kehrere547d8f2014-02-15 21:37:52 -060052* AES (CBC, CFB, ECB, GCM, OFB) from `NIST CAVP`_.
53* AES CTR from :rfc:`3686`.
Paul Kehrer1681a692014-02-11 23:43:51 -060054* 3DES (CBC, CFB, ECB, OFB) from `NIST CAVP`_.
55* ARC4 from :rfc:`6229`.
56* Blowfish (CBC, CFB, ECB, OFB) from `Bruce Schneier's vectors`_.
57* Camellia (ECB) from NTT's `Camellia page`_ as linked by `CRYPTREC`_.
58* Camellia (CBC, CFB, OFB) from `OpenSSL's test vectors`_.
59* CAST5 (ECB) from :rfc:`2144`.
Paul Kehrercf6ffb52014-02-12 16:17:04 -060060* CAST5 (CBC, CFB, OFB) generated by this project.
61 See: :doc:`/development/custom-vectors/cast5`
Paul Kehrer1681a692014-02-11 23:43:51 -060062
Ayrx933dd682014-02-18 23:26:11 +080063Two Factor Authentication
64~~~~~~~~~~~~~~~~~~~~~~~~~
65
66* HOTP from :rfc:`4226`
67* TOTP from :rfc:`6238` (Note that an `errata`_ for the test vectors in RFC 6238 exists)
68
Paul Kehrer1681a692014-02-11 23:43:51 -060069
Paul Kehrercf6ffb52014-02-12 16:17:04 -060070Creating Test Vectors
71---------------------
72
73When official vectors are unavailable ``cryptography`` may choose to build
74its own using existing vectors as source material. Current custom vectors:
75
76.. toctree::
77 :maxdepth: 1
78
79 custom-vectors/cast5
80
81If official test vectors appear in the future the custom generated vectors
82should be discarded.
83
84Any vectors generated by this method must also be prefixed with the following
85header format (substituting the correct information):
86
87.. code-block:: python
88
89 # CAST5 CBC vectors built for https://github.com/pyca/cryptography
90 # Derived from the AESVS MMT test data for CBC
91 # Verified against the CommonCrypto and Go crypto packages
92 # Key Length : 128
93
Paul Kehrer1681a692014-02-11 23:43:51 -060094.. _`NIST`: http://www.nist.gov/
95.. _`IETF`: https://www.ietf.org/
96.. _`NIST CAVP`: http://csrc.nist.gov/groups/STM/cavp/
97.. _`Bruce Schneier's vectors`: https://www.schneier.com/code/vectors.txt
98.. _`Camellia page`: http://info.isl.ntt.co.jp/crypt/eng/camellia/
99.. _`CRYPTREC`: http://www.cryptrec.go.jp
100.. _`OpenSSL's test vectors`: https://github.com/openssl/openssl/blob/97cf1f6c2854a3a955fd7dd3a1f113deba00c9ef/crypto/evp/evptests.txt#L232
101.. _`RIPEMD website`: http://homes.esat.kuleuven.be/~bosselae/ripemd160.html
102.. _`Whirlpool website`: http://www.larc.usp.br/~pbarreto/WhirlpoolPage.html
103.. _`Specification repository`: https://github.com/fernet/spec
Ayrx933dd682014-02-18 23:26:11 +0800104.. _`errata`: http://www.rfc-editor.org/errata_search.php?rfc=6238
Alex Stapleton52e40482014-02-15 21:33:46 +0000105.. _`OpenSSL`: https://www.openssl.org/
106.. _`GnuTLS`: http://www.gnutls.org/