summaryrefslogtreecommitdiffhomepage
path: root/src/crypto/zinc/poly1305/poly1305-arm-glue.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-10-01 03:50:58 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-10-02 14:37:53 +0200
commit30b08000fadb23358e48b382afa2097339ee9bba (patch)
treea7f4dfa99b0853156272b927860f1e54389ae14a /src/crypto/zinc/poly1305/poly1305-arm-glue.h
parent780269c181e73de1ccb4de3b42dee87754182058 (diff)
poly1305: document rationale for base 2^26->2^64/32 conversion
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/crypto/zinc/poly1305/poly1305-arm-glue.h')
-rw-r--r--src/crypto/zinc/poly1305/poly1305-arm-glue.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/crypto/zinc/poly1305/poly1305-arm-glue.h b/src/crypto/zinc/poly1305/poly1305-arm-glue.h
index c694524..92aa226 100644
--- a/src/crypto/zinc/poly1305/poly1305-arm-glue.h
+++ b/src/crypto/zinc/poly1305/poly1305-arm-glue.h
@@ -50,6 +50,17 @@ struct poly1305_arch_internal {
};
#endif
+/* The NEON code uses base 2^26, while the scalar code uses base 2^64 on 64-bit
+ * and base 2^32 on 32-bit. If we hit the unfortunate situation of using NEON
+ * and then having to go back to scalar -- because the user is silly and has
+ * called the update function from two separate contexts -- then we need to
+ * convert back to the original base before proceeding. The below function is
+ * written for 64-bit integers, and so we have to swap words at the end on
+ * big-endian 32-bit. It is possible to reason that the initial reduction below
+ * is sufficient given the implementation invariants. However, for an avoidance
+ * of doubt and because this is not performance critical, we do the full
+ * reduction anyway.
+ */
static void convert_to_base2_64(void *ctx)
{
struct poly1305_arch_internal *state = ctx;