[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Thu Nov 3 12:16:22 UTC 2016


The branch master has been updated
       via  7280a5d332e880adbc73e03086ab070f8effdce7 (commit)
       via  59cec20e783917b706b84c1ab8527cd3362f205d (commit)
       via  97f1e97114822a04a7720b817a789cc9d2553e2b (commit)
       via  f12d6273a508b9bc8eaee4d87918fe0401d747f2 (commit)
       via  7dc60ba7c8314109a1eeef3c801c8c41a7ebbeff (commit)
       via  f2ae2348cef7cdc9bc7bcff8f5cf19384bad45fd (commit)
       via  2c1661714856f75ebd17b2a881c913a08f0103b1 (commit)
       via  bbdec3f24727d86a223d5af12f4e30f5723ce2fc (commit)
       via  b5b7c61fe337e2b5be931f42ce6f827ff344f3f6 (commit)
       via  ab6e147c49f2382d2c30e313dd99aa23f66bc563 (commit)
       via  aeac218372239752e79769da8f7d1db16d87307d (commit)
      from  9c89c8460a4dcf828a22e2dfc279b5ea8a80ec60 (commit)


- Log -----------------------------------------------------------------
commit 7280a5d332e880adbc73e03086ab070f8effdce7
Author: Richard Levitte <levitte at openssl.org>
Date:   Fri Oct 28 21:41:12 2016 +0200

    Clean away remaining 'selftest' code
    
    All of these don't compile cleanly any more, probably haven't for quite
    some time
    
    Reviewed-by: Emilia Käsper <emilia at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/1789)

commit 59cec20e783917b706b84c1ab8527cd3362f205d
Author: Richard Levitte <levitte at openssl.org>
Date:   Thu Oct 27 23:25:09 2016 +0200

    Finally, add a test recipe for the internal tests
    
    Reviewed-by: Emilia Käsper <emilia at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/1789)

commit 97f1e97114822a04a7720b817a789cc9d2553e2b
Author: Richard Levitte <levitte at openssl.org>
Date:   Thu Oct 27 22:18:50 2016 +0200

    Convert mdc2 test print to internal test
    
    Reviewed-by: Emilia Käsper <emilia at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/1789)

commit f12d6273a508b9bc8eaee4d87918fe0401d747f2
Author: Richard Levitte <levitte at openssl.org>
Date:   Thu Oct 27 21:42:45 2016 +0200

    Convert x509 selftests to internal test
    
    Reviewed-by: Emilia Käsper <emilia at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/1789)

commit 7dc60ba7c8314109a1eeef3c801c8c41a7ebbeff
Author: Richard Levitte <levitte at openssl.org>
Date:   Fri Oct 28 01:32:33 2016 +0200

    Add a HEADER_MODES_H guard in include/openssl/modes.h
    
    Reviewed-by: Emilia Käsper <emilia at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/1789)

commit f2ae2348cef7cdc9bc7bcff8f5cf19384bad45fd
Author: Richard Levitte <levitte at openssl.org>
Date:   Thu Oct 27 19:57:41 2016 +0200

    Convert modes selftests (cts128 and gcm128) to internal test
    
    Reviewed-by: Emilia Käsper <emilia at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/1789)

commit 2c1661714856f75ebd17b2a881c913a08f0103b1
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Oct 26 23:12:48 2016 +0200

    Convert asn1 selftests (a_strnid and ameth_lib) into internal test
    
    Reviewed-by: Emilia Käsper <emilia at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/1789)

commit bbdec3f24727d86a223d5af12f4e30f5723ce2fc
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Oct 26 22:31:29 2016 +0200

    VMS: ignore multiply defined symbols when linking programs
    
    The Unix and Windows linkers appear to simply ignore if any symbol is
    defined multiple times in different object files and libraries.
    
    The VMS linker, on the other hand, warns about it, loud and clear.  It
    will still create the executable, but does so screaming.  So we
    complicate things by saving the linker output, look through all the
    errors and warnings, and if they are only made up of %LINK-W-MULDEF,
    we let it pass, otherwise we output the linker output and raise the
    same exit code we got from the linker.
    
    Reviewed-by: Emilia Käsper <emilia at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/1789)

commit b5b7c61fe337e2b5be931f42ce6f827ff344f3f6
Author: Richard Levitte <levitte at openssl.org>
Date:   Thu Oct 27 08:44:36 2016 +0200

    Explain the deal with internal test programs
    
    Reviewed-by: Emilia Käsper <emilia at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/1789)

commit ab6e147c49f2382d2c30e313dd99aa23f66bc563
Author: Richard Levitte <levitte at openssl.org>
Date:   Tue Oct 25 12:40:32 2016 +0200

    Allow indented comments in build.info
    
    Reviewed-by: Emilia Käsper <emilia at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/1789)

commit aeac218372239752e79769da8f7d1db16d87307d
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Oct 26 00:25:44 2016 +0200

    Convert poly1305 selftest into internal test
    
    Reviewed-by: Emilia Käsper <emilia at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/1789)

-----------------------------------------------------------------------

Summary of changes:
 Configurations/descrip.mms.tmpl  |   35 +-
 Configure                        |    2 +-
 crypto/asn1/a_strnid.c           |   77 +-
 crypto/asn1/ameth_lib.c          |   42 +-
 crypto/asn1/standard_methods.h   |   40 +
 crypto/asn1/tbl_standard.h       |   57 ++
 crypto/evp/p5_crpt2.c            |   12 -
 crypto/mdc2/mdc2dgst.c           |   21 -
 crypto/modes/cts128.c            |  193 -----
 crypto/modes/gcm128.c            |  636 --------------
 crypto/objects/obj_xref.c        |   27 -
 crypto/poly1305/poly1305.c       |  507 +-----------
 crypto/poly1305/poly1305_local.h |   27 +
 crypto/rc2/tab.c                 |   93 ---
 crypto/x509v3/standard_exts.h    |   77 ++
 crypto/x509v3/tabtest.c          |   42 -
 crypto/x509v3/v3_lib.c           |   68 +-
 crypto/x509v3/v3conf.c           |   79 --
 crypto/x509v3/v3prin.c           |   50 --
 include/openssl/modes.h          |   17 +-
 test/asn1_internal_test.c        |  152 ++++
 test/build.info                  |   80 ++
 test/mdc2_internal_test.c        |   95 +++
 test/modes_internal_test.c       | 1085 ++++++++++++++++++++++++
 test/poly1305_internal_test.c    | 1701 ++++++++++++++++++++++++++++++++++++++
 test/recipes/03-test_internal.t  |   31 +
 test/x509_internal_test.c        |  100 +++
 27 files changed, 3495 insertions(+), 1851 deletions(-)
 create mode 100644 crypto/asn1/standard_methods.h
 create mode 100644 crypto/asn1/tbl_standard.h
 create mode 100644 crypto/poly1305/poly1305_local.h
 delete mode 100644 crypto/rc2/tab.c
 create mode 100644 crypto/x509v3/standard_exts.h
 delete mode 100644 crypto/x509v3/tabtest.c
 delete mode 100644 crypto/x509v3/v3conf.c
 delete mode 100644 crypto/x509v3/v3prin.c
 create mode 100644 test/asn1_internal_test.c
 create mode 100644 test/mdc2_internal_test.c
 create mode 100644 test/modes_internal_test.c
 create mode 100644 test/poly1305_internal_test.c
 create mode 100644 test/recipes/03-test_internal.t
 create mode 100644 test/x509_internal_test.c

diff --git a/Configurations/descrip.mms.tmpl b/Configurations/descrip.mms.tmpl
index 95262fe..3d221f5 100644
--- a/Configurations/descrip.mms.tmpl
+++ b/Configurations/descrip.mms.tmpl
@@ -751,13 +751,46 @@ EOF
                              $x =~ s|(\.OLB)|$1/LIB|;
                              "WRITE OPT_FILE \"$x\"" } @deps)
           || "\@ !";
+      # The linking commands looks a bit complex, but it's for good reason.
+      # When you link, say, foo.obj, bar.obj and libsomething.exe/share, and
+      # bar.obj happens to have a symbol that also exists in libsomething.exe,
+      # the linker will warn about it, loudly, and will then choose to pick
+      # the first copy encountered (the one in bar.obj in this example).
+      # On Unix and on Windows, the corresponding maneuvre goes through
+      # silently with the same effect.
+      # With some test programs, made for checking the internals of OpenSSL,
+      # we do this kind of linking deliberately, picking a few specific object
+      # files from within [.crypto] or [.ssl] so we can reach symbols that are
+      # otherwise unreachable (since the shareable images only exports the
+      # symbols listed in [.util]*.num), and then with the shared libraries
+      # themselves.  So we need to silence the warning about multiply defined
+      # symbols, to mimic the way linking work on Unix and Windows, and so
+      # the build isn't interrupted (MMS stops when warnings are signaled,
+      # by default), and so someone building doesn't have to worry where it
+      # isn't necessary.  If there are other warnings, however, we show them
+      # and let it break the build.
       return <<"EOF";
 $bin.EXE : $deps
         OPEN/WRITE/SHARE=READ OPT_FILE $bin.OPT
         $write_opt1
         $write_opt2
         CLOSE OPT_FILE
-        LINK/EXEC=$bin.EXE \$(LDFLAGS) $bin.OPT/OPT \$(EX_LIBS)
+        - pipe SPAWN/WAIT/NOLOG/OUT=$bin.LINKLOG -
+                    LINK/EXEC=$bin.EXE \$(LDFLAGS) $bin.OPT/OPT \$(EX_LIBS) ; -
+               link_status = \$status ; link_severity = link_status .AND. 7
+        @ search_severity = 1
+        -@ IF link_severity .EQ. 0 THEN -
+                pipe SEARCH $bin.LINKLOG "%","-"/MATCH=AND | -
+                     SPAWN/WAIT/NOLOG/OUT=NLA0: -
+                          SEARCH SYS\$INPUT: "-W-MULDEF,"/MATCH=NOR ; -
+                     search_severity = \$severity
+        @ ! search_severity is 3 when the last search didn't find any matching
+        @ ! string: %SEARCH-I-NOMATCHES, no strings matched
+        -@ IF search_severity .NE. 3 .OR. link_severity .NE. 1 THEN -
+                TYPE $bin.LINKLOG
+        -@ DELETE $bin.LINKLOG;*
+        @ IF search_severity .NE. 3 .OR. link_severity .NE. 1 THEN -
+                SPAWN/WAIT/NOLOG EXIT 'link_status'
         - PURGE $bin.EXE,$bin.OPT
 EOF
   }
diff --git a/Configure b/Configure
index 958ac5c..884f7bd 100755
--- a/Configure
+++ b/Configure
@@ -1592,7 +1592,7 @@ if ($builder eq "unified") {
                             || $target_kind eq $target{build_file}."(".$builder_platform.")");
                 }
             },
-            qr/^(?:#.*|\s*)$/ => sub { },
+            qr/^\s*(?:#.*)?$/ => sub { },
             "OTHERWISE" => sub { die "Something wrong with this line:\n$_\nat $sourced/$f" },
             "BEFORE" => sub {
                 if ($buildinfo_debug) {
diff --git a/crypto/asn1/a_strnid.c b/crypto/asn1/a_strnid.c
index 53832c8..ce8a646 100644
--- a/crypto/asn1/a_strnid.c
+++ b/crypto/asn1/a_strnid.c
@@ -106,53 +106,7 @@ ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,
  * Now the tables and helper functions for the string table:
  */
 
-/* size limits: this stuff is taken straight from RFC3280 */
-
-#define ub_name                         32768
-#define ub_common_name                  64
-#define ub_locality_name                128
-#define ub_state_name                   128
-#define ub_organization_name            64
-#define ub_organization_unit_name       64
-#define ub_title                        64
-#define ub_email_address                128
-#define ub_serial_number                64
-
-/* From RFC4524 */
-
-#define ub_rfc822_mailbox               256
-
-/* This table must be kept in NID order */
-
-static const ASN1_STRING_TABLE tbl_standard[] = {
-    {NID_commonName, 1, ub_common_name, DIRSTRING_TYPE, 0},
-    {NID_countryName, 2, 2, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
-    {NID_localityName, 1, ub_locality_name, DIRSTRING_TYPE, 0},
-    {NID_stateOrProvinceName, 1, ub_state_name, DIRSTRING_TYPE, 0},
-    {NID_organizationName, 1, ub_organization_name, DIRSTRING_TYPE, 0},
-    {NID_organizationalUnitName, 1, ub_organization_unit_name, DIRSTRING_TYPE,
-     0},
-    {NID_pkcs9_emailAddress, 1, ub_email_address, B_ASN1_IA5STRING,
-     STABLE_NO_MASK},
-    {NID_pkcs9_unstructuredName, 1, -1, PKCS9STRING_TYPE, 0},
-    {NID_pkcs9_challengePassword, 1, -1, PKCS9STRING_TYPE, 0},
-    {NID_pkcs9_unstructuredAddress, 1, -1, DIRSTRING_TYPE, 0},
-    {NID_givenName, 1, ub_name, DIRSTRING_TYPE, 0},
-    {NID_surname, 1, ub_name, DIRSTRING_TYPE, 0},
-    {NID_initials, 1, ub_name, DIRSTRING_TYPE, 0},
-    {NID_serialNumber, 1, ub_serial_number, B_ASN1_PRINTABLESTRING,
-     STABLE_NO_MASK},
-    {NID_friendlyName, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK},
-    {NID_name, 1, ub_name, DIRSTRING_TYPE, 0},
-    {NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
-    {NID_domainComponent, 1, -1, B_ASN1_IA5STRING, STABLE_NO_MASK},
-    {NID_ms_csp_name, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK},
-    {NID_rfc822Mailbox, 1, ub_rfc822_mailbox, B_ASN1_IA5STRING,
-     STABLE_NO_MASK},
-    {NID_INN, 1, 12, B_ASN1_NUMERICSTRING, STABLE_NO_MASK},
-    {NID_OGRN, 1, 13, B_ASN1_NUMERICSTRING, STABLE_NO_MASK},
-    {NID_SNILS, 1, 11, B_ASN1_NUMERICSTRING, STABLE_NO_MASK}
-};
+#include "tbl_standard.h"
 
 static int sk_table_cmp(const ASN1_STRING_TABLE *const *a,
                         const ASN1_STRING_TABLE *const *b)
@@ -256,32 +210,3 @@ static void st_free(ASN1_STRING_TABLE *tbl)
     if (tbl->flags & STABLE_FLAGS_MALLOC)
         OPENSSL_free(tbl);
 }
-
-
-#ifdef STRING_TABLE_TEST
-
-main()
-{
-    ASN1_STRING_TABLE *tmp;
-    int i, last_nid = -1;
-
-    for (tmp = tbl_standard, i = 0; i < OSSL_NELEM(tbl_standard); i++, tmp++) {
-        if (tmp->nid < last_nid) {
-            last_nid = 0;
-            break;
-        }
-        last_nid = tmp->nid;
-    }
-
-    if (last_nid != 0) {
-        printf("Table order OK\n");
-        exit(0);
-    }
-
-    for (tmp = tbl_standard, i = 0; i < OSSL_NELEM(tbl_standard); i++, tmp++)
-        printf("Index %d, NID %d, Name=%s\n", i, tmp->nid,
-               OBJ_nid2ln(tmp->nid));
-
-}
-
-#endif
diff --git a/crypto/asn1/ameth_lib.c b/crypto/asn1/ameth_lib.c
index cfde49a..c677917 100644
--- a/crypto/asn1/ameth_lib.c
+++ b/crypto/asn1/ameth_lib.c
@@ -15,51 +15,11 @@
 #include "internal/asn1_int.h"
 #include "internal/evp_int.h"
 
-/* Keep this sorted in type order !! */
-static const EVP_PKEY_ASN1_METHOD *standard_methods[] = {
-#ifndef OPENSSL_NO_RSA
-    &rsa_asn1_meths[0],
-    &rsa_asn1_meths[1],
-#endif
-#ifndef OPENSSL_NO_DH
-    &dh_asn1_meth,
-#endif
-#ifndef OPENSSL_NO_DSA
-    &dsa_asn1_meths[0],
-    &dsa_asn1_meths[1],
-    &dsa_asn1_meths[2],
-    &dsa_asn1_meths[3],
-    &dsa_asn1_meths[4],
-#endif
-#ifndef OPENSSL_NO_EC
-    &eckey_asn1_meth,
-#endif
-    &hmac_asn1_meth,
-#ifndef OPENSSL_NO_CMAC
-    &cmac_asn1_meth,
-#endif
-#ifndef OPENSSL_NO_DH
-    &dhx_asn1_meth,
-#endif
-#ifndef OPENSSL_NO_EC
-    &ecx25519_asn1_meth
-#endif
-};
+#include "standard_methods.h"
 
 typedef int sk_cmp_fn_type(const char *const *a, const char *const *b);
 static STACK_OF(EVP_PKEY_ASN1_METHOD) *app_methods = NULL;
 
-#ifdef TEST
-void main()
-{
-    int i;
-    for (i = 0; i < OSSL_NELEM(standard_methods); i++)
-        fprintf(stderr, "Number %d id=%d (%s)\n", i,
-                standard_methods[i]->pkey_id,
-                OBJ_nid2sn(standard_methods[i]->pkey_id));
-}
-#endif
-
 DECLARE_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_ASN1_METHOD *,
                            const EVP_PKEY_ASN1_METHOD *, ameth);
 
diff --git a/crypto/asn1/standard_methods.h b/crypto/asn1/standard_methods.h
new file mode 100644
index 0000000..5b8f9dd
--- /dev/null
+++ b/crypto/asn1/standard_methods.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the OpenSSL license (the "License").  You may not use
+ * this file except in compliance with the License.  You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+/* Keep this sorted in type order !! */
+static const EVP_PKEY_ASN1_METHOD *standard_methods[] = {
+#ifndef OPENSSL_NO_RSA
+    &rsa_asn1_meths[0],
+    &rsa_asn1_meths[1],
+#endif
+#ifndef OPENSSL_NO_DH
+    &dh_asn1_meth,
+#endif
+#ifndef OPENSSL_NO_DSA
+    &dsa_asn1_meths[0],
+    &dsa_asn1_meths[1],
+    &dsa_asn1_meths[2],
+    &dsa_asn1_meths[3],
+    &dsa_asn1_meths[4],
+#endif
+#ifndef OPENSSL_NO_EC
+    &eckey_asn1_meth,
+#endif
+    &hmac_asn1_meth,
+#ifndef OPENSSL_NO_CMAC
+    &cmac_asn1_meth,
+#endif
+#ifndef OPENSSL_NO_DH
+    &dhx_asn1_meth,
+#endif
+#ifndef OPENSSL_NO_EC
+    &ecx25519_asn1_meth
+#endif
+};
+
diff --git a/crypto/asn1/tbl_standard.h b/crypto/asn1/tbl_standard.h
new file mode 100644
index 0000000..7fb04f8
--- /dev/null
+++ b/crypto/asn1/tbl_standard.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the OpenSSL license (the "License").  You may not use
+ * this file except in compliance with the License.  You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+/* size limits: this stuff is taken straight from RFC3280 */
+
+#define ub_name                         32768
+#define ub_common_name                  64
+#define ub_locality_name                128
+#define ub_state_name                   128
+#define ub_organization_name            64
+#define ub_organization_unit_name       64
+#define ub_title                        64
+#define ub_email_address                128
+#define ub_serial_number                64
+
+/* From RFC4524 */
+
+#define ub_rfc822_mailbox               256
+
+/* This table must be kept in NID order */
+
+static const ASN1_STRING_TABLE tbl_standard[] = {
+    {NID_commonName, 1, ub_common_name, DIRSTRING_TYPE, 0},
+    {NID_countryName, 2, 2, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
+    {NID_localityName, 1, ub_locality_name, DIRSTRING_TYPE, 0},
+    {NID_stateOrProvinceName, 1, ub_state_name, DIRSTRING_TYPE, 0},
+    {NID_organizationName, 1, ub_organization_name, DIRSTRING_TYPE, 0},
+    {NID_organizationalUnitName, 1, ub_organization_unit_name, DIRSTRING_TYPE,
+     0},
+    {NID_pkcs9_emailAddress, 1, ub_email_address, B_ASN1_IA5STRING,
+     STABLE_NO_MASK},
+    {NID_pkcs9_unstructuredName, 1, -1, PKCS9STRING_TYPE, 0},
+    {NID_pkcs9_challengePassword, 1, -1, PKCS9STRING_TYPE, 0},
+    {NID_pkcs9_unstructuredAddress, 1, -1, DIRSTRING_TYPE, 0},
+    {NID_givenName, 1, ub_name, DIRSTRING_TYPE, 0},
+    {NID_surname, 1, ub_name, DIRSTRING_TYPE, 0},
+    {NID_initials, 1, ub_name, DIRSTRING_TYPE, 0},
+    {NID_serialNumber, 1, ub_serial_number, B_ASN1_PRINTABLESTRING,
+     STABLE_NO_MASK},
+    {NID_friendlyName, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK},
+    {NID_name, 1, ub_name, DIRSTRING_TYPE, 0},
+    {NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
+    {NID_domainComponent, 1, -1, B_ASN1_IA5STRING, STABLE_NO_MASK},
+    {NID_ms_csp_name, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK},
+    {NID_rfc822Mailbox, 1, ub_rfc822_mailbox, B_ASN1_IA5STRING,
+     STABLE_NO_MASK},
+    {NID_INN, 1, 12, B_ASN1_NUMERICSTRING, STABLE_NO_MASK},
+    {NID_OGRN, 1, 13, B_ASN1_NUMERICSTRING, STABLE_NO_MASK},
+    {NID_SNILS, 1, 11, B_ASN1_NUMERICSTRING, STABLE_NO_MASK}
+};
+
diff --git a/crypto/evp/p5_crpt2.c b/crypto/evp/p5_crpt2.c
index 2e45aa3..024996f 100644
--- a/crypto/evp/p5_crpt2.c
+++ b/crypto/evp/p5_crpt2.c
@@ -129,18 +129,6 @@ int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
                              keylen, out);
 }
 
-# ifdef DO_TEST
-main()
-{
-    unsigned char out[4];
-    unsigned char salt[] = { 0x12, 0x34, 0x56, 0x78 };
-    PKCS5_PBKDF2_HMAC_SHA1("password", -1, salt, 4, 5, 4, out);
-    fprintf(stderr, "Out %02X %02X %02X %02X\n",
-            out[0], out[1], out[2], out[3]);
-}
-
-# endif
-
 /*
  * Now the key derivation function itself. This is a bit evil because it has
  * to check the ASN1 parameters are valid: and there are quite a few of
diff --git a/crypto/mdc2/mdc2dgst.c b/crypto/mdc2/mdc2dgst.c
index 37d99f4..14233b9 100644
--- a/crypto/mdc2/mdc2dgst.c
+++ b/crypto/mdc2/mdc2dgst.c
@@ -124,24 +124,3 @@ int MDC2_Final(unsigned char *md, MDC2_CTX *c)
     memcpy(&(md[MDC2_BLOCK]), (char *)c->hh, MDC2_BLOCK);
     return 1;
 }
-
-#undef TEST
-
-#ifdef TEST
-main()
-{
-    unsigned char md[MDC2_DIGEST_LENGTH];
-    int i;
-    MDC2_CTX c;
-    static char *text = "Now is the time for all ";
-
-    MDC2_Init(&c);
-    MDC2_Update(&c, text, strlen(text));
-    MDC2_Final(&(md[0]), &c);
-
-    for (i = 0; i < MDC2_DIGEST_LENGTH; i++)
-        printf("%02X", md[i]);
-    printf("\n");
-}
-
-#endif
diff --git a/crypto/modes/cts128.c b/crypto/modes/cts128.c
index 77ec994..93826a1 100644
--- a/crypto/modes/cts128.c
+++ b/crypto/modes/cts128.c
@@ -328,196 +328,3 @@ size_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out,
 #endif
     return 16 + len + residue;
 }
-
-#if defined(SELFTEST)
-# include <stdio.h>
-# include <openssl/aes.h>
-
-/* test vectors from RFC 3962 */
-static const unsigned char test_key[16] = "chicken teriyaki";
-static const unsigned char test_input[64] =
-    "I would like the" " General Gau's C"
-    "hicken, please, " "and wonton soup.";
-static const unsigned char test_iv[16] =
-    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-
-static const unsigned char vector_17[17] = {
-    0xc6, 0x35, 0x35, 0x68, 0xf2, 0xbf, 0x8c, 0xb4,
-    0xd8, 0xa5, 0x80, 0x36, 0x2d, 0xa7, 0xff, 0x7f,
-    0x97
-};
-
-static const unsigned char vector_31[31] = {
-    0xfc, 0x00, 0x78, 0x3e, 0x0e, 0xfd, 0xb2, 0xc1,
-    0xd4, 0x45, 0xd4, 0xc8, 0xef, 0xf7, 0xed, 0x22,
-    0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0,
-    0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5
-};
-
-static const unsigned char vector_32[32] = {
-    0x39, 0x31, 0x25, 0x23, 0xa7, 0x86, 0x62, 0xd5,
-    0xbe, 0x7f, 0xcb, 0xcc, 0x98, 0xeb, 0xf5, 0xa8,
-    0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0,
-    0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5, 0x84
-};
-
-static const unsigned char vector_47[47] = {
-    0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0,
-    0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5, 0x84,
-    0xb3, 0xff, 0xfd, 0x94, 0x0c, 0x16, 0xa1, 0x8c,
-    0x1b, 0x55, 0x49, 0xd2, 0xf8, 0x38, 0x02, 0x9e,
-    0x39, 0x31, 0x25, 0x23, 0xa7, 0x86, 0x62, 0xd5,
-    0xbe, 0x7f, 0xcb, 0xcc, 0x98, 0xeb, 0xf5
-};
-
-static const unsigned char vector_48[48] = {
-    0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0,
-    0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5, 0x84,
-    0x9d, 0xad, 0x8b, 0xbb, 0x96, 0xc4, 0xcd, 0xc0,
-    0x3b, 0xc1, 0x03, 0xe1, 0xa1, 0x94, 0xbb, 0xd8,
-    0x39, 0x31, 0x25, 0x23, 0xa7, 0x86, 0x62, 0xd5,
-    0xbe, 0x7f, 0xcb, 0xcc, 0x98, 0xeb, 0xf5, 0xa8
-};
-
-static const unsigned char vector_64[64] = {
-    0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0,
-    0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5, 0x84,
-    0x39, 0x31, 0x25, 0x23, 0xa7, 0x86, 0x62, 0xd5,
-    0xbe, 0x7f, 0xcb, 0xcc, 0x98, 0xeb, 0xf5, 0xa8,
-    0x48, 0x07, 0xef, 0xe8, 0x36, 0xee, 0x89, 0xa5,
-    0x26, 0x73, 0x0d, 0xbc, 0x2f, 0x7b, 0xc8, 0x40,
-    0x9d, 0xad, 0x8b, 0xbb, 0x96, 0xc4, 0xcd, 0xc0,
-    0x3b, 0xc1, 0x03, 0xe1, 0xa1, 0x94, 0xbb, 0xd8
-};
-
-static AES_KEY encks, decks;
-
-void test_vector(const unsigned char *vector, size_t len)
-{
-    unsigned char iv[sizeof(test_iv)];
-    unsigned char cleartext[64], ciphertext[64];
-    size_t tail;
-
-    printf("vector_%d\n", len);
-    fflush(stdout);
-
-    if ((tail = len % 16) == 0)
-        tail = 16;
-    tail += 16;
-
-    /* test block-based encryption */
-    memcpy(iv, test_iv, sizeof(test_iv));
-    CRYPTO_cts128_encrypt_block(test_input, ciphertext, len, &encks, iv,
-                                (block128_f) AES_encrypt);
-    if (memcmp(ciphertext, vector, len))
-        fprintf(stderr, "output_%d mismatch\n", len), exit(1);
-    if (memcmp(iv, vector + len - tail, sizeof(iv)))
-        fprintf(stderr, "iv_%d mismatch\n", len), exit(1);
-
-    /* test block-based decryption */
-    memcpy(iv, test_iv, sizeof(test_iv));
-    CRYPTO_cts128_decrypt_block(ciphertext, cleartext, len, &decks, iv,
-                                (block128_f) AES_decrypt);
-    if (memcmp(cleartext, test_input, len))
-        fprintf(stderr, "input_%d mismatch\n", len), exit(2);
-    if (memcmp(iv, vector + len - tail, sizeof(iv)))
-        fprintf(stderr, "iv_%d mismatch\n", len), exit(2);
-
-    /* test streamed encryption */
-    memcpy(iv, test_iv, sizeof(test_iv));
-    CRYPTO_cts128_encrypt(test_input, ciphertext, len, &encks, iv,
-                          (cbc128_f) AES_cbc_encrypt);
-    if (memcmp(ciphertext, vector, len))
-        fprintf(stderr, "output_%d mismatch\n", len), exit(3);
-    if (memcmp(iv, vector + len - tail, sizeof(iv)))
-        fprintf(stderr, "iv_%d mismatch\n", len), exit(3);
-
-    /* test streamed decryption */
-    memcpy(iv, test_iv, sizeof(test_iv));
-    CRYPTO_cts128_decrypt(ciphertext, cleartext, len, &decks, iv,
-                          (cbc128_f) AES_cbc_encrypt);
-    if (memcmp(cleartext, test_input, len))
-        fprintf(stderr, "input_%d mismatch\n", len), exit(4);
-    if (memcmp(iv, vector + len - tail, sizeof(iv)))
-        fprintf(stderr, "iv_%d mismatch\n", len), exit(4);
-}
-
-void test_nistvector(const unsigned char *vector, size_t len)
-{
-    unsigned char iv[sizeof(test_iv)];
-    unsigned char cleartext[64], ciphertext[64], nistvector[64];
-    size_t tail;
-
-    printf("nistvector_%d\n", len);
-    fflush(stdout);
-
-    if ((tail = len % 16) == 0)
-        tail = 16;
-
-    len -= 16 + tail;
-    memcpy(nistvector, vector, len);
-    /* flip two last blocks */
-    memcpy(nistvector + len, vector + len + 16, tail);
-    memcpy(nistvector + len + tail, vector + len, 16);
-    len += 16 + tail;
-    tail = 16;
-
-    /* test block-based encryption */
-    memcpy(iv, test_iv, sizeof(test_iv));
-    CRYPTO_nistcts128_encrypt_block(test_input, ciphertext, len, &encks, iv,
-                                    (block128_f) AES_encrypt);
-    if (memcmp(ciphertext, nistvector, len))
-        fprintf(stderr, "output_%d mismatch\n", len), exit(1);
-    if (memcmp(iv, nistvector + len - tail, sizeof(iv)))
-        fprintf(stderr, "iv_%d mismatch\n", len), exit(1);
-
-    /* test block-based decryption */
-    memcpy(iv, test_iv, sizeof(test_iv));
-    CRYPTO_nistcts128_decrypt_block(ciphertext, cleartext, len, &decks, iv,
-                                    (block128_f) AES_decrypt);
-    if (memcmp(cleartext, test_input, len))
-        fprintf(stderr, "input_%d mismatch\n", len), exit(2);
-    if (memcmp(iv, nistvector + len - tail, sizeof(iv)))
-        fprintf(stderr, "iv_%d mismatch\n", len), exit(2);
-
-    /* test streamed encryption */
-    memcpy(iv, test_iv, sizeof(test_iv));
-    CRYPTO_nistcts128_encrypt(test_input, ciphertext, len, &encks, iv,
-                              (cbc128_f) AES_cbc_encrypt);
-    if (memcmp(ciphertext, nistvector, len))
-        fprintf(stderr, "output_%d mismatch\n", len), exit(3);
-    if (memcmp(iv, nistvector + len - tail, sizeof(iv)))
-        fprintf(stderr, "iv_%d mismatch\n", len), exit(3);
-
-    /* test streamed decryption */
-    memcpy(iv, test_iv, sizeof(test_iv));
-    CRYPTO_nistcts128_decrypt(ciphertext, cleartext, len, &decks, iv,
-                              (cbc128_f) AES_cbc_encrypt);
-    if (memcmp(cleartext, test_input, len))
-        fprintf(stderr, "input_%d mismatch\n", len), exit(4);
-    if (memcmp(iv, nistvector + len - tail, sizeof(iv)))
-        fprintf(stderr, "iv_%d mismatch\n", len), exit(4);
-}
-
-int main()
-{
-    AES_set_encrypt_key(test_key, 128, &encks);
-    AES_set_decrypt_key(test_key, 128, &decks);
-
-    test_vector(vector_17, sizeof(vector_17));
-    test_vector(vector_31, sizeof(vector_31));
-    test_vector(vector_32, sizeof(vector_32));
-    test_vector(vector_47, sizeof(vector_47));
-    test_vector(vector_48, sizeof(vector_48));
-    test_vector(vector_64, sizeof(vector_64));
-
-    test_nistvector(vector_17, sizeof(vector_17));
-    test_nistvector(vector_31, sizeof(vector_31));
-    test_nistvector(vector_32, sizeof(vector_32));
-    test_nistvector(vector_47, sizeof(vector_47));
-    test_nistvector(vector_48, sizeof(vector_48));
-    test_nistvector(vector_64, sizeof(vector_64));
-
-    return 0;
-}
-#endif
diff --git a/crypto/modes/gcm128.c b/crypto/modes/gcm128.c
index df9f654..7dead28 100644
--- a/crypto/modes/gcm128.c
+++ b/crypto/modes/gcm128.c
@@ -1664,639 +1664,3 @@ void CRYPTO_gcm128_release(GCM128_CONTEXT *ctx)
 {
     OPENSSL_clear_free(ctx, sizeof(*ctx));
 }
-
-#if defined(SELFTEST)
-# include <stdio.h>
-# include <openssl/aes.h>
-
-/* Test Case 1 */
-static const u8 K1[16], *P1 = NULL, *A1 = NULL, IV1[12], *C1 = NULL;
-static const u8 T1[] = {
-    0x58, 0xe2, 0xfc, 0xce, 0xfa, 0x7e, 0x30, 0x61,
-    0x36, 0x7f, 0x1d, 0x57, 0xa4, 0xe7, 0x45, 0x5a
-};
-
-/* Test Case 2 */
-# define K2 K1
-# define A2 A1
-# define IV2 IV1
-static const u8 P2[16];
-static const u8 C2[] = {
-    0x03, 0x88, 0xda, 0xce, 0x60, 0xb6, 0xa3, 0x92,
-    0xf3, 0x28, 0xc2, 0xb9, 0x71, 0xb2, 0xfe, 0x78
-};
-
-static const u8 T2[] = {
-    0xab, 0x6e, 0x47, 0xd4, 0x2c, 0xec, 0x13, 0xbd,
-    0xf5, 0x3a, 0x67, 0xb2, 0x12, 0x57, 0xbd, 0xdf
-};
-
-/* Test Case 3 */
-# define A3 A2
-static const u8 K3[] = {
-    0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
-    0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
-};
-
-static const u8 P3[] = {
-    0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
-    0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
-    0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
-    0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
-    0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
-    0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
-    0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
-    0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55
-};
-
-static const u8 IV3[] = {
-    0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
-    0xde, 0xca, 0xf8, 0x88
-};
-
-static const u8 C3[] = {
-    0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24,
-    0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c,
-    0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0,
-    0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e,
-    0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c,
-    0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05,
-    0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97,
-    0x3d, 0x58, 0xe0, 0x91, 0x47, 0x3f, 0x59, 0x85
-};
-
-static const u8 T3[] = {
-    0x4d, 0x5c, 0x2a, 0xf3, 0x27, 0xcd, 0x64, 0xa6,
-    0x2c, 0xf3, 0x5a, 0xbd, 0x2b, 0xa6, 0xfa, 0xb4
-};
-
-/* Test Case 4 */
-# define K4 K3
-# define IV4 IV3
-static const u8 P4[] = {
-    0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
-    0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
-    0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
-    0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
-    0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
-    0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
-    0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
-    0xba, 0x63, 0x7b, 0x39
-};
-
-static const u8 A4[] = {
-    0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
-    0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
-    0xab, 0xad, 0xda, 0xd2
-};
-
-static const u8 C4[] = {
-    0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24,
-    0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c,
-    0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0,
-    0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e,
-    0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c,
-    0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05,
-    0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97,
-    0x3d, 0x58, 0xe0, 0x91
-};
-
-static const u8 T4[] = {
-    0x5b, 0xc9, 0x4f, 0xbc, 0x32, 0x21, 0xa5, 0xdb,
-    0x94, 0xfa, 0xe9, 0x5a, 0xe7, 0x12, 0x1a, 0x47
-};
-
-/* Test Case 5 */
-# define K5 K4
-# define P5 P4
-# define A5 A4
-static const u8 IV5[] = {
-    0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad
-};
-
-static const u8 C5[] = {
-    0x61, 0x35, 0x3b, 0x4c, 0x28, 0x06, 0x93, 0x4a,
-    0x77, 0x7f, 0xf5, 0x1f, 0xa2, 0x2a, 0x47, 0x55,
-    0x69, 0x9b, 0x2a, 0x71, 0x4f, 0xcd, 0xc6, 0xf8,
-    0x37, 0x66, 0xe5, 0xf9, 0x7b, 0x6c, 0x74, 0x23,
-    0x73, 0x80, 0x69, 0x00, 0xe4, 0x9f, 0x24, 0xb2,
-    0x2b, 0x09, 0x75, 0x44, 0xd4, 0x89, 0x6b, 0x42,
-    0x49, 0x89, 0xb5, 0xe1, 0xeb, 0xac, 0x0f, 0x07,
-    0xc2, 0x3f, 0x45, 0x98
-};
-
-static const u8 T5[] = {
-    0x36, 0x12, 0xd2, 0xe7, 0x9e, 0x3b, 0x07, 0x85,
-    0x56, 0x1b, 0xe1, 0x4a, 0xac, 0xa2, 0xfc, 0xcb
-};
-
-/* Test Case 6 */
-# define K6 K5
-# define P6 P5
-# define A6 A5
-static const u8 IV6[] = {
-    0x93, 0x13, 0x22, 0x5d, 0xf8, 0x84, 0x06, 0xe5,
-    0x55, 0x90, 0x9c, 0x5a, 0xff, 0x52, 0x69, 0xaa,
-    0x6a, 0x7a, 0x95, 0x38, 0x53, 0x4f, 0x7d, 0xa1,
-    0xe4, 0xc3, 0x03, 0xd2, 0xa3, 0x18, 0xa7, 0x28,
-    0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39,
-    0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54,
-    0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57,
-    0xa6, 0x37, 0xb3, 0x9b
-};
-
-static const u8 C6[] = {
-    0x8c, 0xe2, 0x49, 0x98, 0x62, 0x56, 0x15, 0xb6,
-    0x03, 0xa0, 0x33, 0xac, 0xa1, 0x3f, 0xb8, 0x94,
-    0xbe, 0x91, 0x12, 0xa5, 0xc3, 0xa2, 0x11, 0xa8,
-    0xba, 0x26, 0x2a, 0x3c, 0xca, 0x7e, 0x2c, 0xa7,
-    0x01, 0xe4, 0xa9, 0xa4, 0xfb, 0xa4, 0x3c, 0x90,
-    0xcc, 0xdc, 0xb2, 0x81, 0xd4, 0x8c, 0x7c, 0x6f,
-    0xd6, 0x28, 0x75, 0xd2, 0xac, 0xa4, 0x17, 0x03,
-    0x4c, 0x34, 0xae, 0xe5
-};
-
-static const u8 T6[] = {
-    0x61, 0x9c, 0xc5, 0xae, 0xff, 0xfe, 0x0b, 0xfa,
-    0x46, 0x2a, 0xf4, 0x3c, 0x16, 0x99, 0xd0, 0x50
-};
-
-/* Test Case 7 */
-static const u8 K7[24], *P7 = NULL, *A7 = NULL, IV7[12], *C7 = NULL;
-static const u8 T7[] = {
-    0xcd, 0x33, 0xb2, 0x8a, 0xc7, 0x73, 0xf7, 0x4b,
-    0xa0, 0x0e, 0xd1, 0xf3, 0x12, 0x57, 0x24, 0x35
-};
-
-/* Test Case 8 */
-# define K8 K7
-# define IV8 IV7
-# define A8 A7
-static const u8 P8[16];
-static const u8 C8[] = {
-    0x98, 0xe7, 0x24, 0x7c, 0x07, 0xf0, 0xfe, 0x41,
-    0x1c, 0x26, 0x7e, 0x43, 0x84, 0xb0, 0xf6, 0x00
-};
-
-static const u8 T8[] = {
-    0x2f, 0xf5, 0x8d, 0x80, 0x03, 0x39, 0x27, 0xab,
-    0x8e, 0xf4, 0xd4, 0x58, 0x75, 0x14, 0xf0, 0xfb
-};
-
-/* Test Case 9 */
-# define A9 A8
-static const u8 K9[] = {
-    0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
-    0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
-    0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c
-};
-
-static const u8 P9[] = {
-    0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
-    0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
-    0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
-    0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
-    0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
-    0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
-    0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
-    0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55
-};
-
-static const u8 IV9[] = {
-    0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
-    0xde, 0xca, 0xf8, 0x88
-};
-
-static const u8 C9[] = {
-    0x39, 0x80, 0xca, 0x0b, 0x3c, 0x00, 0xe8, 0x41,
-    0xeb, 0x06, 0xfa, 0xc4, 0x87, 0x2a, 0x27, 0x57,
-    0x85, 0x9e, 0x1c, 0xea, 0xa6, 0xef, 0xd9, 0x84,
-    0x62, 0x85, 0x93, 0xb4, 0x0c, 0xa1, 0xe1, 0x9c,
-    0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25,
-    0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47,
-    0x18, 0xe2, 0x44, 0x8b, 0x2f, 0xe3, 0x24, 0xd9,
-    0xcc, 0xda, 0x27, 0x10, 0xac, 0xad, 0xe2, 0x56
-};
-
-static const u8 T9[] = {
-    0x99, 0x24, 0xa7, 0xc8, 0x58, 0x73, 0x36, 0xbf,
-    0xb1, 0x18, 0x02, 0x4d, 0xb8, 0x67, 0x4a, 0x14
-};
-
-/* Test Case 10 */
-# define K10 K9
-# define IV10 IV9
-static const u8 P10[] = {
-    0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
-    0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
-    0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
-    0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
-    0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
-    0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
-    0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
-    0xba, 0x63, 0x7b, 0x39
-};
-
-static const u8 A10[] = {
-    0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
-    0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
-    0xab, 0xad, 0xda, 0xd2
-};
-
-static const u8 C10[] = {
-    0x39, 0x80, 0xca, 0x0b, 0x3c, 0x00, 0xe8, 0x41,
-    0xeb, 0x06, 0xfa, 0xc4, 0x87, 0x2a, 0x27, 0x57,
-    0x85, 0x9e, 0x1c, 0xea, 0xa6, 0xef, 0xd9, 0x84,
-    0x62, 0x85, 0x93, 0xb4, 0x0c, 0xa1, 0xe1, 0x9c,
-    0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25,
-    0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47,
-    0x18, 0xe2, 0x44, 0x8b, 0x2f, 0xe3, 0x24, 0xd9,
-    0xcc, 0xda, 0x27, 0x10
-};
-
-static const u8 T10[] = {
-    0x25, 0x19, 0x49, 0x8e, 0x80, 0xf1, 0x47, 0x8f,
-    0x37, 0xba, 0x55, 0xbd, 0x6d, 0x27, 0x61, 0x8c
-};
-
-/* Test Case 11 */
-# define K11 K10
-# define P11 P10
-# define A11 A10
-static const u8 IV11[] = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad };
-
-static const u8 C11[] = {
-    0x0f, 0x10, 0xf5, 0x99, 0xae, 0x14, 0xa1, 0x54,
-    0xed, 0x24, 0xb3, 0x6e, 0x25, 0x32, 0x4d, 0xb8,
-    0xc5, 0x66, 0x63, 0x2e, 0xf2, 0xbb, 0xb3, 0x4f,
-    0x83, 0x47, 0x28, 0x0f, 0xc4, 0x50, 0x70, 0x57,
-    0xfd, 0xdc, 0x29, 0xdf, 0x9a, 0x47, 0x1f, 0x75,
-    0xc6, 0x65, 0x41, 0xd4, 0xd4, 0xda, 0xd1, 0xc9,
-    0xe9, 0x3a, 0x19, 0xa5, 0x8e, 0x8b, 0x47, 0x3f,
-    0xa0, 0xf0, 0x62, 0xf7
-};
-
-static const u8 T11[] = {
-    0x65, 0xdc, 0xc5, 0x7f, 0xcf, 0x62, 0x3a, 0x24,
-    0x09, 0x4f, 0xcc, 0xa4, 0x0d, 0x35, 0x33, 0xf8
-};
-
-/* Test Case 12 */
-# define K12 K11
-# define P12 P11
-# define A12 A11
-static const u8 IV12[] = {
-    0x93, 0x13, 0x22, 0x5d, 0xf8, 0x84, 0x06, 0xe5,
-    0x55, 0x90, 0x9c, 0x5a, 0xff, 0x52, 0x69, 0xaa,
-    0x6a, 0x7a, 0x95, 0x38, 0x53, 0x4f, 0x7d, 0xa1,
-    0xe4, 0xc3, 0x03, 0xd2, 0xa3, 0x18, 0xa7, 0x28,
-    0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39,
-    0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54,
-    0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57,
-    0xa6, 0x37, 0xb3, 0x9b
-};
-
-static const u8 C12[] = {
-    0xd2, 0x7e, 0x88, 0x68, 0x1c, 0xe3, 0x24, 0x3c,
-    0x48, 0x30, 0x16, 0x5a, 0x8f, 0xdc, 0xf9, 0xff,
-    0x1d, 0xe9, 0xa1, 0xd8, 0xe6, 0xb4, 0x47, 0xef,
-    0x6e, 0xf7, 0xb7, 0x98, 0x28, 0x66, 0x6e, 0x45,
-    0x81, 0xe7, 0x90, 0x12, 0xaf, 0x34, 0xdd, 0xd9,
-    0xe2, 0xf0, 0x37, 0x58, 0x9b, 0x29, 0x2d, 0xb3,
-    0xe6, 0x7c, 0x03, 0x67, 0x45, 0xfa, 0x22, 0xe7,
-    0xe9, 0xb7, 0x37, 0x3b
-};
-
-static const u8 T12[] = {
-    0xdc, 0xf5, 0x66, 0xff, 0x29, 0x1c, 0x25, 0xbb,
-    0xb8, 0x56, 0x8f, 0xc3, 0xd3, 0x76, 0xa6, 0xd9
-};
-
-/* Test Case 13 */
-static const u8 K13[32], *P13 = NULL, *A13 = NULL, IV13[12], *C13 = NULL;
-static const u8 T13[] = {
-    0x53, 0x0f, 0x8a, 0xfb, 0xc7, 0x45, 0x36, 0xb9,
-    0xa9, 0x63, 0xb4, 0xf1, 0xc4, 0xcb, 0x73, 0x8b
-};
-
-/* Test Case 14 */
-# define K14 K13
-# define A14 A13
-static const u8 P14[16], IV14[12];
-static const u8 C14[] = {
-    0xce, 0xa7, 0x40, 0x3d, 0x4d, 0x60, 0x6b, 0x6e,
-    0x07, 0x4e, 0xc5, 0xd3, 0xba, 0xf3, 0x9d, 0x18
-};
-
-static const u8 T14[] = {
-    0xd0, 0xd1, 0xc8, 0xa7, 0x99, 0x99, 0x6b, 0xf0,
-    0x26, 0x5b, 0x98, 0xb5, 0xd4, 0x8a, 0xb9, 0x19
-};
-
-/* Test Case 15 */
-# define A15 A14
-static const u8 K15[] = {
-    0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
-    0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
-    0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
-    0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
-};
-
-static const u8 P15[] = {
-    0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
-    0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
-    0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
-    0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
-    0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
-    0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
-    0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
-    0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55
-};
-
-static const u8 IV15[] = {
-    0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
-    0xde, 0xca, 0xf8, 0x88
-};
-
-static const u8 C15[] = {
-    0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07,
-    0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d,
-    0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9,
-    0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa,
-    0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d,
-    0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38,
-    0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a,
-    0xbc, 0xc9, 0xf6, 0x62, 0x89, 0x80, 0x15, 0xad
-};
-
-static const u8 T15[] = {
-    0xb0, 0x94, 0xda, 0xc5, 0xd9, 0x34, 0x71, 0xbd,
-    0xec, 0x1a, 0x50, 0x22, 0x70, 0xe3, 0xcc, 0x6c
-};
-
-/* Test Case 16 */
-# define K16 K15
-# define IV16 IV15
-static const u8 P16[] = {
-    0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
-    0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
-    0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
-    0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
-    0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
-    0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
-    0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
-    0xba, 0x63, 0x7b, 0x39
-};
-
-static const u8 A16[] = {
-    0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
-    0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
-    0xab, 0xad, 0xda, 0xd2
-};
-
-static const u8 C16[] = {
-    0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07,
-    0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d,
-    0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9,
-    0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa,
-    0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d,
-    0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38,
-    0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a,
-    0xbc, 0xc9, 0xf6, 0x62
-};
-
-static const u8 T16[] = {
-    0x76, 0xfc, 0x6e, 0xce, 0x0f, 0x4e, 0x17, 0x68,
-    0xcd, 0xdf, 0x88, 0x53, 0xbb, 0x2d, 0x55, 0x1b
-};
-
-/* Test Case 17 */
-# define K17 K16
-# define P17 P16
-# define A17 A16
-static const u8 IV17[] = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad };
-
-static const u8 C17[] = {
-    0xc3, 0x76, 0x2d, 0xf1, 0xca, 0x78, 0x7d, 0x32,
-    0xae, 0x47, 0xc1, 0x3b, 0xf1, 0x98, 0x44, 0xcb,
-    0xaf, 0x1a, 0xe1, 0x4d, 0x0b, 0x97, 0x6a, 0xfa,
-    0xc5, 0x2f, 0xf7, 0xd7, 0x9b, 0xba, 0x9d, 0xe0,
-    0xfe, 0xb5, 0x82, 0xd3, 0x39, 0x34, 0xa4, 0xf0,
-    0x95, 0x4c, 0xc2, 0x36, 0x3b, 0xc7, 0x3f, 0x78,
-    0x62, 0xac, 0x43, 0x0e, 0x64, 0xab, 0xe4, 0x99,
-    0xf4, 0x7c, 0x9b, 0x1f
-};
-
-static const u8 T17[] = {
-    0x3a, 0x33, 0x7d, 0xbf, 0x46, 0xa7, 0x92, 0xc4,
-    0x5e, 0x45, 0x49, 0x13, 0xfe, 0x2e, 0xa8, 0xf2
-};
-
-/* Test Case 18 */
-# define K18 K17
-# define P18 P17
-# define A18 A17
-static const u8 IV18[] = {
-    0x93, 0x13, 0x22, 0x5d, 0xf8, 0x84, 0x06, 0xe5,
-    0x55, 0x90, 0x9c, 0x5a, 0xff, 0x52, 0x69, 0xaa,
-    0x6a, 0x7a, 0x95, 0x38, 0x53, 0x4f, 0x7d, 0xa1,
-    0xe4, 0xc3, 0x03, 0xd2, 0xa3, 0x18, 0xa7, 0x28,
-    0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39,
-    0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54,
-    0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57,
-    0xa6, 0x37, 0xb3, 0x9b
-};
-
-static const u8 C18[] = {
-    0x5a, 0x8d, 0xef, 0x2f, 0x0c, 0x9e, 0x53, 0xf1,
-    0xf7, 0x5d, 0x78, 0x53, 0x65, 0x9e, 0x2a, 0x20,
-    0xee, 0xb2, 0xb2, 0x2a, 0xaf, 0xde, 0x64, 0x19,
-    0xa0, 0x58, 0xab, 0x4f, 0x6f, 0x74, 0x6b, 0xf4,
-    0x0f, 0xc0, 0xc3, 0xb7, 0x80, 0xf2, 0x44, 0x45,
-    0x2d, 0xa3, 0xeb, 0xf1, 0xc5, 0xd8, 0x2c, 0xde,
-    0xa2, 0x41, 0x89, 0x97, 0x20, 0x0e, 0xf8, 0x2e,
-    0x44, 0xae, 0x7e, 0x3f
-};
-
-static const u8 T18[] = {
-    0xa4, 0x4a, 0x82, 0x66, 0xee, 0x1c, 0x8e, 0xb0,
-    0xc8, 0xb5, 0xd4, 0xcf, 0x5a, 0xe9, 0xf1, 0x9a
-};
-
-/* Test Case 19 */
-# define K19 K1
-# define P19 P1
-# define IV19 IV1
-# define C19 C1
-static const u8 A19[] = {
-    0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
-    0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
-    0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
-    0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
-    0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
-    0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
-    0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
-    0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55,
-    0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07,
-    0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d,
-    0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9,
-    0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa,
-    0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d,
-    0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38,
-    0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a,
-    0xbc, 0xc9, 0xf6, 0x62, 0x89, 0x80, 0x15, 0xad
-};
-
-static const u8 T19[] = {
-    0x5f, 0xea, 0x79, 0x3a, 0x2d, 0x6f, 0x97, 0x4d,
-    0x37, 0xe6, 0x8e, 0x0c, 0xb8, 0xff, 0x94, 0x92
-};
-
-/* Test Case 20 */
-# define K20 K1
-# define A20 A1
-/* this results in 0xff in counter LSB */
-static const u8 IV20[64] = { 0xff, 0xff, 0xff, 0xff };
-
-static const u8 P20[288];
-static const u8 C20[] = {
-    0x56, 0xb3, 0x37, 0x3c, 0xa9, 0xef, 0x6e, 0x4a,
-    0x2b, 0x64, 0xfe, 0x1e, 0x9a, 0x17, 0xb6, 0x14,
-    0x25, 0xf1, 0x0d, 0x47, 0xa7, 0x5a, 0x5f, 0xce,
-    0x13, 0xef, 0xc6, 0xbc, 0x78, 0x4a, 0xf2, 0x4f,
-    0x41, 0x41, 0xbd, 0xd4, 0x8c, 0xf7, 0xc7, 0x70,
-    0x88, 0x7a, 0xfd, 0x57, 0x3c, 0xca, 0x54, 0x18,
-    0xa9, 0xae, 0xff, 0xcd, 0x7c, 0x5c, 0xed, 0xdf,
-    0xc6, 0xa7, 0x83, 0x97, 0xb9, 0xa8, 0x5b, 0x49,
-    0x9d, 0xa5, 0x58, 0x25, 0x72, 0x67, 0xca, 0xab,
-    0x2a, 0xd0, 0xb2, 0x3c, 0xa4, 0x76, 0xa5, 0x3c,
-    0xb1, 0x7f, 0xb4, 0x1c, 0x4b, 0x8b, 0x47, 0x5c,
-    0xb4, 0xf3, 0xf7, 0x16, 0x50, 0x94, 0xc2, 0x29,
-    0xc9, 0xe8, 0xc4, 0xdc, 0x0a, 0x2a, 0x5f, 0xf1,
-    0x90, 0x3e, 0x50, 0x15, 0x11, 0x22, 0x13, 0x76,
-    0xa1, 0xcd, 0xb8, 0x36, 0x4c, 0x50, 0x61, 0xa2,
-    0x0c, 0xae, 0x74, 0xbc, 0x4a, 0xcd, 0x76, 0xce,
-    0xb0, 0xab, 0xc9, 0xfd, 0x32, 0x17, 0xef, 0x9f,
-    0x8c, 0x90, 0xbe, 0x40, 0x2d, 0xdf, 0x6d, 0x86,
-    0x97, 0xf4, 0xf8, 0x80, 0xdf, 0xf1, 0x5b, 0xfb,
-    0x7a, 0x6b, 0x28, 0x24, 0x1e, 0xc8, 0xfe, 0x18,
-    0x3c, 0x2d, 0x59, 0xe3, 0xf9, 0xdf, 0xff, 0x65,
-    0x3c, 0x71, 0x26, 0xf0, 0xac, 0xb9, 0xe6, 0x42,
-    0x11, 0xf4, 0x2b, 0xae, 0x12, 0xaf, 0x46, 0x2b,
-    0x10, 0x70, 0xbe, 0xf1, 0xab, 0x5e, 0x36, 0x06,
-    0x87, 0x2c, 0xa1, 0x0d, 0xee, 0x15, 0xb3, 0x24,
-    0x9b, 0x1a, 0x1b, 0x95, 0x8f, 0x23, 0x13, 0x4c,
-    0x4b, 0xcc, 0xb7, 0xd0, 0x32, 0x00, 0xbc, 0xe4,
-    0x20, 0xa2, 0xf8, 0xeb, 0x66, 0xdc, 0xf3, 0x64,
-    0x4d, 0x14, 0x23, 0xc1, 0xb5, 0x69, 0x90, 0x03,
-    0xc1, 0x3e, 0xce, 0xf4, 0xbf, 0x38, 0xa3, 0xb6,
-    0x0e, 0xed, 0xc3, 0x40, 0x33, 0xba, 0xc1, 0x90,
-    0x27, 0x83, 0xdc, 0x6d, 0x89, 0xe2, 0xe7, 0x74,
-    0x18, 0x8a, 0x43, 0x9c, 0x7e, 0xbc, 0xc0, 0x67,
-    0x2d, 0xbd, 0xa4, 0xdd, 0xcf, 0xb2, 0x79, 0x46,
-    0x13, 0xb0, 0xbe, 0x41, 0x31, 0x5e, 0xf7, 0x78,
-    0x70, 0x8a, 0x70, 0xee, 0x7d, 0x75, 0x16, 0x5c
-};
-
-static const u8 T20[] = {
-    0x8b, 0x30, 0x7f, 0x6b, 0x33, 0x28, 0x6d, 0x0a,
-    0xb0, 0x26, 0xa9, 0xed, 0x3f, 0xe1, 0xe8, 0x5f
-};
-
-# define TEST_CASE(n)    do {                                    \
-        u8 out[sizeof(P##n)];                                   \
-        AES_set_encrypt_key(K##n,sizeof(K##n)*8,&key);          \
-        CRYPTO_gcm128_init(&ctx,&key,(block128_f)AES_encrypt);  \
-        CRYPTO_gcm128_setiv(&ctx,IV##n,sizeof(IV##n));          \
-        memset(out,0,sizeof(out));                              \
-        if (A##n) CRYPTO_gcm128_aad(&ctx,A##n,sizeof(A##n));    \
-        if (P##n) CRYPTO_gcm128_encrypt(&ctx,P##n,out,sizeof(out));     \
-        if (CRYPTO_gcm128_finish(&ctx,T##n,16) ||               \
-            (C##n && memcmp(out,C##n,sizeof(out))))             \
-                ret++, printf ("encrypt test#%d failed.\n",n);  \
-        CRYPTO_gcm128_setiv(&ctx,IV##n,sizeof(IV##n));          \
-        memset(out,0,sizeof(out));                              \
-        if (A##n) CRYPTO_gcm128_aad(&ctx,A##n,sizeof(A##n));    \
-        if (C##n) CRYPTO_gcm128_decrypt(&ctx,C##n,out,sizeof(out));     \
-        if (CRYPTO_gcm128_finish(&ctx,T##n,16) ||               \
-            (P##n && memcmp(out,P##n,sizeof(out))))             \
-                ret++, printf ("decrypt test#%d failed.\n",n);  \
-        } while(0)
-
-int main()
-{
-    GCM128_CONTEXT ctx;
-    AES_KEY key;
-    int ret = 0;
-
-    TEST_CASE(1);
-    TEST_CASE(2);
-    TEST_CASE(3);
-    TEST_CASE(4);
-    TEST_CASE(5);
-    TEST_CASE(6);
-    TEST_CASE(7);
-    TEST_CASE(8);
-    TEST_CASE(9);
-    TEST_CASE(10);
-    TEST_CASE(11);
-    TEST_CASE(12);
-    TEST_CASE(13);
-    TEST_CASE(14);
-    TEST_CASE(15);
-    TEST_CASE(16);
-    TEST_CASE(17);
-    TEST_CASE(18);
-    TEST_CASE(19);
-    TEST_CASE(20);
-
-# ifdef OPENSSL_CPUID_OBJ
-    {
-        size_t start, stop, gcm_t, ctr_t, OPENSSL_rdtsc();
-        union {
-            u64 u;
-            u8 c[1024];
-        } buf;
-        int i;
-
-        AES_set_encrypt_key(K1, sizeof(K1) * 8, &key);
-        CRYPTO_gcm128_init(&ctx, &key, (block128_f) AES_encrypt);
-        CRYPTO_gcm128_setiv(&ctx, IV1, sizeof(IV1));
-
-        CRYPTO_gcm128_encrypt(&ctx, buf.c, buf.c, sizeof(buf));
-        start = OPENSSL_rdtsc();
-        CRYPTO_gcm128_encrypt(&ctx, buf.c, buf.c, sizeof(buf));
-        gcm_t = OPENSSL_rdtsc() - start;
-
-        CRYPTO_ctr128_encrypt(buf.c, buf.c, sizeof(buf),
-                              &key, ctx.Yi.c, ctx.EKi.c, &ctx.mres,
-                              (block128_f) AES_encrypt);
-        start = OPENSSL_rdtsc();
-        CRYPTO_ctr128_encrypt(buf.c, buf.c, sizeof(buf),
-                              &key, ctx.Yi.c, ctx.EKi.c, &ctx.mres,
-                              (block128_f) AES_encrypt);
-        ctr_t = OPENSSL_rdtsc() - start;
-
-        printf("%.2f-%.2f=%.2f\n",
-               gcm_t / (double)sizeof(buf),
-               ctr_t / (double)sizeof(buf),
-               (gcm_t - ctr_t) / (double)sizeof(buf));
-#  ifdef GHASH
-        {
-            void (*gcm_ghash_p) (u64 Xi[2], const u128 Htable[16],
-                                 const u8 *inp, size_t len) = ctx.ghash;
-
-            GHASH((&ctx), buf.c, sizeof(buf));
-            start = OPENSSL_rdtsc();
-            for (i = 0; i < 100; ++i)
-                GHASH((&ctx), buf.c, sizeof(buf));
-            gcm_t = OPENSSL_rdtsc() - start;
-            printf("%.2f\n", gcm_t / (double)sizeof(buf) / (double)i);
-        }
-#  endif
-    }
-# endif
-
-    return ret;
-}
-#endif
diff --git a/crypto/objects/obj_xref.c b/crypto/objects/obj_xref.c
index 627f5bc..9a558a2 100644
--- a/crypto/objects/obj_xref.c
+++ b/crypto/objects/obj_xref.c
@@ -136,30 +136,3 @@ void OBJ_sigid_free(void)
     sk_nid_triple_free(sigx_app);
     sigx_app = NULL;
 }
-
-#ifdef OBJ_XREF_TEST
-
-main()
-{
-    int n1, n2, n3;
-
-    int i, rv;
-# ifdef OBJ_XREF_TEST2
-    for (i = 0; i < OSSL_NELEM(sigoid_srt); i++) {
-        OBJ_add_sigid(sigoid_srt[i][0], sigoid_srt[i][1], sigoid_srt[i][2]);
-    }
-# endif
-
-    for (i = 0; i < OSSL_NELEM(sigoid_srt); i++) {
-        n1 = sigoid_srt[i][0];
-        rv = OBJ_find_sigid_algs(n1, &n2, &n3);
-        printf("Forward: %d, %s %s %s\n", rv,
-               OBJ_nid2ln(n1), OBJ_nid2ln(n2), OBJ_nid2ln(n3));
-        n1 = 0;
-        rv = OBJ_find_sigid_by_algs(&n1, n2, n3);
-        printf("Reverse: %d, %s %s %s\n", rv,
-               OBJ_nid2ln(n1), OBJ_nid2ln(n2), OBJ_nid2ln(n3));
-    }
-}
-
-#endif
diff --git a/crypto/poly1305/poly1305.c b/crypto/poly1305/poly1305.c
index eec4d67..ab4fa83 100644
--- a/crypto/poly1305/poly1305.c
+++ b/crypto/poly1305/poly1305.c
@@ -12,25 +12,7 @@
 #include <openssl/crypto.h>
 
 #include "internal/poly1305.h"
-
-typedef void (*poly1305_blocks_f) (void *ctx, const unsigned char *inp,
-                                   size_t len, unsigned int padbit);
-typedef void (*poly1305_emit_f) (void *ctx, unsigned char mac[16],
-                                 const unsigned int nonce[4]);
-
-struct poly1305_context {
-    double opaque[24];  /* large enough to hold internal state, declared
-                         * 'double' to ensure at least 64-bit invariant
-                         * alignment across all platforms and
-                         * configurations */
-    unsigned int nonce[4];
-    unsigned char data[POLY1305_BLOCK_SIZE];
-    size_t num;
-    struct {
-        poly1305_blocks_f blocks;
-        poly1305_emit_f emit;
-    } func;
-};
+#include "poly1305_local.h"
 
 size_t Poly1305_ctx_size ()
 {
@@ -548,490 +530,3 @@ void Poly1305_Final(POLY1305 *ctx, unsigned char mac[16])
     /* zero out the state */
     OPENSSL_cleanse(ctx, sizeof(*ctx));
 }
-
-#ifdef SELFTEST
-#include <stdio.h>
-
-struct poly1305_test {
-    const char *inputhex;
-    const char *keyhex;
-    const char *outhex;
-};
-
-static const struct poly1305_test poly1305_tests[] = {
-    /*
-     * RFC7539
-     */
-    {
-     "43727970746f6772617068696320466f72756d2052657365617263682047726f"
-     "7570",
-     "85d6be7857556d337f4452fe42d506a8""0103808afb0db2fd4abff6af4149f51b",
-     "a8061dc1305136c6c22b8baf0c0127a9"
-    },
-    /*
-     * test vectors from "The Poly1305-AES message-authentication code"
-     */
-    {
-     "f3f6",
-     "851fc40c3467ac0be05cc20404f3f700""580b3b0f9447bb1e69d095b5928b6dbc",
-     "f4c633c3044fc145f84f335cb81953de"
-    },
-    {
-     "",
-     "a0f3080000f46400d0c7e9076c834403""dd3fab2251f11ac759f0887129cc2ee7",
-     "dd3fab2251f11ac759f0887129cc2ee7"
-    },
-    {
-     "663cea190ffb83d89593f3f476b6bc24d7e679107ea26adb8caf6652d0656136",
-     "48443d0bb0d21109c89a100b5ce2c208""83149c69b561dd88298a1798b10716ef",
-     "0ee1c16bb73f0f4fd19881753c01cdbe"
-    },
-    {
-     "ab0812724a7f1e342742cbed374d94d136c6b8795d45b3819830f2c04491faf0"
-     "990c62e48b8018b2c3e4a0fa3134cb67fa83e158c994d961c4cb21095c1bf9",
-     "12976a08c4426d0ce8a82407c4f48207""80f8c20aa71202d1e29179cbcb555a57",
-     "5154ad0d2cb26e01274fc51148491f1b"
-    },
-    /*
-     * self-generated vectors exercise "significant" lengths, such that
-     * are handled by different code paths
-     */
-    {
-     "ab0812724a7f1e342742cbed374d94d136c6b8795d45b3819830f2c04491faf0"
-     "990c62e48b8018b2c3e4a0fa3134cb67fa83e158c994d961c4cb21095c1bf9af",
-     "12976a08c4426d0ce8a82407c4f48207""80f8c20aa71202d1e29179cbcb555a57",
-     "812059a5da198637cac7c4a631bee466"
-    },
-    {
-     "ab0812724a7f1e342742cbed374d94d136c6b8795d45b3819830f2c04491faf0"
-     "990c62e48b8018b2c3e4a0fa3134cb67",
-     "12976a08c4426d0ce8a82407c4f48207""80f8c20aa71202d1e29179cbcb555a57",
-     "5b88d7f6228b11e2e28579a5c0c1f761"
-    },
-    {
-     "ab0812724a7f1e342742cbed374d94d136c6b8795d45b3819830f2c04491faf0"
-     "990c62e48b8018b2c3e4a0fa3134cb67fa83e158c994d961c4cb21095c1bf9af"
-     "663cea190ffb83d89593f3f476b6bc24d7e679107ea26adb8caf6652d0656136",
-     "12976a08c4426d0ce8a82407c4f48207""80f8c20aa71202d1e29179cbcb555a57",
-     "bbb613b2b6d753ba07395b916aaece15"
-    },
-    {
-     "ab0812724a7f1e342742cbed374d94d136c6b8795d45b3819830f2c04491faf0"
-     "990c62e48b8018b2c3e4a0fa3134cb67fa83e158c994d961c4cb21095c1bf9af"
-     "48443d0bb0d21109c89a100b5ce2c20883149c69b561dd88298a1798b10716ef"
-     "663cea190ffb83d89593f3f476b6bc24",
-     "12976a08c4426d0ce8a82407c4f48207""80f8c20aa71202d1e29179cbcb555a57",
-     "c794d7057d1778c4bbee0a39b3d97342"
-    },
-    {
-     "ab0812724a7f1e342742cbed374d94d136c6b8795d45b3819830f2c04491faf0"
-     "990c62e48b8018b2c3e4a0fa3134cb67fa83e158c994d961c4cb21095c1bf9af"
-     "48443d0bb0d21109c89a100b5ce2c20883149c69b561dd88298a1798b10716ef"
-     "663cea190ffb83d89593f3f476b6bc24d7e679107ea26adb8caf6652d0656136",
-     "12976a08c4426d0ce8a82407c4f48207""80f8c20aa71202d1e29179cbcb555a57",
-     "ffbcb9b371423152d7fca5ad042fbaa9"
-    },
-    {
-     "ab0812724a7f1e342742cbed374d94d136c6b8795d45b3819830f2c04491faf0"
-     "990c62e48b8018b2c3e4a0fa3134cb67fa83e158c994d961c4cb21095c1bf9af"
-     "48443d0bb0d21109c89a100b5ce2c20883149c69b561dd88298a1798b10716ef"
-     "663cea190ffb83d89593f3f476b6bc24d7e679107ea26adb8caf6652d0656136"
-     "812059a5da198637cac7c4a631bee466",
-     "12976a08c4426d0ce8a82407c4f48207""80f8c20aa71202d1e29179cbcb555a57",
-     "069ed6b8ef0f207b3e243bb1019fe632"
-    },
-    {
-     "ab0812724a7f1e342742cbed374d94d136c6b8795d45b3819830f2c04491faf0"
-     "990c62e48b8018b2c3e4a0fa3134cb67fa83e158c994d961c4cb21095c1bf9af"
-     "48443d0bb0d21109c89a100b5ce2c20883149c69b561dd88298a1798b10716ef"
-     "663cea190ffb83d89593f3f476b6bc24d7e679107ea26adb8caf6652d0656136"
-     "812059a5da198637cac7c4a631bee4665b88d7f6228b11e2e28579a5c0c1f761",
-     "12976a08c4426d0ce8a82407c4f48207""80f8c20aa71202d1e29179cbcb555a57",
-     "cca339d9a45fa2368c2c68b3a4179133"
-    },
-    {
-     "ab0812724a7f1e342742cbed374d94d136c6b8795d45b3819830f2c04491faf0"
-     "990c62e48b8018b2c3e4a0fa3134cb67fa83e158c994d961c4cb21095c1bf9af"
-     "48443d0bb0d21109c89a100b5ce2c20883149c69b561dd88298a1798b10716ef"
-     "663cea190ffb83d89593f3f476b6bc24d7e679107ea26adb8caf6652d0656136"
-     "812059a5da198637cac7c4a631bee4665b88d7f6228b11e2e28579a5c0c1f761"
-     "ab0812724a7f1e342742cbed374d94d136c6b8795d45b3819830f2c04491faf0"
-     "990c62e48b8018b2c3e4a0fa3134cb67fa83e158c994d961c4cb21095c1bf9af"
-     "48443d0bb0d21109c89a100b5ce2c20883149c69b561dd88298a1798b10716ef"
-     "663cea190ffb83d89593f3f476b6bc24d7e679107ea26adb8caf6652d0656136",
-     "12976a08c4426d0ce8a82407c4f48207""80f8c20aa71202d1e29179cbcb555a57",
-     "53f6e828a2f0fe0ee815bf0bd5841a34"
-    },
-    {
-     "ab0812724a7f1e342742cbed374d94d136c6b8795d45b3819830f2c04491faf0"
-     "990c62e48b8018b2c3e4a0fa3134cb67fa83e158c994d961c4cb21095c1bf9af"
-     "48443d0bb0d21109c89a100b5ce2c20883149c69b561dd88298a1798b10716ef"
-     "663cea190ffb83d89593f3f476b6bc24d7e679107ea26adb8caf6652d0656136"
-     "812059a5da198637cac7c4a631bee4665b88d7f6228b11e2e28579a5c0c1f761"
-     "ab0812724a7f1e342742cbed374d94d136c6b8795d45b3819830f2c04491faf0"
-     "990c62e48b8018b2c3e4a0fa3134cb67fa83e158c994d961c4cb21095c1bf9af"
-     "48443d0bb0d21109c89a100b5ce2c20883149c69b561dd88298a1798b10716ef"
-     "663cea190ffb83d89593f3f476b6bc24d7e679107ea26adb8caf6652d0656136"
-     "812059a5da198637cac7c4a631bee4665b88d7f6228b11e2e28579a5c0c1f761",
-     "12976a08c4426d0ce8a82407c4f48207""80f8c20aa71202d1e29179cbcb555a57",
-     "b846d44e9bbd53cedffbfbb6b7fa4933"
-    },
-    /*
-     * 4th power of the key spills to 131th bit in SIMD key setup
-     */
-    {
-     "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
-     "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
-     "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
-     "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
-     "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
-     "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
-     "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
-     "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
-     "ad628107e8351d0f2c231a05dc4a4106""00000000000000000000000000000000",
-     "07145a4c02fe5fa32036de68fabe9066"
-    },
-    {
-    /*
-     * poly1305_ieee754.c failed this in final stage
-     */
-     "842364e156336c0998b933a6237726180d9e3fdcbde4cd5d17080fc3beb49614"
-     "d7122c037463ff104d73f19c12704628d417c4c54a3fe30d3c3d7714382d43b0"
-     "382a50a5dee54be844b076e8df88201a1cd43b90eb21643fa96f39b518aa8340"
-     "c942ff3c31baf7c9bdbf0f31ae3fa096bf8c63030609829fe72e179824890bc8"
-     "e08c315c1cce2a83144dbbff09f74e3efc770b54d0984a8f19b14719e6363564"
-     "1d6b1eedf63efbf080e1783d32445412114c20de0b837a0dfa33d6b82825fff4"
-     "4c9a70ea54ce47f07df698e6b03323b53079364a5fc3e9dd034392bdde86dccd"
-     "da94321c5e44060489336cb65bf3989c36f7282c2f5d2b882c171e74",
-     "95d5c005503e510d8cd0aa072c4a4d06""6eabc52d11653df47fbf63ab198bcc26",
-     "f248312e578d9d58f8b7bb4d19105431"
-    },
-    /*
-     * AVX2 in poly1305-x86.pl failed this with 176+32 split
-     */
-    {
-    "248ac31085b6c2adaaa38259a0d7192c5c35d1bb4ef39ad94c38d1c82479e2dd"
-    "2159a077024b0589bc8a20101b506f0a1ad0bbab76e83a83f1b94be6beae74e8"
-    "74cab692c5963a75436b776121ec9f62399a3e66b2d22707dae81933b6277f3c"
-    "8516bcbe26dbbd86f373103d7cf4cad1888c952118fbfbd0d7b4bedc4ae4936a"
-    "ff91157e7aa47c54442ea78d6ac251d324a0fbe49d89cc3521b66d16e9c66a37"
-    "09894e4eb0a4eedc4ae19468e66b81f2"
-    "71351b1d921ea551047abcc6b87a901fde7db79fa1818c11336dbc07244a40eb",
-    "000102030405060708090a0b0c0d0e0f""00000000000000000000000000000000",
-    "bc939bc5281480fa99c6d68c258ec42f"
-    },
-    /*
-     * test vectors from Google
-     */
-    {
-     "",
-     "c8afaac331ee372cd6082de134943b17""4710130e9f6fea8d72293850a667d86c",
-     "4710130e9f6fea8d72293850a667d86c",
-    },
-    {
-     "48656c6c6f20776f726c6421",
-     "746869732069732033322d6279746520""6b657920666f7220506f6c7931333035",
-     "a6f745008f81c916a20dcc74eef2b2f0"
-    },
-    {
-     "0000000000000000000000000000000000000000000000000000000000000000",
-     "746869732069732033322d6279746520""6b657920666f7220506f6c7931333035",
-     "49ec78090e481ec6c26b33b91ccc0307"
-    },
-    {
-     "89dab80b7717c1db5db437860a3f70218e93e1b8f461fb677f16f35f6f87e2a9"
-     "1c99bc3a47ace47640cc95c345be5ecca5a3523c35cc01893af0b64a62033427"
-     "0372ec12482d1b1e363561698a578b359803495bb4e2ef1930b17a5190b580f1"
-     "41300df30adbeca28f6427a8bc1a999fd51c554a017d095d8c3e3127daf9f595",
-     "2d773be37adb1e4d683bf0075e79c4ee""037918535a7f99ccb7040fb5f5f43aea",
-     "c85d15ed44c378d6b00e23064c7bcd51"
-    },
-    {
-     "000000000000000b1703030200000000"
-     "06db1f1f368d696a810a349c0c714c9a5e7850c2407d721acded95e018d7a852"
-     "66a6e1289cdb4aeb18da5ac8a2b0026d24a59ad485227f3eaedbb2e7e35e1c66"
-     "cd60f9abf716dcc9ac42682dd7dab287a7024c4eefc321cc0574e16793e37cec"
-     "03c5bda42b54c114a80b57af26416c7be742005e20855c73e21dc8e2edc9d435"
-     "cb6f6059280011c270b71570051c1c9b3052126620bc1e2730fa066c7a509d53"
-     "c60e5ae1b40aa6e39e49669228c90eecb4a50db32a50bc49e90b4f4b359a1dfd"
-     "11749cd3867fcf2fb7bb6cd4738f6a4ad6f7ca5058f7618845af9f020f6c3b96"
-     "7b8f4cd4a91e2813b507ae66f2d35c18284f7292186062e10fd5510d18775351"
-     "ef334e7634ab4743f5b68f49adcab384d3fd75f7390f4006ef2a295c8c7a076a"
-     "d54546cd25d2107fbe1436c840924aaebe5b370893cd63d1325b8616fc481088"
-     "6bc152c53221b6df373119393255ee72bcaa880174f1717f9184fa91646f17a2"
-     "4ac55d16bfddca9581a92eda479201f0edbf633600d6066d1ab36d5d2415d713"
-     "51bbcd608a25108d25641992c1f26c531cf9f90203bc4cc19f5927d834b0a471"
-     "16d3884bbb164b8ec883d1ac832e56b3918a98601a08d171881541d594db399c"
-     "6ae6151221745aec814c45b0b05b565436fd6f137aa10a0c0b643761dbd6f9a9"
-     "dcb99b1a6e690854ce0769cde39761d82fcdec15f0d92d7d8e94ade8eb83fbe0",
-     "99e5822dd4173c995e3dae0ddefb9774""3fde3b080134b39f76e9bf8d0e88d546",
-     "2637408fe13086ea73f971e3425e2820"
-    },
-    /*
-     * test vectors from Hanno Böck
-     */
-    {
-     "cccccccccccccccccccccccccccccccccccccccccccccccccc80cccccccccccc"
-     "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccecccccc"
-     "ccccccccccccccccccccccccccccccc5cccccccccccccccccccccccccccccccc"
-     "cccccccccce3cccccccccccccccccccccccccccccccccccccccccccccccccccc"
-     "ccccccccaccccccccccccccccccccce6cccccccccc000000afcccccccccccccc"
-     "ccccfffffff50000000000000000000000000000000000000000000000000000"
-     "00ffffffe7000000000000000000000000000000000000000000000000000000"
-     "0000000000000000000000000000000000000000000000000000719205a8521d"
-     "fc",
-     "7f1b0264000000000000000000000000""0000000000000000cccccccccccccccc",
-     "8559b876eceed66eb37798c0457baff9"
-    },
-    {
-     "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000"
-     "00000000800264",
-     "e0001600000000000000000000000000""0000aaaaaaaaaaaaaaaaaaaaaaaaaaaa",
-     "00bd1258978e205444c9aaaa82006fed"
-    },
-    {
-     "02fc",
-     "0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c""0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c",
-     "06120c0c0c0c0c0c0c0c0c0c0c0c0c0c"
-    },
-    {
-     "7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b"
-     "7b7b7b7b7b7b7a7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b"
-     "7b7b5c7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b"
-     "7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b6e7b007b7b7b7b7b7b7b7b7b"
-     "7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7a7b7b7b7b7b7b7b7b7b7b7b7b"
-     "7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b5c7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b"
-     "7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b"
-     "7b6e7b001300000000b300000000000000000000000000000000000000000000"
-     "f20000000000000000000000000000000000002000efff000900000000000000"
-     "0000000000100000000009000000640000000000000000000000001300000000"
-     "b300000000000000000000000000000000000000000000f20000000000000000"
-     "000000000000000000002000efff00090000000000000000007a000010000000"
-     "000900000064000000000000000000000000000000000000000000000000fc",
-     "00ff0000000000000000000000000000""00000000001e00000000000000007b7b",
-     "33205bbf9e9f8f7212ab9e2ab9b7e4a5"
-    },
-    {
-     "7777777777777777777777777777777777777777777777777777777777777777"
-     "7777777777777777777777777777777777777777777777777777777777777777"
-     "777777777777777777777777ffffffe9e9acacacacacacacacacacac0000acac"
-     "ec0100acacac2caca2acacacacacacacacacacac64f2",
-     "0000007f0000007f0100002000000000""0000cf77777777777777777777777777",
-     "02ee7c8c546ddeb1a467e4c3981158b9"
-    },
-    /*
-     * test vectors from Andrew Moon
-     */
-    {   /* nacl */
-     "8e993b9f48681273c29650ba32fc76ce48332ea7164d96a4476fb8c531a1186a"
-     "c0dfc17c98dce87b4da7f011ec48c97271d2c20f9b928fe2270d6fb863d51738"
-     "b48eeee314a7cc8ab932164548e526ae90224368517acfeabd6bb3732bc0e9da"
-     "99832b61ca01b6de56244a9e88d5f9b37973f622a43d14a6599b1f654cb45a74"
-     "e355a5",
-     "eea6a7251c1e72916d11c2cb214d3c25""2539121d8e234e652d651fa4c8cff880",
-     "f3ffc7703f9400e52a7dfb4b3d3305d9"
-    },
-    {   /* wrap 2^130-5 */
-     "ffffffffffffffffffffffffffffffff",
-     "02000000000000000000000000000000""00000000000000000000000000000000",
-     "03000000000000000000000000000000"
-    },
-    {   /* wrap 2^128 */
-     "02000000000000000000000000000000",
-     "02000000000000000000000000000000""ffffffffffffffffffffffffffffffff",
-     "03000000000000000000000000000000"
-    },
-    {   /* limb carry */
-     "fffffffffffffffffffffffffffffffff0ffffffffffffffffffffffffffffff"
-     "11000000000000000000000000000000",
-     "01000000000000000000000000000000""00000000000000000000000000000000",
-     "05000000000000000000000000000000"
-    },
-    {   /* 2^130-5 */
-     "fffffffffffffffffffffffffffffffffbfefefefefefefefefefefefefefefe"
-     "01010101010101010101010101010101",
-     "01000000000000000000000000000000""00000000000000000000000000000000",
-     "00000000000000000000000000000000"
-    },
-    {   /* 2^130-6 */
-     "fdffffffffffffffffffffffffffffff",
-     "02000000000000000000000000000000""00000000000000000000000000000000",
-     "faffffffffffffffffffffffffffffff"
-    },
-    {   /* 5*H+L reduction intermediate */
-     "e33594d7505e43b900000000000000003394d7505e4379cd0100000000000000"
-     "0000000000000000000000000000000001000000000000000000000000000000",
-     "01000000000000000400000000000000""00000000000000000000000000000000",
-     "14000000000000005500000000000000"
-    },
-    {   /* 5*H+L reduction final */
-     "e33594d7505e43b900000000000000003394d7505e4379cd0100000000000000"
-     "00000000000000000000000000000000",
-     "01000000000000000400000000000000""00000000000000000000000000000000",
-     "13000000000000000000000000000000"
-    }
-};
-
-static unsigned char hex_digit(char h)
-{
-    int i = OPENSSL_hexchar2int(h);
-
-    if (i < 0)
-        abort();
-    return i;
-}
-
-static void hex_decode(unsigned char *out, const char *hex)
-{
-    size_t j = 0;
-
-    while (*hex != 0) {
-        unsigned char v = hex_digit(*hex++);
-        v <<= 4;
-        v |= hex_digit(*hex++);
-        out[j++] = v;
-    }
-}
-
-static void hexdump(unsigned char *a, size_t len)
-{
-    size_t i;
-
-    for (i = 0; i < len; i++)
-        printf("%02x", a[i]);
-}
-
-int main()
-{
-    static const unsigned num_tests =
-        sizeof(poly1305_tests) / sizeof(struct poly1305_test);
-    unsigned i;
-    unsigned char key[32], out[16], expected[16];
-    POLY1305 poly1305;
-
-    for (i = 0; i < num_tests; i++) {
-        const struct poly1305_test *test = &poly1305_tests[i];
-        unsigned char *in;
-        size_t inlen = strlen(test->inputhex);
-
-        if (strlen(test->keyhex) != sizeof(key) * 2 ||
-            strlen(test->outhex) != sizeof(out) * 2 || (inlen & 1) == 1)
-            return 1;
-
-        inlen /= 2;
-
-        hex_decode(key, test->keyhex);
-        hex_decode(expected, test->outhex);
-
-        in = malloc(inlen);
-
-        hex_decode(in, test->inputhex);
-
-        Poly1305_Init(&poly1305, key);
-        Poly1305_Update(&poly1305, in, inlen);
-        Poly1305_Final(&poly1305, out);
-
-        if (memcmp(out, expected, sizeof(expected)) != 0) {
-            printf("Poly1305 test #%d failed.\n", i);
-            printf("got:      ");
-            hexdump(out, sizeof(out));
-            printf("\nexpected: ");
-            hexdump(expected, sizeof(expected));
-            printf("\n");
-            return 1;
-        }
-
-        if (inlen > 16) {
-            Poly1305_Init(&poly1305, key);
-            Poly1305_Update(&poly1305, in, 1);
-            Poly1305_Update(&poly1305, in+1, inlen-1);
-            Poly1305_Final(&poly1305, out);
-
-            if (memcmp(out, expected, sizeof(expected)) != 0) {
-                printf("Poly1305 test #%d/1+(N-1) failed.\n", i);
-                printf("got:      ");
-                hexdump(out, sizeof(out));
-                printf("\nexpected: ");
-                hexdump(expected, sizeof(expected));
-                printf("\n");
-                return 1;
-            }
-        }
-
-        if (inlen > 32) {
-            size_t half = inlen / 2;
-
-            Poly1305_Init(&poly1305, key);
-            Poly1305_Update(&poly1305, in, half);
-            Poly1305_Update(&poly1305, in+half, inlen-half);
-            Poly1305_Final(&poly1305, out);
-
-            if (memcmp(out, expected, sizeof(expected)) != 0) {
-                printf("Poly1305 test #%d/2 failed.\n", i);
-                printf("got:      ");
-                hexdump(out, sizeof(out));
-                printf("\nexpected: ");
-                hexdump(expected, sizeof(expected));
-                printf("\n");
-                return 1;
-            }
-
-            for (half = 16; half < inlen; half += 16) {
-                Poly1305_Init(&poly1305, key);
-                Poly1305_Update(&poly1305, in, half);
-                Poly1305_Update(&poly1305, in+half, inlen-half);
-                Poly1305_Final(&poly1305, out);
-
-                if (memcmp(out, expected, sizeof(expected)) != 0) {
-                    printf("Poly1305 test #%d/%d+%d failed.\n",
-                                           i, half, inlen-half);
-                    printf("got:      ");
-                    hexdump(out, sizeof(out));
-                    printf("\nexpected: ");
-                    hexdump(expected, sizeof(expected));
-                    printf("\n");
-                    return 1;
-                }
-            }
-        }
-
-        free(in);
-    }
-
-    printf("PASS\n");
-
-# ifdef OPENSSL_CPUID_OBJ
-    {
-        unsigned char buf[8192];
-        unsigned long long stopwatch;
-        unsigned long long OPENSSL_rdtsc();
-
-        memset (buf,0x55,sizeof(buf));
-        memset (key,0xAA,sizeof(key));
-
-        Poly1305_Init(&poly1305, key);
-
-        for (i=0;i<100000;i++)
-            Poly1305_Update(&poly1305,buf,sizeof(buf));
-
-        stopwatch = OPENSSL_rdtsc();
-        for (i=0;i<10000;i++)
-            Poly1305_Update(&poly1305,buf,sizeof(buf));
-        stopwatch = OPENSSL_rdtsc() - stopwatch;
-
-        printf("%g\n",stopwatch/(double)(i*sizeof(buf)));
-
-        stopwatch = OPENSSL_rdtsc();
-        for (i=0;i<10000;i++) {
-            Poly1305_Init(&poly1305, key);
-            Poly1305_Update(&poly1305,buf,16);
-            Poly1305_Final(&poly1305,buf);
-        }
-        stopwatch = OPENSSL_rdtsc() - stopwatch;
-
-        printf("%g\n",stopwatch/(double)(i));
-    }
-# endif
-    return 0;
-}
-#endif
diff --git a/crypto/poly1305/poly1305_local.h b/crypto/poly1305/poly1305_local.h
new file mode 100644
index 0000000..6d4d9dc
--- /dev/null
+++ b/crypto/poly1305/poly1305_local.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the OpenSSL license (the "License").  You may not use
+ * this file except in compliance with the License.  You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+typedef void (*poly1305_blocks_f) (void *ctx, const unsigned char *inp,
+                                   size_t len, unsigned int padbit);
+typedef void (*poly1305_emit_f) (void *ctx, unsigned char mac[16],
+                                 const unsigned int nonce[4]);
+
+struct poly1305_context {
+    double opaque[24];  /* large enough to hold internal state, declared
+                         * 'double' to ensure at least 64-bit invariant
+                         * alignment across all platforms and
+                         * configurations */
+    unsigned int nonce[4];
+    unsigned char data[POLY1305_BLOCK_SIZE];
+    size_t num;
+    struct {
+        poly1305_blocks_f blocks;
+        poly1305_emit_f emit;
+    } func;
+};
diff --git a/crypto/rc2/tab.c b/crypto/rc2/tab.c
deleted file mode 100644
index bc95dc4..0000000
--- a/crypto/rc2/tab.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 1998-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the OpenSSL license (the "License").  You may not use
- * this file except in compliance with the License.  You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <stdio.h>
-
-unsigned char ebits_to_num[256] = {
-    0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a,
-    0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0,
-    0x30, 0x04, 0xb6, 0xdc, 0x7d, 0xdf, 0x32, 0x4b,
-    0xf7, 0xcb, 0x45, 0x9b, 0x31, 0xbb, 0x21, 0x5a,
-    0x41, 0x9f, 0xe1, 0xd9, 0x4a, 0x4d, 0x9e, 0xda,
-    0xa0, 0x68, 0x2c, 0xc3, 0x27, 0x5f, 0x80, 0x36,
-    0x3e, 0xee, 0xfb, 0x95, 0x1a, 0xfe, 0xce, 0xa8,
-    0x34, 0xa9, 0x13, 0xf0, 0xa6, 0x3f, 0xd8, 0x0c,
-    0x78, 0x24, 0xaf, 0x23, 0x52, 0xc1, 0x67, 0x17,
-    0xf5, 0x66, 0x90, 0xe7, 0xe8, 0x07, 0xb8, 0x60,
-    0x48, 0xe6, 0x1e, 0x53, 0xf3, 0x92, 0xa4, 0x72,
-    0x8c, 0x08, 0x15, 0x6e, 0x86, 0x00, 0x84, 0xfa,
-    0xf4, 0x7f, 0x8a, 0x42, 0x19, 0xf6, 0xdb, 0xcd,
-    0x14, 0x8d, 0x50, 0x12, 0xba, 0x3c, 0x06, 0x4e,
-    0xec, 0xb3, 0x35, 0x11, 0xa1, 0x88, 0x8e, 0x2b,
-    0x94, 0x99, 0xb7, 0x71, 0x74, 0xd3, 0xe4, 0xbf,
-    0x3a, 0xde, 0x96, 0x0e, 0xbc, 0x0a, 0xed, 0x77,
-    0xfc, 0x37, 0x6b, 0x03, 0x79, 0x89, 0x62, 0xc6,
-    0xd7, 0xc0, 0xd2, 0x7c, 0x6a, 0x8b, 0x22, 0xa3,
-    0x5b, 0x05, 0x5d, 0x02, 0x75, 0xd5, 0x61, 0xe3,
-    0x18, 0x8f, 0x55, 0x51, 0xad, 0x1f, 0x0b, 0x5e,
-    0x85, 0xe5, 0xc2, 0x57, 0x63, 0xca, 0x3d, 0x6c,
-    0xb4, 0xc5, 0xcc, 0x70, 0xb2, 0x91, 0x59, 0x0d,
-    0x47, 0x20, 0xc8, 0x4f, 0x58, 0xe0, 0x01, 0xe2,
-    0x16, 0x38, 0xc4, 0x6f, 0x3b, 0x0f, 0x65, 0x46,
-    0xbe, 0x7e, 0x2d, 0x7b, 0x82, 0xf9, 0x40, 0xb5,
-    0x1d, 0x73, 0xf8, 0xeb, 0x26, 0xc7, 0x87, 0x97,
-    0x25, 0x54, 0xb1, 0x28, 0xaa, 0x98, 0x9d, 0xa5,
-    0x64, 0x6d, 0x7a, 0xd4, 0x10, 0x81, 0x44, 0xef,
-    0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f,
-    0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf,
-    0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab,
-};
-
-unsigned char num_to_ebits[256] = {
-    0x5d, 0xbe, 0x9b, 0x8b, 0x11, 0x99, 0x6e, 0x4d,
-    0x59, 0xf3, 0x85, 0xa6, 0x3f, 0xb7, 0x83, 0xc5,
-    0xe4, 0x73, 0x6b, 0x3a, 0x68, 0x5a, 0xc0, 0x47,
-    0xa0, 0x64, 0x34, 0x0c, 0xf1, 0xd0, 0x52, 0xa5,
-    0xb9, 0x1e, 0x96, 0x43, 0x41, 0xd8, 0xd4, 0x2c,
-    0xdb, 0xf8, 0x07, 0x77, 0x2a, 0xca, 0xeb, 0xef,
-    0x10, 0x1c, 0x16, 0x0d, 0x38, 0x72, 0x2f, 0x89,
-    0xc1, 0xf9, 0x80, 0xc4, 0x6d, 0xae, 0x30, 0x3d,
-    0xce, 0x20, 0x63, 0xfe, 0xe6, 0x1a, 0xc7, 0xb8,
-    0x50, 0xe8, 0x24, 0x17, 0xfc, 0x25, 0x6f, 0xbb,
-    0x6a, 0xa3, 0x44, 0x53, 0xd9, 0xa2, 0x01, 0xab,
-    0xbc, 0xb6, 0x1f, 0x98, 0xee, 0x9a, 0xa7, 0x2d,
-    0x4f, 0x9e, 0x8e, 0xac, 0xe0, 0xc6, 0x49, 0x46,
-    0x29, 0xf4, 0x94, 0x8a, 0xaf, 0xe1, 0x5b, 0xc3,
-    0xb3, 0x7b, 0x57, 0xd1, 0x7c, 0x9c, 0xed, 0x87,
-    0x40, 0x8c, 0xe2, 0xcb, 0x93, 0x14, 0xc9, 0x61,
-    0x2e, 0xe5, 0xcc, 0xf6, 0x5e, 0xa8, 0x5c, 0xd6,
-    0x75, 0x8d, 0x62, 0x95, 0x58, 0x69, 0x76, 0xa1,
-    0x4a, 0xb5, 0x55, 0x09, 0x78, 0x33, 0x82, 0xd7,
-    0xdd, 0x79, 0xf5, 0x1b, 0x0b, 0xde, 0x26, 0x21,
-    0x28, 0x74, 0x04, 0x97, 0x56, 0xdf, 0x3c, 0xf0,
-    0x37, 0x39, 0xdc, 0xff, 0x06, 0xa4, 0xea, 0x42,
-    0x08, 0xda, 0xb4, 0x71, 0xb0, 0xcf, 0x12, 0x7a,
-    0x4e, 0xfa, 0x6c, 0x1d, 0x84, 0x00, 0xc8, 0x7f,
-    0x91, 0x45, 0xaa, 0x2b, 0xc2, 0xb1, 0x8f, 0xd5,
-    0xba, 0xf2, 0xad, 0x19, 0xb2, 0x67, 0x36, 0xf7,
-    0x0f, 0x0a, 0x92, 0x7d, 0xe3, 0x9d, 0xe9, 0x90,
-    0x3e, 0x23, 0x27, 0x66, 0x13, 0xec, 0x81, 0x15,
-    0xbd, 0x22, 0xbf, 0x9f, 0x7e, 0xa9, 0x51, 0x4b,
-    0x4c, 0xfb, 0x02, 0xd3, 0x70, 0x86, 0x31, 0xe7,
-    0x3b, 0x05, 0x03, 0x54, 0x60, 0x48, 0x65, 0x18,
-    0xd2, 0xcd, 0x5f, 0x32, 0x88, 0x0e, 0x35, 0xfd,
-};
-
-main()
-{
-    int i, j;
-
-    for (i = 0; i < 256; i++) {
-        for (j = 0; j < 256; j++)
-            if (ebits_to_num[j] == i) {
-                printf("0x%02x,", j);
-                break;
-            }
-    }
-}
diff --git a/crypto/x509v3/standard_exts.h b/crypto/x509v3/standard_exts.h
new file mode 100644
index 0000000..05e0869
--- /dev/null
+++ b/crypto/x509v3/standard_exts.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the OpenSSL license (the "License").  You may not use
+ * this file except in compliance with the License.  You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+/*
+ * This table will be searched using OBJ_bsearch so it *must* kept in order
+ * of the ext_nid values.
+ */
+
+static const X509V3_EXT_METHOD *standard_exts[] = {
+    &v3_nscert,
+    &v3_ns_ia5_list[0],
+    &v3_ns_ia5_list[1],
+    &v3_ns_ia5_list[2],
+    &v3_ns_ia5_list[3],
+    &v3_ns_ia5_list[4],
+    &v3_ns_ia5_list[5],
+    &v3_ns_ia5_list[6],
+    &v3_skey_id,
+    &v3_key_usage,
+    &v3_pkey_usage_period,
+    &v3_alt[0],
+    &v3_alt[1],
+    &v3_bcons,
+    &v3_crl_num,
+    &v3_cpols,
+    &v3_akey_id,
+    &v3_crld,
+    &v3_ext_ku,
+    &v3_delta_crl,
+    &v3_crl_reason,
+#ifndef OPENSSL_NO_OCSP
+    &v3_crl_invdate,
+#endif
+    &v3_sxnet,
+    &v3_info,
+#ifndef OPENSSL_NO_RFC3779
+    &v3_addr,
+    &v3_asid,
+#endif
+#ifndef OPENSSL_NO_OCSP
+    &v3_ocsp_nonce,
+    &v3_ocsp_crlid,
+    &v3_ocsp_accresp,
+    &v3_ocsp_nocheck,
+    &v3_ocsp_acutoff,
+    &v3_ocsp_serviceloc,
+#endif
+    &v3_sinfo,
+    &v3_policy_constraints,
+#ifndef OPENSSL_NO_OCSP
+    &v3_crl_hold,
+#endif
+    &v3_pci,
+    &v3_name_constraints,
+    &v3_policy_mappings,
+    &v3_inhibit_anyp,
+    &v3_idp,
+    &v3_alt[2],
+    &v3_freshest_crl,
+#ifndef OPENSSL_NO_CT
+    &v3_ct_scts[0],
+    &v3_ct_scts[1],
+    &v3_ct_scts[2],
+#endif
+    &v3_tls_feature,
+};
+
+/* Number of standard extensions */
+
+#define STANDARD_EXTENSION_COUNT OSSL_NELEM(standard_exts)
+
diff --git a/crypto/x509v3/tabtest.c b/crypto/x509v3/tabtest.c
deleted file mode 100644
index a33a63a..0000000
--- a/crypto/x509v3/tabtest.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the OpenSSL license (the "License").  You may not use
- * this file except in compliance with the License.  You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-/*
- * Simple program to check the ext_dat.h is correct and print out problems if
- * it is not.
- */
-
-#include <stdio.h>
-
-#include <openssl/x509v3.h>
-
-#include "ext_dat.h"
-
-main()
-{
-    int i, prev = -1, bad = 0;
-    X509V3_EXT_METHOD **tmp;
-    i = OSSL_NELEM(standard_exts);
-    if (i != STANDARD_EXTENSION_COUNT)
-        fprintf(stderr, "Extension number invalid expecting %d\n", i);
-    tmp = standard_exts;
-    for (i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++) {
-        if ((*tmp)->ext_nid < prev)
-            bad = 1;
-        prev = (*tmp)->ext_nid;
-
-    }
-    if (bad) {
-        tmp = standard_exts;
-        fprintf(stderr, "Extensions out of order!\n");
-        for (i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++)
-            printf("%d : %s\n", (*tmp)->ext_nid, OBJ_nid2sn((*tmp)->ext_nid));
-    } else
-        fprintf(stderr, "Order OK\n");
-}
diff --git a/crypto/x509v3/v3_lib.c b/crypto/x509v3/v3_lib.c
index a3ca720..d905800 100644
--- a/crypto/x509v3/v3_lib.c
+++ b/crypto/x509v3/v3_lib.c
@@ -47,73 +47,7 @@ DECLARE_OBJ_BSEARCH_CMP_FN(const X509V3_EXT_METHOD *,
 IMPLEMENT_OBJ_BSEARCH_CMP_FN(const X509V3_EXT_METHOD *,
                              const X509V3_EXT_METHOD *, ext);
 
-/*
- * This table will be searched using OBJ_bsearch so it *must* kept in order
- * of the ext_nid values.
- */
-
-static const X509V3_EXT_METHOD *standard_exts[] = {
-    &v3_nscert,
-    &v3_ns_ia5_list[0],
-    &v3_ns_ia5_list[1],
-    &v3_ns_ia5_list[2],
-    &v3_ns_ia5_list[3],
-    &v3_ns_ia5_list[4],
-    &v3_ns_ia5_list[5],
-    &v3_ns_ia5_list[6],
-    &v3_skey_id,
-    &v3_key_usage,
-    &v3_pkey_usage_period,
-    &v3_alt[0],
-    &v3_alt[1],
-    &v3_bcons,
-    &v3_crl_num,
-    &v3_cpols,
-    &v3_akey_id,
-    &v3_crld,
-    &v3_ext_ku,
-    &v3_delta_crl,
-    &v3_crl_reason,
-#ifndef OPENSSL_NO_OCSP
-    &v3_crl_invdate,
-#endif
-    &v3_sxnet,
-    &v3_info,
-#ifndef OPENSSL_NO_RFC3779
-    &v3_addr,
-    &v3_asid,
-#endif
-#ifndef OPENSSL_NO_OCSP
-    &v3_ocsp_nonce,
-    &v3_ocsp_crlid,
-    &v3_ocsp_accresp,
-    &v3_ocsp_nocheck,
-    &v3_ocsp_acutoff,
-    &v3_ocsp_serviceloc,
-#endif
-    &v3_sinfo,
-    &v3_policy_constraints,
-#ifndef OPENSSL_NO_OCSP
-    &v3_crl_hold,
-#endif
-    &v3_pci,
-    &v3_name_constraints,
-    &v3_policy_mappings,
-    &v3_inhibit_anyp,
-    &v3_idp,
-    &v3_alt[2],
-    &v3_freshest_crl,
-#ifndef OPENSSL_NO_CT
-    &v3_ct_scts[0],
-    &v3_ct_scts[1],
-    &v3_ct_scts[2],
-#endif
-    &v3_tls_feature,
-};
-
-/* Number of standard extensions */
-
-#define STANDARD_EXTENSION_COUNT OSSL_NELEM(standard_exts)
+#include "standard_exts.h"
 
 const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid)
 {
diff --git a/crypto/x509v3/v3conf.c b/crypto/x509v3/v3conf.c
deleted file mode 100644
index 966ab90..0000000
--- a/crypto/x509v3/v3conf.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the OpenSSL license (the "License").  You may not use
- * this file except in compliance with the License.  You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <stdio.h>
-#include "internal/cryptlib.h"
-#include <openssl/asn1.h>
-#include <openssl/conf.h>
-#include <openssl/x509.h>
-#include <openssl/x509v3.h>
-
-/* Test application to add extensions from a config file */
-
-int main(int argc, char **argv)
-{
-    LHASH *conf;
-    X509 *cert;
-    FILE *inf;
-    char *conf_file;
-    int i;
-    int count;
-    X509_EXTENSION *ext;
-    X509V3_add_standard_extensions();
-    ERR_load_crypto_strings();
-    if (!argv[1]) {
-        fprintf(stderr, "Usage: v3conf cert.pem [file.cnf]\n");
-        exit(1);
-    }
-    conf_file = argv[2];
-    if (!conf_file)
-        conf_file = "test.cnf";
-    conf = CONF_load(NULL, "test.cnf", NULL);
-    if (!conf) {
-        fprintf(stderr, "Error opening Config file %s\n", conf_file);
-        ERR_print_errors_fp(stderr);
-        exit(1);
-    }
-
-    inf = fopen(argv[1], "r");
-    if (!inf) {
-        fprintf(stderr, "Can't open certificate file %s\n", argv[1]);
-        exit(1);
-    }
-    cert = PEM_read_X509(inf, NULL, NULL);
-    if (!cert) {
-        fprintf(stderr, "Error reading certificate file %s\n", argv[1]);
-        exit(1);
-    }
-    fclose(inf);
-
-    sk_pop_free(cert->cert_info->extensions, X509_EXTENSION_free);
-    cert->cert_info->extensions = NULL;
-
-    if (!X509V3_EXT_add_conf(conf, NULL, "test_section", cert)) {
-        fprintf(stderr, "Error adding extensions\n");
-        ERR_print_errors_fp(stderr);
-        exit(1);
-    }
-
-    count = X509_get_ext_count(cert);
-    printf("%d extensions\n", count);
-    for (i = 0; i < count; i++) {
-        ext = X509_get_ext(cert, i);
-        printf("%s", OBJ_nid2ln(OBJ_obj2nid(ext->object)));
-        if (ext->critical)
-            printf(",critical:\n");
-        else
-            printf(":\n");
-        X509V3_EXT_print_fp(stdout, ext, 0, 0);
-        printf("\n");
-
-    }
-    return 0;
-}
diff --git a/crypto/x509v3/v3prin.c b/crypto/x509v3/v3prin.c
deleted file mode 100644
index 7431a4e..0000000
--- a/crypto/x509v3/v3prin.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the OpenSSL license (the "License").  You may not use
- * this file except in compliance with the License.  You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <stdio.h>
-#include <openssl/asn1.h>
-#include <openssl/conf.h>
-#include <openssl/x509.h>
-#include <openssl/x509v3.h>
-
-int main(int argc, char **argv)
-{
-    X509 *cert;
-    FILE *inf;
-    int i, count;
-    X509_EXTENSION *ext;
-
-    X509V3_add_standard_extensions();
-    ERR_load_crypto_strings();
-    if (!argv[1]) {
-        fprintf(stderr, "Usage v3prin cert.pem\n");
-        exit(1);
-    }
-    if ((inf = fopen(argv[1], "r")) == NULL) {
-        fprintf(stderr, "Can't open %s\n", argv[1]);
-        exit(1);
-    }
-    if ((cert = PEM_read_X509(inf, NULL, NULL)) == NULL) {
-        fprintf(stderr, "Can't read certificate %s\n", argv[1]);
-        ERR_print_errors_fp(stderr);
-        exit(1);
-    }
-    fclose(inf);
-    count = X509_get_ext_count(cert);
-    printf("%d extensions\n", count);
-    for (i = 0; i < count; i++) {
-        ext = X509_get_ext(cert, i);
-        printf("%s\n", OBJ_nid2ln(OBJ_obj2nid(ext->object)));
-        if (!X509V3_EXT_print_fp(stdout, ext, 0, 0))
-            ERR_print_errors_fp(stderr);
-        printf("\n");
-
-    }
-    return 0;
-}
diff --git a/include/openssl/modes.h b/include/openssl/modes.h
index a04c6a5..d544f98 100644
--- a/include/openssl/modes.h
+++ b/include/openssl/modes.h
@@ -7,11 +7,14 @@
  * https://www.openssl.org/source/license.html
  */
 
-#include <stddef.h>
+#ifndef HEADER_MODES_H
+# define HEADER_MODES_H
 
-#ifdef  __cplusplus
+# include <stddef.h>
+
+# ifdef  __cplusplus
 extern "C" {
-#endif
+# endif
 typedef void (*block128_f) (const unsigned char in[16],
                             unsigned char out[16], const void *key);
 
@@ -166,7 +169,7 @@ size_t CRYPTO_128_unwrap_pad(void *key, const unsigned char *icv,
                              unsigned char *out, const unsigned char *in,
                              size_t inlen, block128_f block);
 
-#ifndef OPENSSL_NO_OCB
+# ifndef OPENSSL_NO_OCB
 typedef struct ocb128_context OCB128_CONTEXT;
 
 typedef void (*ocb128_f) (const unsigned char *in, unsigned char *out,
@@ -196,8 +199,10 @@ int CRYPTO_ocb128_finish(OCB128_CONTEXT *ctx, const unsigned char *tag,
                          size_t len);
 int CRYPTO_ocb128_tag(OCB128_CONTEXT *ctx, unsigned char *tag, size_t len);
 void CRYPTO_ocb128_cleanup(OCB128_CONTEXT *ctx);
-#endif                          /* OPENSSL_NO_OCB */
+# endif                          /* OPENSSL_NO_OCB */
 
-#ifdef  __cplusplus
+# ifdef  __cplusplus
 }
+# endif
+
 #endif
diff --git a/test/asn1_internal_test.c b/test/asn1_internal_test.c
new file mode 100644
index 0000000..fc0ac20
--- /dev/null
+++ b/test/asn1_internal_test.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the OpenSSL license (the "License").  You may not use
+ * this file except in compliance with the License.  You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+/* Internal tests for the asn1 module */
+
+#include <stdio.h>
+#include <string.h>
+
+#include <openssl/asn1.h>
+#include <openssl/evp.h>
+#include <openssl/objects.h>
+#include "testutil.h"
+#include "e_os.h"
+
+typedef struct {
+    const char *test_case_name;
+    const char *test_section;
+} SIMPLE_FIXTURE;
+
+/**********************************************************************
+ *
+ * Test of a_strnid's tbl_standard
+ *
+ ***/
+
+static SIMPLE_FIXTURE setup_tbl_standard(const char *const test_case_name)
+{
+    SIMPLE_FIXTURE fixture;
+    fixture.test_case_name = test_case_name;
+    return fixture;
+}
+
+#include "../crypto/asn1/tbl_standard.h"
+
+static int execute_tbl_standard(SIMPLE_FIXTURE fixture)
+{
+    const ASN1_STRING_TABLE *tmp;
+    int last_nid = -1;
+    size_t i;
+
+    for (tmp = tbl_standard, i = 0; i < OSSL_NELEM(tbl_standard); i++, tmp++) {
+        if (tmp->nid < last_nid) {
+            last_nid = 0;
+            break;
+        }
+        last_nid = tmp->nid;
+    }
+
+    if (last_nid != 0) {
+        fprintf(stderr, "%s: Table order OK\n", fixture.test_section);
+        return 1;
+    }
+
+    for (tmp = tbl_standard, i = 0; i < OSSL_NELEM(tbl_standard); i++, tmp++)
+        fprintf(stderr, "%s: Index %" OSSLzu ", NID %d, Name=%s\n",
+               fixture.test_section, i, tmp->nid, OBJ_nid2ln(tmp->nid));
+
+    return 0;
+}
+
+static void teardown_tbl_standard(SIMPLE_FIXTURE fixture)
+{
+    ERR_print_errors_fp(stderr);
+}
+
+/**********************************************************************
+ *
+ * Test of ameth_lib's standard_methods
+ *
+ ***/
+
+static SIMPLE_FIXTURE setup_standard_methods(const char *const test_case_name)
+{
+    SIMPLE_FIXTURE fixture;
+    fixture.test_case_name = test_case_name;
+    return fixture;
+}
+
+#include "internal/asn1_int.h"
+#include "../crypto/asn1/standard_methods.h"
+
+static int execute_standard_methods(SIMPLE_FIXTURE fixture)
+{
+    const EVP_PKEY_ASN1_METHOD **tmp;
+    int last_pkey_id = -1;
+    size_t i;
+
+    for (tmp = standard_methods, i = 0; i < OSSL_NELEM(standard_methods);
+         i++, tmp++) {
+        if ((*tmp)->pkey_id < last_pkey_id) {
+            last_pkey_id = 0;
+            break;
+        }
+        last_pkey_id = (*tmp)->pkey_id;
+    }
+
+    if (last_pkey_id != 0) {
+        fprintf(stderr, "%s: Table order OK\n", fixture.test_section);
+        return 1;
+    }
+
+    for (tmp = standard_methods, i = 0; i < OSSL_NELEM(standard_methods);
+         i++, tmp++)
+        fprintf(stderr, "%s: Index %" OSSLzu ", pkey ID %d, Name=%s\n",
+               fixture.test_section, i, (*tmp)->pkey_id,
+               OBJ_nid2sn((*tmp)->pkey_id));
+
+    return 0;
+}
+
+static void teardown_standard_methods(SIMPLE_FIXTURE fixture)
+{
+    ERR_print_errors_fp(stderr);
+}
+
+/**********************************************************************
+ *
+ * Test driver
+ *
+ ***/
+
+static struct {
+    const char *section;
+    SIMPLE_FIXTURE (*setup)(const char *const test_case_name);
+    int (*execute)(SIMPLE_FIXTURE);
+    void (*teardown)(SIMPLE_FIXTURE);
+} tests[] = {
+    {"asn1 tlb_standard", setup_tbl_standard, execute_tbl_standard,
+     teardown_tbl_standard},
+    {"asn1 standard_methods", setup_standard_methods, execute_standard_methods,
+     teardown_standard_methods}
+};
+
+static int drive_tests(int idx)
+{
+    SETUP_TEST_FIXTURE(SIMPLE_FIXTURE, tests[idx].setup);
+    fixture.test_section = tests[idx].section;
+    EXECUTE_TEST(tests[idx].execute, tests[idx].teardown);
+}
+
+int main(int argc, char **argv)
+{
+    ADD_ALL_TESTS(drive_tests, OSSL_NELEM(tests));
+
+    return run_tests(argv[0]);
+}
diff --git a/test/build.info b/test/build.info
index aa9b933..46403ea 100644
--- a/test/build.info
+++ b/test/build.info
@@ -298,6 +298,86 @@ IF[{- !$disabled{tests} -}]
     INCLUDE[cipher_overhead_test]=.. ../include
     DEPEND[cipher_overhead_test]=../libcrypto ../libssl
   ENDIF
+
+  # Internal test programs.  These are essentially a collection of internal
+  # test routines.  Because they sometimes need to reach internal symbols that
+  # aren't available through the shared library (at least on Linux, Solaris,
+  # Windows and VMS, where the exported symbols are those listed in util/*.num),
+  # these programs may be built on files directly picked from inside crypto/
+  # or ssl/, to test using symbols that exist in those specific files.  These
+  # programs will also be linked with libcrypto / libssl, so we don't pick
+  # out more specific files than necessary.
+  # This might mean we have multiply defined symbols, but since linking is
+  # ordered with object files first and libraries after, the symbols from the
+  # object files will be chosen before those in the libraries.  This is handled
+  # properly by all linkers.
+  # Note that when building with static libraries, none of those extra files
+  # are needed, since all symbols are available anyway, regardless of what's
+  # listed in util/*.num.
+  PROGRAMS_NO_INST=asn1_internal_test modes_internal_test x509_internal_test
+  IF[{- !$disabled{mdc2} -}]
+    PROGRAMS_NO_INST=mdc2_internal_test
+  ENDIF
+  IF[{- !$disabled{poly1305} -}]
+    PROGRAMS_NO_INST=poly1305_internal_test
+  ENDIF
+
+  SOURCE[poly1305_internal_test]=poly1305_internal_test.c testutil.c
+  IF[{- !$disabled{shared} -}]
+    SOURCE[poly1305_internal_test]= ../crypto/poly1305/poly1305.c \
+        {- $target{poly1305_asm_src} ? "../crypto/poly1305/".$target{poly1305_asm_src} : "" -} \
+        {- $target{cpuid_asm_src} ? "../crypto/".$target{cpuid_asm_src} : "" -} \
+        ../crypto/cryptlib.c
+  ENDIF
+  INCLUDE[poly1305_internal_test]=.. ../include ../crypto/include
+  DEPEND[poly1305_internal_test]=../libcrypto
+
+  SOURCE[asn1_internal_test]=asn1_internal_test.c testutil.c
+  IF[{- !$disabled{shared} -}]
+    SOURCE[asn1_internal_test]= ../crypto/asn1/a_strnid.c \
+        ../crypto/rsa/rsa_ameth.c ../crypto/dsa/dsa_ameth.c \
+        ../crypto/dh/dh_ameth.c ../crypto/ec/ec_ameth.c \
+        ../crypto/hmac/hm_ameth.c ../crypto/cmac/cm_ameth.c \
+        ../crypto/ec/ecx_meth.c ../crypto/ec/curve25519.c
+  ENDIF
+  INCLUDE[asn1_internal_test]=.. ../include ../crypto/include
+  DEPEND[asn1_internal_test]=../libcrypto
+
+  SOURCE[modes_internal_test]=modes_internal_test.c testutil.c
+  IF[{- !$disabled{shared} -}]
+    SOURCE[modes_internal_test]= {- $target{cpuid_asm_src}
+                                    ? "../crypto/".$target{cpuid_asm_src}
+                                    : "" -} \
+        ../crypto/cryptlib.c
+  ENDIF
+  INCLUDE[modes_internal_test]=.. ../include
+  DEPEND[modes_internal_test]=../libcrypto
+
+  # The reason for the huge amount of directly included x509v3 files
+  # is that a table that is checked by x509_internal_test refers to
+  # structures that are spread all over those files.
+  SOURCE[x509_internal_test]=x509_internal_test.c testutil.c
+  IF[{- !$disabled{shared} -}]
+    SOURCE[x509_internal_test]= ../crypto/x509v3/v3_bitst.c \
+        ../crypto/x509v3/v3_ia5.c ../crypto/x509v3/v3_skey.c \
+        ../crypto/x509v3/v3_pku.c ../crypto/x509v3/v3_alt.c \
+        ../crypto/x509v3/v3_bcons.c ../crypto/x509v3/v3_int.c \
+        ../crypto/x509v3/v3_cpols.c ../crypto/x509v3/v3_akey.c \
+        ../crypto/x509v3/v3_crld.c ../crypto/x509v3/v3_utl.c \
+        ../crypto/x509v3/v3_extku.c ../crypto/x509v3/v3_enum.c \
+        ../crypto/x509v3/v3_sxnet.c ../crypto/x509v3/v3_info.c \
+        ../crypto/x509v3/v3_addr.c ../crypto/x509v3/v3_asid.c \
+        ../crypto/x509v3/v3_pcons.c ../crypto/x509v3/v3_pmaps.c \
+        ../crypto/x509v3/v3_pci.c ../crypto/x509v3/v3_ncons.c \
+        ../crypto/x509v3/v3_tlsf.c ../crypto/ocsp/v3_ocsp.c \
+        ../crypto/ct/ct_x509v3.c ../crypto/asn1/a_strex.c
+  ENDIF
+  INCLUDE[x509_internal_test]=.. ../include
+  DEPEND[x509_internal_test]=../libcrypto
+
+  SOURCE[mdc2_internal_test]=mdc2_internal_test.c testutil.c
+  INCLUDE[mdc2_internal_test]=.. ../include
+  DEPEND[mdc2_internal_test]=../libcrypto
 ENDIF
 
 {-
diff --git a/test/mdc2_internal_test.c b/test/mdc2_internal_test.c
new file mode 100644
index 0000000..7f6a95c
--- /dev/null
+++ b/test/mdc2_internal_test.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the OpenSSL license (the "License").  You may not use
+ * this file except in compliance with the License.  You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+/* Internal tests for the mdc2 module */
+
+#include <stdio.h>
+#include <string.h>
+
+#include <openssl/mdc2.h>
+#include "testutil.h"
+#include "e_os.h"
+
+typedef struct {
+    const char *input;
+    const unsigned char expected[MDC2_DIGEST_LENGTH];
+} TESTDATA;
+
+typedef struct {
+    const char *case_name;
+    int num;
+    const TESTDATA *data;
+} SIMPLE_FIXTURE;
+
+/**********************************************************************
+ *
+ * Test of mdc2 internal functions
+ *
+ ***/
+
+static SIMPLE_FIXTURE setup_mdc2(const char *const test_case_name)
+{
+    SIMPLE_FIXTURE fixture;
+    fixture.case_name = test_case_name;
+    return fixture;
+}
+
+static int execute_mdc2(SIMPLE_FIXTURE fixture)
+{
+    unsigned char md[MDC2_DIGEST_LENGTH];
+    MDC2_CTX c;
+
+    MDC2_Init(&c);
+    MDC2_Update(&c, (const unsigned char *)fixture.data->input,
+                strlen(fixture.data->input));
+    MDC2_Final(&(md[0]), &c);
+
+    if (memcmp(fixture.data->expected, md, MDC2_DIGEST_LENGTH)) {
+        fprintf(stderr, "mdc2 test %d: unexpected output\n", fixture.num);
+        return 0;
+    }
+
+    return 1;
+}
+
+static void teardown_mdc2(SIMPLE_FIXTURE fixture)
+{
+    ERR_print_errors_fp(stderr);
+}
+
+/**********************************************************************
+ *
+ * Test driver
+ *
+ ***/
+
+static TESTDATA tests[] = {
+    {
+        "Now is the time for all ",
+        {
+            0x42, 0xE5, 0x0C, 0xD2, 0x24, 0xBA, 0xCE, 0xBA,
+            0x76, 0x0B, 0xDD, 0x2B, 0xD4, 0x09, 0x28, 0x1A
+        }
+    }
+};
+
+static int drive_tests(int idx)
+{
+    SETUP_TEST_FIXTURE(SIMPLE_FIXTURE, setup_mdc2);
+    fixture.num = idx;
+    fixture.data = &tests[idx];
+    EXECUTE_TEST(execute_mdc2, teardown_mdc2);
+}
+
+int main(int argc, char **argv)
+{
+    ADD_ALL_TESTS(drive_tests, OSSL_NELEM(tests));
+
+    return run_tests(argv[0]);
+}
diff --git a/test/modes_internal_test.c b/test/modes_internal_test.c
new file mode 100644
index 0000000..a1ed8c7
--- /dev/null
+++ b/test/modes_internal_test.c
@@ -0,0 +1,1085 @@
+/*
+ * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the OpenSSL license (the "License").  You may not use
+ * this file except in compliance with the License.  You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+/* Internal tests for the modes module */
+
+#include <stdio.h>
+#include <string.h>
+
+#include <openssl/aes.h>
+#include <openssl/modes.h>
+#include "../crypto/modes/modes_lcl.h"
+#include "testutil.h"
+#include "e_os.h"
+
+typedef struct {
+    size_t size;
+    const unsigned char *data;
+}  SIZED_DATA;
+
+/**********************************************************************
+ *
+ * Test of cts128
+ *
+ ***/
+
+typedef struct {
+    const char *case_name;
+    int num;
+    const AES_KEY *encrypt_key_schedule;
+    const AES_KEY *decrypt_key_schedule;
+    const unsigned char *input;
+    SIZED_DATA iv;
+    const SIZED_DATA *vector;
+} CTS128_FIXTURE;
+
+static CTS128_FIXTURE setup_cts128(const char *const test_case_name)
+{
+    CTS128_FIXTURE fixture;
+    fixture.case_name = test_case_name;
+    return fixture;
+}
+
+static int execute_cts128(CTS128_FIXTURE fixture)
+{
+    const unsigned char *test_iv = fixture.iv.data;
+    size_t test_iv_len = fixture.iv.size;
+    const unsigned char *vector = fixture.vector->data;
+    size_t len = fixture.vector->size;
+    const unsigned char *test_input = fixture.input;
+    const AES_KEY *encrypt_key_schedule = fixture.encrypt_key_schedule;
+    const AES_KEY *decrypt_key_schedule = fixture.decrypt_key_schedule;
+    unsigned char iv[16];
+    unsigned char cleartext[64], ciphertext[64];
+    size_t tail;
+
+    fprintf(stderr, "vector_%" OSSLzu "\n", len);
+    fflush(stdout);
+
+    if ((tail = len % 16) == 0)
+        tail = 16;
+    tail += 16;
+
+    /* test block-based encryption */
+    memcpy(iv, test_iv, test_iv_len);
+    CRYPTO_cts128_encrypt_block(test_input, ciphertext, len,
+                                encrypt_key_schedule, iv,
+                                (block128_f)AES_encrypt);
+    if (memcmp(ciphertext, vector, len)) {
+        fprintf(stderr, "block encrypt: output_%" OSSLzu " mismatch\n", len);
+        return 0;
+    }
+    if (memcmp(iv, vector + len - tail, sizeof(iv))) {
+        fprintf(stderr, "block encrypt: iv_%" OSSLzu " mismatch\n", len);
+        return 0;
+    }
+
+    /* test block-based decryption */
+    memcpy(iv, test_iv, test_iv_len);
+    CRYPTO_cts128_decrypt_block(ciphertext, cleartext, len,
+                                decrypt_key_schedule, iv,
+                                (block128_f)AES_decrypt);
+    if (memcmp(cleartext, test_input, len)) {
+        fprintf(stderr, "block decrypt: input_%" OSSLzu " mismatch\n", len);
+        return 0;
+    }
+    if (memcmp(iv, vector + len - tail, sizeof(iv))) {
+        fprintf(stderr, "block decrypt: iv_%" OSSLzu " mismatch\n", len);
+        return 0;
+    }
+
+    /* test streamed encryption */
+    memcpy(iv, test_iv, test_iv_len);
+    CRYPTO_cts128_encrypt(test_input, ciphertext, len, encrypt_key_schedule,
+                          iv, (cbc128_f) AES_cbc_encrypt);
+    if (memcmp(ciphertext, vector, len)) {
+        fprintf(stderr, "stream encrypt: output_%" OSSLzu " mismatch\n", len);
+        return 0;
+    }
+    if (memcmp(iv, vector + len - tail, sizeof(iv))) {
+        fprintf(stderr, "stream encrypt: iv_%" OSSLzu " mismatch\n", len);
+        return 0;
+    }
+
+    /* test streamed decryption */
+    memcpy(iv, test_iv, test_iv_len);
+    CRYPTO_cts128_decrypt(ciphertext, cleartext, len, decrypt_key_schedule, iv,
+                          (cbc128_f)AES_cbc_encrypt);
+    if (memcmp(cleartext, test_input, len)) {
+        fprintf(stderr, "stream decrypt: input_%" OSSLzu " mismatch\n", len);
+        return 0;
+    }
+    if (memcmp(iv, vector + len - tail, sizeof(iv))) {
+        fprintf(stderr, "stream decrypt: iv_%" OSSLzu " mismatch\n", len);
+        return 0;
+    }
+
+    return 1;
+}
+
+static int execute_cts128_nist(CTS128_FIXTURE fixture)
+{
+    const unsigned char *test_iv = fixture.iv.data;
+    size_t test_iv_len = fixture.iv.size;
+    const unsigned char *vector = fixture.vector->data;
+    size_t len = fixture.vector->size;
+    const unsigned char *test_input = fixture.input;
+    const AES_KEY *encrypt_key_schedule = fixture.encrypt_key_schedule;
+    const AES_KEY *decrypt_key_schedule = fixture.decrypt_key_schedule;
+    unsigned char iv[16];
+    unsigned char cleartext[64], ciphertext[64], nistvector[64];
+    size_t tail;
+
+    fprintf(stderr, "nistvector_%" OSSLzu "\n", len);
+    fflush(stdout);
+
+    if ((tail = len % 16) == 0)
+        tail = 16;
+
+    len -= 16 + tail;
+    memcpy(nistvector, vector, len);
+    /* flip two last blocks */
+    memcpy(nistvector + len, vector + len + 16, tail);
+    memcpy(nistvector + len + tail, vector + len, 16);
+    len += 16 + tail;
+    tail = 16;
+
+    /* test block-based encryption */
+    memcpy(iv, test_iv, test_iv_len);
+    CRYPTO_nistcts128_encrypt_block(test_input, ciphertext, len,
+                                    encrypt_key_schedule, iv,
+                                    (block128_f)AES_encrypt);
+    if (memcmp(ciphertext, nistvector, len)) {
+        fprintf(stderr, "output_%" OSSLzu " mismatch\n", len);
+        return 0;
+    }
+    if (memcmp(iv, nistvector + len - tail, sizeof(iv))) {
+        fprintf(stderr, "iv_%" OSSLzu " mismatch\n", len);
+        return 0;
+    }
+
+    /* test block-based decryption */
+    memcpy(iv, test_iv, test_iv_len);
+    CRYPTO_nistcts128_decrypt_block(ciphertext, cleartext, len,
+                                    decrypt_key_schedule, iv,
+                                    (block128_f)AES_decrypt);
+    if (memcmp(cleartext, test_input, len)) {
+        fprintf(stderr, "input_%" OSSLzu " mismatch\n", len);
+        return 0;
+    }
+    if (memcmp(iv, nistvector + len - tail, sizeof(iv))) {
+        fprintf(stderr, "iv_%" OSSLzu " mismatch\n", len);
+        return 0;
+    }
+
+    /* test streamed encryption */
+    memcpy(iv, test_iv, test_iv_len);
+    CRYPTO_nistcts128_encrypt(test_input, ciphertext, len,
+                              encrypt_key_schedule, iv,
+                              (cbc128_f)AES_cbc_encrypt);
+    if (memcmp(ciphertext, nistvector, len)) {
+        fprintf(stderr, "output_%" OSSLzu " mismatch\n", len);
+        return 0;
+    }
+    if (memcmp(iv, nistvector + len - tail, sizeof(iv))) {
+        fprintf(stderr, "iv_%" OSSLzu " mismatch\n", len);
+        return 0;
+    }
+
+    /* test streamed decryption */
+    memcpy(iv, test_iv, test_iv_len);
+    CRYPTO_nistcts128_decrypt(ciphertext, cleartext, len, decrypt_key_schedule,
+                              iv, (cbc128_f)AES_cbc_encrypt);
+    if (memcmp(cleartext, test_input, len)) {
+        fprintf(stderr, "input_%" OSSLzu " mismatch\n", len);
+        return 0;
+    }
+    if (memcmp(iv, nistvector + len - tail, sizeof(iv))) {
+        fprintf(stderr, "iv_%" OSSLzu " mismatch\n", len);
+        return 0;
+    }
+
+    return 1;
+}
+
+static void teardown_cts128(CTS128_FIXTURE fixture)
+{
+    ERR_print_errors_fp(stderr);
+}
+
+/**********************************************************************
+ *
+ * Test of gcm128
+ *
+ ***/
+
+typedef struct {
+    const char *case_name;
+    int num;
+    SIZED_DATA K;
+    SIZED_DATA IV;
+    SIZED_DATA A;
+    SIZED_DATA P;
+    SIZED_DATA C;
+    SIZED_DATA T;
+} GCM128_FIXTURE;
+
+static GCM128_FIXTURE setup_gcm128(const char *const test_case_name)
+{
+    GCM128_FIXTURE fixture;
+    fixture.case_name = test_case_name;
+    return fixture;
+}
+
+static int execute_gcm128(GCM128_FIXTURE fixture)
+{
+    unsigned char out[512];
+    SIZED_DATA *K = &fixture.K;
+    SIZED_DATA *IV = &fixture.IV;
+    SIZED_DATA *A = &fixture.A;
+    SIZED_DATA *P = &fixture.P;
+    SIZED_DATA *C = &fixture.C;
+    SIZED_DATA *T = &fixture.T;
+    int n = fixture.num;
+    GCM128_CONTEXT ctx;
+    AES_KEY key;
+    int err = 0;
+
+    AES_set_encrypt_key(K->data, K->size * 8, &key);
+
+    CRYPTO_gcm128_init(&ctx, &key, (block128_f)AES_encrypt);
+    CRYPTO_gcm128_setiv(&ctx, IV->data, IV->size);
+    memset(out, 0, P->size);
+    if (A->data)
+        CRYPTO_gcm128_aad(&ctx, A->data, A->size);
+    if (P->data)
+        CRYPTO_gcm128_encrypt( &ctx, P->data, out, P->size);
+    if (CRYPTO_gcm128_finish(&ctx, T->data, 16)
+        || (C->data && memcmp(out, C->data, P->size)))
+        err++, fprintf(stderr, "encrypt test#%d failed.\n", n);
+
+    CRYPTO_gcm128_setiv(&ctx, IV->data, IV->size);
+    memset(out, 0, P->size);
+    if (A->data)
+        CRYPTO_gcm128_aad(&ctx, A->data, A->size);
+    if (C->data)
+        CRYPTO_gcm128_decrypt(&ctx, C->data, out, P->size);
+    if (CRYPTO_gcm128_finish(&ctx, T->data, 16)
+        || (P->data && memcmp(out, P->data, P->size)))
+        err++, fprintf(stderr, "decrypt test#%d failed.\n", n);
+
+    return err == 0;
+}
+
+static void teardown_gcm128(GCM128_FIXTURE fixture)
+{
+    ERR_print_errors_fp(stderr);
+}
+
+static void benchmark_gcm128(const unsigned char *K, size_t Klen,
+                             const unsigned char *IV, size_t IVlen)
+{
+#ifdef OPENSSL_CPUID_OBJ
+    GCM128_CONTEXT ctx;
+    AES_KEY key;
+    size_t start, gcm_t, ctr_t, OPENSSL_rdtsc();
+    union {
+        u64 u;
+        u8 c[1024];
+    } buf;
+
+    AES_set_encrypt_key(K, Klen * 8, &key);
+    CRYPTO_gcm128_init(&ctx, &key, (block128_f) AES_encrypt);
+    CRYPTO_gcm128_setiv(&ctx, IV, IVlen);
+
+    CRYPTO_gcm128_encrypt(&ctx, buf.c, buf.c, sizeof(buf));
+    start = OPENSSL_rdtsc();
+    CRYPTO_gcm128_encrypt(&ctx, buf.c, buf.c, sizeof(buf));
+    gcm_t = OPENSSL_rdtsc() - start;
+
+    CRYPTO_ctr128_encrypt(buf.c, buf.c, sizeof(buf),
+                          &key, ctx.Yi.c, ctx.EKi.c, &ctx.mres,
+                          (block128_f) AES_encrypt);
+    start = OPENSSL_rdtsc();
+    CRYPTO_ctr128_encrypt(buf.c, buf.c, sizeof(buf),
+                          &key, ctx.Yi.c, ctx.EKi.c, &ctx.mres,
+                          (block128_f) AES_encrypt);
+    ctr_t = OPENSSL_rdtsc() - start;
+
+    printf("%.2f-%.2f=%.2f\n",
+           gcm_t / (double)sizeof(buf),
+           ctr_t / (double)sizeof(buf),
+           (gcm_t - ctr_t) / (double)sizeof(buf));
+# ifdef GHASH
+    {
+        void (*gcm_ghash_p) (u64 Xi[2], const u128 Htable[16],
+                             const u8 *inp, size_t len) = ctx.ghash;
+
+        GHASH((&ctx), buf.c, sizeof(buf));
+        start = OPENSSL_rdtsc();
+        for (i = 0; i < 100; ++i)
+            GHASH((&ctx), buf.c, sizeof(buf));
+        gcm_t = OPENSSL_rdtsc() - start;
+        printf("%.2f\n", gcm_t / (double)sizeof(buf) / (double)i);
+    }
+# endif
+#else
+    fprintf(stderr,
+            "Benchmarking of modes isn't available on this platform\n");
+#endif
+}
+
+/**********************************************************************
+ *
+ * Test driver
+ *
+ ***/
+
+/* cts128 test vectors from RFC 3962 */
+static const unsigned char cts128_test_key[16] = "chicken teriyaki";
+static const unsigned char cts128_test_input[64] =
+    "I would like the" " General Gau's C"
+    "hicken, please, " "and wonton soup.";
+static const unsigned char cts128_test_iv[] =
+    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+
+static const unsigned char vector_17[17] = {
+    0xc6, 0x35, 0x35, 0x68, 0xf2, 0xbf, 0x8c, 0xb4,
+    0xd8, 0xa5, 0x80, 0x36, 0x2d, 0xa7, 0xff, 0x7f,
+    0x97
+};
+
+static const unsigned char vector_31[31] = {
+    0xfc, 0x00, 0x78, 0x3e, 0x0e, 0xfd, 0xb2, 0xc1,
+    0xd4, 0x45, 0xd4, 0xc8, 0xef, 0xf7, 0xed, 0x22,
+    0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0,
+    0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5
+};
+
+static const unsigned char vector_32[32] = {
+    0x39, 0x31, 0x25, 0x23, 0xa7, 0x86, 0x62, 0xd5,
+    0xbe, 0x7f, 0xcb, 0xcc, 0x98, 0xeb, 0xf5, 0xa8,
+    0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0,
+    0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5, 0x84
+};
+
+static const unsigned char vector_47[47] = {
+    0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0,
+    0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5, 0x84,
+    0xb3, 0xff, 0xfd, 0x94, 0x0c, 0x16, 0xa1, 0x8c,
+    0x1b, 0x55, 0x49, 0xd2, 0xf8, 0x38, 0x02, 0x9e,
+    0x39, 0x31, 0x25, 0x23, 0xa7, 0x86, 0x62, 0xd5,
+    0xbe, 0x7f, 0xcb, 0xcc, 0x98, 0xeb, 0xf5
+};
+
+static const unsigned char vector_48[48] = {
+    0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0,
+    0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5, 0x84,
+    0x9d, 0xad, 0x8b, 0xbb, 0x96, 0xc4, 0xcd, 0xc0,
+    0x3b, 0xc1, 0x03, 0xe1, 0xa1, 0x94, 0xbb, 0xd8,
+    0x39, 0x31, 0x25, 0x23, 0xa7, 0x86, 0x62, 0xd5,
+    0xbe, 0x7f, 0xcb, 0xcc, 0x98, 0xeb, 0xf5, 0xa8
+};
+
+static const unsigned char vector_64[64] = {
+    0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0,
+    0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5, 0x84,
+    0x39, 0x31, 0x25, 0x23, 0xa7, 0x86, 0x62, 0xd5,
+    0xbe, 0x7f, 0xcb, 0xcc, 0x98, 0xeb, 0xf5, 0xa8,
+    0x48, 0x07, 0xef, 0xe8, 0x36, 0xee, 0x89, 0xa5,
+    0x26, 0x73, 0x0d, 0xbc, 0x2f, 0x7b, 0xc8, 0x40,
+    0x9d, 0xad, 0x8b, 0xbb, 0x96, 0xc4, 0xcd, 0xc0,
+    0x3b, 0xc1, 0x03, 0xe1, 0xa1, 0x94, 0xbb, 0xd8
+};
+
+#define CTS128_TEST_VECTOR(len)                 \
+    {                                           \
+        sizeof(vector_##len), vector_##len      \
+    }
+static const SIZED_DATA cts128_vectors[] = {
+    CTS128_TEST_VECTOR(17),
+    CTS128_TEST_VECTOR(31),
+    CTS128_TEST_VECTOR(32),
+    CTS128_TEST_VECTOR(47),
+    CTS128_TEST_VECTOR(48),
+    CTS128_TEST_VECTOR(64),
+};
+
+static AES_KEY *cts128_encrypt_key_schedule()
+{
+    static int init_key = 1;
+    static AES_KEY ks;
+
+    if (init_key) {
+        AES_set_encrypt_key(cts128_test_key, 128, &ks);
+        init_key = 0;
+    }
+    return &ks;
+}
+
+static AES_KEY *cts128_decrypt_key_schedule()
+{
+    static int init_key = 1;
+    static AES_KEY ks;
+
+    if (init_key) {
+        AES_set_decrypt_key(cts128_test_key, 128, &ks);
+        init_key = 0;
+    }
+    return &ks;
+}
+
+static int drive_cts128_tests(int idx)
+{
+    SETUP_TEST_FIXTURE(CTS128_FIXTURE, setup_cts128);
+    fixture.num = idx;
+    fixture.encrypt_key_schedule = cts128_encrypt_key_schedule();
+    fixture.decrypt_key_schedule = cts128_decrypt_key_schedule();
+    fixture.input = cts128_test_input;
+    fixture.iv.size = sizeof(cts128_test_iv);
+    fixture.iv.data = cts128_test_iv;
+    fixture.vector = &cts128_vectors[idx];
+    EXECUTE_TEST(execute_cts128, teardown_cts128);
+}
+
+static int drive_cts128_nist_tests(int idx)
+{
+    SETUP_TEST_FIXTURE(CTS128_FIXTURE, setup_cts128);
+    fixture.num = idx;
+    fixture.encrypt_key_schedule = cts128_encrypt_key_schedule();
+    fixture.decrypt_key_schedule = cts128_decrypt_key_schedule();
+    fixture.input = cts128_test_input;
+    fixture.iv.size = sizeof(cts128_test_iv);
+    fixture.iv.data = cts128_test_iv;
+    fixture.vector = &cts128_vectors[idx];
+    EXECUTE_TEST(execute_cts128_nist, teardown_cts128);
+}
+
+/* Test Case 1 */
+static const u8 K1[16], P1[] = { 0 }, A1[] = { 0 }, IV1[12], C1[] = { 0 };
+static const u8 T1[] = {
+    0x58, 0xe2, 0xfc, 0xce, 0xfa, 0x7e, 0x30, 0x61,
+    0x36, 0x7f, 0x1d, 0x57, 0xa4, 0xe7, 0x45, 0x5a
+};
+
+/* Test Case 2 */
+# define K2 K1
+# define A2 A1
+# define IV2 IV1
+static const u8 P2[16];
+static const u8 C2[] = {
+    0x03, 0x88, 0xda, 0xce, 0x60, 0xb6, 0xa3, 0x92,
+    0xf3, 0x28, 0xc2, 0xb9, 0x71, 0xb2, 0xfe, 0x78
+};
+
+static const u8 T2[] = {
+    0xab, 0x6e, 0x47, 0xd4, 0x2c, 0xec, 0x13, 0xbd,
+    0xf5, 0x3a, 0x67, 0xb2, 0x12, 0x57, 0xbd, 0xdf
+};
+
+/* Test Case 3 */
+# define A3 A2
+static const u8 K3[] = {
+    0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+    0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
+};
+
+static const u8 P3[] = {
+    0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
+    0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
+    0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
+    0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
+    0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
+    0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
+    0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
+    0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55
+};
+
+static const u8 IV3[] = {
+    0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
+    0xde, 0xca, 0xf8, 0x88
+};
+
+static const u8 C3[] = {
+    0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24,
+    0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c,
+    0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0,
+    0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e,
+    0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c,
+    0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05,
+    0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97,
+    0x3d, 0x58, 0xe0, 0x91, 0x47, 0x3f, 0x59, 0x85
+};
+
+static const u8 T3[] = {
+    0x4d, 0x5c, 0x2a, 0xf3, 0x27, 0xcd, 0x64, 0xa6,
+    0x2c, 0xf3, 0x5a, 0xbd, 0x2b, 0xa6, 0xfa, 0xb4
+};
+
+/* Test Case 4 */
+# define K4 K3
+# define IV4 IV3
+static const u8 P4[] = {
+    0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
+    0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
+    0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
+    0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
+    0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
+    0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
+    0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
+    0xba, 0x63, 0x7b, 0x39
+};
+
+static const u8 A4[] = {
+    0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
+    0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
+    0xab, 0xad, 0xda, 0xd2
+};
+
+static const u8 C4[] = {
+    0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24,
+    0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c,
+    0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0,
+    0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e,
+    0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c,
+    0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05,
+    0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97,
+    0x3d, 0x58, 0xe0, 0x91
+};
+
+static const u8 T4[] = {
+    0x5b, 0xc9, 0x4f, 0xbc, 0x32, 0x21, 0xa5, 0xdb,
+    0x94, 0xfa, 0xe9, 0x5a, 0xe7, 0x12, 0x1a, 0x47
+};
+
+/* Test Case 5 */
+# define K5 K4
+# define P5 P4
+# define A5 A4
+static const u8 IV5[] = {
+    0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad
+};
+
+static const u8 C5[] = {
+    0x61, 0x35, 0x3b, 0x4c, 0x28, 0x06, 0x93, 0x4a,
+    0x77, 0x7f, 0xf5, 0x1f, 0xa2, 0x2a, 0x47, 0x55,
+    0x69, 0x9b, 0x2a, 0x71, 0x4f, 0xcd, 0xc6, 0xf8,
+    0x37, 0x66, 0xe5, 0xf9, 0x7b, 0x6c, 0x74, 0x23,
+    0x73, 0x80, 0x69, 0x00, 0xe4, 0x9f, 0x24, 0xb2,
+    0x2b, 0x09, 0x75, 0x44, 0xd4, 0x89, 0x6b, 0x42,
+    0x49, 0x89, 0xb5, 0xe1, 0xeb, 0xac, 0x0f, 0x07,
+    0xc2, 0x3f, 0x45, 0x98
+};
+
+static const u8 T5[] = {
+    0x36, 0x12, 0xd2, 0xe7, 0x9e, 0x3b, 0x07, 0x85,
+    0x56, 0x1b, 0xe1, 0x4a, 0xac, 0xa2, 0xfc, 0xcb
+};
+
+/* Test Case 6 */
+# define K6 K5
+# define P6 P5
+# define A6 A5
+static const u8 IV6[] = {
+    0x93, 0x13, 0x22, 0x5d, 0xf8, 0x84, 0x06, 0xe5,
+    0x55, 0x90, 0x9c, 0x5a, 0xff, 0x52, 0x69, 0xaa,
+    0x6a, 0x7a, 0x95, 0x38, 0x53, 0x4f, 0x7d, 0xa1,
+    0xe4, 0xc3, 0x03, 0xd2, 0xa3, 0x18, 0xa7, 0x28,
+    0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39,
+    0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54,
+    0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57,
+    0xa6, 0x37, 0xb3, 0x9b
+};
+
+static const u8 C6[] = {
+    0x8c, 0xe2, 0x49, 0x98, 0x62, 0x56, 0x15, 0xb6,
+    0x03, 0xa0, 0x33, 0xac, 0xa1, 0x3f, 0xb8, 0x94,
+    0xbe, 0x91, 0x12, 0xa5, 0xc3, 0xa2, 0x11, 0xa8,
+    0xba, 0x26, 0x2a, 0x3c, 0xca, 0x7e, 0x2c, 0xa7,
+    0x01, 0xe4, 0xa9, 0xa4, 0xfb, 0xa4, 0x3c, 0x90,
+    0xcc, 0xdc, 0xb2, 0x81, 0xd4, 0x8c, 0x7c, 0x6f,
+    0xd6, 0x28, 0x75, 0xd2, 0xac, 0xa4, 0x17, 0x03,
+    0x4c, 0x34, 0xae, 0xe5
+};
+
+static const u8 T6[] = {
+    0x61, 0x9c, 0xc5, 0xae, 0xff, 0xfe, 0x0b, 0xfa,
+    0x46, 0x2a, 0xf4, 0x3c, 0x16, 0x99, 0xd0, 0x50
+};
+
+/* Test Case 7 */
+static const u8 K7[24], P7[] = { 0 }, A7[] = { 0 }, IV7[12], C7[] = { 0 };
+static const u8 T7[] = {
+    0xcd, 0x33, 0xb2, 0x8a, 0xc7, 0x73, 0xf7, 0x4b,
+    0xa0, 0x0e, 0xd1, 0xf3, 0x12, 0x57, 0x24, 0x35
+};
+
+/* Test Case 8 */
+# define K8 K7
+# define IV8 IV7
+# define A8 A7
+static const u8 P8[16];
+static const u8 C8[] = {
+    0x98, 0xe7, 0x24, 0x7c, 0x07, 0xf0, 0xfe, 0x41,
+    0x1c, 0x26, 0x7e, 0x43, 0x84, 0xb0, 0xf6, 0x00
+};
+
+static const u8 T8[] = {
+    0x2f, 0xf5, 0x8d, 0x80, 0x03, 0x39, 0x27, 0xab,
+    0x8e, 0xf4, 0xd4, 0x58, 0x75, 0x14, 0xf0, 0xfb
+};
+
+/* Test Case 9 */
+# define A9 A8
+static const u8 K9[] = {
+    0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+    0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
+    0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c
+};
+
+static const u8 P9[] = {
+    0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
+    0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
+    0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
+    0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
+    0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
+    0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
+    0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
+    0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55
+};
+
+static const u8 IV9[] = {
+    0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
+    0xde, 0xca, 0xf8, 0x88
+};
+
+static const u8 C9[] = {
+    0x39, 0x80, 0xca, 0x0b, 0x3c, 0x00, 0xe8, 0x41,
+    0xeb, 0x06, 0xfa, 0xc4, 0x87, 0x2a, 0x27, 0x57,
+    0x85, 0x9e, 0x1c, 0xea, 0xa6, 0xef, 0xd9, 0x84,
+    0x62, 0x85, 0x93, 0xb4, 0x0c, 0xa1, 0xe1, 0x9c,
+    0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25,
+    0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47,
+    0x18, 0xe2, 0x44, 0x8b, 0x2f, 0xe3, 0x24, 0xd9,
+    0xcc, 0xda, 0x27, 0x10, 0xac, 0xad, 0xe2, 0x56
+};
+
+static const u8 T9[] = {
+    0x99, 0x24, 0xa7, 0xc8, 0x58, 0x73, 0x36, 0xbf,
+    0xb1, 0x18, 0x02, 0x4d, 0xb8, 0x67, 0x4a, 0x14
+};
+
+/* Test Case 10 */
+# define K10 K9
+# define IV10 IV9
+static const u8 P10[] = {
+    0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
+    0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
+    0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
+    0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
+    0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
+    0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
+    0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
+    0xba, 0x63, 0x7b, 0x39
+};
+
+static const u8 A10[] = {
+    0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
+    0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
+    0xab, 0xad, 0xda, 0xd2
+};
+
+static const u8 C10[] = {
+    0x39, 0x80, 0xca, 0x0b, 0x3c, 0x00, 0xe8, 0x41,
+    0xeb, 0x06, 0xfa, 0xc4, 0x87, 0x2a, 0x27, 0x57,
+    0x85, 0x9e, 0x1c, 0xea, 0xa6, 0xef, 0xd9, 0x84,
+    0x62, 0x85, 0x93, 0xb4, 0x0c, 0xa1, 0xe1, 0x9c,
+    0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25,
+    0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47,
+    0x18, 0xe2, 0x44, 0x8b, 0x2f, 0xe3, 0x24, 0xd9,
+    0xcc, 0xda, 0x27, 0x10
+};
+
+static const u8 T10[] = {
+    0x25, 0x19, 0x49, 0x8e, 0x80, 0xf1, 0x47, 0x8f,
+    0x37, 0xba, 0x55, 0xbd, 0x6d, 0x27, 0x61, 0x8c
+};
+
+/* Test Case 11 */
+# define K11 K10
+# define P11 P10
+# define A11 A10
+static const u8 IV11[] = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad };
+
+static const u8 C11[] = {
+    0x0f, 0x10, 0xf5, 0x99, 0xae, 0x14, 0xa1, 0x54,
+    0xed, 0x24, 0xb3, 0x6e, 0x25, 0x32, 0x4d, 0xb8,
+    0xc5, 0x66, 0x63, 0x2e, 0xf2, 0xbb, 0xb3, 0x4f,
+    0x83, 0x47, 0x28, 0x0f, 0xc4, 0x50, 0x70, 0x57,
+    0xfd, 0xdc, 0x29, 0xdf, 0x9a, 0x47, 0x1f, 0x75,
+    0xc6, 0x65, 0x41, 0xd4, 0xd4, 0xda, 0xd1, 0xc9,
+    0xe9, 0x3a, 0x19, 0xa5, 0x8e, 0x8b, 0x47, 0x3f,
+    0xa0, 0xf0, 0x62, 0xf7
+};
+
+static const u8 T11[] = {
+    0x65, 0xdc, 0xc5, 0x7f, 0xcf, 0x62, 0x3a, 0x24,
+    0x09, 0x4f, 0xcc, 0xa4, 0x0d, 0x35, 0x33, 0xf8
+};
+
+/* Test Case 12 */
+# define K12 K11
+# define P12 P11
+# define A12 A11
+static const u8 IV12[] = {
+    0x93, 0x13, 0x22, 0x5d, 0xf8, 0x84, 0x06, 0xe5,
+    0x55, 0x90, 0x9c, 0x5a, 0xff, 0x52, 0x69, 0xaa,
+    0x6a, 0x7a, 0x95, 0x38, 0x53, 0x4f, 0x7d, 0xa1,
+    0xe4, 0xc3, 0x03, 0xd2, 0xa3, 0x18, 0xa7, 0x28,
+    0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39,
+    0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54,
+    0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57,
+    0xa6, 0x37, 0xb3, 0x9b
+};
+
+static const u8 C12[] = {
+    0xd2, 0x7e, 0x88, 0x68, 0x1c, 0xe3, 0x24, 0x3c,
+    0x48, 0x30, 0x16, 0x5a, 0x8f, 0xdc, 0xf9, 0xff,
+    0x1d, 0xe9, 0xa1, 0xd8, 0xe6, 0xb4, 0x47, 0xef,
+    0x6e, 0xf7, 0xb7, 0x98, 0x28, 0x66, 0x6e, 0x45,
+    0x81, 0xe7, 0x90, 0x12, 0xaf, 0x34, 0xdd, 0xd9,
+    0xe2, 0xf0, 0x37, 0x58, 0x9b, 0x29, 0x2d, 0xb3,
+    0xe6, 0x7c, 0x03, 0x67, 0x45, 0xfa, 0x22, 0xe7,
+    0xe9, 0xb7, 0x37, 0x3b
+};
+
+static const u8 T12[] = {
+    0xdc, 0xf5, 0x66, 0xff, 0x29, 0x1c, 0x25, 0xbb,
+    0xb8, 0x56, 0x8f, 0xc3, 0xd3, 0x76, 0xa6, 0xd9
+};
+
+/* Test Case 13 */
+static const u8 K13[32], P13[] = { 0 }, A13[] = { 0 }, IV13[12], C13[] = { 0 };
+static const u8 T13[] = {
+    0x53, 0x0f, 0x8a, 0xfb, 0xc7, 0x45, 0x36, 0xb9,
+    0xa9, 0x63, 0xb4, 0xf1, 0xc4, 0xcb, 0x73, 0x8b
+};
+
+/* Test Case 14 */
+# define K14 K13
+# define A14 A13
+static const u8 P14[16], IV14[12];
+static const u8 C14[] = {
+    0xce, 0xa7, 0x40, 0x3d, 0x4d, 0x60, 0x6b, 0x6e,
+    0x07, 0x4e, 0xc5, 0xd3, 0xba, 0xf3, 0x9d, 0x18
+};
+
+static const u8 T14[] = {
+    0xd0, 0xd1, 0xc8, 0xa7, 0x99, 0x99, 0x6b, 0xf0,
+    0x26, 0x5b, 0x98, 0xb5, 0xd4, 0x8a, 0xb9, 0x19
+};
+
+/* Test Case 15 */
+# define A15 A14
+static const u8 K15[] = {
+    0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+    0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
+    0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+    0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
+};
+
+static const u8 P15[] = {
+    0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
+    0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
+    0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
+    0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
+    0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
+    0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
+    0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
+    0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55
+};
+
+static const u8 IV15[] = {
+    0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
+    0xde, 0xca, 0xf8, 0x88
+};
+
+static const u8 C15[] = {
+    0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07,
+    0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d,
+    0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9,
+    0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa,
+    0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d,
+    0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38,
+    0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a,
+    0xbc, 0xc9, 0xf6, 0x62, 0x89, 0x80, 0x15, 0xad
+};
+
+static const u8 T15[] = {
+    0xb0, 0x94, 0xda, 0xc5, 0xd9, 0x34, 0x71, 0xbd,
+    0xec, 0x1a, 0x50, 0x22, 0x70, 0xe3, 0xcc, 0x6c
+};
+
+/* Test Case 16 */
+# define K16 K15
+# define IV16 IV15
+static const u8 P16[] = {
+    0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
+    0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
+    0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
+    0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
+    0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
+    0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
+    0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
+    0xba, 0x63, 0x7b, 0x39
+};
+
+static const u8 A16[] = {
+    0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
+    0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
+    0xab, 0xad, 0xda, 0xd2
+};
+
+static const u8 C16[] = {
+    0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07,
+    0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d,
+    0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9,
+    0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa,
+    0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d,
+    0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38,
+    0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a,
+    0xbc, 0xc9, 0xf6, 0x62
+};
+
+static const u8 T16[] = {
+    0x76, 0xfc, 0x6e, 0xce, 0x0f, 0x4e, 0x17, 0x68,
+    0xcd, 0xdf, 0x88, 0x53, 0xbb, 0x2d, 0x55, 0x1b
+};
+
+/* Test Case 17 */
+# define K17 K16
+# define P17 P16
+# define A17 A16
+static const u8 IV17[] = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad };
+
+static const u8 C17[] = {
+    0xc3, 0x76, 0x2d, 0xf1, 0xca, 0x78, 0x7d, 0x32,
+    0xae, 0x47, 0xc1, 0x3b, 0xf1, 0x98, 0x44, 0xcb,
+    0xaf, 0x1a, 0xe1, 0x4d, 0x0b, 0x97, 0x6a, 0xfa,
+    0xc5, 0x2f, 0xf7, 0xd7, 0x9b, 0xba, 0x9d, 0xe0,
+    0xfe, 0xb5, 0x82, 0xd3, 0x39, 0x34, 0xa4, 0xf0,
+    0x95, 0x4c, 0xc2, 0x36, 0x3b, 0xc7, 0x3f, 0x78,
+    0x62, 0xac, 0x43, 0x0e, 0x64, 0xab, 0xe4, 0x99,
+    0xf4, 0x7c, 0x9b, 0x1f
+};
+
+static const u8 T17[] = {
+    0x3a, 0x33, 0x7d, 0xbf, 0x46, 0xa7, 0x92, 0xc4,
+    0x5e, 0x45, 0x49, 0x13, 0xfe, 0x2e, 0xa8, 0xf2
+};
+
+/* Test Case 18 */
+# define K18 K17
+# define P18 P17
+# define A18 A17
+static const u8 IV18[] = {
+    0x93, 0x13, 0x22, 0x5d, 0xf8, 0x84, 0x06, 0xe5,
+    0x55, 0x90, 0x9c, 0x5a, 0xff, 0x52, 0x69, 0xaa,
+    0x6a, 0x7a, 0x95, 0x38, 0x53, 0x4f, 0x7d, 0xa1,
+    0xe4, 0xc3, 0x03, 0xd2, 0xa3, 0x18, 0xa7, 0x28,
+    0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39,
+    0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54,
+    0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57,
+    0xa6, 0x37, 0xb3, 0x9b
+};
+
+static const u8 C18[] = {
+    0x5a, 0x8d, 0xef, 0x2f, 0x0c, 0x9e, 0x53, 0xf1,
+    0xf7, 0x5d, 0x78, 0x53, 0x65, 0x9e, 0x2a, 0x20,
+    0xee, 0xb2, 0xb2, 0x2a, 0xaf, 0xde, 0x64, 0x19,
+    0xa0, 0x58, 0xab, 0x4f, 0x6f, 0x74, 0x6b, 0xf4,
+    0x0f, 0xc0, 0xc3, 0xb7, 0x80, 0xf2, 0x44, 0x45,
+    0x2d, 0xa3, 0xeb, 0xf1, 0xc5, 0xd8, 0x2c, 0xde,
+    0xa2, 0x41, 0x89, 0x97, 0x20, 0x0e, 0xf8, 0x2e,
+    0x44, 0xae, 0x7e, 0x3f
+};
+
+static const u8 T18[] = {
+    0xa4, 0x4a, 0x82, 0x66, 0xee, 0x1c, 0x8e, 0xb0,
+    0xc8, 0xb5, 0xd4, 0xcf, 0x5a, 0xe9, 0xf1, 0x9a
+};
+
+/* Test Case 19 */
+# define K19 K1
+# define P19 P1
+# define IV19 IV1
+# define C19 C1
+static const u8 A19[] = {
+    0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
+    0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
+    0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
+    0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
+    0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
+    0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
+    0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
+    0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55,
+    0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07,
+    0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d,
+    0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9,
+    0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa,
+    0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d,
+    0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38,
+    0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a,
+    0xbc, 0xc9, 0xf6, 0x62, 0x89, 0x80, 0x15, 0xad
+};
+
+static const u8 T19[] = {
+    0x5f, 0xea, 0x79, 0x3a, 0x2d, 0x6f, 0x97, 0x4d,
+    0x37, 0xe6, 0x8e, 0x0c, 0xb8, 0xff, 0x94, 0x92
+};
+
+/* Test Case 20 */
+# define K20 K1
+# define A20 A1
+/* this results in 0xff in counter LSB */
+static const u8 IV20[64] = { 0xff, 0xff, 0xff, 0xff };
+
+static const u8 P20[288];
+static const u8 C20[] = {
+    0x56, 0xb3, 0x37, 0x3c, 0xa9, 0xef, 0x6e, 0x4a,
+    0x2b, 0x64, 0xfe, 0x1e, 0x9a, 0x17, 0xb6, 0x14,
+    0x25, 0xf1, 0x0d, 0x47, 0xa7, 0x5a, 0x5f, 0xce,
+    0x13, 0xef, 0xc6, 0xbc, 0x78, 0x4a, 0xf2, 0x4f,
+    0x41, 0x41, 0xbd, 0xd4, 0x8c, 0xf7, 0xc7, 0x70,
+    0x88, 0x7a, 0xfd, 0x57, 0x3c, 0xca, 0x54, 0x18,
+    0xa9, 0xae, 0xff, 0xcd, 0x7c, 0x5c, 0xed, 0xdf,
+    0xc6, 0xa7, 0x83, 0x97, 0xb9, 0xa8, 0x5b, 0x49,
+    0x9d, 0xa5, 0x58, 0x25, 0x72, 0x67, 0xca, 0xab,
+    0x2a, 0xd0, 0xb2, 0x3c, 0xa4, 0x76, 0xa5, 0x3c,
+    0xb1, 0x7f, 0xb4, 0x1c, 0x4b, 0x8b, 0x47, 0x5c,
+    0xb4, 0xf3, 0xf7, 0x16, 0x50, 0x94, 0xc2, 0x29,
+    0xc9, 0xe8, 0xc4, 0xdc, 0x0a, 0x2a, 0x5f, 0xf1,
+    0x90, 0x3e, 0x50, 0x15, 0x11, 0x22, 0x13, 0x76,
+    0xa1, 0xcd, 0xb8, 0x36, 0x4c, 0x50, 0x61, 0xa2,
+    0x0c, 0xae, 0x74, 0xbc, 0x4a, 0xcd, 0x76, 0xce,
+    0xb0, 0xab, 0xc9, 0xfd, 0x32, 0x17, 0xef, 0x9f,
+    0x8c, 0x90, 0xbe, 0x40, 0x2d, 0xdf, 0x6d, 0x86,
+    0x97, 0xf4, 0xf8, 0x80, 0xdf, 0xf1, 0x5b, 0xfb,
+    0x7a, 0x6b, 0x28, 0x24, 0x1e, 0xc8, 0xfe, 0x18,
+    0x3c, 0x2d, 0x59, 0xe3, 0xf9, 0xdf, 0xff, 0x65,
+    0x3c, 0x71, 0x26, 0xf0, 0xac, 0xb9, 0xe6, 0x42,
+    0x11, 0xf4, 0x2b, 0xae, 0x12, 0xaf, 0x46, 0x2b,
+    0x10, 0x70, 0xbe, 0xf1, 0xab, 0x5e, 0x36, 0x06,
+    0x87, 0x2c, 0xa1, 0x0d, 0xee, 0x15, 0xb3, 0x24,
+    0x9b, 0x1a, 0x1b, 0x95, 0x8f, 0x23, 0x13, 0x4c,
+    0x4b, 0xcc, 0xb7, 0xd0, 0x32, 0x00, 0xbc, 0xe4,
+    0x20, 0xa2, 0xf8, 0xeb, 0x66, 0xdc, 0xf3, 0x64,
+    0x4d, 0x14, 0x23, 0xc1, 0xb5, 0x69, 0x90, 0x03,
+    0xc1, 0x3e, 0xce, 0xf4, 0xbf, 0x38, 0xa3, 0xb6,
+    0x0e, 0xed, 0xc3, 0x40, 0x33, 0xba, 0xc1, 0x90,
+    0x27, 0x83, 0xdc, 0x6d, 0x89, 0xe2, 0xe7, 0x74,
+    0x18, 0x8a, 0x43, 0x9c, 0x7e, 0xbc, 0xc0, 0x67,
+    0x2d, 0xbd, 0xa4, 0xdd, 0xcf, 0xb2, 0x79, 0x46,
+    0x13, 0xb0, 0xbe, 0x41, 0x31, 0x5e, 0xf7, 0x78,
+    0x70, 0x8a, 0x70, 0xee, 0x7d, 0x75, 0x16, 0x5c
+};
+
+static const u8 T20[] = {
+    0x8b, 0x30, 0x7f, 0x6b, 0x33, 0x28, 0x6d, 0x0a,
+    0xb0, 0x26, 0xa9, 0xed, 0x3f, 0xe1, 0xe8, 0x5f
+};
+
+#define GCM128_TEST_VECTOR(n)                   \
+    {                                           \
+        {sizeof(K##n), K##n},                   \
+        {sizeof(IV##n), IV##n},                 \
+        {sizeof(A##n), A##n},                   \
+        {sizeof(P##n), P##n},                   \
+        {sizeof(C##n), C##n},                   \
+        {sizeof(T##n), T##n}                    \
+    }
+static struct gcm128_data {
+    const SIZED_DATA K;
+    const SIZED_DATA IV;
+    const SIZED_DATA A;
+    const SIZED_DATA P;
+    const SIZED_DATA C;
+    const SIZED_DATA T;
+} gcm128_vectors[] = {
+    GCM128_TEST_VECTOR(1),
+    GCM128_TEST_VECTOR(2),
+    GCM128_TEST_VECTOR(3),
+    GCM128_TEST_VECTOR(4),
+    GCM128_TEST_VECTOR(5),
+    GCM128_TEST_VECTOR(6),
+    GCM128_TEST_VECTOR(7),
+    GCM128_TEST_VECTOR(8),
+    GCM128_TEST_VECTOR(9),
+    GCM128_TEST_VECTOR(10),
+    GCM128_TEST_VECTOR(11),
+    GCM128_TEST_VECTOR(12),
+    GCM128_TEST_VECTOR(13),
+    GCM128_TEST_VECTOR(14),
+    GCM128_TEST_VECTOR(15),
+    GCM128_TEST_VECTOR(16),
+    GCM128_TEST_VECTOR(17),
+    GCM128_TEST_VECTOR(18),
+    GCM128_TEST_VECTOR(19),
+    GCM128_TEST_VECTOR(20)
+};
+
+static int drive_gcm128_tests(int idx)
+{
+    SETUP_TEST_FIXTURE(GCM128_FIXTURE, setup_gcm128);
+    fixture.num = idx;
+    fixture.K.size = gcm128_vectors[idx].K.size;
+    fixture.K.data = fixture.K.size == 1 ? NULL : gcm128_vectors[idx].K.data;
+    fixture.IV.size = gcm128_vectors[idx].IV.size;
+    fixture.IV.data = fixture.IV.size == 1 ? NULL : gcm128_vectors[idx].IV.data;
+    fixture.A.size = gcm128_vectors[idx].A.size;
+    fixture.A.data = fixture.A.size == 1 ? NULL : gcm128_vectors[idx].A.data;
+    fixture.P.size = gcm128_vectors[idx].P.size;
+    fixture.P.data = fixture.P.size == 1 ? NULL : gcm128_vectors[idx].P.data;
+    fixture.C.size = gcm128_vectors[idx].C.size;
+    fixture.C.data = fixture.C.size == 1 ? NULL : gcm128_vectors[idx].C.data;
+    fixture.T.size = gcm128_vectors[idx].T.size;
+    fixture.T.data = fixture.T.size == 1 ? NULL : gcm128_vectors[idx].T.data;
+    EXECUTE_TEST(execute_gcm128, teardown_gcm128);
+}
+
+int main(int argc, char **argv)
+{
+    int result = 0;
+    int iter_argv;
+    int benchmark = 0;
+
+    for (iter_argv = 1; iter_argv < argc; iter_argv++) {
+        if (strcmp(argv[iter_argv], "-b") == 0)
+            benchmark = 1;
+        else if (strcmp(argv[iter_argv], "-h") == 0)
+            goto help;
+    }
+
+    ADD_ALL_TESTS(drive_cts128_tests, OSSL_NELEM(cts128_vectors));
+    ADD_ALL_TESTS(drive_cts128_nist_tests, OSSL_NELEM(cts128_vectors));
+    ADD_ALL_TESTS(drive_gcm128_tests, OSSL_NELEM(gcm128_vectors));
+
+    result = run_tests(argv[0]);
+
+    if (benchmark)
+        benchmark_gcm128(K1, sizeof(K1), IV1, sizeof(IV1));
+
+    return result;
+
+ help:
+    printf("-h\tThis help\n");
+    printf("-b\tBenchmark gcm128 in addition to the tests\n");
+
+    return 0;
+}
diff --git a/test/poly1305_internal_test.c b/test/poly1305_internal_test.c
new file mode 100644
index 0000000..e5e7457
--- /dev/null
+++ b/test/poly1305_internal_test.c
@@ -0,0 +1,1701 @@
+/*
+ * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the OpenSSL license (the "License").  You may not use
+ * this file except in compliance with the License.  You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+/* Internal tests for the poly1305 module */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "testutil.h"
+#include "internal/poly1305.h"
+#include "../crypto/poly1305/poly1305_local.h"
+#include "e_os.h"
+
+typedef struct {
+    size_t size;
+    const unsigned char data[1024];
+} SIZED_DATA;
+
+typedef struct {
+    SIZED_DATA input;
+    SIZED_DATA key;
+    SIZED_DATA expected;
+} TESTDATA;
+
+typedef struct {
+    const char *test_case_name;
+    int test_num;
+    const TESTDATA *test_data;
+} SIMPLE_FIXTURE;
+
+/**********************************************************************
+ *
+ * Test of poly1305 internal functions
+ *
+ ***/
+
+static SIMPLE_FIXTURE setup_poly1305(const char *const test_case_name)
+{
+    SIMPLE_FIXTURE fixture;
+    fixture.test_case_name = test_case_name;
+    return fixture;
+}
+
+/* TODO : hex decoder / encoder should be implemented in testutil.c */
+static void hexdump(const unsigned char *a, size_t len)
+{
+    size_t i;
+
+    for (i = 0; i < len; i++)
+        fprintf(stderr, "%02x", a[i]);
+}
+
+static int execute_poly1305(SIMPLE_FIXTURE fixture)
+{
+    POLY1305 poly1305;
+    unsigned int i = fixture.test_num;
+    const TESTDATA *test = fixture.test_data;
+    const unsigned char *in = test->input.data;
+    size_t inlen = test->input.size;
+    const unsigned char *key = test->key.data;
+    const unsigned char *expected = test->expected.data;
+    size_t expectedlen = test->expected.size;
+    unsigned char out[16];
+
+    if (expectedlen != sizeof(out))
+        return 0;
+
+    Poly1305_Init(&poly1305, key);
+    Poly1305_Update(&poly1305, in, inlen);
+    Poly1305_Final(&poly1305, out);
+
+    if (memcmp(out, expected, expectedlen) != 0) {
+        fprintf(stderr, "Poly1305 test #%d failed.\n", i);
+        fprintf(stderr, "got:      ");
+        hexdump(out, sizeof(out));
+        fprintf(stderr, "\nexpected: ");
+        hexdump(expected, expectedlen);
+        fprintf(stderr, "\n");
+        return 0;
+    }
+
+    if (inlen > 16) {
+        Poly1305_Init(&poly1305, key);
+        Poly1305_Update(&poly1305, in, 1);
+        Poly1305_Update(&poly1305, in+1, inlen-1);
+        Poly1305_Final(&poly1305, out);
+
+        if (memcmp(out, expected, expectedlen) != 0) {
+            fprintf(stderr, "Poly1305 test #%d/1+(N-1) failed.\n", i);
+            fprintf(stderr, "got:      ");
+            hexdump(out, sizeof(out));
+            fprintf(stderr, "\nexpected: ");
+            hexdump(expected, expectedlen);
+            fprintf(stderr, "\n");
+            return 0;
+        }
+    }
+
+    if (inlen > 32) {
+        size_t half = inlen / 2;
+
+        Poly1305_Init(&poly1305, key);
+        Poly1305_Update(&poly1305, in, half);
+        Poly1305_Update(&poly1305, in+half, inlen-half);
+        Poly1305_Final(&poly1305, out);
+
+        if (memcmp(out, expected, expectedlen) != 0) {
+            fprintf(stderr, "Poly1305 test #%d/2 failed.\n", i);
+            fprintf(stderr, "got:      ");
+            hexdump(out, sizeof(out));
+            fprintf(stderr, "\nexpected: ");
+            hexdump(expected, expectedlen);
+            fprintf(stderr, "\n");
+            return 0;
+        }
+
+        for (half = 16; half < inlen; half += 16) {
+            Poly1305_Init(&poly1305, key);
+            Poly1305_Update(&poly1305, in, half);
+            Poly1305_Update(&poly1305, in+half, inlen-half);
+            Poly1305_Final(&poly1305, out);
+
+            if (memcmp(out, expected, expectedlen) != 0) {
+                fprintf(stderr, "Poly1305 test #%d/%" OSSLzu "+%" OSSLzu " failed.\n",
+                       i, half, inlen-half);
+                fprintf(stderr, "got:      ");
+                hexdump(out, sizeof(out));
+                fprintf(stderr, "\nexpected: ");
+                hexdump(expected, expectedlen);
+                fprintf(stderr, "\n");
+                return 0;
+            }
+        }
+    }
+
+    return 1;
+}
+
+static void teardown_poly1305(SIMPLE_FIXTURE fixture)
+{
+    ERR_print_errors_fp(stderr);
+}
+
+static void benchmark_poly1305()
+{
+# ifdef OPENSSL_CPUID_OBJ
+    POLY1305 poly1305;
+    unsigned char key[32];
+    unsigned char buf[8192];
+    unsigned long long stopwatch;
+    unsigned long long OPENSSL_rdtsc();
+    unsigned int i;
+
+    memset (buf,0x55,sizeof(buf));
+    memset (key,0xAA,sizeof(key));
+
+    Poly1305_Init(&poly1305, key);
+
+    for (i=0;i<100000;i++)
+        Poly1305_Update(&poly1305,buf,sizeof(buf));
+
+    stopwatch = OPENSSL_rdtsc();
+    for (i=0;i<10000;i++)
+        Poly1305_Update(&poly1305,buf,sizeof(buf));
+    stopwatch = OPENSSL_rdtsc() - stopwatch;
+
+    printf("%g\n",stopwatch/(double)(i*sizeof(buf)));
+
+    stopwatch = OPENSSL_rdtsc();
+    for (i=0;i<10000;i++) {
+        Poly1305_Init(&poly1305, key);
+        Poly1305_Update(&poly1305,buf,16);
+        Poly1305_Final(&poly1305,buf);
+    }
+    stopwatch = OPENSSL_rdtsc() - stopwatch;
+
+    printf("%g\n",stopwatch/(double)(i));
+# else
+    fprintf(stderr,
+            "Benchmarking of poly1305 isn't available on this platform\n");
+# endif
+}
+
+/**********************************************************************
+ *
+ * Test driver
+ *
+ ***/
+
+static TESTDATA tests[] = {
+    /*
+     * RFC7539
+     */
+    {
+        {
+            34,
+            {
+                0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x67, 0x72,
+                0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x46, 0x6f,
+                0x72, 0x75, 0x6d, 0x20, 0x52, 0x65, 0x73, 0x65,
+                0x61, 0x72, 0x63, 0x68, 0x20, 0x47, 0x72, 0x6f,
+
+                0x75, 0x70
+            }
+        },
+        {
+            32,
+            {
+                0x85, 0xd6, 0xbe, 0x78, 0x57, 0x55, 0x6d, 0x33,
+                0x7f, 0x44, 0x52, 0xfe, 0x42, 0xd5, 0x06, 0xa8,
+                0x01, 0x03, 0x80, 0x8a, 0xfb, 0x0d, 0xb2, 0xfd,
+                0x4a, 0xbf, 0xf6, 0xaf, 0x41, 0x49, 0xf5, 0x1b
+            }
+        },
+        {
+            16,
+            {
+                0xa8, 0x06, 0x1d, 0xc1, 0x30, 0x51, 0x36, 0xc6,
+                0xc2, 0x2b, 0x8b, 0xaf, 0x0c, 0x01, 0x27, 0xa9
+            }
+        }
+    },
+    /*
+     * test vectors from "The Poly1305-AES message-authentication code"
+     */
+    {
+        {
+            2,
+            {
+                0xf3, 0xf6
+            }
+        },
+        {
+            32,
+            {
+                0x85, 0x1f, 0xc4, 0x0c, 0x34, 0x67, 0xac, 0x0b,
+                0xe0, 0x5c, 0xc2, 0x04, 0x04, 0xf3, 0xf7, 0x00,
+                0x58, 0x0b, 0x3b, 0x0f, 0x94, 0x47, 0xbb, 0x1e,
+                0x69, 0xd0, 0x95, 0xb5, 0x92, 0x8b, 0x6d, 0xbc
+            }
+        },
+        {
+            16,
+            {
+                0xf4, 0xc6, 0x33, 0xc3, 0x04, 0x4f, 0xc1, 0x45,
+                0xf8, 0x4f, 0x33, 0x5c, 0xb8, 0x19, 0x53, 0xde
+            }
+        }
+    },
+    {
+        {
+            0,
+            {
+                0
+            }
+        },
+        {
+            32,
+            {
+                0xa0, 0xf3, 0x08, 0x00, 0x00, 0xf4, 0x64, 0x00,
+                0xd0, 0xc7, 0xe9, 0x07, 0x6c, 0x83, 0x44, 0x03,
+                0xdd, 0x3f, 0xab, 0x22, 0x51, 0xf1, 0x1a, 0xc7,
+                0x59, 0xf0, 0x88, 0x71, 0x29, 0xcc, 0x2e, 0xe7
+            }
+        },
+        {
+            16,
+            {
+                0xdd, 0x3f, 0xab, 0x22, 0x51, 0xf1, 0x1a, 0xc7,
+                0x59, 0xf0, 0x88, 0x71, 0x29, 0xcc, 0x2e, 0xe7
+            }
+        }
+    },
+    {
+        {
+            32,
+            {
+                0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
+                0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
+                0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
+                0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36
+            }
+        },
+        {
+            32,
+            {
+                0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
+                0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
+                0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
+                0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef
+            }
+        },
+        {
+            16,
+            {
+                0x0e, 0xe1, 0xc1, 0x6b, 0xb7, 0x3f, 0x0f, 0x4f,
+                0xd1, 0x98, 0x81, 0x75, 0x3c, 0x01, 0xcd, 0xbe
+            }
+        }
+    },
+    {
+        {
+            63,
+            {
+                0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
+                0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
+                0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
+                0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
+
+                0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
+                0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
+                0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
+                0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9
+            }
+        },
+        {
+            32,
+            {
+                0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
+                0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
+                0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
+                0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
+            }
+        },
+        {
+            16,
+            {
+                0x51, 0x54, 0xad, 0x0d, 0x2c, 0xb2, 0x6e, 0x01,
+                0x27, 0x4f, 0xc5, 0x11, 0x48, 0x49, 0x1f, 0x1b
+            }
+        },
+    },
+    /*
+     * self-generated vectors exercise "significant" lengths, such that
+     * are handled by different code paths
+     */
+    {
+        {
+            64,
+            {
+                0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
+                0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
+                0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
+                0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
+
+                0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
+                0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
+                0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
+                0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf
+            }
+        },
+        {
+            32,
+            {
+                0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
+                0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
+                0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
+                0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
+            }
+        },
+        {
+            16,
+            {
+                0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
+                0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66
+            }
+        },
+    },
+    {
+        {
+            48,
+            {
+                0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
+                0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
+                0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
+                0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
+
+                0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
+                0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67
+            }
+        },
+        {
+            32,
+            {
+                0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
+                0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
+                0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
+                0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
+
+            }
+        },
+        {
+            16,
+            {
+                0x5b, 0x88, 0xd7, 0xf6, 0x22, 0x8b, 0x11, 0xe2,
+                0xe2, 0x85, 0x79, 0xa5, 0xc0, 0xc1, 0xf7, 0x61
+            }
+        },
+    },
+    {
+        {
+            96,
+            {
+                0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
+                0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
+                0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
+                0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
+
+                0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
+                0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
+                0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
+                0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
+
+                0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
+                0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
+                0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
+                0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36
+            }
+        },
+        {
+            32,
+            {
+                0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
+                0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
+                0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
+                0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
+            }
+        },
+        {
+            16,
+            {
+                0xbb, 0xb6, 0x13, 0xb2, 0xb6, 0xd7, 0x53, 0xba,
+                0x07, 0x39, 0x5b, 0x91, 0x6a, 0xae, 0xce, 0x15
+            }
+        },
+    },
+    {
+        {
+            112,
+            {
+                0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
+                0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
+                0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
+                0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
+
+                0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
+                0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
+                0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
+                0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
+
+                0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
+                0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
+                0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
+                0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
+
+                0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
+                0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24
+            }
+        },
+        {
+            32,
+            {
+                0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
+                0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
+                0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
+                0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
+            }
+        },
+        {
+            16,
+            {
+                0xc7, 0x94, 0xd7, 0x05, 0x7d, 0x17, 0x78, 0xc4,
+                0xbb, 0xee, 0x0a, 0x39, 0xb3, 0xd9, 0x73, 0x42
+            }
+        },
+    },
+    {
+        {
+            128,
+            {
+                0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
+                0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
+                0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
+                0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
+
+                0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
+                0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
+                0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
+                0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
+
+                0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
+                0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
+                0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
+                0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
+
+                0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
+                0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
+                0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
+                0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36
+            }
+        },
+        {
+            32,
+            {
+                0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
+                0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
+                0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
+                0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
+            }
+        },
+        {
+            16,
+            {
+                0xff, 0xbc, 0xb9, 0xb3, 0x71, 0x42, 0x31, 0x52,
+                0xd7, 0xfc, 0xa5, 0xad, 0x04, 0x2f, 0xba, 0xa9
+            }
+        },
+    },
+    {
+        {
+            144,
+            {
+                0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
+                0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
+                0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
+                0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
+
+                0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
+                0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
+                0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
+                0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
+
+                0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
+                0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
+                0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
+                0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
+
+                0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
+                0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
+                0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
+                0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36,
+
+                0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
+                0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66
+            }
+        },
+        {
+            32,
+            {
+                0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
+                0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
+                0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
+                0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
+            }
+        },
+        {
+            16,
+            {
+                0x06, 0x9e, 0xd6, 0xb8, 0xef, 0x0f, 0x20, 0x7b,
+                0x3e, 0x24, 0x3b, 0xb1, 0x01, 0x9f, 0xe6, 0x32
+            }
+        },
+    },
+    {
+        {
+            160,
+            {
+                0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
+                0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
+                0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
+                0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
+
+                0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
+                0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
+                0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
+                0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
+
+                0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
+                0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
+                0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
+                0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
+
+                0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
+                0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
+                0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
+                0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36,
+
+                0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
+                0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66,
+                0x5b, 0x88, 0xd7, 0xf6, 0x22, 0x8b, 0x11, 0xe2,
+                0xe2, 0x85, 0x79, 0xa5, 0xc0, 0xc1, 0xf7, 0x61
+            }
+        },
+        {
+            32,
+            {
+                0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
+                0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
+                0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
+                0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
+            }
+        },
+        {
+            16,
+            {
+                0xcc, 0xa3, 0x39, 0xd9, 0xa4, 0x5f, 0xa2, 0x36,
+                0x8c, 0x2c, 0x68, 0xb3, 0xa4, 0x17, 0x91, 0x33
+            }
+        },
+    },
+    {
+        {
+            288,
+            {
+                0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
+                0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
+                0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
+                0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
+
+                0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
+                0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
+                0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
+                0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
+
+                0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
+                0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
+                0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
+                0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
+
+                0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
+                0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
+                0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
+                0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36,
+
+                0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
+                0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66,
+                0x5b, 0x88, 0xd7, 0xf6, 0x22, 0x8b, 0x11, 0xe2,
+                0xe2, 0x85, 0x79, 0xa5, 0xc0, 0xc1, 0xf7, 0x61,
+
+                0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
+                0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
+                0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
+                0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
+
+                0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
+                0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
+                0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
+                0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
+
+                0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
+                0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
+                0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
+                0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
+
+                0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
+                0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
+                0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
+                0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36
+            }
+        },
+        {
+            32,
+            {
+                0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
+                0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
+                0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
+                0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
+            }
+        },
+        {
+            16,
+            {
+                0x53, 0xf6, 0xe8, 0x28, 0xa2, 0xf0, 0xfe, 0x0e,
+                0xe8, 0x15, 0xbf, 0x0b, 0xd5, 0x84, 0x1a, 0x34
+            }
+        },
+    },
+    {
+        {
+            320,
+            {
+                0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
+                0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
+                0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
+                0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
+
+                0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
+                0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
+                0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
+                0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
+
+                0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
+                0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
+                0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
+                0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
+
+                0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
+                0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
+                0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
+                0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36,
+
+                0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
+                0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66,
+                0x5b, 0x88, 0xd7, 0xf6, 0x22, 0x8b, 0x11, 0xe2,
+                0xe2, 0x85, 0x79, 0xa5, 0xc0, 0xc1, 0xf7, 0x61,
+
+                0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
+                0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
+                0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
+                0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
+
+                0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
+                0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
+                0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
+                0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
+
+                0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
+                0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
+                0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
+                0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
+
+                0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
+                0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
+                0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
+                0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36,
+
+                0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
+                0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66,
+                0x5b, 0x88, 0xd7, 0xf6, 0x22, 0x8b, 0x11, 0xe2,
+                0xe2, 0x85, 0x79, 0xa5, 0xc0, 0xc1, 0xf7, 0x61
+            }
+        },
+        {
+            32,
+            {
+                0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
+                0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
+                0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
+                0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
+            }
+        },
+        {
+            16,
+            {
+                0xb8, 0x46, 0xd4, 0x4e, 0x9b, 0xbd, 0x53, 0xce,
+                0xdf, 0xfb, 0xfb, 0xb6, 0xb7, 0xfa, 0x49, 0x33
+            }
+        },
+    },
+    /*
+     * 4th power of the key spills to 131th bit in SIMD key setup
+     */
+    {
+        {
+            256,
+            {
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+            }
+        },
+        {
+            32,
+            {
+                0xad, 0x62, 0x81, 0x07, 0xe8, 0x35, 0x1d, 0x0f,
+                0x2c, 0x23, 0x1a, 0x05, 0xdc, 0x4a, 0x41, 0x06,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+            }
+        },
+        {
+            16,
+            {
+                0x07, 0x14, 0x5a, 0x4c, 0x02, 0xfe, 0x5f, 0xa3,
+                0x20, 0x36, 0xde, 0x68, 0xfa, 0xbe, 0x90, 0x66
+            }
+        },
+    },
+    /*
+     * poly1305_ieee754.c failed this in final stage
+     */
+    {
+        {
+            252,
+            {
+                0x84, 0x23, 0x64, 0xe1, 0x56, 0x33, 0x6c, 0x09,
+                0x98, 0xb9, 0x33, 0xa6, 0x23, 0x77, 0x26, 0x18,
+                0x0d, 0x9e, 0x3f, 0xdc, 0xbd, 0xe4, 0xcd, 0x5d,
+                0x17, 0x08, 0x0f, 0xc3, 0xbe, 0xb4, 0x96, 0x14,
+
+                0xd7, 0x12, 0x2c, 0x03, 0x74, 0x63, 0xff, 0x10,
+                0x4d, 0x73, 0xf1, 0x9c, 0x12, 0x70, 0x46, 0x28,
+                0xd4, 0x17, 0xc4, 0xc5, 0x4a, 0x3f, 0xe3, 0x0d,
+                0x3c, 0x3d, 0x77, 0x14, 0x38, 0x2d, 0x43, 0xb0,
+
+                0x38, 0x2a, 0x50, 0xa5, 0xde, 0xe5, 0x4b, 0xe8,
+                0x44, 0xb0, 0x76, 0xe8, 0xdf, 0x88, 0x20, 0x1a,
+                0x1c, 0xd4, 0x3b, 0x90, 0xeb, 0x21, 0x64, 0x3f,
+                0xa9, 0x6f, 0x39, 0xb5, 0x18, 0xaa, 0x83, 0x40,
+
+                0xc9, 0x42, 0xff, 0x3c, 0x31, 0xba, 0xf7, 0xc9,
+                0xbd, 0xbf, 0x0f, 0x31, 0xae, 0x3f, 0xa0, 0x96,
+                0xbf, 0x8c, 0x63, 0x03, 0x06, 0x09, 0x82, 0x9f,
+                0xe7, 0x2e, 0x17, 0x98, 0x24, 0x89, 0x0b, 0xc8,
+
+                0xe0, 0x8c, 0x31, 0x5c, 0x1c, 0xce, 0x2a, 0x83,
+                0x14, 0x4d, 0xbb, 0xff, 0x09, 0xf7, 0x4e, 0x3e,
+                0xfc, 0x77, 0x0b, 0x54, 0xd0, 0x98, 0x4a, 0x8f,
+                0x19, 0xb1, 0x47, 0x19, 0xe6, 0x36, 0x35, 0x64,
+
+                0x1d, 0x6b, 0x1e, 0xed, 0xf6, 0x3e, 0xfb, 0xf0,
+                0x80, 0xe1, 0x78, 0x3d, 0x32, 0x44, 0x54, 0x12,
+                0x11, 0x4c, 0x20, 0xde, 0x0b, 0x83, 0x7a, 0x0d,
+                0xfa, 0x33, 0xd6, 0xb8, 0x28, 0x25, 0xff, 0xf4,
+
+                0x4c, 0x9a, 0x70, 0xea, 0x54, 0xce, 0x47, 0xf0,
+                0x7d, 0xf6, 0x98, 0xe6, 0xb0, 0x33, 0x23, 0xb5,
+                0x30, 0x79, 0x36, 0x4a, 0x5f, 0xc3, 0xe9, 0xdd,
+                0x03, 0x43, 0x92, 0xbd, 0xde, 0x86, 0xdc, 0xcd,
+
+                0xda, 0x94, 0x32, 0x1c, 0x5e, 0x44, 0x06, 0x04,
+                0x89, 0x33, 0x6c, 0xb6, 0x5b, 0xf3, 0x98, 0x9c,
+                0x36, 0xf7, 0x28, 0x2c, 0x2f, 0x5d, 0x2b, 0x88,
+                0x2c, 0x17, 0x1e, 0x74
+            }
+        },
+        {
+            32,
+            {
+                0x95, 0xd5, 0xc0, 0x05, 0x50, 0x3e, 0x51, 0x0d,
+                0x8c, 0xd0, 0xaa, 0x07, 0x2c, 0x4a, 0x4d, 0x06,
+                0x6e, 0xab, 0xc5, 0x2d, 0x11, 0x65, 0x3d, 0xf4,
+                0x7f, 0xbf, 0x63, 0xab, 0x19, 0x8b, 0xcc, 0x26
+            }
+        },
+        {
+            16,
+            {
+                0xf2, 0x48, 0x31, 0x2e, 0x57, 0x8d, 0x9d, 0x58,
+                0xf8, 0xb7, 0xbb, 0x4d, 0x19, 0x10, 0x54, 0x31
+            }
+        },
+    },
+    /*
+     * AVX2 in poly1305-x86.pl failed this with 176+32 split
+     */
+    {
+        {
+            208,
+            {
+                0x24, 0x8a, 0xc3, 0x10, 0x85, 0xb6, 0xc2, 0xad,
+                0xaa, 0xa3, 0x82, 0x59, 0xa0, 0xd7, 0x19, 0x2c,
+                0x5c, 0x35, 0xd1, 0xbb, 0x4e, 0xf3, 0x9a, 0xd9,
+                0x4c, 0x38, 0xd1, 0xc8, 0x24, 0x79, 0xe2, 0xdd,
+
+                0x21, 0x59, 0xa0, 0x77, 0x02, 0x4b, 0x05, 0x89,
+                0xbc, 0x8a, 0x20, 0x10, 0x1b, 0x50, 0x6f, 0x0a,
+                0x1a, 0xd0, 0xbb, 0xab, 0x76, 0xe8, 0x3a, 0x83,
+                0xf1, 0xb9, 0x4b, 0xe6, 0xbe, 0xae, 0x74, 0xe8,
+
+                0x74, 0xca, 0xb6, 0x92, 0xc5, 0x96, 0x3a, 0x75,
+                0x43, 0x6b, 0x77, 0x61, 0x21, 0xec, 0x9f, 0x62,
+                0x39, 0x9a, 0x3e, 0x66, 0xb2, 0xd2, 0x27, 0x07,
+                0xda, 0xe8, 0x19, 0x33, 0xb6, 0x27, 0x7f, 0x3c,
+
+                0x85, 0x16, 0xbc, 0xbe, 0x26, 0xdb, 0xbd, 0x86,
+                0xf3, 0x73, 0x10, 0x3d, 0x7c, 0xf4, 0xca, 0xd1,
+                0x88, 0x8c, 0x95, 0x21, 0x18, 0xfb, 0xfb, 0xd0,
+                0xd7, 0xb4, 0xbe, 0xdc, 0x4a, 0xe4, 0x93, 0x6a,
+
+                0xff, 0x91, 0x15, 0x7e, 0x7a, 0xa4, 0x7c, 0x54,
+                0x44, 0x2e, 0xa7, 0x8d, 0x6a, 0xc2, 0x51, 0xd3,
+                0x24, 0xa0, 0xfb, 0xe4, 0x9d, 0x89, 0xcc, 0x35,
+                0x21, 0xb6, 0x6d, 0x16, 0xe9, 0xc6, 0x6a, 0x37,
+
+                0x09, 0x89, 0x4e, 0x4e, 0xb0, 0xa4, 0xee, 0xdc,
+                0x4a, 0xe1, 0x94, 0x68, 0xe6, 0x6b, 0x81, 0xf2,
+
+                0x71, 0x35, 0x1b, 0x1d, 0x92, 0x1e, 0xa5, 0x51,
+                0x04, 0x7a, 0xbc, 0xc6, 0xb8, 0x7a, 0x90, 0x1f,
+                0xde, 0x7d, 0xb7, 0x9f, 0xa1, 0x81, 0x8c, 0x11,
+                0x33, 0x6d, 0xbc, 0x07, 0x24, 0x4a, 0x40, 0xeb
+            }
+        },
+        {
+            32,
+            {
+                0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+            }
+        },
+        {
+            16,
+            {
+                0xbc, 0x93, 0x9b, 0xc5, 0x28, 0x14, 0x80, 0xfa,
+                0x99, 0xc6, 0xd6, 0x8c, 0x25, 0x8e, 0xc4, 0x2f
+            }
+        },
+    },
+    /*
+     * test vectors from Google
+     */
+    {
+        {
+            0,
+            {
+                0x00,
+            }
+        },
+        {
+            32,
+            {
+                0xc8, 0xaf, 0xaa, 0xc3, 0x31, 0xee, 0x37, 0x2c,
+                0xd6, 0x08, 0x2d, 0xe1, 0x34, 0x94, 0x3b, 0x17,
+                0x47, 0x10, 0x13, 0x0e, 0x9f, 0x6f, 0xea, 0x8d,
+                0x72, 0x29, 0x38, 0x50, 0xa6, 0x67, 0xd8, 0x6c
+            }
+        },
+        {
+            16,
+            {
+                0x47, 0x10, 0x13, 0x0e, 0x9f, 0x6f, 0xea, 0x8d,
+                0x72, 0x29, 0x38, 0x50, 0xa6, 0x67, 0xd8, 0x6c
+            }
+        },
+    },
+    {
+        {
+            12,
+            {
+                0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f,
+                0x72, 0x6c, 0x64, 0x21
+            }
+        },
+        {
+            32,
+            {
+                0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
+                0x33, 0x32, 0x2d, 0x62, 0x79, 0x74, 0x65, 0x20,
+                0x6b, 0x65, 0x79, 0x20, 0x66, 0x6f, 0x72, 0x20,
+                0x50, 0x6f, 0x6c, 0x79, 0x31, 0x33, 0x30, 0x35
+            }
+        },
+        {
+            16,
+            {
+                0xa6, 0xf7, 0x45, 0x00, 0x8f, 0x81, 0xc9, 0x16,
+                0xa2, 0x0d, 0xcc, 0x74, 0xee, 0xf2, 0xb2, 0xf0
+            }
+        },
+    },
+    {
+        {
+            32,
+            {
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+            }
+        },
+        {
+            32,
+            {
+                0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
+                0x33, 0x32, 0x2d, 0x62, 0x79, 0x74, 0x65, 0x20,
+                0x6b, 0x65, 0x79, 0x20, 0x66, 0x6f, 0x72, 0x20,
+                0x50, 0x6f, 0x6c, 0x79, 0x31, 0x33, 0x30, 0x35
+            }
+        },
+        {
+            16,
+            {
+                0x49, 0xec, 0x78, 0x09, 0x0e, 0x48, 0x1e, 0xc6,
+                0xc2, 0x6b, 0x33, 0xb9, 0x1c, 0xcc, 0x03, 0x07
+            }
+        },
+    },
+    {
+        {
+            128,
+            {
+                0x89, 0xda, 0xb8, 0x0b, 0x77, 0x17, 0xc1, 0xdb,
+                0x5d, 0xb4, 0x37, 0x86, 0x0a, 0x3f, 0x70, 0x21,
+                0x8e, 0x93, 0xe1, 0xb8, 0xf4, 0x61, 0xfb, 0x67,
+                0x7f, 0x16, 0xf3, 0x5f, 0x6f, 0x87, 0xe2, 0xa9,
+
+                0x1c, 0x99, 0xbc, 0x3a, 0x47, 0xac, 0xe4, 0x76,
+                0x40, 0xcc, 0x95, 0xc3, 0x45, 0xbe, 0x5e, 0xcc,
+                0xa5, 0xa3, 0x52, 0x3c, 0x35, 0xcc, 0x01, 0x89,
+                0x3a, 0xf0, 0xb6, 0x4a, 0x62, 0x03, 0x34, 0x27,
+
+                0x03, 0x72, 0xec, 0x12, 0x48, 0x2d, 0x1b, 0x1e,
+                0x36, 0x35, 0x61, 0x69, 0x8a, 0x57, 0x8b, 0x35,
+                0x98, 0x03, 0x49, 0x5b, 0xb4, 0xe2, 0xef, 0x19,
+                0x30, 0xb1, 0x7a, 0x51, 0x90, 0xb5, 0x80, 0xf1,
+
+                0x41, 0x30, 0x0d, 0xf3, 0x0a, 0xdb, 0xec, 0xa2,
+                0x8f, 0x64, 0x27, 0xa8, 0xbc, 0x1a, 0x99, 0x9f,
+                0xd5, 0x1c, 0x55, 0x4a, 0x01, 0x7d, 0x09, 0x5d,
+                0x8c, 0x3e, 0x31, 0x27, 0xda, 0xf9, 0xf5, 0x95
+            }
+        },
+        {
+            32,
+            {
+                0x2d, 0x77, 0x3b, 0xe3, 0x7a, 0xdb, 0x1e, 0x4d,
+                0x68, 0x3b, 0xf0, 0x07, 0x5e, 0x79, 0xc4, 0xee,
+                0x03, 0x79, 0x18, 0x53, 0x5a, 0x7f, 0x99, 0xcc,
+                0xb7, 0x04, 0x0f, 0xb5, 0xf5, 0xf4, 0x3a, 0xea
+            }
+        },
+        {
+            16,
+            {
+                0xc8, 0x5d, 0x15, 0xed, 0x44, 0xc3, 0x78, 0xd6,
+                0xb0, 0x0e, 0x23, 0x06, 0x4c, 0x7b, 0xcd, 0x51
+            }
+        },
+    },
+    {
+        {
+            528,
+            {
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b,
+                0x17, 0x03, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00,
+
+                0x06, 0xdb, 0x1f, 0x1f, 0x36, 0x8d, 0x69, 0x6a,
+                0x81, 0x0a, 0x34, 0x9c, 0x0c, 0x71, 0x4c, 0x9a,
+                0x5e, 0x78, 0x50, 0xc2, 0x40, 0x7d, 0x72, 0x1a,
+                0xcd, 0xed, 0x95, 0xe0, 0x18, 0xd7, 0xa8, 0x52,
+
+                0x66, 0xa6, 0xe1, 0x28, 0x9c, 0xdb, 0x4a, 0xeb,
+                0x18, 0xda, 0x5a, 0xc8, 0xa2, 0xb0, 0x02, 0x6d,
+                0x24, 0xa5, 0x9a, 0xd4, 0x85, 0x22, 0x7f, 0x3e,
+                0xae, 0xdb, 0xb2, 0xe7, 0xe3, 0x5e, 0x1c, 0x66,
+
+                0xcd, 0x60, 0xf9, 0xab, 0xf7, 0x16, 0xdc, 0xc9,
+                0xac, 0x42, 0x68, 0x2d, 0xd7, 0xda, 0xb2, 0x87,
+                0xa7, 0x02, 0x4c, 0x4e, 0xef, 0xc3, 0x21, 0xcc,
+                0x05, 0x74, 0xe1, 0x67, 0x93, 0xe3, 0x7c, 0xec,
+
+                0x03, 0xc5, 0xbd, 0xa4, 0x2b, 0x54, 0xc1, 0x14,
+                0xa8, 0x0b, 0x57, 0xaf, 0x26, 0x41, 0x6c, 0x7b,
+                0xe7, 0x42, 0x00, 0x5e, 0x20, 0x85, 0x5c, 0x73,
+                0xe2, 0x1d, 0xc8, 0xe2, 0xed, 0xc9, 0xd4, 0x35,
+
+                0xcb, 0x6f, 0x60, 0x59, 0x28, 0x00, 0x11, 0xc2,
+                0x70, 0xb7, 0x15, 0x70, 0x05, 0x1c, 0x1c, 0x9b,
+                0x30, 0x52, 0x12, 0x66, 0x20, 0xbc, 0x1e, 0x27,
+                0x30, 0xfa, 0x06, 0x6c, 0x7a, 0x50, 0x9d, 0x53,
+
+                0xc6, 0x0e, 0x5a, 0xe1, 0xb4, 0x0a, 0xa6, 0xe3,
+                0x9e, 0x49, 0x66, 0x92, 0x28, 0xc9, 0x0e, 0xec,
+                0xb4, 0xa5, 0x0d, 0xb3, 0x2a, 0x50, 0xbc, 0x49,
+                0xe9, 0x0b, 0x4f, 0x4b, 0x35, 0x9a, 0x1d, 0xfd,
+
+                0x11, 0x74, 0x9c, 0xd3, 0x86, 0x7f, 0xcf, 0x2f,
+                0xb7, 0xbb, 0x6c, 0xd4, 0x73, 0x8f, 0x6a, 0x4a,
+                0xd6, 0xf7, 0xca, 0x50, 0x58, 0xf7, 0x61, 0x88,
+                0x45, 0xaf, 0x9f, 0x02, 0x0f, 0x6c, 0x3b, 0x96,
+
+                0x7b, 0x8f, 0x4c, 0xd4, 0xa9, 0x1e, 0x28, 0x13,
+                0xb5, 0x07, 0xae, 0x66, 0xf2, 0xd3, 0x5c, 0x18,
+                0x28, 0x4f, 0x72, 0x92, 0x18, 0x60, 0x62, 0xe1,
+                0x0f, 0xd5, 0x51, 0x0d, 0x18, 0x77, 0x53, 0x51,
+
+                0xef, 0x33, 0x4e, 0x76, 0x34, 0xab, 0x47, 0x43,
+                0xf5, 0xb6, 0x8f, 0x49, 0xad, 0xca, 0xb3, 0x84,
+                0xd3, 0xfd, 0x75, 0xf7, 0x39, 0x0f, 0x40, 0x06,
+                0xef, 0x2a, 0x29, 0x5c, 0x8c, 0x7a, 0x07, 0x6a,
+
+                0xd5, 0x45, 0x46, 0xcd, 0x25, 0xd2, 0x10, 0x7f,
+                0xbe, 0x14, 0x36, 0xc8, 0x40, 0x92, 0x4a, 0xae,
+                0xbe, 0x5b, 0x37, 0x08, 0x93, 0xcd, 0x63, 0xd1,
+                0x32, 0x5b, 0x86, 0x16, 0xfc, 0x48, 0x10, 0x88,
+
+                0x6b, 0xc1, 0x52, 0xc5, 0x32, 0x21, 0xb6, 0xdf,
+                0x37, 0x31, 0x19, 0x39, 0x32, 0x55, 0xee, 0x72,
+                0xbc, 0xaa, 0x88, 0x01, 0x74, 0xf1, 0x71, 0x7f,
+                0x91, 0x84, 0xfa, 0x91, 0x64, 0x6f, 0x17, 0xa2,
+
+                0x4a, 0xc5, 0x5d, 0x16, 0xbf, 0xdd, 0xca, 0x95,
+                0x81, 0xa9, 0x2e, 0xda, 0x47, 0x92, 0x01, 0xf0,
+                0xed, 0xbf, 0x63, 0x36, 0x00, 0xd6, 0x06, 0x6d,
+                0x1a, 0xb3, 0x6d, 0x5d, 0x24, 0x15, 0xd7, 0x13,
+
+                0x51, 0xbb, 0xcd, 0x60, 0x8a, 0x25, 0x10, 0x8d,
+                0x25, 0x64, 0x19, 0x92, 0xc1, 0xf2, 0x6c, 0x53,
+                0x1c, 0xf9, 0xf9, 0x02, 0x03, 0xbc, 0x4c, 0xc1,
+                0x9f, 0x59, 0x27, 0xd8, 0x34, 0xb0, 0xa4, 0x71,
+
+                0x16, 0xd3, 0x88, 0x4b, 0xbb, 0x16, 0x4b, 0x8e,
+                0xc8, 0x83, 0xd1, 0xac, 0x83, 0x2e, 0x56, 0xb3,
+                0x91, 0x8a, 0x98, 0x60, 0x1a, 0x08, 0xd1, 0x71,
+                0x88, 0x15, 0x41, 0xd5, 0x94, 0xdb, 0x39, 0x9c,
+
+                0x6a, 0xe6, 0x15, 0x12, 0x21, 0x74, 0x5a, 0xec,
+                0x81, 0x4c, 0x45, 0xb0, 0xb0, 0x5b, 0x56, 0x54,
+                0x36, 0xfd, 0x6f, 0x13, 0x7a, 0xa1, 0x0a, 0x0c,
+                0x0b, 0x64, 0x37, 0x61, 0xdb, 0xd6, 0xf9, 0xa9,
+
+                0xdc, 0xb9, 0x9b, 0x1a, 0x6e, 0x69, 0x08, 0x54,
+                0xce, 0x07, 0x69, 0xcd, 0xe3, 0x97, 0x61, 0xd8,
+                0x2f, 0xcd, 0xec, 0x15, 0xf0, 0xd9, 0x2d, 0x7d,
+                0x8e, 0x94, 0xad, 0xe8, 0xeb, 0x83, 0xfb, 0xe0
+            }
+        },
+        {
+            32,
+            {
+                0x99, 0xe5, 0x82, 0x2d, 0xd4, 0x17, 0x3c, 0x99,
+                0x5e, 0x3d, 0xae, 0x0d, 0xde, 0xfb, 0x97, 0x74,
+                0x3f, 0xde, 0x3b, 0x08, 0x01, 0x34, 0xb3, 0x9f,
+                0x76, 0xe9, 0xbf, 0x8d, 0x0e, 0x88, 0xd5, 0x46
+            }
+        },
+        {
+            16,
+            {
+                0x26, 0x37, 0x40, 0x8f, 0xe1, 0x30, 0x86, 0xea,
+                0x73, 0xf9, 0x71, 0xe3, 0x42, 0x5e, 0x28, 0x20
+            }
+        },
+    },
+    /*
+     * test vectors from Hanno Böck
+     */
+    {
+        {
+            257,
+            {
+                0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
+                0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
+                0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
+                0xcc, 0x80, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
+
+                0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
+                0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
+                0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
+                0xcc, 0xcc, 0xcc, 0xcc, 0xce, 0xcc, 0xcc, 0xcc,
+
+                0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
+                0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xc5,
+                0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
+                0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
+
+                0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xe3, 0xcc, 0xcc,
+                0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
+                0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
+                0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
+
+                0xcc, 0xcc, 0xcc, 0xcc, 0xac, 0xcc, 0xcc, 0xcc,
+                0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xe6,
+                0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x00, 0x00, 0x00,
+                0xaf, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
+
+                0xcc, 0xcc, 0xff, 0xff, 0xff, 0xf5, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+                0x00, 0xff, 0xff, 0xff, 0xe7, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x71, 0x92, 0x05, 0xa8, 0x52, 0x1d,
+
+                0xfc
+            }
+        },
+        {
+            32,
+            {
+                0x7f, 0x1b, 0x02, 0x64, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc
+            }
+        },
+        {
+            16,
+            {
+                0x85, 0x59, 0xb8, 0x76, 0xec, 0xee, 0xd6, 0x6e,
+                0xb3, 0x77, 0x98, 0xc0, 0x45, 0x7b, 0xaf, 0xf9
+            }
+        },
+    },
+    {
+        {
+            39,
+            {
+                0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+                0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x64
+            }
+        },
+        {
+            32,
+            {
+                0xe0, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+                0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa
+            }
+        },
+        {
+            16,
+            {
+                0x00, 0xbd, 0x12, 0x58, 0x97, 0x8e, 0x20, 0x54,
+                0x44, 0xc9, 0xaa, 0xaa, 0x82, 0x00, 0x6f, 0xed
+            }
+        },
+    },
+    {
+        {
+            2,
+            {
+                0x02, 0xfc
+            }
+        },
+        {
+            32,
+            {
+                0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+                0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+                0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+                0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c
+            }
+        },
+        {
+            16,
+            {
+                0x06, 0x12, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+                0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c
+            }
+        },
+    },
+    {
+        {
+            415,
+            {
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7a, 0x7b,
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+
+                0x7b, 0x7b, 0x5c, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+                0x7b, 0x7b, 0x7b, 0x7b, 0x6e, 0x7b, 0x00, 0x7b,
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+                0x7b, 0x7b, 0x7b, 0x7a, 0x7b, 0x7b, 0x7b, 0x7b,
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x5c,
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+                0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
+
+                0x7b, 0x6e, 0x7b, 0x00, 0x13, 0x00, 0x00, 0x00,
+                0x00, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+                0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x20, 0x00, 0xef, 0xff, 0x00,
+                0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
+                0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x64, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00,
+
+                0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x20, 0x00, 0xef, 0xff, 0x00, 0x09,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x7a, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
+
+                0x00, 0x09, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc
+            }
+        },
+        {
+            32,
+            {
+                0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, 0x7b
+            }
+        },
+        {
+            16,
+            {
+                0x33, 0x20, 0x5b, 0xbf, 0x9e, 0x9f, 0x8f, 0x72,
+                0x12, 0xab, 0x9e, 0x2a, 0xb9, 0xb7, 0xe4, 0xa5
+            }
+        },
+    },
+    {
+        {
+            118,
+            {
+                0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
+                0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
+                0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
+                0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
+
+                0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
+                0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
+                0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
+                0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
+
+                0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
+                0x77, 0x77, 0x77, 0x77, 0xff, 0xff, 0xff, 0xe9,
+                0xe9, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac,
+                0xac, 0xac, 0xac, 0xac, 0x00, 0x00, 0xac, 0xac,
+
+                0xec, 0x01, 0x00, 0xac, 0xac, 0xac, 0x2c, 0xac,
+                0xa2, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac,
+                0xac, 0xac, 0xac, 0xac, 0x64, 0xf2
+            }
+        },
+        {
+            32,
+            {
+                0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x7f,
+                0x01, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0xcf, 0x77, 0x77, 0x77, 0x77, 0x77,
+                0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77
+            }
+        },
+        {
+            16,
+            {
+                0x02, 0xee, 0x7c, 0x8c, 0x54, 0x6d, 0xde, 0xb1,
+                0xa4, 0x67, 0xe4, 0xc3, 0x98, 0x11, 0x58, 0xb9
+            }
+        },
+    },
+    /*
+     * test vectors from Andrew Moon
+     */
+    { /* nacl */
+        {
+            131,
+            {
+                0x8e, 0x99, 0x3b, 0x9f, 0x48, 0x68, 0x12, 0x73,
+                0xc2, 0x96, 0x50, 0xba, 0x32, 0xfc, 0x76, 0xce,
+                0x48, 0x33, 0x2e, 0xa7, 0x16, 0x4d, 0x96, 0xa4,
+                0x47, 0x6f, 0xb8, 0xc5, 0x31, 0xa1, 0x18, 0x6a,
+
+                0xc0, 0xdf, 0xc1, 0x7c, 0x98, 0xdc, 0xe8, 0x7b,
+                0x4d, 0xa7, 0xf0, 0x11, 0xec, 0x48, 0xc9, 0x72,
+                0x71, 0xd2, 0xc2, 0x0f, 0x9b, 0x92, 0x8f, 0xe2,
+                0x27, 0x0d, 0x6f, 0xb8, 0x63, 0xd5, 0x17, 0x38,
+
+                0xb4, 0x8e, 0xee, 0xe3, 0x14, 0xa7, 0xcc, 0x8a,
+                0xb9, 0x32, 0x16, 0x45, 0x48, 0xe5, 0x26, 0xae,
+                0x90, 0x22, 0x43, 0x68, 0x51, 0x7a, 0xcf, 0xea,
+                0xbd, 0x6b, 0xb3, 0x73, 0x2b, 0xc0, 0xe9, 0xda,
+
+                0x99, 0x83, 0x2b, 0x61, 0xca, 0x01, 0xb6, 0xde,
+                0x56, 0x24, 0x4a, 0x9e, 0x88, 0xd5, 0xf9, 0xb3,
+                0x79, 0x73, 0xf6, 0x22, 0xa4, 0x3d, 0x14, 0xa6,
+                0x59, 0x9b, 0x1f, 0x65, 0x4c, 0xb4, 0x5a, 0x74,
+
+                0xe3, 0x55, 0xa5
+            }
+        },
+        {
+            32,
+            {
+                0xee, 0xa6, 0xa7, 0x25, 0x1c, 0x1e, 0x72, 0x91,
+                0x6d, 0x11, 0xc2, 0xcb, 0x21, 0x4d, 0x3c, 0x25,
+                0x25, 0x39, 0x12, 0x1d, 0x8e, 0x23, 0x4e, 0x65,
+                0x2d, 0x65, 0x1f, 0xa4, 0xc8, 0xcf, 0xf8, 0x80
+            }
+        },
+        {
+            16,
+            {
+                0xf3, 0xff, 0xc7, 0x70, 0x3f, 0x94, 0x00, 0xe5,
+                0x2a, 0x7d, 0xfb, 0x4b, 0x3d, 0x33, 0x05, 0xd9
+            }
+        },
+    },
+    { /* wrap 2^130-5 */
+        {
+            16,
+            {
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+            }
+        },
+        {
+            32,
+            {
+                0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+            }
+        },
+        {
+            16,
+            {
+                0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+            }
+        },
+    },
+    { /* wrap 2^128 */
+        {
+            16,
+            {
+                0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+            }
+        },
+        {
+            32,
+            {
+                0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+            }
+        },
+        {
+            16,
+            {
+                0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+            }
+        },
+    },
+    { /* limb carry */
+        {
+            48,
+            {
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+
+                0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+            }
+        },
+        {
+            32,
+            {
+                0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+            }
+        },
+        {
+            16,
+            {
+                0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+            }
+        },
+    },
+    { /* 2^130-5 */
+        {
+            48,
+            {
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xfb, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
+                0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
+
+                0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+                0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01
+            }
+        },
+        {
+            32,
+            {
+                0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+            }
+        },
+        {
+            16,
+            {
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+
+            }
+        },
+    },
+    { /* 2^130-6 */
+        {
+            16,
+            {
+                0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+            }
+        },
+        {
+            32,
+            {
+                0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+            }
+        },
+        {
+            16,
+            {
+                0xfa, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+            }
+        },
+    },
+    { /* 5*H+L reduction intermediate */
+        {
+            64,
+            {
+                0xe3, 0x35, 0x94, 0xd7, 0x50, 0x5e, 0x43, 0xb9,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x33, 0x94, 0xd7, 0x50, 0x5e, 0x43, 0x79, 0xcd,
+                0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+            }
+        },
+        {
+            32,
+            {
+                0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+            }
+        },
+        {
+            16,
+            {
+                0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+            }
+        },
+    },
+    { /* 5*H+L reduction final */
+        {
+            48,
+            {
+                0xe3, 0x35, 0x94, 0xd7, 0x50, 0x5e, 0x43, 0xb9,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x33, 0x94, 0xd7, 0x50, 0x5e, 0x43, 0x79, 0xcd,
+                0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+
+            }
+        },
+        {
+            32,
+            {
+                0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+            }
+        },
+        {
+            16,
+            {
+                0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+            }
+        }
+    }
+};
+
+static int drive_tests(int idx)
+{
+    SETUP_TEST_FIXTURE(SIMPLE_FIXTURE, setup_poly1305);
+    fixture.test_num = idx;
+    fixture.test_data = &tests[idx];
+    EXECUTE_TEST(execute_poly1305, teardown_poly1305);
+}
+
+int main(int argc, char **argv)
+{
+    int result = 0;
+    int iter_argv;
+    int benchmark = 0;
+
+    for (iter_argv = 1; iter_argv < argc; iter_argv++) {
+        if (strcmp(argv[iter_argv], "-b") == 0)
+            benchmark = 1;
+        else if (strcmp(argv[iter_argv], "-h") == 0)
+            goto help;
+    }
+
+    ADD_ALL_TESTS(drive_tests, OSSL_NELEM(tests));
+
+    result = run_tests(argv[0]);
+
+    if (benchmark)
+        benchmark_poly1305();
+
+    return result;
+
+ help:
+    printf("-h\tThis help\n");
+    printf("-b\tBenchmark in addition to the tests\n");
+
+    return 0;
+}
diff --git a/test/recipes/03-test_internal.t b/test/recipes/03-test_internal.t
new file mode 100644
index 0000000..5c7e897
--- /dev/null
+++ b/test/recipes/03-test_internal.t
@@ -0,0 +1,31 @@
+#! /usr/bin/env perl
+# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the OpenSSL license (the "License").  You may not use
+# this file except in compliance with the License.  You can obtain a copy
+# in the file LICENSE in the source distribution or at
+# https://www.openssl.org/source/license.html
+
+use strict;
+use OpenSSL::Test qw/:DEFAULT bldtop_file/;
+use OpenSSL::Test::Utils;
+
+setup("test_internal");
+
+my %known_internal_tests =
+  ( mdc2_internal_test => !disabled("mdc2"),
+    poly1305_internal_test => !disabled("poly1305"),
+    modes_internal_test => 1,
+    asn1_internal_test => 1,
+    x509_internal_test => 1 );
+
+plan tests => scalar keys %known_internal_tests;
+
+foreach (keys %known_internal_tests) {
+ SKIP:
+    {
+	skip "Skipping $_, it's disabled in this configuration", 1
+	    unless $known_internal_tests{$_};
+	ok(run(test([$_])), "Running $_");
+    }
+}
diff --git a/test/x509_internal_test.c b/test/x509_internal_test.c
new file mode 100644
index 0000000..76cc2ed
--- /dev/null
+++ b/test/x509_internal_test.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the OpenSSL license (the "License").  You may not use
+ * this file except in compliance with the License.  You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+/* Internal tests for the x509 and x509v3 modules */
+
+#include <stdio.h>
+#include <string.h>
+
+#include <openssl/x509.h>
+#include <openssl/x509v3.h>
+#include "testutil.h"
+#include "e_os.h"
+
+typedef struct {
+    const char *test_case_name;
+    const char *test_section;
+} SIMPLE_FIXTURE;
+
+/**********************************************************************
+ *
+ * Test of x509v3
+ *
+ ***/
+
+static SIMPLE_FIXTURE setup_standard_exts(const char *const test_case_name)
+{
+    SIMPLE_FIXTURE fixture;
+    fixture.test_case_name = test_case_name;
+    return fixture;
+}
+
+#include "../crypto/x509v3/ext_dat.h"
+#include "../crypto/x509v3/standard_exts.h"
+
+static int execute_standard_exts(SIMPLE_FIXTURE fixture)
+{
+    size_t i;
+    int prev = -1, good = 1;
+    const X509V3_EXT_METHOD **tmp;
+
+    tmp = standard_exts;
+    for (i = 0; i < OSSL_NELEM(standard_exts); i++, tmp++) {
+        if ((*tmp)->ext_nid < prev)
+            good = 0;
+        prev = (*tmp)->ext_nid;
+
+    }
+    if (!good) {
+        tmp = standard_exts;
+        fprintf(stderr, "Extensions out of order!\n");
+        for (i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++)
+            fprintf(stderr, "%d : %s\n", (*tmp)->ext_nid,
+                    OBJ_nid2sn((*tmp)->ext_nid));
+    } else {
+        fprintf(stderr, "Order OK\n");
+    }
+
+    return good;
+}
+
+static void teardown_standard_exts(SIMPLE_FIXTURE fixture)
+{
+    ERR_print_errors_fp(stderr);
+}
+
+/**********************************************************************
+ *
+ * Test driver
+ *
+ ***/
+
+static struct {
+    const char *section;
+    SIMPLE_FIXTURE (*setup)(const char *const test_case_name);
+    int (*execute)(SIMPLE_FIXTURE);
+    void (*teardown)(SIMPLE_FIXTURE);
+} tests[] = {
+    {"standard_exts", setup_standard_exts, execute_standard_exts,
+     teardown_standard_exts},
+};
+
+static int drive_tests(int idx)
+{
+    SETUP_TEST_FIXTURE(SIMPLE_FIXTURE, tests[idx].setup);
+    fixture.test_section = tests[idx].section;
+    EXECUTE_TEST(tests[idx].execute, tests[idx].teardown);
+}
+
+int main(int argc, char **argv)
+{
+    ADD_ALL_TESTS(drive_tests, OSSL_NELEM(tests));
+
+    return run_tests(argv[0]);
+}


More information about the openssl-commits mailing list