#include "mech_locl.h"
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
gss_wrap_iov(OM_uint32 * minor_status,
gss_ctx_id_t context_handle,
int conf_req_flag,
gss_qop_t qop_req,
int * conf_state,
gss_iov_buffer_desc *iov,
int iov_count)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
gssapi_mech_interface m;
if (minor_status)
*minor_status = 0;
if (conf_state)
*conf_state = 0;
if (ctx == NULL)
return GSS_S_NO_CONTEXT;
if (iov == NULL && iov_count != 0)
return GSS_S_CALL_INACCESSIBLE_READ;
m = ctx->gc_mech;
if (m->gm_wrap_iov == NULL)
return GSS_S_UNAVAILABLE;
return (m->gm_wrap_iov)(minor_status, ctx->gc_ctx,
conf_req_flag, qop_req, conf_state,
iov, iov_count);
}
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
gss_unwrap_iov(OM_uint32 *minor_status,
gss_ctx_id_t context_handle,
int *conf_state,
gss_qop_t *qop_state,
gss_iov_buffer_desc *iov,
int iov_count)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
gssapi_mech_interface m;
if (minor_status)
*minor_status = 0;
if (conf_state)
*conf_state = 0;
if (qop_state)
*qop_state = 0;
if (ctx == NULL)
return GSS_S_NO_CONTEXT;
if (iov == NULL && iov_count != 0)
return GSS_S_CALL_INACCESSIBLE_READ;
m = ctx->gc_mech;
if (m->gm_unwrap_iov == NULL)
return GSS_S_UNAVAILABLE;
return (m->gm_unwrap_iov)(minor_status, ctx->gc_ctx,
conf_state, qop_state,
iov, iov_count);
}
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
gss_wrap_iov_length(OM_uint32 * minor_status,
gss_ctx_id_t context_handle,
int conf_req_flag,
gss_qop_t qop_req,
int *conf_state,
gss_iov_buffer_desc *iov,
int iov_count)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
gssapi_mech_interface m;
if (minor_status)
*minor_status = 0;
if (conf_state)
*conf_state = 0;
if (ctx == NULL)
return GSS_S_NO_CONTEXT;
if (iov == NULL && iov_count != 0)
return GSS_S_CALL_INACCESSIBLE_READ;
m = ctx->gc_mech;
if (m->gm_wrap_iov_length == NULL)
return GSS_S_UNAVAILABLE;
return (m->gm_wrap_iov_length)(minor_status, ctx->gc_ctx,
conf_req_flag, qop_req, conf_state,
iov, iov_count);
}
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
gss_release_iov_buffer(OM_uint32 *minor_status,
gss_iov_buffer_desc *iov,
int iov_count)
{
OM_uint32 junk;
int i;
if (minor_status)
*minor_status = 0;
if (iov == NULL && iov_count != 0)
return GSS_S_CALL_INACCESSIBLE_READ;
for (i = 0; i < iov_count; i++) {
if ((iov[i].type & GSS_IOV_BUFFER_FLAG_ALLOCATED) == 0)
continue;
gss_release_buffer(&junk, &iov[i].buffer);
iov[i].type &= ~GSS_IOV_BUFFER_FLAG_ALLOCATED;
}
return GSS_S_COMPLETE;
}
gss_iov_buffer_desc *
_gss_mg_find_buffer(gss_iov_buffer_desc *iov,
int iov_count,
OM_uint32 type)
{
int i;
for (i = 0; i < iov_count; i++)
if (GSS_IOV_BUFFER_TYPE(iov[i].type) == type)
return &iov[i];
return NULL;
}
OM_uint32
_gss_mg_allocate_buffer(OM_uint32 *minor_status,
gss_iov_buffer_desc *buffer,
size_t size)
{
if (buffer->type & GSS_IOV_BUFFER_TYPE_FLAG_ALLOCATED) {
if (buffer->buffer.length == size)
return GSS_S_COMPLETE;
free(buffer->buffer.value);
}
buffer->buffer.value = malloc(size);
buffer->buffer.length = size;
if (buffer->buffer.value == NULL) {
*minor_status = ENOMEM;
return GSS_S_FAILURE;
}
buffer->type |= GSS_IOV_BUFFER_TYPE_FLAG_ALLOCATED;
return GSS_S_COMPLETE;
}
gss_OID_desc GSSAPI_LIB_FUNCTION __gss_c_attr_stream_sizes_oid_desc =
{10, rk_UNCONST("\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x03")};
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
gss_context_query_attributes(OM_uint32 *minor_status,
const gss_ctx_id_t context_handle,
const gss_OID attribute,
void *data,
size_t len)
{
if (minor_status)
*minor_status = 0;
if (gss_oid_equal(GSS_C_ATTR_STREAM_SIZES, attribute)) {
memset(data, 0, len);
return GSS_S_COMPLETE;
}
return GSS_S_FAILURE;
}
#undef GSS_C_ATTR_STREAM_SIZES
GSSAPI_LIB_VARIABLE gss_OID GSS_C_ATTR_STREAM_SIZES =
&__gss_c_attr_stream_sizes_oid_desc;