Skip to content

Commit

Permalink
Remove python2 blocks from C code
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKueltz committed Dec 26, 2019
1 parent f9baf6a commit 85d9403
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 26 deletions.
13 changes: 0 additions & 13 deletions src/_chacha20.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,14 @@ static PyObject * _chacha20_cipher(PyObject *self, PyObject *args) {
ChaCha20XOR(out, (unsigned char *)in, msgLen, (unsigned char *)key, (unsigned char *)nonce,
counter);

#if PY_MAJOR_VERSION >= 3
return Py_BuildValue("y#", out, msgLen);
#else
return Py_BuildValue("s#", out, msgLen);
#endif
}

static PyMethodDef _chacha20__methods__[] = {
{"cipher", _chacha20_cipher, METH_VARARGS, "Encrypt / Decrypt data via"},
{NULL, NULL, 0, NULL} /* Sentinel */
};


#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"_chacha20",
Expand All @@ -160,10 +154,3 @@ PyMODINIT_FUNC PyInit__chacha20(void) {
PyObject * m = PyModule_Create(&moduledef);
return m;
}


#else
PyMODINIT_FUNC init_chacha20(void) {
Py_InitModule("_chacha20", _chacha20__methods__);
}
#endif
13 changes: 0 additions & 13 deletions src/_poly1305.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,20 +278,14 @@ static PyObject * _poly1305_tag(PyObject *self, PyObject *args) {
Poly1305Update(&state, (unsigned char *)msg, msgLen);
Poly1305Finish(&state, mac);

#if PY_MAJOR_VERSION >= 3
return Py_BuildValue("y#", mac, macSize);
#else
return Py_BuildValue("s#", mac, macSize);
#endif
}

static PyMethodDef _poly1305__methods__[] = {
{"tag", _poly1305_tag, METH_VARARGS, "Tag a message via Poly1305."},
{NULL, NULL, 0, NULL} /* Sentinel */
};


#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"_poly1305",
Expand All @@ -308,10 +302,3 @@ PyMODINIT_FUNC PyInit__poly1305(void) {
PyObject * m = PyModule_Create(&moduledef);
return m;
}


#else
PyMODINIT_FUNC init_poly1305(void) {
Py_InitModule("_poly1305", _poly1305__methods__);
}
#endif

0 comments on commit 85d9403

Please sign in to comment.