#include <catacomb/bintab.h>
#include <catacomb/dsa.h>
#include <catacomb/x25519.h>
+#include <catacomb/x448.h>
#include <catacomb/ed25519.h>
#include <catacomb/gf.h>
C(KF_BURN), C(KF_OPT),
C(EC_XONLY), C(EC_YBIT), C(EC_LSB), C(EC_CMPR), C(EC_EXPLY), C(EC_SORT),
C(X25519_KEYSZ), C(X25519_PUBSZ), C(X25519_OUTSZ),
+ C(X448_KEYSZ), C(X448_PUBSZ), C(X448_OUTSZ),
C(ED25519_KEYSZ), C(ED25519_PUBSZ), C(ED25519_SIGSZ),
#define ENTRY(tag, val, str) C(KERR_##tag),
KEY_ERRORS(ENTRY)
_augment(RSAPriv, _tmp)
###--------------------------------------------------------------------------
-### Bernstein's elliptic curve crypto.
+### Bernstein's elliptic curve crypto and related schemes.
X25519_BASE = \
bytes('0900000000000000000000000000000000000000000000000000000000000000')
+X448_BASE = \
+ bytes('05000000000000000000000000000000000000000000000000000000'
+ '00000000000000000000000000000000000000000000000000000000')
+
Z128 = bytes('00000000000000000000000000000000')
class _BoxyPub (object):
def _op(me, k, X): return x25519(k, X)
def _hashkey(me, z): return hsalsa20_prf(z, Z128)
+class X448Pub (_BoxyPub):
+ _PUBSZ = X448_PUBSZ
+ _BASE = X448_BASE
+
+class X448Priv (_BoxyPriv, X448Pub):
+ _KEYSZ = X448_KEYSZ
+ def _op(me, k, X): return x448(k, X)
+ ##def _hashkey(me, z): return ???
+
class Ed25519Pub (object):
def __init__(me, pub):
me.pub = pub
return (rc);
}
-/*----- X25519 ------------------------------------------------------------*/
+/*----- X25519 and related algorithms -------------------------------------*/
static PyObject *meth_x25519(PyObject *me, PyObject *arg)
{
return (0);
}
+static PyObject *meth_x448(PyObject *me, PyObject *arg)
+{
+ const char *k, *p;
+ Py_ssize_t ksz, psz;
+ PyObject *rc = 0;
+ if (!PyArg_ParseTuple(arg, "s#s#:x448", &k, &ksz, &p, &psz)) goto end;
+ if (ksz != X448_KEYSZ) VALERR("bad key length");
+ if (psz != X448_PUBSZ) VALERR("bad public length");
+ rc = bytestring_pywrap(0, X448_OUTSZ);
+ x448((octet *)PyString_AS_STRING(rc),
+ (const octet *)k, (const octet *)p);
+ return (rc);
+end:
+ return (0);
+}
+
/*----- Ed25519 -----------------------------------------------------------*/
static PyObject *meth_ed25519_pubkey(PyObject *me, PyObject *arg)
generate(NBITS, [event = pgen_nullev, rng = rand, nsteps = 0]) -> R")
METH (x25519, "\
x25519(KEY, PUBLIC) -> SHARED")
+ METH (x448, "\
+x448(KEY, PUBLIC) -> SHARED")
METH (ed25519_pubkey, "\
ed25519_pubkey(KEY) -> PUBLIC")
KWMETH(ed25519_sign, "\