aboutsummaryrefslogtreecommitdiff
path: root/src/libsec/port/egalloc.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-03-21 14:04:56 +0000
committerrsc <devnull@localhost>2004-03-21 14:04:56 +0000
commit0fc65b37a1e7585ca2347bf61dcb8bc3a6b146a4 (patch)
treedd9189a823998f494082adb769451f12be056566 /src/libsec/port/egalloc.c
parent768206abfcf505fb034a0151bf263bc0b1f2380c (diff)
downloadplan9port-0fc65b37a1e7585ca2347bf61dcb8bc3a6b146a4.tar.gz
plan9port-0fc65b37a1e7585ca2347bf61dcb8bc3a6b146a4.tar.bz2
plan9port-0fc65b37a1e7585ca2347bf61dcb8bc3a6b146a4.zip
Add most of libsec.
Diffstat (limited to 'src/libsec/port/egalloc.c')
-rw-r--r--src/libsec/port/egalloc.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/libsec/port/egalloc.c b/src/libsec/port/egalloc.c
new file mode 100644
index 00000000..3f0753da
--- /dev/null
+++ b/src/libsec/port/egalloc.c
@@ -0,0 +1,70 @@
+#include "os.h"
+#include <mp.h>
+#include <libsec.h>
+
+EGpub*
+egpuballoc(void)
+{
+ EGpub *eg;
+
+ eg = mallocz(sizeof(*eg), 1);
+ if(eg == nil)
+ sysfatal("egpuballoc");
+ return eg;
+}
+
+void
+egpubfree(EGpub *eg)
+{
+ if(eg == nil)
+ return;
+ mpfree(eg->p);
+ mpfree(eg->alpha);
+ mpfree(eg->key);
+ free(eg);
+}
+
+
+EGpriv*
+egprivalloc(void)
+{
+ EGpriv *eg;
+
+ eg = mallocz(sizeof(*eg), 1);
+ if(eg == nil)
+ sysfatal("egprivalloc");
+ return eg;
+}
+
+void
+egprivfree(EGpriv *eg)
+{
+ if(eg == nil)
+ return;
+ mpfree(eg->pub.p);
+ mpfree(eg->pub.alpha);
+ mpfree(eg->pub.key);
+ mpfree(eg->secret);
+ free(eg);
+}
+
+EGsig*
+egsigalloc(void)
+{
+ EGsig *eg;
+
+ eg = mallocz(sizeof(*eg), 1);
+ if(eg == nil)
+ sysfatal("egsigalloc");
+ return eg;
+}
+
+void
+egsigfree(EGsig *eg)
+{
+ if(eg == nil)
+ return;
+ mpfree(eg->r);
+ mpfree(eg->s);
+ free(eg);
+}