This breaks programs which thing they can parse arbitrary key-size
descriptors. The obvious such thing is the Python interface, so note
that we need a later version.
size_t keysz(size_t sz, const octet *ksz)
{
size_t keysz(size_t sz, const octet *ksz)
{
+ unsigned op = ksz[0]&KSZ_OPMASK;
+ unsigned wd = (ksz[0]&KSZ_16BIT) ? 2 : 1;
+ unsigned t, u, v;
+
+ ksz++;
+#define ARG(i) (wd == 1 ? ksz[i] : LOAD16(2*i))
- return (ksz[1]);
- else switch (ksz[0]) {
- case KSZ_ANY:
- return (sz);
+ return (ARG(0));
+ else switch (op) {
+ case KSZ_ANY: return (sz);
- if (ksz[4])
- sz -= sz % ksz[4];
- if (sz < ksz[2])
- return (0);
- if (ksz[3] && sz > ksz[3])
- return (ksz[3]);
+ t = ARG(1); u = ARG(2); v = ARG(3);
+ if (v) sz -= sz%v;
+ if (sz < t) return (0);
+ if (u && sz > u) return (u);
- case KSZ_SET: {
- unsigned q = 0;
- for (ksz++; *ksz; ksz++) {
- if (sz >= *ksz && q < *ksz)
- q = *ksz;
+ case KSZ_SET:
+ u = 0;
+ for (;;) {
+ t = ARG(0); ksz += wd; if (!t) break;
+ if (sz >= t && u < t) u = t;
assert(((void)"bad key size table", 0));
return (0);
assert(((void)"bad key size table", 0));
return (0);
* * @KSZ_SET@ requires that %$k \in {\,a_i\,}$%.
*/
* * @KSZ_SET@ requires that %$k \in {\,a_i\,}$%.
*/
+#define KSZ_OPMASK 0x1f /* Kinds of keysize specs */
enum {
KSZ_ANY, /* Allows any key at all */
KSZ_RANGE, /* Allows keys within a range */
enum {
KSZ_ANY, /* Allows any key at all */
KSZ_RANGE, /* Allows keys within a range */
- KSZ_SET /* Allows specific sizes of keys */
+ KSZ_SET, /* Allows specific sizes of keys */
+#define KSZ_16BIT 0x20 /* Arguments are 16 bits long */
+
/*----- Key sizes for symmetric algorithms --------------------------------*/
/* --- @keysz@ --- *
/*----- Key sizes for symmetric algorithms --------------------------------*/
/* --- @keysz@ --- *
Architecture: any
Depends: ${shlibs:Depends}
Recommends: catacomb-bin
Architecture: any
Depends: ${shlibs:Depends}
Recommends: catacomb-bin
+Breaks: python-catacomb (<< 1.1.2)
Description: A cryptographic library
Catacomb is a cryptographic library. It implements a large number of
encryption algorithms, hash functions, message authentication codes
Description: A cryptographic library
Catacomb is a cryptographic library. It implements a large number of
encryption algorithms, hash functions, message authentication codes