Mark Wooding [Tue, 19 Nov 2019 00:19:38 +0000 (00:19 +0000)]
*.c: Use Python's facilities for defining class and static methods.
These weren't available when this library was first written, but the
workaround is rather ugly and no longer necessary.
Mark Wooding [Mon, 18 Nov 2019 19:53:29 +0000 (19:53 +0000)]
*.c: Rearrange and reformat the class methods.
This is preparation for using Python's built-in facilities for marking
static and and class methods (which weren't around when this project
started out, which is why things are the rather strange way that they
are).
Mark Wooding [Sun, 20 Oct 2019 21:46:05 +0000 (22:46 +0100)]
*.c: Make all of the type-definition tables read-only.
The hard part is a new collection of macros which strip the `const'
qualifier from the actual table definitions, after checking that they
actually have the correct type.
And then there's the slog of actually changing all of the definitions
and using the new macros.
Mark Wooding [Mon, 21 Oct 2019 12:07:43 +0000 (13:07 +0100)]
catacomb-python.h (GEN): Remove `const' from input table type carefully.
We have this new machinery, so we should use it.
Mark Wooding [Sun, 20 Oct 2019 18:24:37 +0000 (19:24 +0100)]
pyke/pyke.c: Check conversions hidden inside `KWLIST' and `KWMETH'.
Introduce a new macro `CONVERT_CAREFULLY' which checks (via a rather
sleazy hack) that its operand is of the expected type before converting
it to some other type. This is protected by an `#ifdef' guard because
I'm thinking about adding it to a version of mLib, but I want to keep
the Pyke core independent of mLib.
Use this new macro to build better versions of `KWLIST' and `KWMETH',
which have casts hidden inside them, so that we can now be certain that
the method table entries match up with the functions. (Spoiler: they
didn't, quite, and commit
19bff42f99d41cd9b8953ff61edfe35380b54d88,
backported onto the 1.1.x branch, fixes the bug that was found by this
change.)
Mark Wooding [Sun, 20 Oct 2019 18:17:41 +0000 (19:17 +0100)]
pyke/pyke.h, key.c: Rename `INDEXERR' to `MAPERR'.
The name `INDEXERR' was pointlessly confusing, given the existing
`IXERR' which actually raises Python's `IndexError'. It's important,
though, that `KEYERR' be reserved for Catacomb's `KeyError' exception,
which really is an error about (cryptographic) keys. So `MAPERR' it is.
Mark Wooding [Fri, 10 Apr 2020 22:27:20 +0000 (23:27 +0100)]
Splice 'pyke/' prehistory from commit '
c1756f78cbf3007438b3eb2fbfbd632d070be6ca'
git-subtree-dir: pyke
git-subtree-mainline:
10e6f88a407ce04807b6ad76a81be553f8d7abaa
git-subtree-split:
c1756f78cbf3007438b3eb2fbfbd632d070be6ca
(This commit was built by hand to splice the synthetic prehistory onto
the `pyke/' subtree history.)
* pyke-prehistory.head: (83 commits)
pyke/, ...: Extract utilities into a sort-of reusable library.
(Pruned history of `catacomb-python' begins here.)
catacomb-python.h: Delete a stray trailing `\'.
catacomb-python.h: Add a macro to declare module init functions.
util.c: Replace mLib `DISCARD' with a plain `(void)' cast.
util.c: Rewrite `addmethods' to remove dependency on <mLib/darray.h>.
catacomb.c: Use a less awful version comparison.
catacomb.c, util.c: Export `modname' and set it in main entry point.
*.c: Use `Py_XDECREF' where applicable.
*.c: Reformat docstrings.
catacomb-python.h: Give up on Python versions prior to 2.5.
*.c: Use Python macros rather than functions where possible.
catacomb-python.h, *.c: Move definitions back into implementation files.
Merge branch '1.3.x'
Merge branch '1.2.x' into 1.3.x
*.c: Be more careful about `PySequence_Size'.
catacomb-python.h: Add a macro for raising `OverflowError'.
util.c (mkexc): Populate dictionary before constructing exception class.
catacomb.c, util.c: Publish negative constants correctly.
field.c: Delete the completely unused `getfe' function.
catacomb.c: Publish `RAND_IBITS' constant.
...
Mark Wooding [Sun, 20 Oct 2019 16:51:13 +0000 (17:51 +0100)]
pyke/, ...: Extract utilities into a sort-of reusable library.
This commit changes no code, but it moves a lot of it about. Tidying up
will come later.
Mark Wooding [Fri, 10 Apr 2020 22:02:06 +0000 (23:02 +0100)]
(Pruned history of `catacomb-python' begins here.)
The code which is now the `Pyke' library used to be part of the Catacomb
Python bindings. Beginning here is a pruned version of that history,
limited to the files which actually contributed to the `Pyke' codebase.
It was constructed from the original history, starting at revision
10e6f88a407ce04807b6ad76a81be553f8d7abaa, by running
git filter-branch --prune-empty --index-filter '
git ls-files -s | {
mode=old
keep=
while read m h s f; do
case $mode,$f in
old,util.c | old,catacomb.c | old,catacomb-python.h)
keep="$keep $m,$h,$f" ;;
old,pyke/*)
keep="$m,$h,${f#*/}" mode=new ;;
new,pyke/*)
keep="$keep $m,$h,${f#*/}" ;;
esac
git update-index --force-remove $f
done
for i in $keep; do
git update-index --add --cacheinfo $i
done
}
' pyke-prehistory.head -- pyke/ util.c catacomb.c catacomb-python.h
and the tucking this empty commit beneath the head which actually
introduces the `pyke/' directory. (This subterfuge is, unfortunately,
necessary for `git subtree' to construct the right history.)
Mark Wooding [Sun, 20 Oct 2019 16:51:13 +0000 (17:51 +0100)]
pyke/, ...: Extract utilities into a sort-of reusable library.
This commit changes no code, but it moves a lot of it about. Tidying up
will come later.
Mark Wooding [Tue, 22 Oct 2019 18:22:07 +0000 (19:22 +0100)]
catacomb-python.h: Delete a stray trailing `\'.
This doesn't actually hurt anything because of the following blank line,
but, umm, ...
Mark Wooding [Tue, 22 Oct 2019 18:22:07 +0000 (19:22 +0100)]
catacomb-python.h: Delete a stray trailing `\'.
This doesn't actually hurt anything because of the following blank line,
but, umm, ...
Mark Wooding [Sun, 20 Oct 2019 17:18:05 +0000 (18:18 +0100)]
catacomb-python.h: Add a macro to declare module init functions.
Mark Wooding [Sun, 20 Oct 2019 17:18:05 +0000 (18:18 +0100)]
catacomb-python.h: Add a macro to declare module init functions.
Mark Wooding [Sun, 20 Oct 2019 17:56:07 +0000 (18:56 +0100)]
util.c: Replace mLib `DISCARD' with a plain `(void)' cast.
Mark Wooding [Sun, 20 Oct 2019 17:56:07 +0000 (18:56 +0100)]
util.c: Replace mLib `DISCARD' with a plain `(void)' cast.
Mark Wooding [Sun, 20 Oct 2019 17:03:35 +0000 (18:03 +0100)]
util.c: Rewrite `addmethods' to remove dependency on <mLib/darray.h>.
Mark Wooding [Sun, 20 Oct 2019 17:03:35 +0000 (18:03 +0100)]
util.c: Rewrite `addmethods' to remove dependency on <mLib/darray.h>.
Mark Wooding [Sun, 20 Oct 2019 20:03:38 +0000 (21:03 +0100)]
catacomb.c: Use a less awful version comparison.
Mark Wooding [Sun, 20 Oct 2019 20:03:38 +0000 (21:03 +0100)]
catacomb.c: Use a less awful version comparison.
Mark Wooding [Sun, 20 Oct 2019 16:57:11 +0000 (17:57 +0100)]
catacomb.c, util.c: Export `modname' and set it in main entry point.
This is preliminary work in splitting out the Catacomb-independent
utilities so that they can be used by other projects.
Mark Wooding [Sun, 20 Oct 2019 16:57:11 +0000 (17:57 +0100)]
catacomb.c, util.c: Export `modname' and set it in main entry point.
This is preliminary work in splitting out the Catacomb-independent
utilities so that they can be used by other projects.
Mark Wooding [Sat, 19 Oct 2019 13:31:40 +0000 (14:31 +0100)]
*.c: Use `Py_XDECREF' where applicable.
The Python 2.5 version of `Py_DECREF' isn't properly braced, so `if (x)
Py_DECREF(x);' provokes a dangling-`else' warning from the compiler.
Mark Wooding [Sat, 19 Oct 2019 13:31:40 +0000 (14:31 +0100)]
*.c: Use `Py_XDECREF' where applicable.
The Python 2.5 version of `Py_DECREF' isn't properly braced, so `if (x)
Py_DECREF(x);' provokes a dangling-`else' warning from the compiler.
Mark Wooding [Fri, 22 Nov 2019 20:30:31 +0000 (20:30 +0000)]
*.c: Reformat docstrings.
No functional changes here: just changing how the strings are
represented in the source.
Mark Wooding [Fri, 22 Nov 2019 20:30:31 +0000 (20:30 +0000)]
*.c: Reformat docstrings.
No functional changes here: just changing how the strings are
represented in the source.
Mark Wooding [Fri, 22 Nov 2019 22:43:02 +0000 (22:43 +0000)]
catacomb-python.h: Give up on Python versions prior to 2.5.
Mark Wooding [Fri, 22 Nov 2019 20:22:45 +0000 (20:22 +0000)]
mp.c: Improve docstring.
Mark Wooding [Sun, 24 Nov 2019 12:35:45 +0000 (12:35 +0000)]
*.c: Use Python macros rather than functions where possible.
Mark Wooding [Fri, 22 Nov 2019 18:34:56 +0000 (18:34 +0000)]
pgen.c: Write a `pgen' status code as `PGST' consistently in docstrings.
Mark Wooding [Sun, 20 Oct 2019 14:56:54 +0000 (15:56 +0100)]
catacomb-python.h, *.c: Move definitions back into implementation files.
The header was chock full of implementation details which weren't
needed by anything. Move things which aren't needed further afield back
into their home files, and delete things like conversion functions which
aren't actually being used.
Also, some light reordering of the things that are left.
(This patch turns out to be remarkably commutative through the enormous
pile of changes coming up.)
Mark Wooding [Sun, 20 Oct 2019 21:53:24 +0000 (22:53 +0100)]
key.c: Delete the `barf' function.
What even?
I think this must have been ancient debugging code, but it should never
have seen release.
Mark Wooding [Sun, 20 Oct 2019 21:07:40 +0000 (22:07 +0100)]
bytestring.c: Delete unused buffer methods on `C.ByteString'.
I think this was needed in some ancient Python in order to inherit the
buffer methods from `str', but Python 2.5 certainly works fine without.
Mark Wooding [Sun, 20 Oct 2019 20:08:32 +0000 (21:08 +0100)]
buffer.c: Give `BufferError' a text message.
Mark Wooding [Fri, 22 Nov 2019 22:43:02 +0000 (22:43 +0000)]
catacomb-python.h: Give up on Python versions prior to 2.5.
Mark Wooding [Wed, 23 Oct 2019 09:41:34 +0000 (10:41 +0100)]
field.c: Push field-polynomial property into binary-field base class.
Using the same code as for prime fields was a mistake, but sharing the
same code between polynomial- and normal-basis fields works just fine;
but there's no point in duplicating the property-table entry when
there's a perfectly good superclass to hang the property off -- and it
already has a property table!
Mark Wooding [Sun, 24 Nov 2019 12:35:45 +0000 (12:35 +0000)]
*.c: Use Python macros rather than functions where possible.
Mark Wooding [Sun, 20 Oct 2019 14:56:54 +0000 (15:56 +0100)]
catacomb-python.h, *.c: Move definitions back into implementation files.
The header was chock full of implementation details which weren't
needed by anything. Move things which aren't needed further afield back
into their home files, and delete things like conversion functions which
aren't actually being used.
Also, some light reordering of the things that are left.
(This patch turns out to be remarkably commutative through the enormous
pile of changes coming up.)
Mark Wooding [Sun, 24 Nov 2019 12:08:34 +0000 (12:08 +0000)]
.gitignore: Reorder the patterns and make them more specific.
Place recursively applicable patterns at the top (just `*.pyc' for
now). Prefix others with `/' to keep them local. Suffix directory
names with `/' for clarity's sake.
Mark Wooding [Sun, 24 Nov 2019 11:35:32 +0000 (11:35 +0000)]
.gitignore: Delete some obsolete things.
I think `dist' and `deb-build' were from old private workflow that
shouldn't have leaked into the master repository. I have a vague
recollection that `build-stamp' was from CDBS, which we no longer use.
I honestly have no idea what `py' and `test.py' were, but they've been
there from the beginning.
Mark Wooding [Sun, 24 Nov 2019 12:05:48 +0000 (12:05 +0000)]
catacomb/.gitignore: Delete obsolete file.
I think this was only created because Subversion ignore patterns didn't
affect subdirectories.
Mark Wooding [Tue, 7 Apr 2020 23:53:56 +0000 (00:53 +0100)]
.gdbinit: Delete this obsolete file.
It's set up for my particular development environment, using a Python
version that's not even supported any more. And project-specific
`.gdbinit' files really don't work very well as things to distribute,
for vaguely obvious security reasons.
Mark Wooding [Tue, 7 Apr 2020 23:59:00 +0000 (00:59 +0100)]
Merge branch '1.3.x' into HEAD
* 1.3.x:
t/t-rand.py: Set the correct refernce seed value for `dsarand'.
rand.c: More `Py_ssize_t' fixes.
Mark Wooding [Tue, 7 Apr 2020 23:40:52 +0000 (00:40 +0100)]
t/t-rand.py: Set the correct refernce seed value for `dsarand'.
The number of steps taken is different on 32- and 64-bit platforms, with
no especially easy way to calculate it in a principled way. Just use a
stupid case analysis to get the right answer.
Mark Wooding [Tue, 7 Apr 2020 23:56:01 +0000 (00:56 +0100)]
Merge branch '1.2.x' into 1.3.x
* 1.2.x:
rand.c: More `Py_ssize_t' fixes.
Mark Wooding [Tue, 7 Apr 2020 23:19:14 +0000 (00:19 +0100)]
rand.c: More `Py_ssize_t' fixes.
Mark Wooding [Mon, 6 Apr 2020 02:38:50 +0000 (02:38 +0000)]
Merge branch '1.3.x'
* 1.3.x:
ec.c: Fix length type which should have been `Py_ssize_t'.
Mark Wooding [Mon, 6 Apr 2020 02:38:33 +0000 (02:38 +0000)]
Merge branch '1.2.x' into 1.3.x
* 1.2.x:
ec.c: Fix length type which should have been `Py_ssize_t'.
Mark Wooding [Mon, 6 Apr 2020 02:34:24 +0000 (02:34 +0000)]
ec.c: Fix length type which should have been `Py_ssize_t'.
Mark Wooding [Wed, 27 Nov 2019 15:12:23 +0000 (15:12 +0000)]
Merge branch '1.3.x'
* 1.3.x: (101 commits)
rand.c: Show keyword argument as optional.
mp.c: Fix punctuation error in docstrings.
t/t-*.py: Use the `WriteBuffer.contents' property.
t/t-bytes.py: Check that indexing, slicing, etc. return `C.ByteString'.
t/t-algorithms.py: Add a simple test for `Keccak1600.copy'.
t/t-algorithms.py: Add tests for other HSalsa20 and HChaCha key sizes.
t/t-algorithms.py: Add AEAD tests.
t/t-algorithms.py: Add tests for the new `KeySZ.pad' method.
catacomb/__init__.py (KeySZRange.pad): Return correct value.
algorithms.c: Propagate `AEADF_NOAAD' to `aad' objects.
algorithms.c (
AEADAAD.copy): Propagate the hashed length to the copy.
t/: Add a test suite.
ec.c: Don't lose error status when constructing points from a sequence.
ec.c: Free partially constructed points coordinatewise.
*.c: Be more careful about `PySequence_Size'.
key.c: Reformat the rest of the `KeyError' constructor.
key.c: Parse `KeyError' constructor arguments by hand.
catacomb-python.h: Add a macro for raising `OverflowError'.
key.c: Collect `KeyError' argument count as a separate step.
key.c: Use tuple functions on `KeyError' argument tuple.
...
Mark Wooding [Wed, 27 Nov 2019 15:12:23 +0000 (15:12 +0000)]
Merge branch '1.3.x'
* 1.3.x: (101 commits)
rand.c: Show keyword argument as optional.
mp.c: Fix punctuation error in docstrings.
t/t-*.py: Use the `WriteBuffer.contents' property.
t/t-bytes.py: Check that indexing, slicing, etc. return `C.ByteString'.
t/t-algorithms.py: Add a simple test for `Keccak1600.copy'.
t/t-algorithms.py: Add tests for other HSalsa20 and HChaCha key sizes.
t/t-algorithms.py: Add AEAD tests.
t/t-algorithms.py: Add tests for the new `KeySZ.pad' method.
catacomb/__init__.py (KeySZRange.pad): Return correct value.
algorithms.c: Propagate `AEADF_NOAAD' to `aad' objects.
algorithms.c (
AEADAAD.copy): Propagate the hashed length to the copy.
t/: Add a test suite.
ec.c: Don't lose error status when constructing points from a sequence.
ec.c: Free partially constructed points coordinatewise.
*.c: Be more careful about `PySequence_Size'.
key.c: Reformat the rest of the `KeyError' constructor.
key.c: Parse `KeyError' constructor arguments by hand.
catacomb-python.h: Add a macro for raising `OverflowError'.
key.c: Collect `KeyError' argument count as a separate step.
key.c: Use tuple functions on `KeyError' argument tuple.
...
Mark Wooding [Fri, 22 Nov 2019 17:23:46 +0000 (17:23 +0000)]
rand.c: Show keyword argument as optional.
Mark Wooding [Fri, 22 Nov 2019 18:56:54 +0000 (18:56 +0000)]
mp.c: Fix punctuation error in docstrings.
Mark Wooding [Sun, 17 Nov 2019 23:46:49 +0000 (23:46 +0000)]
t/t-*.py: Use the `WriteBuffer.contents' property.
Mark Wooding [Sun, 17 Nov 2019 23:44:57 +0000 (23:44 +0000)]
t/t-bytes.py: Check that indexing, slicing, etc. return `C.ByteString'.
Mark Wooding [Sun, 17 Nov 2019 23:42:26 +0000 (23:42 +0000)]
t/t-algorithms.py: Add a simple test for `Keccak1600.copy'.
Mark Wooding [Sun, 17 Nov 2019 23:42:00 +0000 (23:42 +0000)]
t/t-algorithms.py: Add tests for other HSalsa20 and HChaCha key sizes.
Mark Wooding [Sun, 17 Nov 2019 23:41:36 +0000 (23:41 +0000)]
t/t-algorithms.py: Add AEAD tests.
Mark Wooding [Sun, 17 Nov 2019 23:41:14 +0000 (23:41 +0000)]
t/t-algorithms.py: Add tests for the new `KeySZ.pad' method.
Mark Wooding [Sun, 17 Nov 2019 23:23:41 +0000 (23:23 +0000)]
catacomb/__init__.py (KeySZRange.pad): Return correct value.
If the input is already a multiple of the modulus, then don't round up
to the next one.
Mark Wooding [Sun, 13 Oct 2019 23:55:20 +0000 (00:55 +0100)]
algorithms.c: Propagate `AEADF_NOAAD' to `aad' objects.
Mark Wooding [Sun, 13 Oct 2019 23:52:58 +0000 (00:52 +0100)]
algorithms.c (
AEADAAD.copy): Propagate the hashed length to the copy.
Mark Wooding [Wed, 27 Nov 2019 15:11:08 +0000 (15:11 +0000)]
Merge branch '1.2.x' into 1.3.x
* 1.2.x: (89 commits)
t/: Add a test suite.
ec.c: Don't lose error status when constructing points from a sequence.
ec.c: Free partially constructed points coordinatewise.
*.c: Be more careful about `PySequence_Size'.
key.c: Reformat the rest of the `KeyError' constructor.
key.c: Parse `KeyError' constructor arguments by hand.
catacomb-python.h: Add a macro for raising `OverflowError'.
key.c: Collect `KeyError' argument count as a separate step.
key.c: Use tuple functions on `KeyError' argument tuple.
key.c: Rename sad-path label to `end'.
key.c: Delete duplicate setting of `errstring'.
util.c (mkexc): Populate dictionary before constructing exception class.
key.c: Only set the error code.
catacomb.c, util.c: Publish negative constants correctly.
field.c: Delete the completely unused `getfe' function.
key.c (convfilter): Fix sense of error tests.
buffer.c, ec.c: Fix required size for EC `buffer' encoding.
algorithms.c: Fix `max' property name in docstrings.
catacomb/__init__.py (_HashBase): Check that integers are within bounds.
debian/rules: Build using the provided Makefile.
...
Mark Wooding [Wed, 27 Nov 2019 15:11:08 +0000 (15:11 +0000)]
Merge branch '1.2.x' into 1.3.x
* 1.2.x: (89 commits)
t/: Add a test suite.
ec.c: Don't lose error status when constructing points from a sequence.
ec.c: Free partially constructed points coordinatewise.
*.c: Be more careful about `PySequence_Size'.
key.c: Reformat the rest of the `KeyError' constructor.
key.c: Parse `KeyError' constructor arguments by hand.
catacomb-python.h: Add a macro for raising `OverflowError'.
key.c: Collect `KeyError' argument count as a separate step.
key.c: Use tuple functions on `KeyError' argument tuple.
key.c: Rename sad-path label to `end'.
key.c: Delete duplicate setting of `errstring'.
util.c (mkexc): Populate dictionary before constructing exception class.
key.c: Only set the error code.
catacomb.c, util.c: Publish negative constants correctly.
field.c: Delete the completely unused `getfe' function.
key.c (convfilter): Fix sense of error tests.
buffer.c, ec.c: Fix required size for EC `buffer' encoding.
algorithms.c: Fix `max' property name in docstrings.
catacomb/__init__.py (_HashBase): Check that integers are within bounds.
debian/rules: Build using the provided Makefile.
...
Mark Wooding [Sat, 16 Nov 2019 18:53:24 +0000 (18:53 +0000)]
t/: Add a test suite.
It's fairly substantial, but far from complete. It's also a little
strange in places because it's been sent backwards in time from the
future.
When building the Debian package, run the tests verbosely, so that if
the test crashes I stand a chance of figuring out where.
Mark Wooding [Sun, 24 Nov 2019 16:36:24 +0000 (16:36 +0000)]
*.c: Be more careful about `PySequence_Size'.
This can be implemented by Python, so it can throw exceptions.
Fortunately, Python checks that the result is nonnegative, so we don't
have to worry about that.
Mark Wooding [Sun, 24 Nov 2019 22:30:48 +0000 (22:30 +0000)]
ec.c: Don't lose error status when constructing points from a sequence.
The code would call `ecptxl_2' or `ecptxl_3' as appropriate, stash the
error status in `rc', and then fall out of the `if/else if' ladder to
`ok' -- which clobbers `rc', losing the error. This is unfortunate if
the point has been partially filled in.
The right fix is to go unconditionally to `end'. We already have `rc'
set appropriately, so `ok' isn't necessary; `ecptxl_2' has already
converted the point to internal form, and `ecptxl_3' constructs the
point in internal form anyway, so it would be wrong to drop into `fix'.
Mark Wooding [Sun, 24 Nov 2019 14:59:35 +0000 (14:59 +0000)]
catacomb-python.h: Add a macro for raising `OverflowError'.
Mark Wooding [Sun, 24 Nov 2019 22:16:53 +0000 (22:16 +0000)]
ec.c: Free partially constructed points coordinatewise.
The `EC_DESTROY' macro assumes that the other coordinates are null if
and only if `p->x' is. This works badly with the current code
structure, which fills in coordinates as it goes along, and I think this
is a better fix than trying to maintain the coordinates in temporaries
until we're done.
Mark Wooding [Sun, 24 Nov 2019 16:36:24 +0000 (16:36 +0000)]
*.c: Be more careful about `PySequence_Size'.
This can be implemented by Python, so it can throw exceptions.
Fortunately, Python checks that the result is nonnegative, so we don't
have to worry about that.
Mark Wooding [Sun, 24 Nov 2019 16:26:22 +0000 (16:26 +0000)]
key.c: Reformat the rest of the `KeyError' constructor.
Mark Wooding [Sun, 24 Nov 2019 16:25:18 +0000 (16:25 +0000)]
key.c: Parse `KeyError' constructor arguments by hand.
This allows additional arguments to be stored, as is conventional for
exception classes.
Mark Wooding [Sun, 24 Nov 2019 14:59:35 +0000 (14:59 +0000)]
catacomb-python.h: Add a macro for raising `OverflowError'.
Mark Wooding [Sun, 24 Nov 2019 16:21:09 +0000 (16:21 +0000)]
key.c: Collect `KeyError' argument count as a separate step.
Mark Wooding [Sun, 24 Nov 2019 15:07:08 +0000 (15:07 +0000)]
util.c (mkexc): Populate dictionary before constructing exception class.
It turns out that the dictionary contents are copied into the new class
rather than being used by reference, so populating it later doesn't
actually do anything.
Mark Wooding [Sun, 24 Nov 2019 16:19:14 +0000 (16:19 +0000)]
key.c: Use tuple functions on `KeyError' argument tuple.
Mark Wooding [Sun, 24 Nov 2019 15:11:46 +0000 (15:11 +0000)]
catacomb.c, util.c: Publish negative constants correctly.
The various `KERR_...' constants and `PGEN_ABORT' are canonically
negative integers, but weren't published correctly. Add a flags word to
`struct nameval' to identify constants which should really be signed,
and some fancy footwork to convert unsigned integers back to negative
values without upsetting C. Adjust the `C' macro to spot negative
constants and mark them specially.
Not all is well. In particular, the `KEXP_...' constants should /not/
be published as signed values, even if `time_t' is signed on the target
platform, because the Python bindings handle them exclusively as
`unsigned long' values. To make this work, also introduce `CF' which
allows us to set the flags explicitly, and use it for `KEXP_...'.
Mark Wooding [Sun, 24 Nov 2019 14:54:21 +0000 (14:54 +0000)]
key.c: Rename sad-path label to `end'.
Now we can use our exception-raising macros.
Mark Wooding [Sun, 24 Nov 2019 14:48:27 +0000 (14:48 +0000)]
key.c: Delete duplicate setting of `errstring'.
This code is a total mess, and doesn't work anyway. Let's start
cleaning it up.
Mark Wooding [Sun, 24 Nov 2019 15:07:08 +0000 (15:07 +0000)]
util.c (mkexc): Populate dictionary before constructing exception class.
It turns out that the dictionary contents are copied into the new class
rather than being used by reference, so populating it later doesn't
actually do anything.
Mark Wooding [Sun, 24 Nov 2019 14:50:01 +0000 (14:50 +0000)]
key.c: Only set the error code.
This briefly makes the error string unavailable, but only because the
actual constructor isn't wired up -- and if it were wired up then it
would fail immediately because it's programmed to accept only a single
argument.
Mark Wooding [Sun, 24 Nov 2019 15:11:46 +0000 (15:11 +0000)]
catacomb.c, util.c: Publish negative constants correctly.
The various `KERR_...' constants and `PGEN_ABORT' are canonically
negative integers, but weren't published correctly. Add a flags word to
`struct nameval' to identify constants which should really be signed,
and some fancy footwork to convert unsigned integers back to negative
values without upsetting C. Adjust the `C' macro to spot negative
constants and mark them specially.
Not all is well. In particular, the `KEXP_...' constants should /not/
be published as signed values, even if `time_t' is signed on the target
platform, because the Python bindings handle them exclusively as
`unsigned long' values. To make this work, also introduce `CF' which
allows us to set the flags explicitly, and use it for `KEXP_...'.
Mark Wooding [Sat, 23 Nov 2019 16:04:29 +0000 (16:04 +0000)]
field.c: Delete the completely unused `getfe' function.
It was introduced in the original commit, and never used at all.
Mark Wooding [Sat, 23 Nov 2019 16:04:29 +0000 (16:04 +0000)]
field.c: Delete the completely unused `getfe' function.
It was introduced in the original commit, and never used at all.
Mark Wooding [Thu, 21 Nov 2019 18:23:56 +0000 (18:23 +0000)]
key.c (convfilter): Fix sense of error tests.
So this never worked either.
Mark Wooding [Thu, 21 Nov 2019 19:53:22 +0000 (19:53 +0000)]
buffer.c, ec.c: Fix required size for EC `buffer' encoding.
The problem is zero coordinates: the point at infinity is encoded as a
zero length word, so zero coordinates must be encoded as a single zero
byte, preceded by a length word of 1 -- which overruns the output buffer
provided, unless we take special care, which we haven't.
Mark Wooding [Tue, 19 Nov 2019 22:33:12 +0000 (22:33 +0000)]
algorithms.c: Fix `max' property name in docstrings.
How embarrassing.
Mark Wooding [Sun, 17 Nov 2019 22:57:47 +0000 (22:57 +0000)]
catacomb/__init__.py (_HashBase): Check that integers are within bounds.
The version of the `struct' module included with Python 2.5 writes a
warning to `stderr' and truncates rather than raising an exception. Do
the work ourselves.
Mark Wooding [Sun, 17 Nov 2019 04:23:00 +0000 (04:23 +0000)]
debian/rules: Build using the provided Makefile.
There were several problems with the old system. Firstly, it only
actually worked by accident: setting an explicit build directory caused
Debhelper to search there for a makefile (which it didn't find, for
obvious reasons) and fall back to the Python distutils system. That
would be OK, but only because there's only been one Python version I've
wanted to support in Debian for ages; but that's likely to change. And
it won't run tests properly.
Instead, delete the `-B' option (which will break the upcoming tests).
Now Debhelper will build via the Makefile. Set the `PYTHONS'
environment variable to the Python versions supported in Debian. And
set the prefix correctly during installation.
Mark Wooding [Mon, 25 Nov 2019 17:30:56 +0000 (17:30 +0000)]
debian/control: Add an explicit build-dependency on `dh-python'.
Mark Wooding [Sun, 17 Nov 2019 03:14:31 +0000 (03:14 +0000)]
catacomb.c: Publish `RAND_IBITS' constant.
This is a limit on how much you can request in `seed', so it's sort of
important.
Mark Wooding [Sun, 17 Nov 2019 03:14:51 +0000 (03:14 +0000)]
catacomb/__init__.py: Make KMAC `copy' work.
Two fixes needed:
* Return the `new' object from `copy'.
* Introduce a `_bare_new' class method to handle constructing the
destination object, because `KMAC...' objects need a key argument.
Mark Wooding [Sun, 17 Nov 2019 01:34:12 +0000 (01:34 +0000)]
util.c: Make `default' arguments optional in `get', `setdefault', `pop'.
Alas, `pop' is a little trickier than the others.
Mark Wooding [Sun, 17 Nov 2019 03:14:31 +0000 (03:14 +0000)]
catacomb.c: Publish `RAND_IBITS' constant.
This is a limit on how much you can request in `seed', so it's sort of
important.
Mark Wooding [Sun, 17 Nov 2019 01:33:34 +0000 (01:33 +0000)]
util.c: Fix sense of error check in `popitem'.
Mark Wooding [Fri, 15 Nov 2019 18:30:55 +0000 (18:30 +0000)]
rand.c: Fix `TrueRand' constructor so it can possibly work.
Mark Wooding [Fri, 15 Nov 2019 13:30:43 +0000 (13:30 +0000)]
pubkey.c (RSAPriv): Fix segfault if `p' is provided but not `q'.
Stupid typo.
Mark Wooding [Mon, 14 Oct 2019 00:04:46 +0000 (01:04 +0100)]
catacomb/__init__.py (_ShakeBase._copy): Actally copy the hash state.
Rather than sharing because that doesn't end well.
Mark Wooding [Mon, 14 Oct 2019 00:03:58 +0000 (01:03 +0100)]
algorithms.c (ShakeNN.copy): Return the copy rather than the original.
Mark Wooding [Mon, 14 Oct 2019 00:00:20 +0000 (01:00 +0100)]
algorithms.c (KECCAK.extract): Fix method name in keyword-args string.