Set ELF visibility to keep all of our external symbols to ourselves.
[pyke] / catacomb.c
index 65d3985..affb5d3 100644 (file)
@@ -1,13 +1,11 @@
 /* -*-c-*-
  *
- * $Id$
- *
  * Where the fun begins
  *
  * (c) 2004 Straylight/Edgeware
  */
 
-/*----- Licensing notice --------------------------------------------------* 
+/*----- Licensing notice --------------------------------------------------*
  *
  * This file is part of the Python interface to Catacomb.
  *
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * Catacomb/Python is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with Catacomb/Python; if not, write to the Free Software Foundation,
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -46,6 +44,14 @@ static const struct nameval consts[] = {
   C(KF_CATMASK), C(KCAT_SYMM), C(KCAT_PRIV), C(KCAT_PUB), C(KCAT_SHARE),
   C(KF_NONSECRET),
   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),
+    C(ED25519_MAXPERSOSZ),
+  C(ED448_KEYSZ), C(ED448_PUBSZ), C(ED448_SIGSZ), C(ED448_MAXPERSOSZ),
+  C(AEADF_PCHSZ), C(AEADF_PCMSZ), C(AEADF_PCTSZ),
+  C(AEADF_AADNDEP), C(AEADF_AADFIRST), C(AEADF_NOAAD),
 #define ENTRY(tag, val, str) C(KERR_##tag),
   KEY_ERRORS(ENTRY)
 #undef ENTRY
@@ -146,11 +152,27 @@ static PyMethodDef methods[] = {
   { 0 }
 };
 
-void init_base(void)
+static void init_random(void)
+{
+#if PY_MAJOR_VERSION >= 3 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 6)
+  char *seed;
+  uint32 r;
+
+  if (!Py_HashRandomizationFlag) return;
+  seed = getenv("PYTHONHASHSEED");
+  if (!seed || strcmp(seed, "random") == 0) 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
+}
+
+EXPORT void init_base(void)
 {
   PyObject *mod;
   addmethods(methods);
   INIT_MODULES;
+  init_random();
   mod = Py_InitModule("catacomb._base", donemethods());
   INSERT_MODULES;
   INSERT("smallprimes", smallprimes());