1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
GSSAPI="BASE" # This ensures that a full module is generated by Cython
from gssapi.raw.cython_types cimport *
from gssapi.raw.sec_contexts cimport SecurityContext
from gssapi.raw.ext_dce cimport IOV, gss_iov_buffer_desc
from gssapi.raw.misc import GSSError
from gssapi.raw.ext_dce import IOVBufferType
cdef extern from "python_gssapi_ext.h":
OM_uint32 gss_get_mic_iov(OM_uint32 *min_stat, gss_ctx_id_t context_handle,
gss_qop_t qop_req, gss_iov_buffer_desc *iov,
int iov_count) nogil
OM_uint32 gss_get_mic_iov_length(OM_uint32 *min_stat,
gss_ctx_id_t context_handle,
gss_qop_t qop_req,
gss_iov_buffer_desc *iov,
int iov_count) nogil
OM_uint32 gss_verify_mic_iov(OM_uint32 *min_stat,
gss_ctx_id_t context_handle,
gss_qop_t *qop_state,
gss_iov_buffer_desc *iov,
int iov_count) nogil
# more in the enum extension file
IOV.AUTO_ALLOC_BUFFERS.add(IOVBufferType.mic_token)
def get_mic_iov(SecurityContext context not None, IOV message not None,
qop=None):
cdef gss_qop_t qop_req = qop if qop is not None else GSS_C_QOP_DEFAULT
cdef gss_iov_buffer_desc *res_arr = message.__cvalue__()
cdef OM_uint32 maj_stat, min_stat
with nogil:
maj_stat = gss_get_mic_iov(&min_stat, context.raw_ctx, qop_req,
res_arr, message.iov_len)
if maj_stat == GSS_S_COMPLETE:
message.c_changed = True
return
else:
raise GSSError(maj_stat, min_stat)
def get_mic_iov_length(SecurityContext context not None, IOV message not None,
qop=None):
cdef gss_qop_t qop_req = qop if qop is not None else GSS_C_QOP_DEFAULT
cdef gss_iov_buffer_desc *res_arr = message.__cvalue__()
cdef OM_uint32 maj_stat, min_stat
with nogil:
maj_stat = gss_get_mic_iov_length(&min_stat, context.raw_ctx, qop_req,
res_arr, message.iov_len)
if maj_stat == GSS_S_COMPLETE:
message.c_changed = True
return
else:
raise GSSError(maj_stat, min_stat)
def verify_mic_iov(SecurityContext context not None, IOV message not None,
qop=None):
cdef gss_iov_buffer_desc *res_arr = message.__cvalue__()
cdef gss_qop_t qop_state
cdef OM_uint32 maj_stat, min_stat
with nogil:
maj_stat = gss_verify_mic_iov(&min_stat, context.raw_ctx, &qop_state,
res_arr, message.iov_len)
if maj_stat == GSS_S_COMPLETE:
return qop_state
else:
raise GSSError(maj_stat, min_stat)
|