fixup! More style fixes for the curve448 code
[openssl.git] / crypto / ec / curve448 / point_448.h
index 92949e3fa9aa884a52a4167038be362e8308b595..0ef3b8714e26334ba8e2f0c0af6bd0f0bbb50482 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
  * Copyright 2015-2016 Cryptography Research, Inc.
  *
  * Licensed under the OpenSSL license (the "License").  You may not use
  * Originally written by Mike Hamburg
  */
 
-#ifndef __C448_POINT_448_H__
-# define __C448_POINT_448_H__ 1
+#ifndef HEADER_POINT_448_H
+# define HEADER_POINT_448_H
 
 # include "curve448utils.h"
 # include "field.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+/* Comb config: number of combs, n, t, s. */
+#define COMBS_N 5
+#define COMBS_T 5
+#define COMBS_S 18
+
+/* Projective Niels coordinates */
+typedef struct {
+    gf a, b, c;
+} niels_s, niels_t[1];
+typedef struct {
+    niels_t n;
+    gf z;
+} pniels_t[1];
+
+/* Precomputed base */
+struct curve448_precomputed_s {
+    niels_t table[COMBS_N << (COMBS_T - 1)];
+};
 
 # define C448_SCALAR_LIMBS ((446-1)/C448_WORD_BITS+1)
 
@@ -64,6 +79,7 @@ extern const curve448_point_t curve448_point_identity;
 
 /* Precomputed table for the base point on the curve. */
 extern const struct curve448_precomputed_s *curve448_precomputed_base;
+extern const niels_t *curve448_wnaf_base;
 
 /*
  * Read a scalar from wire format or from bytes.
@@ -76,9 +92,8 @@ extern const struct curve448_precomputed_s *curve448_precomputed_base;
  * C448_FAILURE: The scalar was greater than the modulus, and has been reduced
  * modulo that modulus.
  */
-__owur c448_error_t curve448_scalar_decode(
-                            curve448_scalar_t out,
-                            const unsigned char ser[C448_SCALAR_BYTES]);
+c448_error_t curve448_scalar_decode(curve448_scalar_t out,
+                                    const unsigned char ser[C448_SCALAR_BYTES]);
 
 /*
  * Read a scalar from wire format or from bytes.  Reduces mod scalar prime.
@@ -100,7 +115,7 @@ void curve448_scalar_encode(unsigned char ser[C448_SCALAR_BYTES],
                             const curve448_scalar_t s);
 
 /*
- * Add two scalars. The scalars may use the same memory.
+ * Add two scalars. |a|, |b| and |out| may alias each other.
  * 
  * a (in): One scalar.
  * b (in): Another scalar.
@@ -110,7 +125,7 @@ void curve448_scalar_add(curve448_scalar_t out,
                          const curve448_scalar_t a, const curve448_scalar_t b);
 
 /*
- * Subtract two scalars.  The scalars may use the same memory.
+ * Subtract two scalars.  |a|, |b| and |out| may alias each other.
  * a (in): One scalar.
  * b (in): Another scalar.
  * out (out): a-b.
@@ -119,7 +134,7 @@ void curve448_scalar_sub(curve448_scalar_t out,
                          const curve448_scalar_t a, const curve448_scalar_t b);
 
 /*
- * Multiply two scalars. The scalars may use the same memory.
+ * Multiply two scalars. |a|, |b| and |out| may alias each other.
  * 
  * a (in): One scalar.
  * b (in): Another scalar.
@@ -129,7 +144,7 @@ void curve448_scalar_mul(curve448_scalar_t out,
                          const curve448_scalar_t a, const curve448_scalar_t b);
 
 /*
-* Halve a scalar.  The scalars may use the same memory.
+* Halve a scalar.  |a| and |out| may alias each other.
 * 
 * a (in): A scalar.
 * out (out): a/2.
@@ -137,7 +152,7 @@ void curve448_scalar_mul(curve448_scalar_t out,
 void curve448_scalar_halve(curve448_scalar_t out, const curve448_scalar_t a);
 
 /*
- * Copy a scalar.  The scalars may use the same memory, in which case this
+ * Copy a scalar.  The scalars may alias each other, in which case this
  * function does nothing.
  * 
  * a (in): A scalar.
@@ -283,8 +298,4 @@ void curve448_scalar_destroy(curve448_scalar_t scalar);
 /* Overwrite point with zeros. */
 void curve448_point_destroy(curve448_point_t point);
 
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif                          /* __C448_POINT_448_H__ */
+#endif                          /* HEADER_POINT_448_H */