+Sat Oct 19 00:38:22 1996 Theodore Y. Ts'o <tytso@mit.edu>
+
+ * ser_sctx.c (kg_oid_externalize, kg_oid_internalize,
+ kg_oid_size): Add a GSSAPI OID magic number to the
+ externalized OID, so that if the OID is skipped, (it is
+ optional), the serialization code can resyncronize if
+ necessary.
+ (kg_queue_internalize, kg_queue_externalize,
+ kg_queue_size): New functions to externalize the gssapi
+ queue.
+ (kg_ctx_size, kg_ctx_exteranlize, kg_ctx_import): Changed
+ to include the mech_used field and to include the auth
+ context.
+
+ * gssapi_krb5.c (kg_get_context): Add calls to correctly
+ initialize the serializers needed by import and export sec
+ context.
+
+ * delete_sec_context.c (krb5_gss_delete_sec_context): Remember to
+ release the mech_used OID if necessary!
+
Wed Oct 16 17:53:17 1996 Marc Horowitz <marc@mit.edu>
* accept_sec_context.c (krb5_gss_accept_sec_context): return an
{
gss_OID oid = (gss_OID) arg;
+ (void) krb5_ser_pack_int32(KV5M_GSS_OID, buffer, lenremain);
(void) krb5_ser_pack_int32((krb5_int32) oid->length,
buffer, lenremain);
(void) krb5_ser_pack_bytes((krb5_octet *) oid->elements,
oid->length, buffer, lenremain);
+ (void) krb5_ser_pack_int32(KV5M_GSS_OID, buffer, lenremain);
return 0;
}
krb5_octet **buffer;
size_t *lenremain;
{
+ krb5_error_code kret;
gss_OID oid;
krb5_int32 ibuf;
+ krb5_octet *bp;
+ size_t remain;
+
+ bp = *buffer;
+ remain = *lenremain;
+
+ /* Read in and check our magic number */
+ if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
+ return (EINVAL);
+
+ if (ibuf != KV5M_GSS_OID)
+ return (EINVAL);
oid = (gss_OID) malloc(sizeof(gss_OID_desc));
if (oid == NULL)
return ENOMEM;
- (void) krb5_ser_unpack_int32(&ibuf, buffer, lenremain);
+ (void) krb5_ser_unpack_int32(&ibuf, &bp, &remain);
oid->length = ibuf;
+ oid->elements = malloc(ibuf);
+ if (oid->elements == 0) {
+ free(oid);
+ return ENOMEM;
+ }
(void) krb5_ser_unpack_bytes((krb5_octet *) oid->elements,
- oid->length, buffer, lenremain);
+ oid->length, &bp, &remain);
+
+ /* Read in and check our trailing magic number */
+ if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
+ return (EINVAL);
+
+ if (ibuf != KV5M_GSS_OID)
+ return (EINVAL);
+
+ *buffer = bp;
+ *lenremain = remain;
+ *argp = (krb5_pointer) oid;
return 0;
}
kret = EINVAL;
if ((oid = (gss_OID) arg)) {
- required = sizeof(krb5_int32);
+ required = 2*sizeof(krb5_int32); /* For the header and trailer */
+ required += sizeof(krb5_int32);
required += oid->length;
kret = 0;
return(kret);
}
+static krb5_error_code
+kg_queue_externalize(kcontext, arg, buffer, lenremain)
+ krb5_context kcontext;
+ krb5_pointer arg;
+ krb5_octet **buffer;
+ size_t *lenremain;
+{
+ (void) krb5_ser_pack_int32(KV5M_GSS_QUEUE, buffer, lenremain);
+ g_queue_externalize(arg, buffer, lenremain);
+ (void) krb5_ser_pack_int32(KV5M_GSS_QUEUE, buffer, lenremain);
+ return 0;
+}
+
+static krb5_error_code
+kg_queue_internalize(kcontext, argp, buffer, lenremain)
+ krb5_context kcontext;
+ krb5_pointer *argp;
+ krb5_octet **buffer;
+ size_t *lenremain;
+{
+ krb5_error_code kret;
+ gss_OID oid;
+ krb5_int32 ibuf;
+ krb5_octet *bp;
+ size_t remain;
+
+ bp = *buffer;
+ remain = *lenremain;
+
+ /* Read in and check our magic number */
+ if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
+ return (EINVAL);
+
+ if (ibuf != KV5M_GSS_QUEUE)
+ return (EINVAL);
+
+ g_queue_internalize(argp, &bp, &remain);
+
+ /* Read in and check our trailing magic number */
+ if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
+ return (EINVAL);
+
+ if (ibuf != KV5M_GSS_QUEUE)
+ return (EINVAL);
+
+ *buffer = bp;
+ *lenremain = remain;
+ return 0;
+}
+
+krb5_error_code
+kg_queue_size(kcontext, arg, sizep)
+ krb5_context kcontext;
+ krb5_pointer arg;
+ size_t *sizep;
+{
+ krb5_error_code kret;
+ size_t required;
+
+ kret = EINVAL;
+ if (arg) {
+ required = 2*sizeof(krb5_int32); /* For the header and trailer */
+ g_queue_size(arg, &required);
+
+ kret = 0;
+ *sizep += required;
+ }
+ return(kret);
+}
+
/*
* Determine the size required for this krb5_gss_ctx_id_rec.
*/
(krb5_pointer) ctx->mech_used,
&required);
+ if (!kret && ctx->seqstate)
+ kret = kg_queue_size(kcontext, ctx->seqstate, &required);
+
+ if (!kret)
+ kret = krb5_size_opaque(kcontext,
+ KV5M_AUTH_CONTEXT,
+ (krb5_pointer) ctx->auth_context,
+ &required);
if (!kret)
*sizep += required;
}
(krb5_pointer) &ctx->seq,
&bp, &remain);
+ if (!kret && ctx->seqstate)
+ kret = kg_queue_externalize(kcontext,
+ ctx->seqstate, &bp, &remain);
+
+ if (!kret)
+ kret = krb5_externalize_opaque(kcontext,
+ KV5M_AUTH_CONTEXT,
+ (krb5_pointer) ctx->auth_context,
+ &bp, &remain);
+
if (!kret) {
(void) krb5_ser_pack_int32(KG_CONTEXT, &bp, &remain);
*buffer = bp;
}
}
+ if (!kret) {
+ kret = kg_queue_internalize(kcontext, &ctx->seqstate,
+ &bp, &remain);
+ if (kret == EINVAL)
+ kret = 0;
+ }
+
+ if (!kret)
+ kret = krb5_internalize_opaque(kcontext,
+ KV5M_AUTH_CONTEXT,
+ (krb5_pointer *) &ctx->auth_context,
+ &bp, &remain);
+
/* Get trailer */
if (!kret &&
!(kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)) &&