from cinap, first cut at a man page for ec functions. i did apply the usual man page formatting Reference: /n/atom/patch/applied/ecman Date: Mon Sep 21 00:49:05 CES 2015 Signed-off-by: quanstro@quanstro.net --- /sys/man/2/ec Thu Jan 1 00:00:00 1970 +++ /sys/man/2/ec Mon Sep 21 00:47:52 2015 @@ -0,0 +1,128 @@ +.TH EC 2 +.SH NAME +ecassign, +ecadd, +ecmul, +strtoec, +ecgen, +ecverify, +ecpubverify, +ecdsasign, +ecdsaverify \- elliptic curve cryptography +.SH SYNOPSIS +.B #include +.br +.B #include +.br +.B #include +.br +.B #include +.PP +.B +void ecassign(ECdomain *dom, ECpoint *old, ECpoint *new) +.PP +.B +void ecadd(ECdomain *dom, ECpoint *a, ECpoint *b, ECpoint *s) +.PP +.B +void ecmul(ECdomain *dom, ECpoint *a, mpint *k, ECpoint *s) +.PP +.B +ECpoint* strtoec(ECdomain *dom, char *s, char **rptr, ECpoint *p) +.PP +.B +ECpriv* ecgen(ECdomain *dom, ECpriv *p) +.PP +.B +int ecverify(ECdomain *dom, ECpoint *p) +.PP +.B +int ecpubverify(ECdomain *dom, ECpub *p) +.PP +.B +void ecdsasign(ECdomain *dom, ECpriv *priv, uchar *dig, int dlen, mpint *r, mpint *s) +.PP +.B +int ecdsaverify(ECdomain *dom, ECpub *pub, uchar *dig, int dlen, mpint *r, mpint *s) +.DT +.SH DESCRIPTION +These functions implement elliptic curve cryptography. +An elliptic curve together with cryptographic parameters are specified using an +.BR ECdomain . +A point on the curve are represented by an +.BR ECpoint . +.PP +.BR Ecassign , +.BR ecadd , +and +.BR ecmul +are analogous to their counterparts in +.IR mp (2). +.PP +.B Strtoec +converts a hex string representing an octet string as specified in +.I Standards for Efficient Cryptography (SEC) 1 +to an +.BR ECpoint . +Both uncompressed and compressed formats are supported. +If +.B rptr +is not +.BR nil , +it is used to return the position in the string where the parser stopped. +If +.B p +is +.B nil +space is allocated automatically, otherwise the given +.B ECpoint +is used. +.B Nil +is returned on +.IR malloc (2) +failure. +.PP +.B Ecverify +and +.B ecpubverify +return 1 +if the point or public key is valid, and 0 otherwise +.RI [ sic .]. +.PP +.B Ecgen +generates a keypair and returns a pointer to it. +.B Nil +is returned on +.I malloc +failure. +If +.B p +is +.BR nil , +space is allocated automatically, otherwise the given +.B ECpriv +is used. +.PP +.B ecdsasign +and +.B ecdsaverify +create or verify, respectively, a signature using the ECDSA scheme specified in +.I SEC 1. +It is vital that +.B dig +is a cryptographic hash to the message. +.B Ecdsasign +writes the signature to +.B r +and +.B s +which are assumed to be allocated. +.SH SOURCE +.B /sys/src/libsec/port/ecc.c +.SH SEE ALSO +.IR malloc (2), +.IR mp (2), +.br +.I +Standards for Efficient Cryptography (SEC) 1: Elliptic Curve Cryptography +- Certicom Research, 2009