ser_auth.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* lib/krb5/krb/ser_auth.c
*
* Copyright 1995 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
* require a specific license from the United States Government.
* It is the responsibility of any person or organization contemplating
* export to obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*
*/
/*
* ser_auth.c - Serialize krb5_authenticator structure.
*/
#include "k5-int.h"
/*
* Routines to deal with externalizing the krb5_authenticator:
* krb5_authenticator_size();
* krb5_authenticator_externalize();
* krb5_authenticator_internalize();
*/
/* Local data */
static const krb5_ser_entry krb5_authenticator_ser_entry = {
KV5M_AUTHENTICATOR, /* Type */
krb5_authenticator_size, /* Sizer routine */
krb5_authenticator_externalize, /* Externalize routine */
krb5_authenticator_internalize /* Internalize routine */
};
/*
* krb5_authenticator_size() - Determine the size required to externalize
* the krb5_authenticator.
*/
static krb5_error_code
{
/*
* krb5_authenticator requires at minimum:
* krb5_int32 for KV5M_AUTHENTICATOR
* krb5_int32 for seconds
* krb5_int32 for cusec
* krb5_int32 for seq_number
* krb5_int32 for number in authorization_data array.
* krb5_int32 for KV5M_AUTHENTICATOR
*/
if (authenticator) {
/* Calculate size required by client, if appropriate */
if (authenticator->client)
&required);
else
kret = 0;
/* Calculate size required by checksum, if appropriate */
&required);
/* Calculate size required by subkey, if appropriate */
&required);
/* Calculate size required by authorization_data, if appropriate */
int i;
&required);
}
}
}
if (!kret)
return(kret);
}
/*
* krb5_authenticator_externalize() - Externalize the krb5_authenticator.
*/
static krb5_error_code
krb5_octet **buffer;
{
krb5_octet *bp;
int i;
required = 0;
if (authenticator) {
/* First write our magic number */
/* Now ctime */
/* Now cusec */
/* Now seq_number */
/* Now handle client, if appropriate */
if (authenticator->client)
&bp,
&remain);
else
kret = 0;
/* Now handle checksum, if appropriate */
&bp,
&remain);
/* Now handle subkey, if appropriate */
&bp,
&remain);
/* Now handle authorization_data, if appropriate */
if (!kret) {
for (i=0; authenticator->authorization_data[i]; i++);
else
i = 0;
/* Now pound out the authorization_data */
if (authenticator->authorization_data) {
i++)
&bp,
&remain);
}
}
/*
* If we were successful, write trailer then update the pointer and
* remaining length;
*/
if (!kret) {
/* Write our trailer */
}
}
}
return(kret);
}
/*
* krb5_authenticator_internalize() - Internalize the krb5_authenticator.
*/
static krb5_error_code
krb5_octet **buffer;
{
krb5_octet *bp;
int i;
/* Read our magic number */
ibuf = 0;
if (ibuf == KV5M_AUTHENTICATOR) {
/* Get memory for the authenticator */
(authenticator = (krb5_authenticator *)
MALLOC(sizeof(krb5_authenticator)))) {
/* Get ctime */
/* Get cusec */
/* Get seq_number */
kret = 0;
/* Attempt to read in the client */
(krb5_pointer *)
&bp,
&remain);
kret = 0;
/* Attempt to read in the checksum */
if (!kret) {
(krb5_pointer *)
&bp,
&remain);
kret = 0;
}
/* Attempt to read in the subkey */
if (!kret) {
(krb5_pointer *)
&bp,
&remain);
kret = 0;
}
/* Attempt to read in the authorization data count */
/* Get memory for the authorization data pointers */
sizeof(krb5_authdata *) * len);
(krb5_pointer *)
&bp,
&remain);
}
/* Finally, find the trailer */
if (!kret) {
else
}
}
}
if (!kret) {
}
else
}
}
return(kret);
}
/*
* Register the authenticator serializer.
*/
{
}