blob: d82ab3deb330eb8579604d06a25e4a6e830925ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#include "os.h"
#include <mp.h>
#include <libsec.h>
DSApub*
dsapuballoc(void)
{
DSApub *dsa;
dsa = mallocz(sizeof(*dsa), 1);
if(dsa == nil)
sysfatal("dsapuballoc");
return dsa;
}
void
dsapubfree(DSApub *dsa)
{
if(dsa == nil)
return;
mpfree(dsa->p);
mpfree(dsa->q);
mpfree(dsa->alpha);
mpfree(dsa->key);
free(dsa);
}
DSApriv*
dsaprivalloc(void)
{
DSApriv *dsa;
dsa = mallocz(sizeof(*dsa), 1);
if(dsa == nil)
sysfatal("dsaprivalloc");
return dsa;
}
void
dsaprivfree(DSApriv *dsa)
{
if(dsa == nil)
return;
mpfree(dsa->pub.p);
mpfree(dsa->pub.q);
mpfree(dsa->pub.alpha);
mpfree(dsa->pub.key);
mpfree(dsa->secret);
free(dsa);
}
DSAsig*
dsasigalloc(void)
{
DSAsig *dsa;
dsa = mallocz(sizeof(*dsa), 1);
if(dsa == nil)
sysfatal("dsasigalloc");
return dsa;
}
void
dsasigfree(DSAsig *dsa)
{
if(dsa == nil)
return;
mpfree(dsa->r);
mpfree(dsa->s);
free(dsa);
}
|