]> git.lizzy.rs Git - plan9front.git/blob - sys/man/2/ec
added ec(2), added ripemd160 to sechash(2)
[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 function implement elliptic curve cryptography.
50 An elliptic curve together with cryptographic parameters are specified using a 
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 work 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 SEC 1 to a
63 .B ECpoint
64 struct. Both uncompressed and compressed formats are supported.
65 If 
66 .B rptr
67 is not
68 .BR nil ,
69 it is used to return the position in the string where the parser stopped.
70 If
71 .BR p " is " nil
72 space is allocated automatically, else the given struct is used.
73 .PP
74 .B ecverify
75 and
76 .B ecpubverify
77 verify that the given point or public key, resp., is valid.
78 .PP
79 .B ecgen
80 generates a keypair and returns a pointer to it.
81 If
82 .BR p " is " nil
83 space is allocated automatically, else the given struct is used.
84 .PP
85 .B ecdsasign
86 and
87 .B ecdsaverify
88 create or verify, resp., a signature using the ECDSA scheme specified in SEC 1.
89 It is absolutely vital that
90 .B dig
91 is a cryptographic hash to the message.
92 .B ecdsasign
93 writes the signature to
94 .BR r " and " s
95 which are assumed to be allocated properly.
96 .SH RETURN VALUE
97 .B *verify
98 functions return
99 .B 1
100 for a positive result.
101 Functions returning pointers may return
102 .B nil
103 in case of error (e.g. failing
104 .IR malloc (2)).
105 .SH SOURCE
106 .B /sys/src/libsec/ec.c
107 .SH SEE ALSO
108 Standards for Efficient Cryptography (SEC) 1: Elliptic Curve Cryptography, Certicom Research, 2009