2 Unix SMB/CIFS implementation.
3 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "lib/replace/system/python.h"
20 #include "python/py3compat.h"
22 #include "python/modules.h"
23 #include "pycredentials.h"
24 #include "param/param.h"
25 #include "auth/credentials/credentials_internal.h"
26 #include "auth/credentials/credentials_krb5.h"
27 #include "librpc/gen_ndr/dcerpc.h"
28 #include "librpc/gen_ndr/samr.h" /* for struct samr_Password */
29 #include "librpc/gen_ndr/netlogon.h"
30 #include "libcli/util/pyerrors.h"
31 #include "libcli/auth/libcli_auth.h"
32 #include "param/pyparam.h"
34 #include "libcli/auth/libcli_auth.h"
35 #include "system/kerberos.h"
36 #include "auth/kerberos/kerberos.h"
37 #include "libcli/smb/smb_constants.h"
39 static PyObject
*py_creds_new(PyTypeObject
*type
, PyObject
*args
, PyObject
*kwargs
)
41 return pytalloc_steal(type
, cli_credentials_init(NULL
));
44 static PyObject
*PyCredentials_from_cli_credentials(struct cli_credentials
*creds
)
46 return pytalloc_reference(&PyCredentials
, creds
);
49 static PyObject
*py_creds_get_username(PyObject
*self
, PyObject
*unused
)
51 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
53 PyErr_Format(PyExc_TypeError
, "Credentials expected");
56 return PyString_FromStringOrNULL(cli_credentials_get_username(creds
));
59 static PyObject
*py_creds_set_username(PyObject
*self
, PyObject
*args
)
62 enum credentials_obtained obt
= CRED_SPECIFIED
;
64 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
66 PyErr_Format(PyExc_TypeError
, "Credentials expected");
70 if (!PyArg_ParseTuple(args
, "s|i", &newval
, &_obt
)) {
75 return PyBool_FromLong(cli_credentials_set_username(creds
, newval
, obt
));
78 static PyObject
*py_creds_get_ntlm_username_domain(PyObject
*self
, PyObject
*unused
)
80 TALLOC_CTX
*frame
= talloc_stackframe();
81 const char *user
= NULL
;
82 const char *domain
= NULL
;
84 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
86 PyErr_Format(PyExc_TypeError
, "Credentials expected");
89 cli_credentials_get_ntlm_username_domain(creds
,
90 frame
, &user
, &domain
);
91 ret
= Py_BuildValue("(ss)",
99 static PyObject
*py_creds_get_ntlm_response(PyObject
*self
, PyObject
*args
, PyObject
*kwargs
)
101 TALLOC_CTX
*frame
= talloc_stackframe();
102 PyObject
*ret
= NULL
;
104 struct timeval tv_now
;
105 NTTIME server_timestamp
;
106 DATA_BLOB challenge
= data_blob_null
;
107 DATA_BLOB target_info
= data_blob_null
;
109 DATA_BLOB lm_response
= data_blob_null
;
110 DATA_BLOB nt_response
= data_blob_null
;
111 DATA_BLOB lm_session_key
= data_blob_null
;
112 DATA_BLOB nt_session_key
= data_blob_null
;
113 const char *kwnames
[] = { "flags", "challenge",
116 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
118 PyErr_Format(PyExc_TypeError
, "Credentials expected");
122 tv_now
= timeval_current();
123 server_timestamp
= timeval_to_nttime(&tv_now
);
125 if (!PyArg_ParseTupleAndKeywords(args
, kwargs
, "is#|s#",
126 discard_const_p(char *, kwnames
),
131 &target_info
.length
)) {
135 status
= cli_credentials_get_ntlm_response(creds
,
140 &lm_response
, &nt_response
,
141 &lm_session_key
, &nt_session_key
);
143 if (!NT_STATUS_IS_OK(status
)) {
144 PyErr_SetNTSTATUS(status
);
149 ret
= Py_BuildValue("{sis" PYARG_BYTES_LEN
"s" PYARG_BYTES_LEN
150 "s" PYARG_BYTES_LEN
"s" PYARG_BYTES_LEN
"}",
153 (const char *)lm_response
.data
, lm_response
.length
,
155 (const char *)nt_response
.data
, nt_response
.length
,
157 (const char *)lm_session_key
.data
, lm_session_key
.length
,
159 (const char *)nt_session_key
.data
, nt_session_key
.length
);
164 static PyObject
*py_creds_get_principal(PyObject
*self
, PyObject
*unused
)
166 TALLOC_CTX
*frame
= talloc_stackframe();
167 PyObject
*ret
= NULL
;
168 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
170 PyErr_Format(PyExc_TypeError
, "Credentials expected");
173 ret
= PyString_FromStringOrNULL(cli_credentials_get_principal(creds
, frame
));
178 static PyObject
*py_creds_set_principal(PyObject
*self
, PyObject
*args
)
181 enum credentials_obtained obt
= CRED_SPECIFIED
;
183 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
185 PyErr_Format(PyExc_TypeError
, "Credentials expected");
189 if (!PyArg_ParseTuple(args
, "s|i", &newval
, &_obt
)) {
194 return PyBool_FromLong(cli_credentials_set_principal(creds
, newval
, obt
));
197 static PyObject
*py_creds_get_password(PyObject
*self
, PyObject
*unused
)
199 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
201 PyErr_Format(PyExc_TypeError
, "Credentials expected");
204 return PyString_FromStringOrNULL(cli_credentials_get_password(creds
));
207 static PyObject
*py_creds_set_password(PyObject
*self
, PyObject
*args
)
209 const char *newval
= NULL
;
210 enum credentials_obtained obt
= CRED_SPECIFIED
;
212 PyObject
*result
= NULL
;
213 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
215 PyErr_Format(PyExc_TypeError
, "Credentials expected");
219 if (!PyArg_ParseTuple(args
, PYARG_STR_UNI
"|i", "utf8", &newval
, &_obt
)) {
224 result
= PyBool_FromLong(cli_credentials_set_password(creds
, newval
, obt
));
225 PyMem_Free(discard_const_p(void*, newval
));
229 static PyObject
*py_creds_set_utf16_password(PyObject
*self
, PyObject
*args
)
231 enum credentials_obtained obt
= CRED_SPECIFIED
;
233 PyObject
*newval
= NULL
;
234 DATA_BLOB blob
= data_blob_null
;
238 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
240 PyErr_Format(PyExc_TypeError
, "Credentials expected");
244 if (!PyArg_ParseTuple(args
, "O|i", &newval
, &_obt
)) {
249 result
= PyBytes_AsStringAndSize(newval
, (char **)&blob
.data
, &size
);
251 PyErr_SetString(PyExc_RuntimeError
, "Failed to convert passed value to Bytes");
256 ok
= cli_credentials_set_utf16_password(creds
,
259 return PyBool_FromLong(ok
);
262 static PyObject
*py_creds_get_old_password(PyObject
*self
, PyObject
*unused
)
264 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
266 PyErr_Format(PyExc_TypeError
, "Credentials expected");
269 return PyString_FromStringOrNULL(cli_credentials_get_old_password(creds
));
272 static PyObject
*py_creds_set_old_password(PyObject
*self
, PyObject
*args
)
275 enum credentials_obtained obt
= CRED_SPECIFIED
;
277 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
279 PyErr_Format(PyExc_TypeError
, "Credentials expected");
283 if (!PyArg_ParseTuple(args
, "s|i", &oldval
, &_obt
)) {
288 return PyBool_FromLong(cli_credentials_set_old_password(creds
, oldval
, obt
));
291 static PyObject
*py_creds_set_old_utf16_password(PyObject
*self
, PyObject
*args
)
293 PyObject
*oldval
= NULL
;
294 DATA_BLOB blob
= data_blob_null
;
298 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
300 PyErr_Format(PyExc_TypeError
, "Credentials expected");
304 if (!PyArg_ParseTuple(args
, "O", &oldval
)) {
308 result
= PyBytes_AsStringAndSize(oldval
, (char **)&blob
.data
, &size
);
310 PyErr_SetString(PyExc_RuntimeError
, "Failed to convert passed value to Bytes");
315 ok
= cli_credentials_set_old_utf16_password(creds
,
318 return PyBool_FromLong(ok
);
321 static PyObject
*py_creds_get_domain(PyObject
*self
, PyObject
*unused
)
323 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
325 PyErr_Format(PyExc_TypeError
, "Credentials expected");
328 return PyString_FromStringOrNULL(cli_credentials_get_domain(creds
));
331 static PyObject
*py_creds_set_domain(PyObject
*self
, PyObject
*args
)
334 enum credentials_obtained obt
= CRED_SPECIFIED
;
336 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
338 PyErr_Format(PyExc_TypeError
, "Credentials expected");
342 if (!PyArg_ParseTuple(args
, "s|i", &newval
, &_obt
)) {
347 return PyBool_FromLong(cli_credentials_set_domain(creds
, newval
, obt
));
350 static PyObject
*py_creds_get_realm(PyObject
*self
, PyObject
*unused
)
352 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
354 PyErr_Format(PyExc_TypeError
, "Credentials expected");
357 return PyString_FromStringOrNULL(cli_credentials_get_realm(creds
));
360 static PyObject
*py_creds_set_realm(PyObject
*self
, PyObject
*args
)
363 enum credentials_obtained obt
= CRED_SPECIFIED
;
365 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
367 PyErr_Format(PyExc_TypeError
, "Credentials expected");
371 if (!PyArg_ParseTuple(args
, "s|i", &newval
, &_obt
)) {
376 return PyBool_FromLong(cli_credentials_set_realm(creds
, newval
, obt
));
379 static PyObject
*py_creds_get_bind_dn(PyObject
*self
, PyObject
*unused
)
381 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
383 PyErr_Format(PyExc_TypeError
, "Credentials expected");
386 return PyString_FromStringOrNULL(cli_credentials_get_bind_dn(creds
));
389 static PyObject
*py_creds_set_bind_dn(PyObject
*self
, PyObject
*args
)
392 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
394 PyErr_Format(PyExc_TypeError
, "Credentials expected");
397 if (!PyArg_ParseTuple(args
, "z", &newval
))
400 return PyBool_FromLong(cli_credentials_set_bind_dn(creds
, newval
));
403 static PyObject
*py_creds_get_workstation(PyObject
*self
, PyObject
*unused
)
405 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
407 PyErr_Format(PyExc_TypeError
, "Credentials expected");
410 return PyString_FromStringOrNULL(cli_credentials_get_workstation(creds
));
413 static PyObject
*py_creds_set_workstation(PyObject
*self
, PyObject
*args
)
416 enum credentials_obtained obt
= CRED_SPECIFIED
;
418 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
420 PyErr_Format(PyExc_TypeError
, "Credentials expected");
424 if (!PyArg_ParseTuple(args
, "s|i", &newval
, &_obt
)) {
429 return PyBool_FromLong(cli_credentials_set_workstation(creds
, newval
, obt
));
432 static PyObject
*py_creds_is_anonymous(PyObject
*self
, PyObject
*unused
)
434 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
436 PyErr_Format(PyExc_TypeError
, "Credentials expected");
439 return PyBool_FromLong(cli_credentials_is_anonymous(creds
));
442 static PyObject
*py_creds_set_anonymous(PyObject
*self
, PyObject
*unused
)
444 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
446 PyErr_Format(PyExc_TypeError
, "Credentials expected");
449 cli_credentials_set_anonymous(creds
);
453 static PyObject
*py_creds_authentication_requested(PyObject
*self
, PyObject
*unused
)
455 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
457 PyErr_Format(PyExc_TypeError
, "Credentials expected");
460 return PyBool_FromLong(cli_credentials_authentication_requested(creds
));
463 static PyObject
*py_creds_wrong_password(PyObject
*self
, PyObject
*unused
)
465 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
467 PyErr_Format(PyExc_TypeError
, "Credentials expected");
470 return PyBool_FromLong(cli_credentials_wrong_password(creds
));
473 static PyObject
*py_creds_set_cmdline_callbacks(PyObject
*self
, PyObject
*unused
)
475 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
477 PyErr_Format(PyExc_TypeError
, "Credentials expected");
480 return PyBool_FromLong(cli_credentials_set_cmdline_callbacks(creds
));
483 static PyObject
*py_creds_parse_string(PyObject
*self
, PyObject
*args
)
486 enum credentials_obtained obt
= CRED_SPECIFIED
;
488 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
490 PyErr_Format(PyExc_TypeError
, "Credentials expected");
494 if (!PyArg_ParseTuple(args
, "s|i", &newval
, &_obt
)) {
499 cli_credentials_parse_string(creds
, newval
, obt
);
503 static PyObject
*py_creds_parse_file(PyObject
*self
, PyObject
*args
)
506 enum credentials_obtained obt
= CRED_SPECIFIED
;
508 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
510 PyErr_Format(PyExc_TypeError
, "Credentials expected");
514 if (!PyArg_ParseTuple(args
, "s|i", &newval
, &_obt
)) {
519 cli_credentials_parse_file(creds
, newval
, obt
);
523 static PyObject
*py_cli_credentials_set_password_will_be_nt_hash(PyObject
*self
, PyObject
*args
)
525 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
526 PyObject
*py_val
= NULL
;
529 if (!PyArg_ParseTuple(args
, "O!", &PyBool_Type
, &py_val
)) {
532 val
= PyObject_IsTrue(py_val
);
534 cli_credentials_set_password_will_be_nt_hash(creds
, val
);
538 static PyObject
*py_creds_get_nt_hash(PyObject
*self
, PyObject
*unused
)
541 struct samr_Password
*ntpw
= NULL
;
542 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
544 PyErr_Format(PyExc_TypeError
, "Credentials expected");
547 ntpw
= cli_credentials_get_nt_hash(creds
, creds
);
552 ret
= PyBytes_FromStringAndSize(discard_const_p(char, ntpw
->hash
), 16);
557 static PyObject
*py_creds_set_nt_hash(PyObject
*self
, PyObject
*args
)
559 PyObject
*py_cp
= Py_None
;
560 const struct samr_Password
*pwd
= NULL
;
561 enum credentials_obtained obt
= CRED_SPECIFIED
;
563 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
565 PyErr_Format(PyExc_TypeError
, "Credentials expected");
569 if (!PyArg_ParseTuple(args
, "O|i", &py_cp
, &_obt
)) {
574 if (!py_check_dcerpc_type(py_cp
, "samba.dcerpc.samr", "Password")) {
575 /* py_check_dcerpc_type sets TypeError */
579 pwd
= pytalloc_get_ptr(py_cp
);
581 return PyBool_FromLong(cli_credentials_set_nt_hash(creds
, pwd
, obt
));
584 static PyObject
*py_creds_get_kerberos_state(PyObject
*self
, PyObject
*unused
)
587 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
589 PyErr_Format(PyExc_TypeError
, "Credentials expected");
592 state
= cli_credentials_get_kerberos_state(creds
);
593 return PyLong_FromLong(state
);
596 static PyObject
*py_creds_set_kerberos_state(PyObject
*self
, PyObject
*args
)
599 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
601 PyErr_Format(PyExc_TypeError
, "Credentials expected");
604 if (!PyArg_ParseTuple(args
, "i", &state
))
607 cli_credentials_set_kerberos_state(creds
, state
, CRED_SPECIFIED
);
611 static PyObject
*py_creds_set_krb_forwardable(PyObject
*self
, PyObject
*args
)
614 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
616 PyErr_Format(PyExc_TypeError
, "Credentials expected");
619 if (!PyArg_ParseTuple(args
, "i", &state
))
622 cli_credentials_set_krb_forwardable(creds
, state
);
627 static PyObject
*py_creds_get_forced_sasl_mech(PyObject
*self
, PyObject
*unused
)
629 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
631 PyErr_Format(PyExc_TypeError
, "Credentials expected");
634 return PyString_FromStringOrNULL(cli_credentials_get_forced_sasl_mech(creds
));
637 static PyObject
*py_creds_set_forced_sasl_mech(PyObject
*self
, PyObject
*args
)
640 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
642 PyErr_Format(PyExc_TypeError
, "Credentials expected");
646 if (!PyArg_ParseTuple(args
, "s", &newval
)) {
650 cli_credentials_set_forced_sasl_mech(creds
, newval
);
654 static PyObject
*py_creds_set_conf(PyObject
*self
, PyObject
*args
)
656 PyObject
*py_lp_ctx
= Py_None
;
657 struct loadparm_context
*lp_ctx
;
659 struct cli_credentials
*creds
;
662 creds
= PyCredentials_AsCliCredentials(self
);
664 PyErr_Format(PyExc_TypeError
, "Credentials expected");
668 if (!PyArg_ParseTuple(args
, "|O", &py_lp_ctx
)) {
672 mem_ctx
= talloc_new(NULL
);
673 if (mem_ctx
== NULL
) {
678 lp_ctx
= lpcfg_from_py_object(mem_ctx
, py_lp_ctx
);
679 if (lp_ctx
== NULL
) {
680 talloc_free(mem_ctx
);
684 ok
= cli_credentials_set_conf(creds
, lp_ctx
);
685 talloc_free(mem_ctx
);
693 static PyObject
*py_creds_guess(PyObject
*self
, PyObject
*args
)
695 PyObject
*py_lp_ctx
= Py_None
;
696 struct loadparm_context
*lp_ctx
;
698 struct cli_credentials
*creds
;
701 creds
= PyCredentials_AsCliCredentials(self
);
703 PyErr_Format(PyExc_TypeError
, "Credentials expected");
707 if (!PyArg_ParseTuple(args
, "|O", &py_lp_ctx
))
710 mem_ctx
= talloc_new(NULL
);
711 if (mem_ctx
== NULL
) {
716 lp_ctx
= lpcfg_from_py_object(mem_ctx
, py_lp_ctx
);
717 if (lp_ctx
== NULL
) {
718 talloc_free(mem_ctx
);
722 ok
= cli_credentials_guess(creds
, lp_ctx
);
723 talloc_free(mem_ctx
);
731 static PyObject
*py_creds_set_machine_account(PyObject
*self
, PyObject
*args
)
733 PyObject
*py_lp_ctx
= Py_None
;
734 struct loadparm_context
*lp_ctx
;
736 struct cli_credentials
*creds
;
739 creds
= PyCredentials_AsCliCredentials(self
);
741 PyErr_Format(PyExc_TypeError
, "Credentials expected");
745 if (!PyArg_ParseTuple(args
, "|O", &py_lp_ctx
))
748 mem_ctx
= talloc_new(NULL
);
749 if (mem_ctx
== NULL
) {
754 lp_ctx
= lpcfg_from_py_object(mem_ctx
, py_lp_ctx
);
755 if (lp_ctx
== NULL
) {
756 talloc_free(mem_ctx
);
760 status
= cli_credentials_set_machine_account(creds
, lp_ctx
);
761 talloc_free(mem_ctx
);
763 PyErr_NTSTATUS_IS_ERR_RAISE(status
);
768 static PyObject
*PyCredentialCacheContainer_from_ccache_container(struct ccache_container
*ccc
)
770 return pytalloc_reference(&PyCredentialCacheContainer
, ccc
);
774 static PyObject
*py_creds_get_named_ccache(PyObject
*self
, PyObject
*args
)
776 PyObject
*py_lp_ctx
= Py_None
;
777 char *ccache_name
= NULL
;
778 struct loadparm_context
*lp_ctx
;
779 struct ccache_container
*ccc
;
780 struct tevent_context
*event_ctx
;
782 const char *error_string
;
783 struct cli_credentials
*creds
;
786 creds
= PyCredentials_AsCliCredentials(self
);
788 PyErr_Format(PyExc_TypeError
, "Credentials expected");
792 if (!PyArg_ParseTuple(args
, "|Os", &py_lp_ctx
, &ccache_name
))
795 mem_ctx
= talloc_new(NULL
);
796 if (mem_ctx
== NULL
) {
801 lp_ctx
= lpcfg_from_py_object(mem_ctx
, py_lp_ctx
);
802 if (lp_ctx
== NULL
) {
803 talloc_free(mem_ctx
);
807 event_ctx
= samba_tevent_context_init(mem_ctx
);
809 ret
= cli_credentials_get_named_ccache(creds
, event_ctx
, lp_ctx
,
810 ccache_name
, &ccc
, &error_string
);
811 talloc_unlink(mem_ctx
, lp_ctx
);
813 talloc_steal(ccc
, event_ctx
);
814 talloc_free(mem_ctx
);
815 return PyCredentialCacheContainer_from_ccache_container(ccc
);
818 PyErr_SetString(PyExc_RuntimeError
, error_string
?error_string
:"NULL");
820 talloc_free(mem_ctx
);
824 static PyObject
*py_creds_set_named_ccache(PyObject
*self
, PyObject
*args
)
826 struct loadparm_context
*lp_ctx
= NULL
;
827 enum credentials_obtained obt
= CRED_SPECIFIED
;
828 const char *error_string
= NULL
;
829 TALLOC_CTX
*mem_ctx
= NULL
;
831 PyObject
*py_lp_ctx
= Py_None
;
834 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
836 PyErr_Format(PyExc_TypeError
, "Credentials expected");
840 if (!PyArg_ParseTuple(args
, "s|iO", &newval
, &_obt
, &py_lp_ctx
))
844 mem_ctx
= talloc_new(NULL
);
845 if (mem_ctx
== NULL
) {
850 lp_ctx
= lpcfg_from_py_object(mem_ctx
, py_lp_ctx
);
851 if (lp_ctx
== NULL
) {
852 talloc_free(mem_ctx
);
856 ret
= cli_credentials_set_ccache(creds
,
862 PyErr_SetString(PyExc_RuntimeError
,
863 error_string
!= NULL
? error_string
: "NULL");
864 talloc_free(mem_ctx
);
868 talloc_free(mem_ctx
);
872 static PyObject
*py_creds_set_gensec_features(PyObject
*self
, PyObject
*args
)
874 unsigned int gensec_features
;
875 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
877 PyErr_Format(PyExc_TypeError
, "Credentials expected");
881 if (!PyArg_ParseTuple(args
, "I", &gensec_features
))
884 cli_credentials_set_gensec_features(creds
,
891 static PyObject
*py_creds_get_gensec_features(PyObject
*self
, PyObject
*args
)
893 unsigned int gensec_features
;
894 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
896 PyErr_Format(PyExc_TypeError
, "Credentials expected");
900 gensec_features
= cli_credentials_get_gensec_features(creds
);
901 return PyLong_FromLong(gensec_features
);
904 static PyObject
*py_creds_new_client_authenticator(PyObject
*self
,
907 struct netr_Authenticator auth
;
908 struct cli_credentials
*creds
= NULL
;
909 struct netlogon_creds_CredentialState
*nc
= NULL
;
910 PyObject
*ret
= NULL
;
913 creds
= PyCredentials_AsCliCredentials(self
);
915 PyErr_SetString(PyExc_RuntimeError
,
916 "Failed to get credentials from python");
920 nc
= creds
->netlogon_creds
;
922 PyErr_SetString(PyExc_ValueError
,
923 "No netlogon credentials cannot make "
924 "client authenticator");
928 status
= netlogon_creds_client_authenticator(nc
, &auth
);
929 if (!NT_STATUS_IS_OK(status
)) {
930 PyErr_SetString(PyExc_ValueError
,
931 "Failed to create client authenticator");
935 ret
= Py_BuildValue("{s"PYARG_BYTES_LEN
"si}",
937 (const char *) &auth
.cred
, sizeof(auth
.cred
),
938 "timestamp", auth
.timestamp
);
942 static PyObject
*py_creds_set_secure_channel_type(PyObject
*self
, PyObject
*args
)
944 unsigned int channel_type
;
945 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
947 PyErr_Format(PyExc_TypeError
, "Credentials expected");
951 if (!PyArg_ParseTuple(args
, "I", &channel_type
))
954 cli_credentials_set_secure_channel_type(
961 static PyObject
*py_creds_get_secure_channel_type(PyObject
*self
, PyObject
*args
)
963 enum netr_SchannelType channel_type
= SEC_CHAN_NULL
;
964 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
966 PyErr_Format(PyExc_TypeError
, "Credentials expected");
970 channel_type
= cli_credentials_get_secure_channel_type(creds
);
972 return PyLong_FromLong(channel_type
);
975 static PyObject
*py_creds_get_netlogon_creds(PyObject
*self
, PyObject
*unused
)
977 struct cli_credentials
*creds
= NULL
;
978 struct netlogon_creds_CredentialState
*ncreds
= NULL
;
979 PyObject
*py_ncreds
= Py_None
;
981 creds
= PyCredentials_AsCliCredentials(self
);
983 PyErr_Format(PyExc_TypeError
, "Credentials expected");
987 if (creds
->netlogon_creds
== NULL
) {
991 ncreds
= netlogon_creds_copy(NULL
, creds
->netlogon_creds
);
992 if (ncreds
== NULL
) {
997 py_ncreds
= py_return_ndr_struct("samba.dcerpc.schannel",
998 "netlogon_creds_CredentialState",
1001 if (py_ncreds
== NULL
) {
1002 TALLOC_FREE(ncreds
);
1009 static PyObject
*py_creds_set_netlogon_creds(PyObject
*self
, PyObject
*args
)
1011 struct cli_credentials
*creds
= NULL
;
1012 const struct netlogon_creds_CredentialState
*ncreds
= NULL
;
1013 PyObject
*py_ncreds
= Py_None
;
1015 creds
= PyCredentials_AsCliCredentials(self
);
1016 if (creds
== NULL
) {
1017 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1021 if (!PyArg_ParseTuple(args
, "O", &py_ncreds
))
1024 if (py_ncreds
== Py_None
) {
1029 ok
= py_check_dcerpc_type(py_ncreds
,
1030 "samba.dcerpc.schannel",
1031 "netlogon_creds_CredentialState");
1033 /* py_check_dcerpc_type sets TypeError */
1037 ncreds
= pytalloc_get_type(py_ncreds
,
1038 struct netlogon_creds_CredentialState
);
1039 if (ncreds
== NULL
) {
1040 /* pytalloc_get_type sets TypeError */
1045 cli_credentials_set_netlogon_creds(creds
, ncreds
);
1046 if (ncreds
!= NULL
&& creds
->netlogon_creds
== NULL
) {
1054 static PyObject
*py_creds_set_kerberos_salt_principal(PyObject
*self
, PyObject
*args
)
1056 char *salt_principal
= NULL
;
1057 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
1058 if (creds
== NULL
) {
1059 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1063 if (!PyArg_ParseTuple(args
, "s", &salt_principal
))
1066 cli_credentials_set_salt_principal(
1073 static PyObject
*py_creds_get_kerberos_salt_principal(PyObject
*self
, PyObject
*unused
)
1075 TALLOC_CTX
*mem_ctx
;
1076 PyObject
*ret
= NULL
;
1077 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
1078 if (creds
== NULL
) {
1079 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1082 mem_ctx
= talloc_new(NULL
);
1083 if (mem_ctx
== NULL
) {
1088 ret
= PyString_FromStringOrNULL(cli_credentials_get_salt_principal(creds
, mem_ctx
));
1090 TALLOC_FREE(mem_ctx
);
1095 static PyObject
*py_creds_get_kerberos_key_current_or_old(PyObject
*self
, PyObject
*args
, bool old
)
1097 struct loadparm_context
*lp_ctx
= NULL
;
1098 TALLOC_CTX
*mem_ctx
= NULL
;
1099 PyObject
*py_lp_ctx
= Py_None
;
1103 PyObject
*ret
= NULL
;
1104 struct cli_credentials
*creds
= PyCredentials_AsCliCredentials(self
);
1105 if (creds
== NULL
) {
1106 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1110 if (!PyArg_ParseTuple(args
, "i|O", &enctype
, &py_lp_ctx
))
1113 mem_ctx
= talloc_new(NULL
);
1114 if (mem_ctx
== NULL
) {
1119 lp_ctx
= lpcfg_from_py_object(mem_ctx
, py_lp_ctx
);
1120 if (lp_ctx
== NULL
) {
1121 talloc_free(mem_ctx
);
1125 code
= cli_credentials_get_kerberos_key(creds
,
1132 PyErr_SetString(PyExc_RuntimeError
,
1133 "Failed to generate Kerberos key");
1134 talloc_free(mem_ctx
);
1138 ret
= PyBytes_FromStringAndSize((const char *)key
.data
,
1140 talloc_free(mem_ctx
);
1144 static PyObject
*py_creds_get_kerberos_key(PyObject
*self
, PyObject
*args
)
1146 return py_creds_get_kerberos_key_current_or_old(self
, args
, false);
1149 static PyObject
*py_creds_get_old_kerberos_key(PyObject
*self
, PyObject
*args
)
1151 return py_creds_get_kerberos_key_current_or_old(self
, args
, true);
1154 static PyObject
*py_creds_encrypt_netr_crypt_password(PyObject
*self
,
1157 struct cli_credentials
*creds
= NULL
;
1158 struct netr_CryptPassword
*pwd
= NULL
;
1159 struct samr_CryptPassword spwd
;
1160 enum dcerpc_AuthType auth_type
= DCERPC_AUTH_TYPE_NONE
;
1161 enum dcerpc_AuthLevel auth_level
= DCERPC_AUTH_LEVEL_NONE
;
1163 PyObject
*py_cp
= Py_None
;
1165 creds
= PyCredentials_AsCliCredentials(self
);
1166 if (creds
== NULL
) {
1167 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1171 if (!PyArg_ParseTuple(args
, "O", &py_cp
)) {
1175 if (!py_check_dcerpc_type(py_cp
, "samba.dcerpc.netlogon", "netr_CryptPassword")) {
1176 /* py_check_dcerpc_type sets TypeError */
1180 pwd
= pytalloc_get_ptr(py_cp
);
1182 /* pytalloc_get_type sets TypeError */
1186 memcpy(spwd
.data
, pwd
->data
, 512);
1187 PUSH_LE_U32(spwd
.data
, 512, pwd
->length
);
1189 status
= netlogon_creds_encrypt_samr_CryptPassword(creds
->netlogon_creds
,
1194 memcpy(pwd
->data
, spwd
.data
, 512);
1195 pwd
->length
= PULL_LE_U32(spwd
.data
, 512);
1198 PyErr_NTSTATUS_IS_ERR_RAISE(status
);
1203 static PyObject
*py_creds_encrypt_netr_PasswordInfo(PyObject
*self
,
1207 const char * const kwnames
[] = {
1213 struct cli_credentials
*creds
= NULL
;
1214 PyObject
*py_info
= Py_None
;
1215 enum netr_LogonInfoClass level
= NetlogonInteractiveInformation
;
1216 union netr_LogonLevel logon
= { .password
= NULL
, };
1217 uint8_t auth_type
= DCERPC_AUTH_TYPE_NONE
;
1218 uint8_t auth_level
= DCERPC_AUTH_LEVEL_NONE
;
1222 creds
= PyCredentials_AsCliCredentials(self
);
1223 if (creds
== NULL
) {
1224 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1228 if (creds
->netlogon_creds
== NULL
) {
1229 PyErr_Format(PyExc_ValueError
, "NetLogon credentials not set");
1233 if (!PyArg_ParseTupleAndKeywords(args
, kwargs
, "Obb",
1234 discard_const_p(char *, kwnames
),
1235 &py_info
, &auth_type
, &auth_level
))
1240 ok
= py_check_dcerpc_type(py_info
,
1241 "samba.dcerpc.netlogon",
1242 "netr_PasswordInfo");
1244 /* py_check_dcerpc_type sets TypeError */
1248 logon
.password
= pytalloc_get_type(py_info
, struct netr_PasswordInfo
);
1249 if (logon
.password
== NULL
) {
1250 /* pytalloc_get_type sets TypeError */
1254 status
= netlogon_creds_encrypt_samlogon_logon(creds
->netlogon_creds
,
1260 PyErr_NTSTATUS_IS_ERR_RAISE(status
);
1265 static PyObject
*py_creds_get_smb_signing(PyObject
*self
, PyObject
*unused
)
1267 enum smb_signing_setting signing_state
;
1268 struct cli_credentials
*creds
= NULL
;
1270 creds
= PyCredentials_AsCliCredentials(self
);
1271 if (creds
== NULL
) {
1272 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1276 signing_state
= cli_credentials_get_smb_signing(creds
);
1277 return PyLong_FromLong(signing_state
);
1280 static PyObject
*py_creds_set_smb_signing(PyObject
*self
, PyObject
*args
)
1282 enum smb_signing_setting signing_state
;
1283 struct cli_credentials
*creds
= NULL
;
1284 enum credentials_obtained obt
= CRED_SPECIFIED
;
1286 creds
= PyCredentials_AsCliCredentials(self
);
1287 if (creds
== NULL
) {
1288 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1291 if (!PyArg_ParseTuple(args
, "i|i", &signing_state
, &obt
)) {
1295 switch (signing_state
) {
1296 case SMB_SIGNING_DEFAULT
:
1297 case SMB_SIGNING_OFF
:
1298 case SMB_SIGNING_IF_REQUIRED
:
1299 case SMB_SIGNING_DESIRED
:
1300 case SMB_SIGNING_REQUIRED
:
1303 PyErr_Format(PyExc_TypeError
, "Invalid signing state value");
1307 cli_credentials_set_smb_signing(creds
, signing_state
, obt
);
1311 static PyObject
*py_creds_get_smb_ipc_signing(PyObject
*self
, PyObject
*unused
)
1313 enum smb_signing_setting signing_state
;
1314 struct cli_credentials
*creds
= NULL
;
1316 creds
= PyCredentials_AsCliCredentials(self
);
1317 if (creds
== NULL
) {
1318 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1322 signing_state
= cli_credentials_get_smb_ipc_signing(creds
);
1323 return PyLong_FromLong(signing_state
);
1326 static PyObject
*py_creds_set_smb_ipc_signing(PyObject
*self
, PyObject
*args
)
1328 enum smb_signing_setting signing_state
;
1329 struct cli_credentials
*creds
= NULL
;
1330 enum credentials_obtained obt
= CRED_SPECIFIED
;
1332 creds
= PyCredentials_AsCliCredentials(self
);
1333 if (creds
== NULL
) {
1334 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1337 if (!PyArg_ParseTuple(args
, "i|i", &signing_state
, &obt
)) {
1341 switch (signing_state
) {
1342 case SMB_SIGNING_DEFAULT
:
1343 case SMB_SIGNING_OFF
:
1344 case SMB_SIGNING_IF_REQUIRED
:
1345 case SMB_SIGNING_DESIRED
:
1346 case SMB_SIGNING_REQUIRED
:
1349 PyErr_Format(PyExc_TypeError
, "Invalid signing state value");
1353 cli_credentials_set_smb_ipc_signing(creds
, signing_state
, obt
);
1357 static PyObject
*py_creds_get_smb_encryption(PyObject
*self
, PyObject
*unused
)
1359 enum smb_encryption_setting encryption_state
;
1360 struct cli_credentials
*creds
= NULL
;
1362 creds
= PyCredentials_AsCliCredentials(self
);
1363 if (creds
== NULL
) {
1364 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1368 encryption_state
= cli_credentials_get_smb_encryption(creds
);
1369 return PyLong_FromLong(encryption_state
);
1372 static PyObject
*py_creds_set_smb_encryption(PyObject
*self
, PyObject
*args
)
1374 enum smb_encryption_setting encryption_state
;
1375 struct cli_credentials
*creds
= NULL
;
1376 enum credentials_obtained obt
= CRED_SPECIFIED
;
1378 creds
= PyCredentials_AsCliCredentials(self
);
1379 if (creds
== NULL
) {
1380 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1383 if (!PyArg_ParseTuple(args
, "i|i", &encryption_state
, &obt
)) {
1387 switch (encryption_state
) {
1388 case SMB_ENCRYPTION_DEFAULT
:
1389 case SMB_ENCRYPTION_OFF
:
1390 case SMB_ENCRYPTION_IF_REQUIRED
:
1391 case SMB_ENCRYPTION_DESIRED
:
1392 case SMB_ENCRYPTION_REQUIRED
:
1395 PyErr_Format(PyExc_TypeError
, "Invalid encryption state value");
1399 (void)cli_credentials_set_smb_encryption(creds
, encryption_state
, obt
);
1403 static PyObject
*py_creds_get_krb5_fast_armor_credentials(PyObject
*self
, PyObject
*unused
)
1405 struct cli_credentials
*creds
= NULL
;
1406 struct cli_credentials
*fast_creds
= NULL
;
1408 creds
= PyCredentials_AsCliCredentials(self
);
1409 if (creds
== NULL
) {
1410 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1414 fast_creds
= cli_credentials_get_krb5_fast_armor_credentials(creds
);
1415 if (fast_creds
== NULL
) {
1419 return PyCredentials_from_cli_credentials(fast_creds
);
1422 static PyObject
*py_creds_set_krb5_fast_armor_credentials(PyObject
*self
, PyObject
*args
)
1424 struct cli_credentials
*creds
= NULL
;
1425 PyObject
*pyfast_creds
;
1426 struct cli_credentials
*fast_creds
= NULL
;
1427 int fast_armor_required
= 0;
1430 creds
= PyCredentials_AsCliCredentials(self
);
1431 if (creds
== NULL
) {
1432 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1435 if (!PyArg_ParseTuple(args
, "Op", &pyfast_creds
, &fast_armor_required
)) {
1438 if (pyfast_creds
== Py_None
) {
1441 fast_creds
= PyCredentials_AsCliCredentials(pyfast_creds
);
1442 if (fast_creds
== NULL
) {
1443 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1448 status
= cli_credentials_set_krb5_fast_armor_credentials(creds
,
1450 fast_armor_required
);
1452 PyErr_NTSTATUS_IS_ERR_RAISE(status
);
1456 static PyObject
*py_creds_get_krb5_require_fast_armor(PyObject
*self
, PyObject
*unused
)
1458 bool krb5_fast_armor_required
;
1459 struct cli_credentials
*creds
= NULL
;
1461 creds
= PyCredentials_AsCliCredentials(self
);
1462 if (creds
== NULL
) {
1463 PyErr_Format(PyExc_TypeError
, "Credentials expected");
1467 krb5_fast_armor_required
= cli_credentials_get_krb5_require_fast_armor(creds
);
1468 return PyBool_FromLong(krb5_fast_armor_required
);
1471 static PyMethodDef py_creds_methods
[] = {
1473 .ml_name
= "get_username",
1474 .ml_meth
= py_creds_get_username
,
1475 .ml_flags
= METH_NOARGS
,
1476 .ml_doc
= "S.get_username() -> username\nObtain username.",
1479 .ml_name
= "set_username",
1480 .ml_meth
= py_creds_set_username
,
1481 .ml_flags
= METH_VARARGS
,
1482 .ml_doc
= "S.set_username(name[, credentials.SPECIFIED]) -> None\n"
1486 .ml_name
= "get_principal",
1487 .ml_meth
= py_creds_get_principal
,
1488 .ml_flags
= METH_NOARGS
,
1489 .ml_doc
= "S.get_principal() -> user@realm\nObtain user principal.",
1492 .ml_name
= "set_principal",
1493 .ml_meth
= py_creds_set_principal
,
1494 .ml_flags
= METH_VARARGS
,
1495 .ml_doc
= "S.set_principal(name[, credentials.SPECIFIED]) -> None\n"
1496 "Change principal.",
1499 .ml_name
= "get_password",
1500 .ml_meth
= py_creds_get_password
,
1501 .ml_flags
= METH_NOARGS
,
1502 .ml_doc
= "S.get_password() -> password\n"
1506 .ml_name
= "get_ntlm_username_domain",
1507 .ml_meth
= py_creds_get_ntlm_username_domain
,
1508 .ml_flags
= METH_NOARGS
,
1509 .ml_doc
= "S.get_ntlm_username_domain() -> (domain, username)\n"
1510 "Obtain NTLM username and domain, split up either as (DOMAIN, user) or (\"\", \"user@realm\").",
1513 .ml_name
= "get_ntlm_response",
1514 .ml_meth
= PY_DISCARD_FUNC_SIG(PyCFunction
,
1515 py_creds_get_ntlm_response
),
1516 .ml_flags
= METH_VARARGS
| METH_KEYWORDS
,
1517 .ml_doc
= "S.get_ntlm_response"
1518 "(flags, challenge[, target_info]) -> "
1519 "(flags, lm_response, nt_response, lm_session_key, nt_session_key)\n"
1520 "Obtain LM or NTLM response.",
1523 .ml_name
= "set_password",
1524 .ml_meth
= py_creds_set_password
,
1525 .ml_flags
= METH_VARARGS
,
1526 .ml_doc
= "S.set_password(password[, credentials.SPECIFIED]) -> None\n"
1530 .ml_name
= "set_utf16_password",
1531 .ml_meth
= py_creds_set_utf16_password
,
1532 .ml_flags
= METH_VARARGS
,
1533 .ml_doc
= "S.set_utf16_password(password[, credentials.SPECIFIED]) -> None\n"
1537 .ml_name
= "get_old_password",
1538 .ml_meth
= py_creds_get_old_password
,
1539 .ml_flags
= METH_NOARGS
,
1540 .ml_doc
= "S.get_old_password() -> password\n"
1541 "Obtain old password.",
1544 .ml_name
= "set_old_password",
1545 .ml_meth
= py_creds_set_old_password
,
1546 .ml_flags
= METH_VARARGS
,
1547 .ml_doc
= "S.set_old_password(password[, credentials.SPECIFIED]) -> None\n"
1548 "Change old password.",
1551 .ml_name
= "set_old_utf16_password",
1552 .ml_meth
= py_creds_set_old_utf16_password
,
1553 .ml_flags
= METH_VARARGS
,
1554 .ml_doc
= "S.set_old_utf16_password(password[, credentials.SPECIFIED]) -> None\n"
1555 "Change old password.",
1558 .ml_name
= "get_domain",
1559 .ml_meth
= py_creds_get_domain
,
1560 .ml_flags
= METH_NOARGS
,
1561 .ml_doc
= "S.get_domain() -> domain\n"
1562 "Obtain domain name.",
1565 .ml_name
= "set_domain",
1566 .ml_meth
= py_creds_set_domain
,
1567 .ml_flags
= METH_VARARGS
,
1568 .ml_doc
= "S.set_domain(domain[, credentials.SPECIFIED]) -> None\n"
1569 "Change domain name.",
1572 .ml_name
= "get_realm",
1573 .ml_meth
= py_creds_get_realm
,
1574 .ml_flags
= METH_NOARGS
,
1575 .ml_doc
= "S.get_realm() -> realm\n"
1576 "Obtain realm name.",
1579 .ml_name
= "set_realm",
1580 .ml_meth
= py_creds_set_realm
,
1581 .ml_flags
= METH_VARARGS
,
1582 .ml_doc
= "S.set_realm(realm[, credentials.SPECIFIED]) -> None\n"
1583 "Change realm name.",
1586 .ml_name
= "get_bind_dn",
1587 .ml_meth
= py_creds_get_bind_dn
,
1588 .ml_flags
= METH_NOARGS
,
1589 .ml_doc
= "S.get_bind_dn() -> bind dn\n"
1593 .ml_name
= "set_bind_dn",
1594 .ml_meth
= py_creds_set_bind_dn
,
1595 .ml_flags
= METH_VARARGS
,
1596 .ml_doc
= "S.set_bind_dn(bind_dn) -> None\n"
1600 .ml_name
= "is_anonymous",
1601 .ml_meth
= py_creds_is_anonymous
,
1602 .ml_flags
= METH_NOARGS
,
1605 .ml_name
= "set_anonymous",
1606 .ml_meth
= py_creds_set_anonymous
,
1607 .ml_flags
= METH_NOARGS
,
1608 .ml_doc
= "S.set_anonymous() -> None\n"
1609 "Use anonymous credentials.",
1612 .ml_name
= "get_workstation",
1613 .ml_meth
= py_creds_get_workstation
,
1614 .ml_flags
= METH_NOARGS
,
1617 .ml_name
= "set_workstation",
1618 .ml_meth
= py_creds_set_workstation
,
1619 .ml_flags
= METH_VARARGS
,
1622 .ml_name
= "authentication_requested",
1623 .ml_meth
= py_creds_authentication_requested
,
1624 .ml_flags
= METH_NOARGS
,
1627 .ml_name
= "wrong_password",
1628 .ml_meth
= py_creds_wrong_password
,
1629 .ml_flags
= METH_NOARGS
,
1630 .ml_doc
= "S.wrong_password() -> bool\n"
1631 "Indicate the returned password was incorrect.",
1634 .ml_name
= "set_cmdline_callbacks",
1635 .ml_meth
= py_creds_set_cmdline_callbacks
,
1636 .ml_flags
= METH_NOARGS
,
1637 .ml_doc
= "S.set_cmdline_callbacks() -> bool\n"
1638 "Use command-line to obtain credentials not explicitly set.",
1641 .ml_name
= "parse_string",
1642 .ml_meth
= py_creds_parse_string
,
1643 .ml_flags
= METH_VARARGS
,
1644 .ml_doc
= "S.parse_string(text[, credentials.SPECIFIED]) -> None\n"
1645 "Parse credentials string.",
1648 .ml_name
= "parse_file",
1649 .ml_meth
= py_creds_parse_file
,
1650 .ml_flags
= METH_VARARGS
,
1651 .ml_doc
= "S.parse_file(filename[, credentials.SPECIFIED]) -> None\n"
1652 "Parse credentials file.",
1655 .ml_name
= "set_password_will_be_nt_hash",
1656 .ml_meth
= py_cli_credentials_set_password_will_be_nt_hash
,
1657 .ml_flags
= METH_VARARGS
,
1658 .ml_doc
= "S.set_password_will_be_nt_hash(bool) -> None\n"
1659 "Alters the behaviour of S.set_password() "
1660 "to expect the NTHASH as hexstring.",
1663 .ml_name
= "get_nt_hash",
1664 .ml_meth
= py_creds_get_nt_hash
,
1665 .ml_flags
= METH_NOARGS
,
1668 .ml_name
= "set_nt_hash",
1669 .ml_meth
= py_creds_set_nt_hash
,
1670 .ml_flags
= METH_VARARGS
,
1671 .ml_doc
= "S.set_net_sh(samr_Password[, credentials.SPECIFIED]) -> bool\n"
1675 .ml_name
= "get_kerberos_state",
1676 .ml_meth
= py_creds_get_kerberos_state
,
1677 .ml_flags
= METH_NOARGS
,
1680 .ml_name
= "set_kerberos_state",
1681 .ml_meth
= py_creds_set_kerberos_state
,
1682 .ml_flags
= METH_VARARGS
,
1685 .ml_name
= "set_krb_forwardable",
1686 .ml_meth
= py_creds_set_krb_forwardable
,
1687 .ml_flags
= METH_VARARGS
,
1690 .ml_name
= "set_conf",
1691 .ml_meth
= py_creds_set_conf
,
1692 .ml_flags
= METH_VARARGS
,
1696 .ml_meth
= py_creds_guess
,
1697 .ml_flags
= METH_VARARGS
,
1700 .ml_name
= "set_machine_account",
1701 .ml_meth
= py_creds_set_machine_account
,
1702 .ml_flags
= METH_VARARGS
,
1705 .ml_name
= "get_named_ccache",
1706 .ml_meth
= py_creds_get_named_ccache
,
1707 .ml_flags
= METH_VARARGS
,
1710 .ml_name
= "set_named_ccache",
1711 .ml_meth
= py_creds_set_named_ccache
,
1712 .ml_flags
= METH_VARARGS
,
1713 .ml_doc
= "S.set_named_ccache(krb5_ccache_name, obtained, lp) -> None\n"
1714 "Set credentials to KRB5 Credentials Cache (by name).",
1717 .ml_name
= "set_gensec_features",
1718 .ml_meth
= py_creds_set_gensec_features
,
1719 .ml_flags
= METH_VARARGS
,
1722 .ml_name
= "get_gensec_features",
1723 .ml_meth
= py_creds_get_gensec_features
,
1724 .ml_flags
= METH_NOARGS
,
1727 .ml_name
= "get_forced_sasl_mech",
1728 .ml_meth
= py_creds_get_forced_sasl_mech
,
1729 .ml_flags
= METH_NOARGS
,
1730 .ml_doc
= "S.get_forced_sasl_mech() -> SASL mechanism\nObtain forced SASL mechanism.",
1733 .ml_name
= "set_forced_sasl_mech",
1734 .ml_meth
= py_creds_set_forced_sasl_mech
,
1735 .ml_flags
= METH_VARARGS
,
1736 .ml_doc
= "S.set_forced_sasl_mech(name) -> None\n"
1737 "Set forced SASL mechanism.",
1740 .ml_name
= "new_client_authenticator",
1741 .ml_meth
= py_creds_new_client_authenticator
,
1742 .ml_flags
= METH_NOARGS
,
1743 .ml_doc
= "S.new_client_authenticator() -> Authenticator\n"
1744 "Get a new client NETLOGON_AUTHENTICATOR"},
1746 .ml_name
= "set_secure_channel_type",
1747 .ml_meth
= py_creds_set_secure_channel_type
,
1748 .ml_flags
= METH_VARARGS
,
1751 .ml_name
= "get_secure_channel_type",
1752 .ml_meth
= py_creds_get_secure_channel_type
,
1753 .ml_flags
= METH_VARARGS
,
1756 .ml_name
= "get_netlogon_creds",
1757 .ml_meth
= py_creds_get_netlogon_creds
,
1758 .ml_flags
= METH_NOARGS
,
1761 .ml_name
= "set_netlogon_creds",
1762 .ml_meth
= py_creds_set_netlogon_creds
,
1763 .ml_flags
= METH_VARARGS
,
1766 .ml_name
= "set_kerberos_salt_principal",
1767 .ml_meth
= py_creds_set_kerberos_salt_principal
,
1768 .ml_flags
= METH_VARARGS
,
1771 .ml_name
= "get_kerberos_salt_principal",
1772 .ml_meth
= py_creds_get_kerberos_salt_principal
,
1773 .ml_flags
= METH_VARARGS
,
1776 .ml_name
= "get_kerberos_key",
1777 .ml_meth
= py_creds_get_kerberos_key
,
1778 .ml_flags
= METH_VARARGS
,
1779 .ml_doc
= "S.get_kerberos_key(enctype, [lp]) -> bytes\n"
1780 "Generate a Kerberos key using the current password and\n"
1781 "the salt on this credentials object",
1784 .ml_name
= "get_old_kerberos_key",
1785 .ml_meth
= py_creds_get_old_kerberos_key
,
1786 .ml_flags
= METH_VARARGS
,
1787 .ml_doc
= "S.get_old_kerberos_key(enctype, [lp]) -> bytes\n"
1788 "Generate a Kerberos key using the old (previous) password and\n"
1789 "the salt on this credentials object",
1792 .ml_name
= "encrypt_netr_crypt_password",
1793 .ml_meth
= py_creds_encrypt_netr_crypt_password
,
1794 .ml_flags
= METH_VARARGS
,
1795 .ml_doc
= "S.encrypt_netr_crypt_password(password) -> None\n"
1796 "Encrypt the supplied password using the session key and\n"
1797 "the negotiated encryption algorithm in place\n"
1798 "i.e. it overwrites the original data"},
1800 .ml_name
= "encrypt_netr_PasswordInfo",
1801 .ml_meth
= PY_DISCARD_FUNC_SIG(PyCFunction
,
1802 py_creds_encrypt_netr_PasswordInfo
),
1803 .ml_flags
= METH_VARARGS
| METH_KEYWORDS
,
1804 .ml_doc
= "S.encrypt_netr_PasswordInfo(info, "
1805 "auth_type, auth_level) -> None\n"
1806 "Encrypt the supplied password info using the session key and\n"
1807 "the negotiated encryption algorithm in place\n"
1808 "i.e. it overwrites the original data"
1811 .ml_name
= "get_smb_signing",
1812 .ml_meth
= py_creds_get_smb_signing
,
1813 .ml_flags
= METH_NOARGS
,
1816 .ml_name
= "set_smb_signing",
1817 .ml_meth
= py_creds_set_smb_signing
,
1818 .ml_flags
= METH_VARARGS
,
1821 .ml_name
= "get_smb_ipc_signing",
1822 .ml_meth
= py_creds_get_smb_ipc_signing
,
1823 .ml_flags
= METH_NOARGS
,
1826 .ml_name
= "set_smb_ipc_signing",
1827 .ml_meth
= py_creds_set_smb_ipc_signing
,
1828 .ml_flags
= METH_VARARGS
,
1831 .ml_name
= "get_smb_encryption",
1832 .ml_meth
= py_creds_get_smb_encryption
,
1833 .ml_flags
= METH_NOARGS
,
1836 .ml_name
= "set_smb_encryption",
1837 .ml_meth
= py_creds_set_smb_encryption
,
1838 .ml_flags
= METH_VARARGS
,
1841 .ml_name
= "get_krb5_fast_armor_credentials",
1842 .ml_meth
= py_creds_get_krb5_fast_armor_credentials
,
1843 .ml_flags
= METH_NOARGS
,
1844 .ml_doc
= "S.get_krb5_fast_armor_credentials() -> Credentials\n"
1845 "Get the Kerberos FAST credentials set on this credentials object"
1848 .ml_name
= "set_krb5_fast_armor_credentials",
1849 .ml_meth
= py_creds_set_krb5_fast_armor_credentials
,
1850 .ml_flags
= METH_VARARGS
,
1851 .ml_doc
= "S.set_krb5_fast_armor_credentials(credentials, required) -> None\n"
1852 "Set Kerberos FAST credentials for this credentials object, and if FAST armoring must be used."
1855 .ml_name
= "get_krb5_require_fast_armor",
1856 .ml_meth
= py_creds_get_krb5_require_fast_armor
,
1857 .ml_flags
= METH_NOARGS
,
1858 .ml_doc
= "S.get_krb5_fast_armor() -> bool\n"
1859 "Indicate if Kerberos FAST armor is required"
1864 PyTypeObject PyCredentials
= {
1865 .tp_name
= "credentials.Credentials",
1866 .tp_new
= py_creds_new
,
1867 .tp_flags
= Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
,
1868 .tp_methods
= py_creds_methods
,
1871 static PyObject
*py_ccache_name(PyObject
*self
, PyObject
*unused
)
1873 struct ccache_container
*ccc
= NULL
;
1875 PyObject
*py_name
= NULL
;
1878 ccc
= pytalloc_get_type(self
, struct ccache_container
);
1880 ret
= krb5_cc_get_full_name(ccc
->smb_krb5_context
->krb5_context
,
1881 ccc
->ccache
, &name
);
1883 py_name
= PyString_FromStringOrNULL(name
);
1884 krb5_free_string(ccc
->smb_krb5_context
->krb5_context
, name
);
1886 PyErr_SetString(PyExc_RuntimeError
,
1887 "Failed to get ccache name");
1893 static PyMethodDef py_ccache_container_methods
[] = {
1894 { "get_name", py_ccache_name
, METH_NOARGS
,
1895 "S.get_name() -> name\nObtain KRB5 credentials cache name." },
1899 PyTypeObject PyCredentialCacheContainer
= {
1900 .tp_name
= "credentials.CredentialCacheContainer",
1901 .tp_flags
= Py_TPFLAGS_DEFAULT
,
1902 .tp_methods
= py_ccache_container_methods
,
1905 static PyObject
*py_netlogon_creds_kerberos_init(PyObject
*module
,
1909 const char * const kwnames
[] = {
1911 "client_computer_name",
1912 "secure_channel_type",
1913 "client_requested_flags",
1917 const char *client_account
= NULL
;
1918 const char *client_computer_name
= NULL
;
1919 unsigned short secure_channel_type
= 0;
1920 unsigned int client_requested_flags
= 0;
1921 unsigned int negotiate_flags
= 0;
1922 struct netlogon_creds_CredentialState
*ncreds
= NULL
;
1923 PyObject
*py_ncreds
= Py_None
;
1926 ok
= PyArg_ParseTupleAndKeywords(args
, kwargs
, "ssHII",
1927 discard_const_p(char *, kwnames
),
1929 &client_computer_name
,
1930 &secure_channel_type
,
1931 &client_requested_flags
,
1937 ncreds
= netlogon_creds_kerberos_init(NULL
,
1939 client_computer_name
,
1940 secure_channel_type
,
1941 client_requested_flags
,
1942 NULL
, /* client_sid */
1944 if (ncreds
== NULL
) {
1949 py_ncreds
= py_return_ndr_struct("samba.dcerpc.schannel",
1950 "netlogon_creds_CredentialState",
1953 if (py_ncreds
== NULL
) {
1954 TALLOC_FREE(ncreds
);
1961 static PyObject
*py_netlogon_creds_random_challenge(PyObject
*module
,
1964 struct netr_Credential
*challenge
= NULL
;
1965 PyObject
*py_challenge
= Py_None
;
1967 challenge
= talloc(NULL
, struct netr_Credential
);
1968 if (challenge
== NULL
) {
1972 netlogon_creds_random_challenge(challenge
);
1974 py_challenge
= py_return_ndr_struct("samba.dcerpc.netlogon",
1978 if (py_challenge
== NULL
) {
1979 TALLOC_FREE(challenge
);
1983 return py_challenge
;
1986 static PyObject
*py_netlogon_creds_client_init(PyObject
*module
,
1990 const char * const kwnames
[] = {
1992 "client_computer_name",
1993 "secure_channel_type",
1997 "client_requested_flags",
2001 const char *client_account
= NULL
;
2002 const char *client_computer_name
= NULL
;
2003 unsigned short secure_channel_type
= 0;
2004 unsigned int client_requested_flags
= 0;
2005 unsigned int negotiate_flags
= 0;
2006 PyObject
*py_client_challenge
= Py_None
;
2007 const struct netr_Credential
*client_challenge
= NULL
;
2008 PyObject
*py_server_challenge
= Py_None
;
2009 const struct netr_Credential
*server_challenge
= NULL
;
2010 PyObject
*py_machine_password
= Py_None
;
2011 const struct samr_Password
*machine_password
= NULL
;
2012 struct netlogon_creds_CredentialState
*ncreds
= NULL
;
2013 PyObject
*py_ncreds
= Py_None
;
2014 struct netr_Credential
*initial_credential
= NULL
;
2015 PyObject
*py_initial_credential
= Py_None
;
2016 PyObject
*py_result
= Py_None
;
2019 ok
= PyArg_ParseTupleAndKeywords(args
, kwargs
, "ssHOOOII",
2020 discard_const_p(char *, kwnames
),
2022 &client_computer_name
,
2023 &secure_channel_type
,
2024 &py_client_challenge
,
2025 &py_server_challenge
,
2026 &py_machine_password
,
2027 &client_requested_flags
,
2033 ok
= py_check_dcerpc_type(py_client_challenge
,
2034 "samba.dcerpc.netlogon",
2037 /* py_check_dcerpc_type sets TypeError */
2041 client_challenge
= pytalloc_get_type(py_client_challenge
,
2042 struct netr_Credential
);
2043 if (client_challenge
== NULL
) {
2044 /* pytalloc_get_type sets TypeError */
2048 ok
= py_check_dcerpc_type(py_server_challenge
,
2049 "samba.dcerpc.netlogon",
2052 /* py_check_dcerpc_type sets TypeError */
2057 * we can't use pytalloc_get_type as
2058 * NDR_PULL_ALLOC()/talloc_ptrtype() doesn't set the
2059 * correct talloc name because of old
2062 server_challenge
= pytalloc_get_ptr(py_server_challenge
);
2063 if (server_challenge
== NULL
) {
2067 ok
= py_check_dcerpc_type(py_machine_password
,
2068 "samba.dcerpc.samr",
2071 /* py_check_dcerpc_type sets TypeError */
2075 machine_password
= pytalloc_get_type(py_machine_password
,
2076 struct samr_Password
);
2077 if (machine_password
== NULL
) {
2078 /* pytalloc_get_type sets TypeError */
2082 initial_credential
= talloc_zero(NULL
, struct netr_Credential
);
2083 if (initial_credential
== NULL
) {
2088 ncreds
= netlogon_creds_client_init(NULL
,
2090 client_computer_name
,
2091 secure_channel_type
,
2096 client_requested_flags
,
2098 if (ncreds
== NULL
) {
2099 TALLOC_FREE(initial_credential
);
2104 py_ncreds
= py_return_ndr_struct("samba.dcerpc.schannel",
2105 "netlogon_creds_CredentialState",
2108 if (py_ncreds
== NULL
) {
2109 TALLOC_FREE(initial_credential
);
2110 TALLOC_FREE(ncreds
);
2114 py_initial_credential
= py_return_ndr_struct("samba.dcerpc.netlogon",
2117 initial_credential
);
2118 if (py_ncreds
== NULL
) {
2119 Py_DECREF(py_ncreds
);
2120 TALLOC_FREE(initial_credential
);
2124 py_result
= Py_BuildValue("(OO)",
2126 py_initial_credential
);
2127 if (py_result
== NULL
) {
2128 Py_DECREF(py_ncreds
);
2129 Py_DECREF(py_initial_credential
);
2136 static PyObject
*py_netlogon_creds_client_update(PyObject
*module
,
2140 const char * const kwnames
[] = {
2146 PyObject
*py_ncreds
= Py_None
;
2147 struct netlogon_creds_CredentialState
*ncreds
= NULL
;
2148 unsigned int negotiated_flags
= 0;
2149 unsigned int client_rid
= 0;
2152 ok
= PyArg_ParseTupleAndKeywords(args
, kwargs
, "OII",
2153 discard_const_p(char *, kwnames
),
2161 ok
= py_check_dcerpc_type(py_ncreds
,
2162 "samba.dcerpc.schannel",
2163 "netlogon_creds_CredentialState");
2165 /* py_check_dcerpc_type sets TypeError */
2169 ncreds
= pytalloc_get_type(py_ncreds
,
2170 struct netlogon_creds_CredentialState
);
2171 if (ncreds
== NULL
) {
2172 /* pytalloc_get_type sets TypeError */
2176 ncreds
->negotiate_flags
= negotiated_flags
;
2177 ncreds
->client_sid
.sub_auths
[0] = client_rid
;
2182 static PyObject
*py_netlogon_creds_client_authenticator(PyObject
*module
,
2186 const char * const kwnames
[] = {
2190 PyObject
*py_ncreds
= Py_None
;
2191 struct netlogon_creds_CredentialState
*ncreds
= NULL
;
2192 struct netlogon_creds_CredentialState _ncreds
;
2193 struct netr_Authenticator _auth
;
2194 struct netr_Authenticator
*auth
= NULL
;
2195 PyObject
*py_auth
= Py_None
;
2199 ok
= PyArg_ParseTupleAndKeywords(args
, kwargs
, "O",
2200 discard_const_p(char *, kwnames
),
2206 ok
= py_check_dcerpc_type(py_ncreds
,
2207 "samba.dcerpc.schannel",
2208 "netlogon_creds_CredentialState");
2210 /* py_check_dcerpc_type sets TypeError */
2214 ncreds
= pytalloc_get_type(py_ncreds
,
2215 struct netlogon_creds_CredentialState
);
2216 if (ncreds
== NULL
) {
2217 /* pytalloc_get_type sets TypeError */
2222 status
= netlogon_creds_client_authenticator(&_ncreds
, &_auth
);
2223 PyErr_NTSTATUS_IS_ERR_RAISE(status
);
2225 auth
= talloc(NULL
, struct netr_Authenticator
);
2232 py_auth
= py_return_ndr_struct("samba.dcerpc.netlogon",
2233 "netr_Authenticator",
2236 if (py_auth
== NULL
) {
2245 static PyObject
*py_netlogon_creds_client_verify(PyObject
*module
,
2249 const char * const kwnames
[] = {
2251 "received_credentials",
2256 PyObject
*py_ncreds
= Py_None
;
2257 struct netlogon_creds_CredentialState
*ncreds
= NULL
;
2258 PyObject
*py_rcreds
= Py_None
;
2259 const struct netr_Credential
*rcreds
= NULL
;
2260 uint8_t _auth_type
= DCERPC_AUTH_TYPE_NONE
;
2261 enum dcerpc_AuthType auth_type
;
2262 uint8_t _auth_level
= DCERPC_AUTH_LEVEL_NONE
;
2263 enum dcerpc_AuthLevel auth_level
;
2267 ok
= PyArg_ParseTupleAndKeywords(args
, kwargs
, "OObb",
2268 discard_const_p(char *, kwnames
),
2276 auth_type
= _auth_type
;
2277 auth_level
= _auth_level
;
2279 ok
= py_check_dcerpc_type(py_ncreds
,
2280 "samba.dcerpc.schannel",
2281 "netlogon_creds_CredentialState");
2283 /* py_check_dcerpc_type sets TypeError */
2287 ncreds
= pytalloc_get_type(py_ncreds
,
2288 struct netlogon_creds_CredentialState
);
2289 if (ncreds
== NULL
) {
2290 /* pytalloc_get_type sets TypeError */
2294 ok
= py_check_dcerpc_type(py_rcreds
,
2295 "samba.dcerpc.netlogon",
2298 /* py_check_dcerpc_type sets TypeError */
2303 * we can't use pytalloc_get_type as
2304 * NDR_PULL_ALLOC()/talloc_ptrtype() doesn't set the
2305 * correct talloc name because of old
2308 rcreds
= pytalloc_get_ptr(py_rcreds
);
2309 if (rcreds
== NULL
) {
2313 status
= netlogon_creds_client_verify(ncreds
,
2317 PyErr_NTSTATUS_IS_ERR_RAISE(status
);
2322 static PyObject
*py_netlogon_creds_encrypt_netr_LogonLevel(PyObject
*module
,
2326 const char * const kwnames
[] = {
2334 PyObject
*py_ncreds
= Py_None
;
2335 struct netlogon_creds_CredentialState
*ncreds
= NULL
;
2337 enum netr_LogonInfoClass level
= NetlogonInteractiveInformation
;
2338 PyObject
*py_info
= Py_None
;
2339 union netr_LogonLevel logon
= { .password
= NULL
, };
2340 const void *info_ptr
= NULL
;
2341 uint8_t _auth_type
= DCERPC_AUTH_TYPE_NONE
;
2342 enum dcerpc_AuthType auth_type
;
2343 uint8_t _auth_level
= DCERPC_AUTH_LEVEL_NONE
;
2344 enum dcerpc_AuthLevel auth_level
;
2348 ok
= PyArg_ParseTupleAndKeywords(args
, kwargs
, "ObObb",
2349 discard_const_p(char *, kwnames
),
2359 auth_type
= _auth_type
;
2360 auth_level
= _auth_level
;
2362 ok
= py_check_dcerpc_type(py_ncreds
,
2363 "samba.dcerpc.schannel",
2364 "netlogon_creds_CredentialState");
2366 /* py_check_dcerpc_type sets TypeError */
2370 ncreds
= pytalloc_get_type(py_ncreds
,
2371 struct netlogon_creds_CredentialState
);
2372 if (ncreds
== NULL
) {
2373 /* pytalloc_get_type sets TypeError */
2378 case NetlogonInteractiveInformation
:
2379 case NetlogonInteractiveTransitiveInformation
:
2380 case NetlogonServiceInformation
:
2381 case NetlogonServiceTransitiveInformation
:
2382 ok
= py_check_dcerpc_type(py_info
,
2383 "samba.dcerpc.netlogon",
2384 "netr_PasswordInfo");
2386 /* py_check_dcerpc_type sets TypeError */
2390 logon
.password
= pytalloc_get_type(py_info
,
2391 struct netr_PasswordInfo
);
2392 if (logon
.password
== NULL
) {
2393 /* pytalloc_get_type sets TypeError */
2396 info_ptr
= logon
.password
;
2399 case NetlogonNetworkInformation
:
2400 case NetlogonNetworkTransitiveInformation
:
2401 ok
= py_check_dcerpc_type(py_info
,
2402 "samba.dcerpc.netlogon",
2403 "netr_NetworkInfo");
2405 /* py_check_dcerpc_type sets TypeError */
2409 logon
.network
= pytalloc_get_type(py_info
,
2410 struct netr_NetworkInfo
);
2411 if (logon
.network
== NULL
) {
2412 /* pytalloc_get_type sets TypeError */
2415 info_ptr
= logon
.network
;
2418 case NetlogonGenericInformation
:
2419 ok
= py_check_dcerpc_type(py_info
,
2420 "samba.dcerpc.netlogon",
2421 "netr_GenericInfo");
2423 /* py_check_dcerpc_type sets TypeError */
2427 logon
.generic
= pytalloc_get_type(py_info
,
2428 struct netr_GenericInfo
);
2429 if (logon
.generic
== NULL
) {
2430 /* pytalloc_get_type sets TypeError */
2433 info_ptr
= logon
.generic
;
2436 case NetlogonTicketLogonInformation
:
2437 ok
= py_check_dcerpc_type(py_info
,
2438 "samba.dcerpc.netlogon",
2439 "netr_TicketLogonInfo");
2441 /* py_check_dcerpc_type sets TypeError */
2445 logon
.ticket
= pytalloc_get_type(py_info
,
2446 struct netr_TicketLogonInfo
);
2447 if (logon
.ticket
== NULL
) {
2448 /* pytalloc_get_type sets TypeError */
2451 info_ptr
= logon
.ticket
;
2455 if (info_ptr
== NULL
) {
2456 PyErr_SetString(PyExc_ValueError
,
2457 "Invalid netr_LogonInfoClass value");
2461 status
= netlogon_creds_encrypt_samlogon_logon(ncreds
,
2466 PyErr_NTSTATUS_IS_ERR_RAISE(status
);
2471 static PyObject
*py_netlogon_creds_decrypt_netr_Validation(PyObject
*module
,
2475 const char * const kwnames
[] = {
2483 PyObject
*py_ncreds
= Py_None
;
2484 struct netlogon_creds_CredentialState
*ncreds
= NULL
;
2486 enum netr_ValidationInfoClass level
= NetlogonValidationUasInfo
;
2487 PyObject
*py_validation
= Py_None
;
2488 union netr_Validation validation
= { .generic
= NULL
, };
2489 const void *validation_ptr
= NULL
;
2490 uint8_t _auth_type
= DCERPC_AUTH_TYPE_NONE
;
2491 enum dcerpc_AuthType auth_type
;
2492 uint8_t _auth_level
= DCERPC_AUTH_LEVEL_NONE
;
2493 enum dcerpc_AuthLevel auth_level
;
2497 ok
= PyArg_ParseTupleAndKeywords(args
, kwargs
, "ObObb",
2498 discard_const_p(char *, kwnames
),
2508 auth_type
= _auth_type
;
2509 auth_level
= _auth_level
;
2511 ok
= py_check_dcerpc_type(py_ncreds
,
2512 "samba.dcerpc.schannel",
2513 "netlogon_creds_CredentialState");
2515 /* py_check_dcerpc_type sets TypeError */
2519 ncreds
= pytalloc_get_type(py_ncreds
,
2520 struct netlogon_creds_CredentialState
);
2521 if (ncreds
== NULL
) {
2522 /* pytalloc_get_type sets TypeError */
2527 case NetlogonValidationUasInfo
:
2530 case NetlogonValidationSamInfo
:
2531 ok
= py_check_dcerpc_type(py_validation
,
2532 "samba.dcerpc.netlogon",
2535 /* py_check_dcerpc_type sets TypeError */
2540 * we can't use pytalloc_get_type as
2541 * NDR_PULL_ALLOC()/talloc_ptrtype() doesn't set the
2542 * correct talloc name because of old
2545 validation
.sam2
= pytalloc_get_ptr(py_validation
);
2546 if (validation
.sam2
== NULL
) {
2549 validation_ptr
= validation
.sam2
;
2552 case NetlogonValidationSamInfo2
:
2553 ok
= py_check_dcerpc_type(py_validation
,
2554 "samba.dcerpc.netlogon",
2557 /* py_check_dcerpc_type sets TypeError */
2562 * we can't use pytalloc_get_type as
2563 * NDR_PULL_ALLOC()/talloc_ptrtype() doesn't set the
2564 * correct talloc name because of old
2567 validation
.sam3
= pytalloc_get_ptr(py_validation
);
2568 if (validation
.sam3
== NULL
) {
2571 validation_ptr
= validation
.sam3
;
2574 case NetlogonValidationGenericInfo2
:
2575 ok
= py_check_dcerpc_type(py_validation
,
2576 "samba.dcerpc.netlogon",
2577 "netr_GenericInfo2");
2579 /* py_check_dcerpc_type sets TypeError */
2584 * we can't use pytalloc_get_type as
2585 * NDR_PULL_ALLOC()/talloc_ptrtype() doesn't set the
2586 * correct talloc name because of old
2589 validation
.generic
= pytalloc_get_ptr(py_validation
);
2590 if (validation
.generic
== NULL
) {
2593 validation_ptr
= validation
.generic
;
2596 case NetlogonValidationSamInfo4
:
2597 ok
= py_check_dcerpc_type(py_validation
,
2598 "samba.dcerpc.netlogon",
2601 /* py_check_dcerpc_type sets TypeError */
2606 * we can't use pytalloc_get_type as
2607 * NDR_PULL_ALLOC()/talloc_ptrtype() doesn't set the
2608 * correct talloc name because of old
2611 validation
.sam6
= pytalloc_get_ptr(py_validation
);
2612 if (validation
.sam6
== NULL
) {
2615 validation_ptr
= validation
.sam6
;
2618 case NetlogonValidationTicketLogon
:
2619 ok
= py_check_dcerpc_type(py_validation
,
2620 "samba.dcerpc.netlogon",
2621 "netr_ValidationTicketLogon");
2623 /* py_check_dcerpc_type sets TypeError */
2628 * we can't use pytalloc_get_type as
2629 * NDR_PULL_ALLOC()/talloc_ptrtype() doesn't set the
2630 * correct talloc name because of old
2633 validation
.ticket
= pytalloc_get_ptr(py_validation
);
2634 if (validation
.ticket
== NULL
) {
2637 validation_ptr
= validation
.ticket
;
2642 if (validation_ptr
== NULL
) {
2643 PyErr_SetString(PyExc_RuntimeError
,
2644 "Unexpected netr_Validation value");
2648 status
= netlogon_creds_decrypt_samlogon_validation(ncreds
,
2653 PyErr_NTSTATUS_IS_ERR_RAISE(status
);
2658 static PyObject
*py_netlogon_creds_decrypt_samr_Password(PyObject
*module
,
2662 const char * const kwnames
[] = {
2669 PyObject
*py_ncreds
= Py_None
;
2670 struct netlogon_creds_CredentialState
*ncreds
= NULL
;
2671 PyObject
*py_pwd
= Py_None
;
2672 struct samr_Password
*pwd
= NULL
;
2673 uint8_t _auth_type
= DCERPC_AUTH_TYPE_NONE
;
2674 enum dcerpc_AuthType auth_type
;
2675 uint8_t _auth_level
= DCERPC_AUTH_LEVEL_NONE
;
2676 enum dcerpc_AuthLevel auth_level
;
2680 ok
= PyArg_ParseTupleAndKeywords(args
, kwargs
, "OObb",
2681 discard_const_p(char *, kwnames
),
2689 auth_type
= _auth_type
;
2690 auth_level
= _auth_level
;
2692 ok
= py_check_dcerpc_type(py_ncreds
,
2693 "samba.dcerpc.schannel",
2694 "netlogon_creds_CredentialState");
2696 /* py_check_dcerpc_type sets TypeError */
2700 ncreds
= pytalloc_get_type(py_ncreds
,
2701 struct netlogon_creds_CredentialState
);
2702 if (ncreds
== NULL
) {
2703 /* pytalloc_get_type sets TypeError */
2707 ok
= py_check_dcerpc_type(py_pwd
,
2708 "samba.dcerpc.samr",
2711 /* py_check_dcerpc_type sets TypeError */
2716 * we can't use pytalloc_get_type as
2717 * NDR_PULL_ALLOC()/talloc_ptrtype() doesn't set the
2718 * correct talloc name because of old
2721 pwd
= pytalloc_get_ptr(py_pwd
);
2723 /* pytalloc_get_type sets TypeError */
2727 status
= netlogon_creds_decrypt_samr_Password(ncreds
,
2731 PyErr_NTSTATUS_IS_ERR_RAISE(status
);
2736 static PyObject
*py_netlogon_creds_encrypt_samr_Password(PyObject
*module
,
2740 const char * const kwnames
[] = {
2747 PyObject
*py_ncreds
= Py_None
;
2748 struct netlogon_creds_CredentialState
*ncreds
= NULL
;
2749 PyObject
*py_pwd
= Py_None
;
2750 struct samr_Password
*pwd
= NULL
;
2751 uint8_t _auth_type
= DCERPC_AUTH_TYPE_NONE
;
2752 enum dcerpc_AuthType auth_type
;
2753 uint8_t _auth_level
= DCERPC_AUTH_LEVEL_NONE
;
2754 enum dcerpc_AuthLevel auth_level
;
2758 ok
= PyArg_ParseTupleAndKeywords(args
, kwargs
, "OObb",
2759 discard_const_p(char *, kwnames
),
2767 auth_type
= _auth_type
;
2768 auth_level
= _auth_level
;
2770 ok
= py_check_dcerpc_type(py_ncreds
,
2771 "samba.dcerpc.schannel",
2772 "netlogon_creds_CredentialState");
2774 /* py_check_dcerpc_type sets TypeError */
2778 ncreds
= pytalloc_get_type(py_ncreds
,
2779 struct netlogon_creds_CredentialState
);
2780 if (ncreds
== NULL
) {
2781 /* pytalloc_get_type sets TypeError */
2785 ok
= py_check_dcerpc_type(py_pwd
,
2786 "samba.dcerpc.samr",
2789 /* py_check_dcerpc_type sets TypeError */
2793 pwd
= pytalloc_get_type(py_pwd
,
2794 struct samr_Password
);
2796 /* pytalloc_get_type sets TypeError */
2800 status
= netlogon_creds_encrypt_samr_Password(ncreds
,
2804 PyErr_NTSTATUS_IS_ERR_RAISE(status
);
2809 static PyObject
*py_netlogon_creds_encrypt_netr_CryptPassword(PyObject
*module
,
2813 const char * const kwnames
[] = {
2820 PyObject
*py_ncreds
= Py_None
;
2821 struct netlogon_creds_CredentialState
*ncreds
= NULL
;
2822 PyObject
*py_pwd
= Py_None
;
2823 struct netr_CryptPassword
*pwd
= NULL
;
2824 struct samr_CryptPassword spwd
;
2825 uint8_t _auth_type
= DCERPC_AUTH_TYPE_NONE
;
2826 enum dcerpc_AuthType auth_type
;
2827 uint8_t _auth_level
= DCERPC_AUTH_LEVEL_NONE
;
2828 enum dcerpc_AuthLevel auth_level
;
2832 ok
= PyArg_ParseTupleAndKeywords(args
, kwargs
, "OObb",
2833 discard_const_p(char *, kwnames
),
2841 auth_type
= _auth_type
;
2842 auth_level
= _auth_level
;
2844 ok
= py_check_dcerpc_type(py_ncreds
,
2845 "samba.dcerpc.schannel",
2846 "netlogon_creds_CredentialState");
2848 /* py_check_dcerpc_type sets TypeError */
2852 ncreds
= pytalloc_get_type(py_ncreds
,
2853 struct netlogon_creds_CredentialState
);
2854 if (ncreds
== NULL
) {
2855 /* pytalloc_get_type sets TypeError */
2859 ok
= py_check_dcerpc_type(py_pwd
,
2860 "samba.dcerpc.netlogon",
2861 "netr_CryptPassword");
2863 /* py_check_dcerpc_type sets TypeError */
2867 pwd
= pytalloc_get_type(py_pwd
,
2868 struct netr_CryptPassword
);
2870 /* pytalloc_get_type sets TypeError */
2874 memcpy(spwd
.data
, pwd
->data
, 512);
2875 PUSH_LE_U32(spwd
.data
, 512, pwd
->length
);
2877 status
= netlogon_creds_encrypt_samr_CryptPassword(ncreds
,
2882 memcpy(pwd
->data
, spwd
.data
, 512);
2883 pwd
->length
= PULL_LE_U32(spwd
.data
, 512);
2886 PyErr_NTSTATUS_IS_ERR_RAISE(status
);
2891 static PyObject
*py_netlogon_creds_encrypt_SendToSam(PyObject
*module
,
2895 const char * const kwnames
[] = {
2902 PyObject
*py_ncreds
= Py_None
;
2903 struct netlogon_creds_CredentialState
*ncreds
= NULL
;
2904 PyObject
*py_opaque
= Py_None
;
2905 uint8_t *opaque_data
= NULL
;
2906 size_t opaque_length
= 0;
2907 uint8_t _auth_type
= DCERPC_AUTH_TYPE_NONE
;
2908 enum dcerpc_AuthType auth_type
;
2909 uint8_t _auth_level
= DCERPC_AUTH_LEVEL_NONE
;
2910 enum dcerpc_AuthLevel auth_level
;
2914 ok
= PyArg_ParseTupleAndKeywords(args
, kwargs
, "OSbb",
2915 discard_const_p(char *, kwnames
),
2923 auth_type
= _auth_type
;
2924 auth_level
= _auth_level
;
2926 ok
= py_check_dcerpc_type(py_ncreds
,
2927 "samba.dcerpc.schannel",
2928 "netlogon_creds_CredentialState");
2930 /* py_check_dcerpc_type sets TypeError */
2934 ncreds
= pytalloc_get_type(py_ncreds
,
2935 struct netlogon_creds_CredentialState
);
2936 if (ncreds
== NULL
) {
2937 /* pytalloc_get_type sets TypeError */
2941 opaque_data
= (uint8_t *)PyBytes_AsString(py_opaque
);
2942 opaque_length
= PyBytes_Size(py_opaque
);
2944 status
= netlogon_creds_encrypt_SendToSam(ncreds
,
2949 PyErr_NTSTATUS_IS_ERR_RAISE(status
);
2954 static PyMethodDef py_module_methods
[] = {
2956 .ml_name
= "netlogon_creds_kerberos_init",
2957 .ml_meth
= PY_DISCARD_FUNC_SIG(PyCFunction
,
2958 py_netlogon_creds_kerberos_init
),
2959 .ml_flags
= METH_VARARGS
| METH_KEYWORDS
,
2960 .ml_doc
= "credentials.netlogon_creds_kerberos_init("
2961 "client_account, client_computer_name,"
2962 "secure_channel_type, "
2963 "client_requested_flags, negotiate_flags)"
2964 "-> netlogon_creds_CredentialState\n"
2965 "Create a new state for netr_ServerAuthenticateKerberos()",
2968 .ml_name
= "netlogon_creds_random_challenge",
2969 .ml_meth
= py_netlogon_creds_random_challenge
,
2970 .ml_flags
= METH_NOARGS
,
2971 .ml_doc
= "credentials.netlogon_creds_random_challenge()"
2972 "-> netr_Credential\n"
2973 "Create a new random netr_Credential",
2976 .ml_name
= "netlogon_creds_client_init",
2977 .ml_meth
= PY_DISCARD_FUNC_SIG(PyCFunction
,
2978 py_netlogon_creds_client_init
),
2979 .ml_flags
= METH_VARARGS
| METH_KEYWORDS
,
2980 .ml_doc
= "credentials.netlogon_creds_client_init("
2981 "client_account, client_computer_name,"
2982 "secure_channel_type, "
2983 "client_challenge, server_challenge, "
2984 "machine_password, "
2985 "client_requested_flags, negotiate_flags)"
2986 "-> (netlogon_creds_CredentialState, initial_credential)\n"
2987 "Create a new state for netr_ServerAuthenticate3()",
2990 .ml_name
= "netlogon_creds_client_update",
2991 .ml_meth
= PY_DISCARD_FUNC_SIG(PyCFunction
,
2992 py_netlogon_creds_client_update
),
2993 .ml_flags
= METH_VARARGS
| METH_KEYWORDS
,
2994 .ml_doc
= "credentials.netlogon_creds_client_update("
2995 "netlogon_creds, negotiated_flags, client_rid)"
2997 "Update the negotiated flags and client rid",
3000 .ml_name
= "netlogon_creds_client_authenticator",
3001 .ml_meth
= PY_DISCARD_FUNC_SIG(PyCFunction
,
3002 py_netlogon_creds_client_authenticator
),
3003 .ml_flags
= METH_VARARGS
| METH_KEYWORDS
,
3004 .ml_doc
= "credentials.netlogon_creds_client_authenticator(netlogon_creds) -> Authenticator\n"
3005 "Get a new client NETLOGON_AUTHENTICATOR"
3008 .ml_name
= "netlogon_creds_client_verify",
3009 .ml_meth
= PY_DISCARD_FUNC_SIG(PyCFunction
,
3010 py_netlogon_creds_client_verify
),
3011 .ml_flags
= METH_VARARGS
| METH_KEYWORDS
,
3012 .ml_doc
= "credentials.py_netlogon_creds_client_verify(netlogon_creds, "
3013 "received_credentials, auth_type, auth_level) -> None\n"
3014 "Verify the NETLOGON_AUTHENTICATOR.credentials from a server"
3017 .ml_name
= "netlogon_creds_encrypt_netr_LogonLevel",
3018 .ml_meth
= PY_DISCARD_FUNC_SIG(PyCFunction
,
3019 py_netlogon_creds_encrypt_netr_LogonLevel
),
3020 .ml_flags
= METH_VARARGS
| METH_KEYWORDS
,
3021 .ml_doc
= "credentials.netlogon_creds_encrypt_netr_LogonLevel(netlogon_creds, "
3022 "level, info, auth_type, auth_level) -> None\n"
3023 "Encrypt the supplied logon info using the session key and\n"
3024 "the negotiated encryption algorithm in place\n"
3025 "i.e. it overwrites the original data",
3028 .ml_name
= "netlogon_creds_decrypt_netr_Validation",
3029 .ml_meth
= PY_DISCARD_FUNC_SIG(PyCFunction
,
3030 py_netlogon_creds_decrypt_netr_Validation
),
3031 .ml_flags
= METH_VARARGS
| METH_KEYWORDS
,
3032 .ml_doc
= "credentials.netlogon_creds_decrypt_netr_Validation(netlogon_creds, "
3033 "level, validation, auth_type, auth_level) -> None\n"
3034 "Encrypt the supplied validation info using the session key and\n"
3035 "the negotiated encryption algorithm in place\n"
3036 "i.e. it overwrites the original data",
3039 .ml_name
= "netlogon_creds_decrypt_samr_Password",
3040 .ml_meth
= PY_DISCARD_FUNC_SIG(PyCFunction
,
3041 py_netlogon_creds_decrypt_samr_Password
),
3042 .ml_flags
= METH_VARARGS
| METH_KEYWORDS
,
3043 .ml_doc
= "credentials.netlogon_creds_decrypt_samr_Password(netlogon_creds, "
3044 "pwd, auth_type, auth_level) -> None\n"
3045 "Encrypt the supplied samr_Password using the session key and\n"
3046 "the negotiated encryption algorithm in place\n"
3047 "i.e. it overwrites the original data",
3050 .ml_name
= "netlogon_creds_encrypt_samr_Password",
3051 .ml_meth
= PY_DISCARD_FUNC_SIG(PyCFunction
,
3052 py_netlogon_creds_encrypt_samr_Password
),
3053 .ml_flags
= METH_VARARGS
| METH_KEYWORDS
,
3054 .ml_doc
= "credentials.netlogon_creds_encrypt_samr_Password(netlogon_creds, "
3055 "pwd, auth_type, auth_level) -> None\n"
3056 "Encrypt the supplied samr_Password using the session key and\n"
3057 "the negotiated encryption algorithm in place\n"
3058 "i.e. it overwrites the original data",
3061 .ml_name
= "netlogon_creds_encrypt_netr_CryptPassword",
3062 .ml_meth
= PY_DISCARD_FUNC_SIG(PyCFunction
,
3063 py_netlogon_creds_encrypt_netr_CryptPassword
),
3064 .ml_flags
= METH_VARARGS
| METH_KEYWORDS
,
3065 .ml_doc
= "credentials.netlogon_creds_encrypt_netr_CryptPassword(netlogon_creds, "
3066 "pwd, auth_type, auth_level) -> None\n"
3067 "Encrypt the supplied netr_CryptPassword using the session key and\n"
3068 "the negotiated encryption algorithm in place\n"
3069 "i.e. it overwrites the original data",
3072 .ml_name
= "netlogon_creds_encrypt_SendToSam",
3073 .ml_meth
= PY_DISCARD_FUNC_SIG(PyCFunction
,
3074 py_netlogon_creds_encrypt_SendToSam
),
3075 .ml_flags
= METH_VARARGS
| METH_KEYWORDS
,
3076 .ml_doc
= "credentials.netlogon_creds_encrypt_SendToSam(netlogon_creds, "
3077 "opaque_buffer, auth_type, auth_level) -> None\n"
3078 "Encrypt the supplied opaque_buffer using the session key and\n"
3079 "the negotiated encryption algorithm in place\n"
3080 "i.e. it overwrites the original data",
3085 static struct PyModuleDef moduledef
= {
3086 PyModuleDef_HEAD_INIT
,
3087 .m_name
= "credentials",
3088 .m_doc
= "Credentials management.",
3090 .m_methods
= py_module_methods
,
3093 MODULE_INIT_FUNC(credentials
)
3096 if (pytalloc_BaseObject_PyType_Ready(&PyCredentials
) < 0)
3099 if (pytalloc_BaseObject_PyType_Ready(&PyCredentialCacheContainer
) < 0)
3102 m
= PyModule_Create(&moduledef
);
3106 PyModule_AddObject(m
, "UNINITIALISED", PyLong_FromLong(CRED_UNINITIALISED
));
3107 PyModule_AddObject(m
, "SMB_CONF", PyLong_FromLong(CRED_SMB_CONF
));
3108 PyModule_AddObject(m
, "CALLBACK", PyLong_FromLong(CRED_CALLBACK
));
3109 PyModule_AddObject(m
, "GUESS_ENV", PyLong_FromLong(CRED_GUESS_ENV
));
3110 PyModule_AddObject(m
, "GUESS_FILE", PyLong_FromLong(CRED_GUESS_FILE
));
3111 PyModule_AddObject(m
, "CALLBACK_RESULT", PyLong_FromLong(CRED_CALLBACK_RESULT
));
3112 PyModule_AddObject(m
, "SPECIFIED", PyLong_FromLong(CRED_SPECIFIED
));
3114 PyModule_AddObject(m
, "AUTO_USE_KERBEROS", PyLong_FromLong(CRED_USE_KERBEROS_DESIRED
));
3115 PyModule_AddObject(m
, "DONT_USE_KERBEROS", PyLong_FromLong(CRED_USE_KERBEROS_DISABLED
));
3116 PyModule_AddObject(m
, "MUST_USE_KERBEROS", PyLong_FromLong(CRED_USE_KERBEROS_REQUIRED
));
3118 PyModule_AddObject(m
, "AUTO_KRB_FORWARDABLE", PyLong_FromLong(CRED_AUTO_KRB_FORWARDABLE
));
3119 PyModule_AddObject(m
, "NO_KRB_FORWARDABLE", PyLong_FromLong(CRED_NO_KRB_FORWARDABLE
));
3120 PyModule_AddObject(m
, "FORCE_KRB_FORWARDABLE", PyLong_FromLong(CRED_FORCE_KRB_FORWARDABLE
));
3121 PyModule_AddObject(m
, "CLI_CRED_NTLM2", PyLong_FromLong(CLI_CRED_NTLM2
));
3122 PyModule_AddObject(m
, "CLI_CRED_NTLMv2_AUTH", PyLong_FromLong(CLI_CRED_NTLMv2_AUTH
));
3123 PyModule_AddObject(m
, "CLI_CRED_LANMAN_AUTH", PyLong_FromLong(CLI_CRED_LANMAN_AUTH
));
3124 PyModule_AddObject(m
, "CLI_CRED_NTLM_AUTH", PyLong_FromLong(CLI_CRED_NTLM_AUTH
));
3125 PyModule_AddObject(m
, "CLI_CRED_CLEAR_AUTH", PyLong_FromLong(CLI_CRED_CLEAR_AUTH
));
3127 PyModule_AddObject(m
, "SMB_SIGNING_DEFAULT", PyLong_FromLong(SMB_SIGNING_DEFAULT
));
3128 PyModule_AddObject(m
, "SMB_SIGNING_OFF", PyLong_FromLong(SMB_SIGNING_OFF
));
3129 PyModule_AddObject(m
, "SMB_SIGNING_IF_REQUIRED", PyLong_FromLong(SMB_SIGNING_IF_REQUIRED
));
3130 PyModule_AddObject(m
, "SMB_SIGNING_DESIRED", PyLong_FromLong(SMB_SIGNING_DESIRED
));
3131 PyModule_AddObject(m
, "SMB_SIGNING_REQUIRED", PyLong_FromLong(SMB_SIGNING_REQUIRED
));
3133 PyModule_AddObject(m
, "SMB_ENCRYPTION_DEFAULT", PyLong_FromLong(SMB_ENCRYPTION_DEFAULT
));
3134 PyModule_AddObject(m
, "SMB_ENCRYPTION_OFF", PyLong_FromLong(SMB_ENCRYPTION_OFF
));
3135 PyModule_AddObject(m
, "SMB_ENCRYPTION_IF_REQUIRED", PyLong_FromLong(SMB_ENCRYPTION_IF_REQUIRED
));
3136 PyModule_AddObject(m
, "SMB_ENCRYPTION_DESIRED", PyLong_FromLong(SMB_ENCRYPTION_DESIRED
));
3137 PyModule_AddObject(m
, "SMB_ENCRYPTION_REQUIRED", PyLong_FromLong(SMB_ENCRYPTION_REQUIRED
));
3139 PyModule_AddObject(m
, "ENCTYPE_ARCFOUR_HMAC", PyLong_FromLong(ENCTYPE_ARCFOUR_HMAC
));
3140 PyModule_AddObject(m
, "ENCTYPE_AES128_CTS_HMAC_SHA1_96", PyLong_FromLong(ENCTYPE_AES128_CTS_HMAC_SHA1_96
));
3141 PyModule_AddObject(m
, "ENCTYPE_AES256_CTS_HMAC_SHA1_96", PyLong_FromLong(ENCTYPE_AES256_CTS_HMAC_SHA1_96
));
3143 Py_INCREF(&PyCredentials
);
3144 PyModule_AddObject(m
, "Credentials", (PyObject
*)&PyCredentials
);
3145 Py_INCREF(&PyCredentialCacheContainer
);
3146 PyModule_AddObject(m
, "CredentialCacheContainer", (PyObject
*)&PyCredentialCacheContainer
);