]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libsec/port/egalloc.c
libsec: generalize pbkdf2_hmac_sha1() to pbkdf2_x() passing the hmac as an argument
[plan9front.git] / sys / src / libsec / port / egalloc.c
1 #include "os.h"
2 #include <mp.h>
3 #include <libsec.h>
4
5 EGpub*
6 egpuballoc(void)
7 {
8         EGpub *eg;
9
10         eg = mallocz(sizeof(*eg), 1);
11         if(eg == nil)
12                 sysfatal("egpuballoc");
13         return eg;
14 }
15
16 void
17 egpubfree(EGpub *eg)
18 {
19         if(eg == nil)
20                 return;
21         mpfree(eg->p);
22         mpfree(eg->alpha);
23         mpfree(eg->key);
24         free(eg);
25 }
26
27
28 EGpriv*
29 egprivalloc(void)
30 {
31         EGpriv *eg;
32
33         eg = mallocz(sizeof(*eg), 1);
34         if(eg == nil)
35                 sysfatal("egprivalloc");
36         return eg;
37 }
38
39 void
40 egprivfree(EGpriv *eg)
41 {
42         if(eg == nil)
43                 return;
44         mpfree(eg->pub.p);
45         mpfree(eg->pub.alpha);
46         mpfree(eg->pub.key);
47         mpfree(eg->secret);
48         free(eg);
49 }
50
51 EGsig*
52 egsigalloc(void)
53 {
54         EGsig *eg;
55
56         eg = mallocz(sizeof(*eg), 1);
57         if(eg == nil)
58                 sysfatal("egsigalloc");
59         return eg;
60 }
61
62 void
63 egsigfree(EGsig *eg)
64 {
65         if(eg == nil)
66                 return;
67         mpfree(eg->r);
68         mpfree(eg->s);
69         free(eg);
70 }