summaryrefslogtreecommitdiff
path: root/sys/include/libsec.h
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2014-09-14 02:29:18 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2014-09-14 02:29:18 +0200
commit6c68876db6d25b8c646295fecc75a6363d0bdc75 (patch)
tree26017f9d8aa6fab798a3cc762b8b274d86bd033d /sys/include/libsec.h
parent4cf00ca6cb40918c8ca89aebf02e8ca41c857e94 (diff)
libsec: add diffie-hellman functions
Diffstat (limited to 'sys/include/libsec.h')
-rw-r--r--sys/include/libsec.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/include/libsec.h b/sys/include/libsec.h
index a9c24b91c..4ab074fdb 100644
--- a/sys/include/libsec.h
+++ b/sys/include/libsec.h
@@ -439,3 +439,22 @@ void base58enc(uchar *, char *, int);
int base58dec(char *, uchar *, int);
DigestState* ripemd160(uchar *, ulong, uchar *, DigestState *);
+
+/*
+ * Diffie-Hellman key exchange
+ */
+
+typedef struct DHstate DHstate;
+struct DHstate
+{
+ mpint *g; /* base g */
+ mpint *p; /* large prime */
+ mpint *x; /* random secret */
+ mpint *y; /* public key y = g ^ x % p */
+};
+
+/* generate new public key: y = g ^ x % p */
+mpint* dh_new(DHstate *dh, mpint *p, mpint *g);
+
+/* calculate shared key: k = pub ^ x % p */
+mpint* dh_finish(DHstate *dh, mpint *pub);