865 static PyObject *py_sss_encrypt(PySssPasswordObject *self,
866 PyObject *args,
867 PyObject *kwds)
868 {
869 char *password = NULL;
870 int plen; /* may contain NULL bytes */
871 char *obfpwd = NULL;
872 TALLOC_CTX *tctx = NULL;
873 int ret;
874 int mode;
875 PyObject *retval = NULL;
876
877 /* parse arguments */
878 if (!PyArg_ParseTuple(args, discard_const_p(char, "s#i"),
879 &password, &plen, &mode)) {
when PyArg_ParseTuple() succeeds
taking False path
880 return NULL;
881 }
882
883 tctx = talloc_new(NULL);
884 if (!tctx) {
885 PyErr_NoMemory();
when treating unknown void * from src/python/pysss.c:884 as non-NULL
taking False path
886 return NULL;
887 }
888
889 ret = sss_password_encrypt(tctx, password, plen+1,
890 mode, &obfpwd);
891 if (ret != EOK) {
892 PyErr_SetSssError(ret);
when considering range: -0x80000000 <= value <= -1
taking True path
893 goto fail;
894 }
895
896 retval = Py_BuildValue(sss_py_const_p(char, "s"), obfpwd);
897 if (retval == NULL) {
898 goto fail;
899 }
900
901 fail:
902 talloc_zfree(tctx);
903 return retval;
904 }
905