/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
*
* 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. Furthermore if you modify this software you must label
* your software as modified software and not distribute it in such a
* fashion that it might be confused with the original M.I.T. software.
* 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.
*
*/
#include "k5-int.h"
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include "kdb_xdr.h"
{
char *princ_name;
/* need to store the NULL for decoding */
}
return(retval);
}
void
{
}
{
int i, j;
unsigned int unparse_princ_size;
char * unparse_princ;
unsigned char * nextloc;
/*
* Generate one lump of data from the krb5_db_entry.
* This data must be independent of byte order of the machine,
* compact and extensible.
*/
/*
* First allocate enough space for all the data.
* Need 2 bytes for the length of the base structure
* then 36 [ 8 * 4 + 2 * 2] bytes for the base information
* [ attributes, max_life, max_renewable_life, expiration,
* pw_expiration, last_success, last_failed, fail_auth_count ]
* [ n_key_data, n_tl_data ]
* then XX bytes [ e_length ] for the extra data [ e_data ]
* then XX bytes [ 2 for length + length for string ] for the principal,
* then (4 [type + length] + tl_data_length) bytes per tl_data
* then (4 + (4 + key_data_length) per key_data_contents) bytes per key_data
*/
return(retval);
i = 0;
/* tl_data is a linked list */
i++;
}
goto epc_error;
}
/* key_data is an array */
for (i = 0; i < entry->n_key_data; i++) {
}
}
goto epc_error;
}
/*
* Now we go through entry again, this time copying data
* These first entries are always saved regardless of version
*/
/* Base Length */
nextloc += 2;
/* Attributes */
nextloc += 4;
/* Max Life */
nextloc += 4;
/* Max Renewable Life */
nextloc += 4;
/* When the client expires */
nextloc += 4;
/* When its passwd expires */
nextloc += 4;
/* Last successful passwd */
nextloc += 4;
/* Last failed passwd attempt */
nextloc += 4;
/* # of failed passwd attempt */
nextloc += 4;
/* # tl_data strutures */
nextloc += 2;
/* # key_data strutures */
nextloc += 2;
/* Put extended fields here */
abort();
/* Any extra data that this version doesn't understand. */
}
/*
* Now we get to the principal.
* To squeze a few extra bytes out it is always assumed to come
* after the base type.
*/
nextloc += 2;
/* tl_data is a linked list, of type, legth, contents */
nextloc += 2;
nextloc += 2;
}
/* key_data is an array */
for (i = 0; i < entry->n_key_data; i++) {
nextloc += 2;
nextloc += 2;
nextloc += 2;
nextloc += 2;
if (length) {
}
}
}
return retval;
}
void
{
return;
}
{
int sizeleft, i;
unsigned char * nextloc;
/* Zero out entry and NULL pointers */
/*
* undo the effects of encode_princ_contents.
*
* The first part is decoding the base type. If the base type is
* bigger than the original base type then the additional fields
* need to be filled in. If the base type is larger than any
* known base type the additional data goes in e_data.
*/
/* First do the easy stuff */
if ((sizeleft -= KRB5_KDB_V1_BASE_LENGTH) < 0)
return KRB5_KDB_TRUNCATED_RECORD;
/* Base Length */
nextloc += 2;
/* Attributes */
nextloc += 4;
/* Max Life */
nextloc += 4;
/* Max Renewable Life */
nextloc += 4;
/* When the client expires */
nextloc += 4;
/* When its passwd expires */
nextloc += 4;
/* Last successful passwd */
nextloc += 4;
/* Last failed passwd attempt */
nextloc += 4;
/* # of failed passwd attempt */
nextloc += 4;
/* # tl_data strutures */
nextloc += 2;
return KRB5_KDB_TRUNCATED_RECORD;
/* # key_data strutures */
nextloc += 2;
if (entry->n_key_data < 0)
return KRB5_KDB_TRUNCATED_RECORD;
/* Check for extra data */
} else {
return ENOMEM;
}
}
/*
* Get the principal name for the entry
* (stored as a string which gets unparsed.)
*/
if ((sizeleft -= 2) < 0) {
goto error_out;
}
i = 0;
i = (int) i16;
nextloc += 2;
goto error_out;
goto error_out;
}
sizeleft -= i;
nextloc += i;
/* tl_data is a linked list */
if ((sizeleft -= 4) < 0) {
goto error_out;
}
if ((*tl_data = (krb5_tl_data *)
goto error_out;
}
nextloc += 2;
nextloc += 2;
goto error_out;
}
goto error_out;
}
}
/* key_data is an array */
goto error_out;
}
for (i = 0; i < entry->n_key_data; i++) {
int j;
if ((sizeleft -= 4) < 0) {
goto error_out;
}
nextloc += 2;
nextloc += 2;
/* key_data_ver determins number of elements and how to unparse them. */
for (j = 0; j < key_data->key_data_ver; j++) {
if ((sizeleft -= 4) < 0) {
goto error_out;
}
nextloc += 2;
nextloc += 2;
goto error_out;
}
if (key_data->key_data_length[j]) {
goto error_out;
}
key_data->key_data_length[j]);
}
}
} else {
/* This isn't right. I'll fix it later */
abort();
}
}
return 0;
return retval;
}
void
{
int i, j;
if (tl_data->tl_data_contents)
}
for (i = 0; i < entry->n_key_data; i++) {
0,
}
}
}
}
}
return;
}