progs/perftest.c: Use from Glibc syscall numbers.
[catacomb] / math / ec-raw.h
index 4792bd7..df8d1ab 100644 (file)
 
 /*----- Data formatting ---------------------------------------------------*/
 
+/* EC2OSP/OS2ECP bit mask. */
+#define EC_YBIT 1u                     /* The compressed @y@-coordinate */
+#define EC_XONLY 1u                    /* The @y@-coordinate is absent */
+#define EC_CMPR 2u                     /* Compressed @y@-coordinate */
+#define EC_LSB 2u                      /* Use `lsb' compression */
+#define EC_EXPLY 4u                    /* Explicit @y@-coordinate */
+#define EC_SORT 8u                     /* Use `sort' rather than `lsb' */
+
+/* --- @ec_ec2osp@ --- *
+ *
+ * Arguments:  @ec_curve *c@ = elliptic curve
+ *             @unsigned f@ = format flags for output
+ *             @buf *b@ = pointer to a buffer
+ *             @const ec *p@ = an elliptic curve point
+ *
+ * Returns:    Zero on success, nonzero on failure.
+ *
+ * Use:                Puts an elliptic curve point to the given buffer using the
+ *             standard uncompressed format described in P1363 and SEC1.
+ *             This requires at most @1 + 2 * c->f->noctets@ space in the
+ *             buffer.
+ *
+ *             Point compression features are determined by @f@ as follows.
+ *             If @EC_CMPR@ is set then point compression is performed and a
+ *             compressed form of the %$y$%-coordinate is contained in the
+ *             first output byte; if @EC_SORT@ is set then P1363a `SORT'
+ *             compression is used, otherwise LSB compression.  If
+ *             @EC_EXPLY@ is set, then an explicit %$y$%-coordinate is
+ *             output in full.  Otherwise the %$y$%-coordinate is
+ *             suppressed.
+ *
+ *             Returns failure (@-1@) if the flags are invalid, or if there
+ *             isn't enough space in the output buffer.
+ */
+
+extern int ec_ec2osp(ec_curve */*c*/, unsigned /*f*/,
+                    buf */*b*/, const ec */*p*/);
+
+/* --- @ec_os2ecp@ --- *
+ *
+ * Arguments:  @ec_curve *c = elliptic curve
+ *             @unsigned f@ = format flags for input
+ *             @buf *b@ = pointer to a buffer
+ *             @ec *d@ = an elliptic curve point
+ *
+ * Returns:    Zero on success, nonzero on failure.
+ *
+ * Use:                Reads an elliptic curve point from the given buffer using the
+ *             standard uncompressed format described in P1363 and SEC1.
+ *
+ *             Point compression features are determined by @f@ as follows.
+ *             If @EC_LSB@ is set, then accept an LSB-compressed %$y$%-
+ *             coordinate; if @EC_SORT@ is set, then accept a SORT-
+ *             compressed %$y$%-coordinate; if @EC_EXPLY@ is set, then
+ *             accept an explicit %$y$%-coordinate; if @EC_XONLY@ is set
+ *             then accept a bare %$x$%-coordinate (a correct
+ *             %$y$%-coordinate is chosen arbitrarily).  Hybrid forms are
+ *             acceptable, and the input is checked to verify that the
+ *             redundant representations are consistent.  If no flags are
+ *             set in @f@, then no input (other than the point at infinity)
+ *             will be acceptable.
+ */
+
+extern int ec_os2ecp(ec_curve */*c*/, unsigned /*f*/, buf */*b*/, ec */*d*/);
+
 /* --- @ec_putraw@ --- *
  *
  * Arguments:  @ec_curve *c@ = elliptic curve