]> git.lizzy.rs Git - plan9front.git/blob - sys/man/2/ec
add HISTORY to various man pages
[plan9front.git] / sys / man / 2 / ec
1 .TH EC 2
2 .SH NAME
3 ecassign,
4 ecadd,
5 ecmul,
6 strtoec,
7 ecgen,
8 ecverify,
9 ecpubverify,
10 ecdsasign,
11 ecdsaverify \- elliptic curve cryptography
12 .SH SYNOPSIS
13 .B #include <u.h>
14 .br
15 .B #include <libc.h>
16 .br
17 .B #include <mp.h>
18 .br
19 .B #include <libsec.h>
20 .PP
21 .B
22 void    ecassign(ECdomain *dom, ECpoint *old, ECpoint *new);
23 .PP
24 .B
25 void    ecadd(ECdomain *dom, ECpoint *a, ECpoint *b, ECpoint *s);
26 .PP
27 .B
28 void    ecmul(ECdomain *dom, ECpoint *a, mpint *k, ECpoint *s);
29 .PP
30 .B
31 ECpoint*        strtoec(ECdomain *dom, char *s, char **rptr, ECpoint *p);
32 .PP
33 .B
34 ECpriv* ecgen(ECdomain *dom, ECpriv *p);
35 .PP
36 .B
37 int     ecverify(ECdomain *dom, ECpoint *p);
38 .PP
39 .B
40 int     ecpubverify(ECdomain *dom, ECpub *p);
41 .PP
42 .B
43 void    ecdsasign(ECdomain *dom, ECpriv *priv, uchar *dig, int dlen, mpint *r, mpint *s);
44 .PP
45 .B
46 int     ecdsaverify(ECdomain *dom, ECpub *pub, uchar *dig, int dlen, mpint *r, mpint *s);
47 .DT
48 .SH DESCRIPTION
49 These functions implement elliptic curve cryptography.
50 An elliptic curve together with cryptographic parameters are specified using an
51 .B ECdomain
52 struct.
53 Points on the curve are represented by 
54 .B ECpoint
55 structs.
56 .PP
57 .BR ecassign ", " ecadd " and " ecmul
58 are analogous to their counterparts in
59 .IR mp (2).
60 .PP
61 .B strtoec
62 converts a hex string representing an octet string as specified in
63 .I Standards for Efficient Cryptography (SEC) 1
64 to an
65 .B ECpoint
66 struct. Both uncompressed and compressed formats are supported.
67 If 
68 .B rptr
69 is not
70 .BR nil ,
71 it is used to return the position in the string where the parser stopped.
72 If
73 .BR p " is " nil
74 space is allocated automatically, else the given struct is used.
75 .PP
76 .B ecverify
77 and
78 .B ecpubverify
79 verify that the given point or public key, respectively, is valid.
80 .PP
81 .B ecgen
82 generates a keypair and returns a pointer to it.
83 If
84 .BR p " is " nil
85 space is allocated automatically, else the given struct is used.
86 .PP
87 .B ecdsasign
88 and
89 .B ecdsaverify
90 create or verify, respectively, a signature using the ECDSA scheme specified in
91 .I SEC 1.
92 It is absolutely vital that
93 .B dig
94 is a cryptographic hash to the message.
95 .B ecdsasign
96 writes the signature to
97 .BR r " and " s
98 which are assumed to be allocated properly.
99 .SH RETURN VALUE
100 .B *verify
101 functions return
102 .B 1
103 for a positive result.
104 Functions returning pointers may return
105 .B nil
106 in case of error
107 .I (e.g.
108 failing
109 .IR malloc (2)).
110 .SH SOURCE
111 .B /sys/src/libsec/port/ecc.c
112 .SH SEE ALSO
113 .I
114 Standards for Efficient Cryptography (SEC) 1: Elliptic Curve Cryptography
115 - Certicom Research, 2009
116 .SH HISTORY
117 This implementation of elliptic curve cryptography first appeared in 9front (June, 2012).