From eee202c309ed165de8a46a44486cea5ac0b4828e Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Thu, 11 May 2017 10:42:15 +0100 Subject: [PATCH] pubkey.c: Add support for Ed448 signatures, following RFC8032. --- catacomb-python.h | 1 + catacomb.c | 1 + catacomb/__init__.py | 12 ++++++++++++ pubkey.c | 3 ++- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/catacomb-python.h b/catacomb-python.h index 65f2ed1..0307701 100644 --- a/catacomb-python.h +++ b/catacomb-python.h @@ -92,6 +92,7 @@ #include #include #include +#include #include #include diff --git a/catacomb.c b/catacomb.c index 9e3b9cb..f9e8587 100644 --- a/catacomb.c +++ b/catacomb.c @@ -49,6 +49,7 @@ static const struct nameval consts[] = { C(X448_KEYSZ), C(X448_PUBSZ), C(X448_OUTSZ), C(ED25519_KEYSZ), C(ED25519_PUBSZ), C(ED25519_SIGSZ), C(ED25519_MAXPERSOSZ), + C(ED448_KEYSZ), C(ED448_PUBSZ), C(ED448_SIGSZ), C(ED448_MAXPERSOSZ), #define ENTRY(tag, val, str) C(KERR_##tag), KEY_ERRORS(ENTRY) #undef ENTRY diff --git a/catacomb/__init__.py b/catacomb/__init__.py index 5cbf993..e283744 100644 --- a/catacomb/__init__.py +++ b/catacomb/__init__.py @@ -910,6 +910,18 @@ class Ed25519Priv (_EdDSAPriv, Ed25519Pub): def sign(me, msg, **kw): return ed25519_sign(me.priv, msg, pub = me.pub, **kw) +class Ed448Pub (_EdDSAPub): + _PUBSZ = KeySZSet(ED448_PUBSZ) + _HASH = shake256 + def verify(me, msg, sig, **kw): + return ed448_verify(me.pub, msg, sig, **kw) + +class Ed448Priv (_EdDSAPriv, Ed448Pub): + _KEYSZ = KeySZAny(ED448_KEYSZ) + def _pubkey(me, priv): return ed448_pubkey(priv) + def sign(me, msg, **kw): + return ed448_sign(me.priv, msg, pub = me.pub, **kw) + ###-------------------------------------------------------------------------- ### Built-in named curves and prime groups. diff --git a/pubkey.c b/pubkey.c index 7374429..f94108f 100644 --- a/pubkey.c +++ b/pubkey.c @@ -1164,7 +1164,8 @@ XDHS(DEFXDH) /*----- Ed25519 and related algorithms ------------------------------------*/ #define EDDSAS(_) \ - _(ED25519, ed25519, -1, ctx) + _(ED25519, ed25519, -1, ctx) \ + _(ED448, ed448, 0, ) #define DEFEDDSA(ED, ed, phdflt, sigver) \ \ -- 2.11.0