pub/, progs/: Add support for X448 key exchange, defined in RFC7748.
[catacomb] / progs / perftest.c
index 3377487..b2722a4 100644 (file)
@@ -63,6 +63,7 @@
 #include "ec.h"
 #include "group.h"
 #include "x25519.h"
+#include "x448.h"
 #include "ed25519.h"
 
 #include "cc.h"
@@ -289,6 +290,24 @@ static void *x25519_jobinit(opts *o)
 static void x25519_jobrun(void *cc)
   { x25519_jobctx *c = cc; octet z[X25519_OUTSZ]; x25519(z, c->k, c->p); }
 
+/* --- x448 --- */
+
+typedef struct x448_jobctx {
+  octet k[X448_KEYSZ];
+  octet p[X448_PUBSZ];
+} x448_jobctx;
+
+static void *x448_jobinit(opts *o)
+{
+  x448_jobctx *c = CREATE(x448_jobctx);
+  rand_get(RAND_GLOBAL, c->k, sizeof(c->k));
+  rand_get(RAND_GLOBAL, c->p, sizeof(c->p));
+  return (c);
+}
+
+static void x448_jobrun(void *cc)
+  { x448_jobctx *c = cc; octet z[X448_OUTSZ]; x448(z, c->k, c->p); }
+
 /* --- Ed25519 --- */
 
 typedef struct ed25519_signctx {
@@ -556,6 +575,7 @@ static const jobops jobtab[] = {
   { "rsa-priv-blind",          rsaprivblind_init,      rsapriv_run },
   { "rsa-pub",                 rsapub_init,            rsapub_run },
   { "x25519",                  x25519_jobinit,         x25519_jobrun },
+  { "x448",                    x448_jobinit,           x448_jobrun },
   { "ed25519-sign",            ed25519_signinit,       ed25519_signrun },
   { "ed25519-vrf",             ed25519_vrfinit,        ed25519_vrfrun },
   { "ksched",                  ksched_init,            ksched_run },