~mdw
/
catacomb-python
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
algorithms.c, ec.c, field.c: Replace properties by member access.
[catacomb-python]
/
catacomb.c
diff --git
a/catacomb.c
b/catacomb.c
index
d7b3dc7
..
01311bf
100644
(file)
--- a/
catacomb.c
+++ b/
catacomb.c
@@
-31,7
+31,8
@@
/*----- Main code ---------------------------------------------------------*/
static const struct nameval consts[] = {
/*----- Main code ---------------------------------------------------------*/
static const struct nameval consts[] = {
-#define C(x) { #x, x }
+#define CF(f, x) { #x, f, x }
+#define C(x) { #x, 0, x }
C(FTY_PRIME), C(FTY_BINARY),
C(PGEN_PASS), C(PGEN_FAIL), C(PGEN_BEGIN), C(PGEN_TRY), C(PGEN_DONE),
C(PGEN_ABORT),
C(FTY_PRIME), C(FTY_BINARY),
C(PGEN_PASS), C(PGEN_FAIL), C(PGEN_BEGIN), C(PGEN_TRY), C(PGEN_DONE),
C(PGEN_ABORT),
@@
-51,10
+52,13
@@
static const struct nameval consts[] = {
C(ED25519_KEYSZ), C(ED25519_PUBSZ), C(ED25519_SIGSZ),
C(ED25519_MAXPERSOSZ),
C(ED448_KEYSZ), C(ED448_PUBSZ), C(ED448_SIGSZ), C(ED448_MAXPERSOSZ),
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),
+ C(AEADF_PCHSZ), C(AEADF_PCMSZ), C(AEADF_PCTSZ),
+ C(AEADF_AADNDEP), C(AEADF_AADFIRST), C(AEADF_NOAAD),
+#define ENTRY(tag, val, str) CF(CF_SIGNED, KERR_##tag),
KEY_ERRORS(ENTRY)
#undef ENTRY
#undef C
KEY_ERRORS(ENTRY)
#undef ENTRY
#undef C
+#undef CF
{ 0 }
};
{ 0 }
};
@@
-70,11
+74,12
@@
PyObject *mexp_common(PyObject *me, PyObject *arg,
PyObject *qq, *x, *y, *z = 0;
char *v = 0, *vv;
PyObject *qq, *x, *y, *z = 0;
char *v = 0, *vv;
- if (PyTuple_
Size
(arg) == 1)
- arg = PyTuple_G
etItem
(arg, 0);
+ if (PyTuple_
GET_SIZE
(arg) == 1)
+ arg = PyTuple_G
ET_ITEM
(arg, 0);
Py_INCREF(arg);
if (!PySequence_Check(arg)) TYERR("not a sequence");
Py_INCREF(arg);
if (!PySequence_Check(arg)) TYERR("not a sequence");
- n = PySequence_Size(arg); if (!n) { z = id(me); goto end; }
+ n = PySequence_Size(arg); if (n < 0) goto end;
+ if (!n) { z = id(me); goto end; }
x = PySequence_GetItem(arg, 0);
if (PySequence_Check(x))
flat = 0;
x = PySequence_GetItem(arg, 0);
if (PySequence_Check(x))
flat = 0;
@@
-124,13
+129,26
@@
end:
return (z);
}
return (z);
}
+int convmpw(PyObject *o, void *pp)
+{
+ unsigned long u;
+ unsigned *p = pp;
+
+ if (!convulong(o, &u)) goto end;
+ if (u > MPW_MAX) VALERR("out of range");
+ *p = u;
+ return (1);
+end:
+ return (0);
+}
+
static PyObject *smallprimes(void)
{
PyObject *v = PyList_New(NPRIME);
int i;
for (i = 0; i < NPRIME; i++)
static PyObject *smallprimes(void)
{
PyObject *v = PyList_New(NPRIME);
int i;
for (i = 0; i < NPRIME; i++)
- PyList_S
etItem
(v, i, PyInt_FromLong(primetab[i]));
+ PyList_S
ET_ITEM
(v, i, PyInt_FromLong(primetab[i]));
return (v);
}
return (v);
}
@@
-139,36
+157,38
@@
static PyObject *meth__ego(PyObject *me, PyObject *arg)
char *argv0;
if (!PyArg_ParseTuple(arg, "s:_ego", &argv0))
return (0);
char *argv0;
if (!PyArg_ParseTuple(arg, "s:_ego", &argv0))
return (0);
- if (
strcmp(QUIS, "<UNNAMED>") == 0
)
+ if (
STRCMP(QUIS, ==, "<UNNAMED>")
)
ego(argv0);
RETURN_NONE;
}
static PyMethodDef methods[] = {
#define METHNAME(func) meth_##func
ego(argv0);
RETURN_NONE;
}
static PyMethodDef methods[] = {
#define METHNAME(func) meth_##func
- METH (_ego,
"_ego(ARGV0)")
+ METH (_ego, "_ego(ARGV0)")
#undef METHNAME
{ 0 }
};
static void init_random(void)
{
#undef METHNAME
{ 0 }
};
static void init_random(void)
{
-#if PY_
MAJOR_VERSION >= 3 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 6)
+#if PY_
VERSION_HEX >= 0x02060000
char *seed;
uint32 r;
if (!Py_HashRandomizationFlag) return;
seed = getenv("PYTHONHASHSEED");
char *seed;
uint32 r;
if (!Py_HashRandomizationFlag) return;
seed = getenv("PYTHONHASHSEED");
- if (!seed ||
strcmp(seed, "random") == 0
) r = GR_WORD(&rand_global);
+ if (!seed ||
STRCMP(seed, ==, "random")
) r = GR_WORD(&rand_global);
else r = strtoul(seed, 0, 0);
if (!r) r = 0xe011f220; /* zero doesn't work well */
unihash_setkey(&unihash_global, r);
#endif
}
else r = strtoul(seed, 0, 0);
if (!r) r = 0xe011f220; /* zero doesn't work well */
unihash_setkey(&unihash_global, r);
#endif
}
-void init_base(void)
+
EXPORT
void init_base(void)
{
PyObject *mod;
{
PyObject *mod;
+
+ modname = PyString_FromString("catacomb");
addmethods(methods);
INIT_MODULES;
init_random();
addmethods(methods);
INIT_MODULES;
init_random();