/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "dh_gssapi.h"
/*
* This module implements the interfaces for replay and out-of-sequence
* detection.
*/
/*
* The following routines are for debuging:
* __context_debug_set_next_seqno
* __context_debug_get_next_seqno
* __context_debug_set_last_seqno
* __context_debug_get_last_seqno
* __context_debug_print_seq_hist
* __context_debug_get_hist_size
* __context_debug
*
* These routines are declared static and there addresses placed into a table.
* There is one publicly declare routine __context_debug_entry that is used
* to fetch these entries. This way other routines can be added with out
* changing the map-version file. This is being done for use with a libgss
* test driver. In particular this technique is being used to implement
* a pseudo libgss entry point gss_context_cntrl. Its declaration is
* OM_uint32
* gss_context_cntl(OM_uint32 *minor, gss_ctx_id_t ctx, int cmd, void *argp);
*
* Hence the declaratin of the debug routines below.
*/
/* Set the next sequence number to be sent */
static OM_uint32
{
if (minor == 0)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
*minor = DH_SUCCESS;
/*
* If context, set the sequence number.
* Locking should not be necessary since OM_uint32 should be atomic
* size.
*/
if (ctx) {
}
return (GSS_S_COMPLETE);
}
/* Get the next sequence number to be sent */
static OM_uint32
{
if (minor == 0)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
if (argp == 0)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
*minor = DH_SUCCESS;
/* Grap the next sequence number */
return (GSS_S_COMPLETE);
}
/* Set the last sequence number to was seen */
static OM_uint32
{
if (minor == 0)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
*minor = DH_SUCCESS;
/*
* If context, set the sequence number.
* Locking should not be necessary since OM_uint32 should be atomic
* size.
*/
if (ctx) {
}
return (GSS_S_COMPLETE);
}
/* Get the last sequence number seen */
static OM_uint32
{
if (minor == 0)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
if (argp == 0)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
*minor = DH_SUCCESS;
/* Grap the next sequence number */
return (GSS_S_COMPLETE);
}
static seq_word_t
{
int i;
seq_word_t t = 0;
for (i = 0; i < WBITS; i++)
if (r & ((seq_word_t)1 << i))
return (t);
}
/* Print out the sequence history to stderr */
static OM_uint32
{
int i;
if (minor == 0)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
*minor = DH_SUCCESS;
/* Print out the sequence history */
for (i = 0; i < SSIZE; i++)
return (GSS_S_COMPLETE);
}
/* Fetch the size of the history */
static OM_uint32
{
if (minor == 0)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
if (argp == 0)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
*minor = DH_SUCCESS;
return (GSS_S_COMPLETE);
}
/* Set the debug flag on the context */
static OM_uint32
{
if (minor == 0)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
*minor = DH_SUCCESS;
return (GSS_S_COMPLETE);
}
/* Type to descript debug routines */
/* Array of debug entries defined above */
};
/* Structure to hold the debug entries */
static struct {
int no_entries;
sizeof (__context_debug_entry_array)/sizeof (fptr),
};
/*
* Exported entry point for debug routines. A call to this routine will
* return a pointer to the above structure.
*/
void*
{
return (&__context_debug_entry_points);
}
/* *************** End of Debug Section ***************** */
/* Clear all the bits in a sequence array */
static void
{
unsigned int i;
for (i = 0; i < SSIZE; i++)
}
/* Check that a bit is set in a sequence array */
static unsigned int
{
return (0);
}
/* Set a bit in a sequence array */
void
{
}
/* Clear a bit in a sequence array */
/*
* This function is not used, but is here as a comment for completeness.
* Lint will complain if it is not commented out.
* static void
* clear_bit(seq_array_t sa, unsigned int bit)
* {
* if (bit < NBITS)
* }
*/
/*
* Sift the bits in a sequence array by n
*
* The seqeunece arrays are logically arranged least significant bit to
* most significant bit, where the LSB represents that last sequence
* number seen. Thus this routine shifts the entire array to the left by
* n.
*
* 0 NBITS-1
* +---------------------------------------------------------------+
* | |
* +---------------------------------------------------------------+
* ^
* This bit corresponds to the last sequence number seen sa->seqno.
*/
static void
{
int i, m;
/* How many words to shift */
m = n / WBITS;
/* Do we need to shift by words */
if (m) {
for (i = SSIZE - 1; i >= m; i--)
for (; i >= 0; i--)
}
if (m >= SSIZE)
return;
/* The bits we need to shift */
n %= WBITS;
if (n == 0)
return;
for (i = m; i < SSIZE; i++) {
/* The out going bits */
/*
* shift this part of the bit array and "add in"
* the most significant bits shifted out of the previous
* previous word.
*/
/* The output of this word is the input to the next */
}
}
/*
* See if the given sequence number is out of sequence or is a replay
* on the given context. If the context is not interested in either
* just return GSS_S_COMPLETE
*/
{
OM_uint32 n;
/*
* See if there is anything to do. If not return with no bits set.
*/
return (stat);
/* lock the history why we check */
/* If debugging print out the current history */
/* See if n is zero or that the high order bit is set or n = 0 */
if ((n & ~((~((OM_uint32)0)) >> 1)) || n == 0) {
/* sequence number is in the past */
/*
* We want the small piece of the pie, so take the
* 2s complement (-n).
*/
n = ~n + 1;
/* the sequence number is ancient history */
if (n > NBITS - 1)
/* See if it has been seen before */
else {
/* Otherwise we've seen it now, so recored the fact */
/* If we care, report that we're out of sequence */
}
} else {
/* sequence number is in the future so shift */
/* The sequence number is the most recent now */
/* So set the most recent bit */
/* if n > 1 and we care report a gap in the sequence */
}
/* If we're debugging print out the new state */
/* Let other threads in */
/* return the status */
return (stat);
}
/*
* Set the next sequence number to use on this context.
* Return that sequence number.
*/
{
OM_uint32 t;
t = ctx->next_seqno++;
return (t);
}
/*
* Initialize sequence history on a new context
*/
void
{
}
/*
* Destroy sequence history on a context.
*/
void
{
if (ctx) {
}
}