tech-invite   World Map     

3GPP     Specs     Glossaries     Architecture     IMS     UICC       IETF     RFCs     Groups     SIP     ABNFs       Search

RFC 2744

 
 
 

Generic Security Service API Version 2 : C-bindings

Part 2 of 4, p. 20 to 49
Prev RFC Part       Next RFC Part

 


prevText      Top       Page 20 
4.   Additional Controls

   This section discusses the optional services that a context initiator
   may request of the GSS-API at context establishment. Each of these
   services is requested by setting a flag in the req_flags input
   parameter to gss_init_sec_context.

   The optional services currently defined are:

   Delegation - The (usually temporary) transfer of rights from
       initiator to acceptor, enabling the acceptor to authenticate
       itself as an agent of the initiator.

   Mutual Authentication - In addition to the initiator authenticating
       its identity to the context acceptor, the context acceptor should
       also authenticate itself to the initiator.

   Replay detection - In addition to providing message integrity
       services, gss_get_mic and gss_wrap should include message
       numbering information to enable gss_verify_mic and gss_unwrap to
       detect if a message has been duplicated.

   Out-of-sequence detection - In addition to providing message
       integrity services, gss_get_mic and gss_wrap should include
       message sequencing information to enable gss_verify_mic and
       gss_unwrap to detect if a message has been received out of
       sequence.

Top       Page 21 
   Anonymous authentication - The establishment of the security context
       should not reveal the initiator's identity to the context
       acceptor.

   Any currently undefined bits within such flag arguments should be
   ignored by GSS-API implementations when presented by an application,
   and should be set to zero when returned to the application by the
   GSS-API implementation.

   Some mechanisms may not support all optional services, and some
   mechanisms may only support some services in conjunction with others.
   Both gss_init_sec_context and gss_accept_sec_context inform the
   applications which services will be available from the context when
   the establishment phase is complete, via the ret_flags output
   parameter.  In general, if the security mechanism is capable of
   providing a requested service, it should do so, even if additional
   services must be enabled in order to provide the requested service.
   If the mechanism is incapable of providing a requested service, it
   should proceed without the service, leaving the application to abort
   the context establishment process if it considers the requested
   service to be mandatory.

   Some mechanisms may specify that support for some services is
   optional, and that implementors of the mechanism need not provide it.
   This is most commonly true of the confidentiality service, often
   because of legal restrictions on the use of data-encryption, but may
   apply to any of the services.  Such mechanisms are required to send
   at least one token from acceptor to initiator during context
   establishment when the initiator indicates a desire to use such a
   service, so that the initiating GSS-API can correctly indicate
   whether the service is supported by the acceptor's GSS-API.

4.1. Delegation

   The GSS-API allows delegation to be controlled by the initiating
   application via a boolean parameter to gss_init_sec_context(), the
   routine that establishes a security context.  Some mechanisms do not
   support delegation, and for such mechanisms attempts by an
   application to enable delegation are ignored.

   The acceptor of a security context for which the initiator enabled
   delegation will receive (via the delegated_cred_handle parameter of
   gss_accept_sec_context) a credential handle that contains the
   delegated identity, and this credential handle may be used to
   initiate subsequent GSS-API security contexts as an agent or delegate
   of the initiator.  If the original initiator's identity is "A" and
   the delegate's identity is "B", then, depending on the underlying
   mechanism, the identity embodied by the delegated credential may be

Top       Page 22 
   either "A" or "B acting for A".

   For many mechanisms that support delegation, a simple boolean does
   not provide enough control.  Examples of additional aspects of
   delegation control that a mechanism might provide to an application
   are duration of delegation, network addresses from which delegation
   is valid, and constraints on the tasks that may be performed by a
   delegate.  Such controls are presently outside the scope of the GSS-
   API.  GSS-API implementations supporting mechanisms offering
   additional controls should provide extension routines that allow
   these controls to be exercised (perhaps by modifying the initiator's
   GSS-API credential prior to its use in establishing a context).
   However, the simple delegation control provided by GSS-API should
   always be able to over-ride other mechanism-specific delegation
   controls - If the application instructs gss_init_sec_context() that
   delegation is not desired, then the implementation must not permit
   delegation to occur. This is an exception to the general rule that a
   mechanism may enable services even if they are not requested -
   delegation may only be provided at the explicit request of the
   application.

4.2. Mutual authentication

   Usually, a context acceptor will require that a context initiator
   authenticate itself so that the acceptor may make an access-control
   decision prior to performing a service for the initiator.  In some
   cases, the initiator may also request that the acceptor authenticate
   itself.  GSS-API allows the initiating application to request this
   mutual authentication service by setting a flag when calling
   gss_init_sec_context.

   The initiating application is informed as to whether or not the
   context acceptor has authenticated itself.  Note that some mechanisms
   may not support mutual authentication, and other mechanisms may
   always perform mutual authentication, whether or not the initiating
   application requests it.  In particular, mutual authentication my be
   required by some mechanisms in order to support replay or out-of-
   sequence message detection, and for such mechanisms a request for
   either of these services will automatically enable mutual
   authentication.

Top       Page 23 
4.3. Replay and out-of-sequence detection

   The GSS-API may provide detection of mis-ordered message once a
   security context has been established.  Protection may be applied to
   messages by either application, by calling either gss_get_mic or
   gss_wrap, and verified by the peer application by calling
   gss_verify_mic or gss_unwrap.

   gss_get_mic calculates a cryptographic MIC over an application
   message, and returns that MIC in a token.  The application should
   pass both the token and the message to the peer application, which
   presents them to gss_verify_mic.

   gss_wrap calculates a cryptographic MIC of an application message,
   and places both the MIC and the message inside a single token.  The
   Application should pass the token to the peer application, which
   presents it to gss_unwrap to extract the message and verify the MIC.

   Either pair of routines may be capable of detecting out-of-sequence
   message delivery, or duplication of messages. Details of such mis-
   ordered messages are indicated through supplementary status bits in
   the major status code returned by gss_verify_mic or gss_unwrap.  The
   relevant supplementary bits are:

   GSS_S_DUPLICATE_TOKEN - The token is a duplicate of one that has
                    already been received and processed.  Only
                    contexts that claim to provide replay detection
                    may set this bit.
   GSS_S_OLD_TOKEN - The token is too old to determine whether or
                    not it is a duplicate.  Contexts supporting
                    out-of-sequence detection but not replay
                    detection should always set this bit if
                    GSS_S_UNSEQ_TOKEN is set; contexts that support
                    replay detection should only set this bit if the
                    token is so old that it cannot be checked for
                    duplication.
   GSS_S_UNSEQ_TOKEN - A later token has already been processed.
   GSS_S_GAP_TOKEN - An earlier token has not yet been received.

   A mechanism need not maintain a list of all tokens that have been
   processed in order to support these status codes.  A typical
   mechanism might retain information about only the most recent "N"
   tokens processed, allowing it to distinguish duplicates and missing
   tokens within the most recent "N" messages; the receipt of a token
   older than the most recent "N" would result in a GSS_S_OLD_TOKEN
   status.

Top       Page 24 
4.4. Anonymous Authentication

   In certain situations, an application may wish to initiate the
   authentication process to authenticate a peer, without revealing its
   own identity.  As an example, consider an application providing
   access to a database containing medical information, and offering
   unrestricted access to the service.  A client of such a service might
   wish to authenticate the service (in order to establish trust in any
   information retrieved from it), but might not wish the service to be
   able to obtain the client's identity (perhaps due to privacy concerns
   about the specific inquiries, or perhaps simply to avoid being placed
   on mailing-lists).

   In normal use of the GSS-API, the initiator's identity is made
   available to the acceptor as a result of the context establishment
   process.  However, context initiators may request that their identity
   not be revealed to the context acceptor. Many mechanisms do not
   support anonymous authentication, and for such mechanisms the request
   will not be honored.  An authentication token will be still be
   generated, but the application is always informed if a requested
   service is unavailable, and has the option to abort context
   establishment if anonymity is valued above the other security
   services that would require a context to be established.

   In addition to informing the application that a context is
   established anonymously (via the ret_flags outputs from
   gss_init_sec_context and gss_accept_sec_context), the optional
   src_name output from gss_accept_sec_context and gss_inquire_context
   will, for such contexts, return a reserved internal-form name,
   defined by the implementation.

   When presented to gss_display_name, this reserved internal-form name
   will result in a printable name that is syntactically distinguishable
   from any valid principal name supported by the implementation,
   associated with a name-type object identifier with the value
   GSS_C_NT_ANONYMOUS, whose value us given in Appendix A.  The
   printable form of an anonymous name should be chosen such that it
   implies anonymity, since this name may appear in, for example, audit
   logs.  For example, the string "<anonymous>" might be a good choice,
   if no valid printable names supported by the implementation can begin
   with "<" and end with ">".

4.5. Confidentiality

   If a context supports the confidentiality service, gss_wrap may be
   used to encrypt application messages.  Messages are selectively
   encrypted, under the control of the conf_req_flag input parameter to
   gss_wrap.

Top       Page 25 
4.6. Inter-process context transfer

   GSS-API V2 provides routines (gss_export_sec_context and
   gss_import_sec_context) which allow a security context to be
   transferred between processes on a single machine.  The most common
   use for such a feature is a client-server design where the server is
   implemented as a single process that accepts incoming security
   contexts, which then launches child processes to deal with the data
   on these contexts.  In such a design, the child processes must have
   access to the security context data structure created within the
   parent by its call to gss_accept_sec_context so that they can use
   per-message protection services and delete the security context when
   the communication session ends.

   Since the security context data structure is expected to contain
   sequencing information, it is impractical in general to share a
   context between processes.  Thus GSS-API provides a call
   (gss_export_sec_context) that the process which currently owns the
   context can call to declare that it has no intention to use the
   context subsequently, and to create an inter-process token containing
   information needed by the adopting process to successfully import the
   context.  After successful completion of gss_export_sec_context, the
   original security context is made inaccessible to the calling process
   by GSS-API, and any context handles referring to this context are no
   longer valid.  The originating process transfers the inter-process
   token to the adopting process, which passes it to
   gss_import_sec_context, and a fresh gss_ctx_id_t is created such that
   it is functionally identical to the original context.

   The inter-process token may contain sensitive data from the original
   security context (including cryptographic keys). Applications using
   inter-process tokens to transfer security contexts must take
   appropriate steps to protect these tokens in transit.

   Implementations are not required to support the inter-process
   transfer of security contexts.  The ability to transfer a security
   context is indicated when the context is created, by
   gss_init_sec_context or gss_accept_sec_context setting the
   GSS_C_TRANS_FLAG bit in their ret_flags parameter.

4.7. The use of incomplete contexts

   Some mechanisms may allow the per-message services to be used before
   the context establishment process is complete.  For example, a
   mechanism may include sufficient information in its initial context-
   level token for the context acceptor to immediately decode messages
   protected with gss_wrap or gss_get_mic.  For such a mechanism, the
   initiating application need not wait until subsequent context-level

Top       Page 26 
   tokens have been sent and received before invoking the per-message
   protection services.

   The ability of a context to provide per-message services in advance
   of complete context establishment is indicated by the setting of the
   GSS_C_PROT_READY_FLAG bit in the ret_flags parameter from
   gss_init_sec_context and gss_accept_sec_context. Applications wishing
   to use per-message protection services on partially-established
   contexts should check this flag before attempting to invoke gss_wrap
   or gss_get_mic.

5. GSS-API Routine Descriptions

   In addition to the explicit major status codes documented here, the
   code GSS_S_FAILURE may be returned by any routine, indicating an
   implementation-specific or mechanism-specific error condition,
   further details of which are reported via the minor_status parameter.

5.1. gss_accept_sec_context

   OM_uint32 gss_accept_sec_context (
     OM_uint32           *minor_status,
     gss_ctx_id_t        *context_handle,
     const gss_cred_id_t acceptor_cred_handle,
     const gss_buffer_t  input_token_buffer,
     const gss_channel_bindings_t  input_chan_bindings,
     const gss_name_t    *src_name,
     gss_OID             *mech_type,
     gss_buffer_t        output_token,
     OM_uint32           *ret_flags,
     OM_uint32           *time_rec,
     gss_cred_id_t       *delegated_cred_handle)

   Purpose:

   Allows a remotely initiated security context between the application
   and a remote peer to be established.  The routine may return a
   output_token which should be transferred to the peer application,
   where the peer application will present it to gss_init_sec_context.
   If no token need be sent, gss_accept_sec_context will indicate this
   by setting the length field of the output_token argument to zero.  To
   complete the context establishment, one or more reply tokens may be
   required from the peer application; if so, gss_accept_sec_context
   will return a status flag of GSS_S_CONTINUE_NEEDED, in which case it
   should be called again when the reply token is received from the peer
   application, passing the token to gss_accept_sec_context via the
   input_token parameters.

Top       Page 27 
   Portable applications should be constructed to use the token length
   and return status to determine whether a token needs to be sent or
   waited for.  Thus a typical portable caller should always invoke
   gss_accept_sec_context within a loop:

   gss_ctx_id_t context_hdl = GSS_C_NO_CONTEXT;

   do {
     receive_token_from_peer(input_token);
     maj_stat = gss_accept_sec_context(&min_stat,
                                       &context_hdl,
                                       cred_hdl,
                                       input_token,
                                       input_bindings,
                                       &client_name,
                                       &mech_type,
                                       output_token,
                                       &ret_flags,
                                       &time_rec,
                                       &deleg_cred);
     if (GSS_ERROR(maj_stat)) {
       report_error(maj_stat, min_stat);
     };
     if (output_token->length != 0) {
       send_token_to_peer(output_token);

       gss_release_buffer(&min_stat, output_token);
     };
     if (GSS_ERROR(maj_stat)) {
       if (context_hdl != GSS_C_NO_CONTEXT)
         gss_delete_sec_context(&min_stat,
                                &context_hdl,
                                GSS_C_NO_BUFFER);
       break;
     };
   } while (maj_stat & GSS_S_CONTINUE_NEEDED);

   Whenever the routine returns a major status that includes the value
   GSS_S_CONTINUE_NEEDED, the context is not fully established and the
   following restrictions apply to the output parameters:

   The value returned via the time_rec parameter is undefined Unless the
   accompanying ret_flags parameter contains the bit
   GSS_C_PROT_READY_FLAG, indicating that per-message services may be
   applied in advance of a successful completion status, the value
   returned via the mech_type parameter may be undefined until the
   routine returns a major status value of GSS_S_COMPLETE.

Top       Page 28 
   The values of the GSS_C_DELEG_FLAG,
   GSS_C_MUTUAL_FLAG,GSS_C_REPLAY_FLAG, GSS_C_SEQUENCE_FLAG,
   GSS_C_CONF_FLAG,GSS_C_INTEG_FLAG and GSS_C_ANON_FLAG bits returned
   via the ret_flags parameter should contain the values that the
   implementation expects would be valid if context establishment were
   to succeed.

   The values of the GSS_C_PROT_READY_FLAG and GSS_C_TRANS_FLAG bits
   within ret_flags should indicate the actual state at the time
   gss_accept_sec_context returns, whether or not the context is fully
   established.

   Although this requires that GSS-API implementations set the
   GSS_C_PROT_READY_FLAG in the final ret_flags returned to a caller
   (i.e. when accompanied by a GSS_S_COMPLETE status code), applications
   should not rely on this behavior as the flag was not defined in
   Version 1 of the GSS-API. Instead, applications should be prepared to
   use per-message services after a successful context establishment,
   according to the GSS_C_INTEG_FLAG and GSS_C_CONF_FLAG values.

   All other bits within the ret_flags argument should be set to zero.
   While the routine returns GSS_S_CONTINUE_NEEDED, the values returned
   via the ret_flags argument indicate the services that the
   implementation expects to be available from the established context.

   If the initial call of gss_accept_sec_context() fails, the
   implementation should not create a context object, and should leave
   the value of the context_handle parameter set to GSS_C_NO_CONTEXT to
   indicate this.  In the event of a failure on a subsequent call, the
   implementation is permitted to delete the "half-built" security
   context (in which case it should set the context_handle parameter to
   GSS_C_NO_CONTEXT), but the preferred behavior is to leave the
   security context (and the context_handle parameter) untouched for the
   application to delete (using gss_delete_sec_context).

   During context establishment, the informational status bits
   GSS_S_OLD_TOKEN and GSS_S_DUPLICATE_TOKEN indicate fatal errors, and
   GSS-API mechanisms should always return them in association with a
   routine error of GSS_S_FAILURE.  This requirement for pairing did not
   exist in version 1 of the GSS-API specification, so applications that
   wish to run over version 1 implementations must special-case these
   codes.

Top       Page 29 
   Parameters:

   context_handle    gss_ctx_id_t, read/modify context handle for new
                        context.  Supply GSS_C_NO_CONTEXT for first
                        call; use value returned in subsequent calls.
                        Once gss_accept_sec_context() has returned a
                        value via this parameter, resources have been
                        assigned to the corresponding context, and must
                        be freed by the application after use with a
                        call to gss_delete_sec_context().


   acceptor_cred_handle  gss_cred_id_t, read Credential handle claimed
                         by context acceptor. Specify
                         GSS_C_NO_CREDENTIAL to accept the context as a
                         default principal.  If GSS_C_NO_CREDENTIAL is
                         specified, but no default acceptor principal is
                         defined, GSS_S_NO_CRED will be returned.

   input_token_buffer   buffer, opaque, read token obtained from remote
                        application.

   input_chan_bindings  channel bindings, read, optional Application-
                        specified bindings.  Allows application to
                        securely bind channel identification information
                        to the security context.  If channel bindings
                        are not used, specify GSS_C_NO_CHANNEL_BINDINGS.

   src_name             gss_name_t, modify, optional Authenticated name
                        of context initiator.  After use, this name
                        should be deallocated by passing it to
                        gss_release_name().  If not required, specify
                        NULL.

   mech_type            Object ID, modify, optional Security mechanism
                        used.  The returned OID value will be a pointer
                        into static storage, and should be treated as
                        read-only by the caller (in particular, it does
                        not need to be freed).  If not required, specify
                        NULL.

   output_token         buffer, opaque, modify Token to be passed to
                        peer application.  If the length field of the
                        returned token buffer is 0, then no token need
                        be passed to the peer application.  If a non-
                        zero length field is returned, the associated
                        storage must be freed after use by the
                        application with a call to gss_release_buffer().

Top       Page 30 
   ret_flags            bit-mask, modify, optional Contains various
                        independent flags, each of which indicates that
                        the context supports a specific service option.
                        If not needed, specify NULL.  Symbolic names are
                        provided for each flag, and the symbolic names
                        corresponding to the required flags should be
                        logically-ANDed with the ret_flags value to test
                        whether a given option is supported by the
                        context.  The flags are:
                        GSS_C_DELEG_FLAG
                        True - Delegated credentials are available
                               via the delegated_cred_handle
                               parameter
                        False - No credentials were delegated
                        GSS_C_MUTUAL_FLAG
                        True - Remote peer asked for mutual
                               authentication
                        False - Remote peer did not ask for mutual
                                authentication
                        GSS_C_REPLAY_FLAG
                        True - replay of protected messages
                               will be detected
                        False - replayed messages will not be
                                detected
                        GSS_C_SEQUENCE_FLAG
                        True - out-of-sequence protected
                               messages will be detected
                        False - out-of-sequence messages will not
                                be detected
                        GSS_C_CONF_FLAG
                        True - Confidentiality service may be
                               invoked by calling the gss_wrap
                               routine
                        False - No confidentiality service (via
                                gss_wrap) available. gss_wrap will
                                provide message encapsulation,
                                data-origin authentication and
                                integrity services only.
                        GSS_C_INTEG_FLAG
                        True - Integrity service may be invoked by
                               calling either gss_get_mic or
                               gss_wrap routines.
                        False - Per-message integrity service
                                unavailable.
                        GSS_C_ANON_FLAG
                        True - The initiator does not wish to
                               be authenticated; the src_name
                               parameter (if requested) contains

Top       Page 31 
                               an anonymous internal name.
                        False - The initiator has been
                                authenticated normally.
                        GSS_C_PROT_READY_FLAG
                        True - Protection services (as specified
                               by the states of the GSS_C_CONF_FLAG
                               and GSS_C_INTEG_FLAG) are available
                               if the accompanying major status
                               return value is either GSS_S_COMPLETE
                               or GSS_S_CONTINUE_NEEDED.
                        False - Protection services (as specified
                                by the states of the GSS_C_CONF_FLAG
                                and GSS_C_INTEG_FLAG) are available
                                only if the accompanying major status
                                return value is GSS_S_COMPLETE.
                        GSS_C_TRANS_FLAG
                        True - The resultant security context may
                               be transferred to other processes via
                               a call to gss_export_sec_context().
                        False - The security context is not
                                transferable.
                        All other bits should be set to zero.

   time_rec             Integer, modify, optional
                        number of seconds for which the context will
                        remain valid. Specify NULL if not required.

   delegated_cred_handle
                        gss_cred_id_t, modify, optional credential
                        handle for credentials received from context
                        initiator.  Only valid if deleg_flag in
                        ret_flags is true, in which case an explicit
                        credential handle (i.e. not GSS_C_NO_CREDENTIAL)
                        will be returned; if deleg_flag is false,
                        gss_accept_context() will set this parameter to
                        GSS_C_NO_CREDENTIAL.  If a credential handle is
                        returned, the associated resources must be
                        released by the application after use with a
                        call to gss_release_cred().  Specify NULL if not
                        required.

   minor_status         Integer, modify
                        Mechanism specific status code.

   GSS_S_CONTINUE_NEEDED Indicates that a token from the peer
                         application is required to complete the
                         context, and that gss_accept_sec_context must
                         be called again with that token.

Top       Page 32 
   GSS_S_DEFECTIVE_TOKEN Indicates that consistency checks performed on
                         the input_token failed.

   GSS_S_DEFECTIVE_CREDENTIAL Indicates that consistency checks
                         performed on the credential failed.

   GSS_S_NO_CRED     The supplied credentials were not valid for context
                         acceptance, or the credential handle did not
                         reference any credentials.

   GSS_S_CREDENTIALS_EXPIRED The referenced credentials have expired.

   GSS_S_BAD_BINDINGS  The input_token contains different channel
                         bindings to those specified via the
                         input_chan_bindings parameter.

   GSS_S_NO_CONTEXT  Indicates that the supplied context handle did not
                         refer to a valid context.

   GSS_S_BAD_SIG     The input_token contains an invalid MIC.

   GSS_S_OLD_TOKEN   The input_token was too old.  This is a fatal error
                         during context establishment.

   GSS_S_DUPLICATE_TOKEN The input_token is valid, but is a duplicate of
                         a token already processed.  This is a fatal
                         error during context establishment.

   GSS_S_BAD_MECH    The received token specified a mechanism that is
                         not supported by the implementation or the
                         provided credential.

5.2. gss_acquire_cred

   OM_uint32 gss_acquire_cred (
     OM_uint32         *minor_status,
     const gss_name_t  desired_name,
     OM_uint32         time_req,
     const gss_OID_set desired_mechs,
     gss_cred_usage_t  cred_usage,
     gss_cred_id_t     *output_cred_handle,
     gss_OID_set       *actual_mechs,
     OM_uint32         *time_rec)

Top       Page 33 
   Purpose:

   Allows an application to acquire a handle for a pre-existing
   credential by name.  GSS-API implementations must impose a local
   access-control policy on callers of this routine to prevent
   unauthorized callers from acquiring credentials to which they are not
   entitled.  This routine is not intended to provide a "login to the
   network" function, as such a function would involve the creation of
   new credentials rather than merely acquiring a handle to existing
   credentials.  Such functions, if required, should be defined in
   implementation-specific extensions to the API.

   If desired_name is GSS_C_NO_NAME, the call is interpreted as a
   request for a credential handle that will invoke default behavior
   when passed to gss_init_sec_context() (if cred_usage is
   GSS_C_INITIATE or GSS_C_BOTH) or gss_accept_sec_context() (if
   cred_usage is GSS_C_ACCEPT or GSS_C_BOTH).

   Mechanisms should honor the desired_mechs parameter, and return a
   credential that is suitable to use only with the requested
   mechanisms.  An exception to this is the case where one underlying
   credential element can be shared by multiple mechanisms; in this case
   it is permissible for an implementation to indicate all mechanisms
   with which the credential element may be used.  If desired_mechs is
   an empty set, behavior is undefined.

   This routine is expected to be used primarily by context acceptors,
   since implementations are likely to provide mechanism-specific ways
   of obtaining GSS-API initiator credentials from the system login
   process.  Some implementations may therefore not support the
   acquisition of GSS_C_INITIATE or GSS_C_BOTH credentials via
   gss_acquire_cred for any name other than GSS_C_NO_NAME, or a name
   produced by applying either gss_inquire_cred to a valid credential,
   or gss_inquire_context to an active context.

   If credential acquisition is time-consuming for a mechanism, the
   mechanism may choose to delay the actual acquisition until the
   credential is required (e.g. by gss_init_sec_context or
   gss_accept_sec_context).  Such mechanism-specific implementation
   decisions should be invisible to the calling application; thus a call
   of gss_inquire_cred immediately following the call of
   gss_acquire_cred must return valid credential data, and may therefore
   incur the overhead of a deferred credential acquisition.

Top       Page 34 
   Parameters:

   desired_name      gss_name_t, read
                     Name of principal whose credential
                     should be acquired

   time_req          Integer, read, optional
                     number of seconds that credentials
                     should remain valid. Specify GSS_C_INDEFINITE
                     to request that the credentials have the maximum
                     permitted lifetime.

   desired_mechs     Set of Object IDs, read, optional
                     set of underlying security mechanisms that
                     may be used.  GSS_C_NO_OID_SET may be used
                     to obtain an implementation-specific default.

   cred_usage        gss_cred_usage_t, read
                     GSS_C_BOTH - Credentials may be used
                        either to initiate or accept
                        security contexts.
                     GSS_C_INITIATE - Credentials will only be
                        used to initiate security contexts.
                     GSS_C_ACCEPT - Credentials will only be used to
                        accept security contexts.

   output_cred_handle  gss_cred_id_t, modify
                       The returned credential handle.  Resources
                       associated with this credential handle must
                       be released by the application after use
                       with a call to gss_release_cred().

   actual_mechs      Set of Object IDs, modify, optional
                     The set of mechanisms for which the
                     credential is valid.  Storage associated
                     with the returned OID-set must be released by
                     the application after use with a call to
                     gss_release_oid_set().  Specify NULL if not
                     required.

   time_rec          Integer, modify, optional
                     Actual number of seconds for which the
                     returned credentials will remain valid.  If the
                     implementation does not support expiration of
                     credentials, the value GSS_C_INDEFINITE will
                     be returned. Specify NULL if not required

Top       Page 35 
   minor_status      Integer, modify
                     Mechanism specific status code.

   Function value:  GSS status code

   GSS_S_COMPLETE    Successful completion

   GSS_S_BAD_MECH    Unavailable mechanism requested

   GSS_S_BAD_NAMETYPE Type contained within desired_name parameter
                      is not supported

   GSS_S_BAD_NAME    Value supplied for desired_name parameter is ill
                     formed.

   GSS_S_CREDENTIALS_EXPIRED The credentials could not be acquired
                             Because they have expired.

   GSS_S_NO_CRED     No credentials were found for the specified name.

5.3. gss_add_cred

   OM_uint32 gss_add_cred (
     OM_uint32           *minor_status,
     const gss_cred_id_t input_cred_handle,
     const gss_name_t    desired_name,
     const gss_OID       desired_mech,
     gss_cred_usage_t    cred_usage,
     OM_uint32           initiator_time_req,
     OM_uint32           acceptor_time_req,
     gss_cred_id_t       *output_cred_handle,
     gss_OID_set         *actual_mechs,
     OM_uint32           *initiator_time_rec,
     OM_uint32           *acceptor_time_rec)

   Purpose:

   Adds a credential-element to a credential.  The credential-element is
   identified by the name of the principal to which it refers.  GSS-API
   implementations must impose a local access-control policy on callers
   of this routine to prevent unauthorized callers from acquiring
   credential-elements to which they are not entitled. This routine is
   not intended to provide a "login to the network" function, as such a
   function would involve the creation of new mechanism-specific
   authentication data, rather than merely acquiring a GSS-API handle to
   existing data.  Such functions, if required, should be defined in
   implementation-specific extensions to the API.

Top       Page 36 
   If desired_name is GSS_C_NO_NAME, the call is interpreted as a
   request to add a credential element that will invoke default behavior
   when passed to gss_init_sec_context() (if cred_usage is
   GSS_C_INITIATE or GSS_C_BOTH) or gss_accept_sec_context() (if
   cred_usage is GSS_C_ACCEPT or GSS_C_BOTH).

   This routine is expected to be used primarily by context acceptors,
   since implementations are likely to provide mechanism-specific ways
   of obtaining GSS-API initiator credentials from the system login
   process.  Some implementations may therefore not support the
   acquisition of GSS_C_INITIATE or GSS_C_BOTH credentials via
   gss_acquire_cred for any name other than GSS_C_NO_NAME, or a name
   produced by applying either gss_inquire_cred to a valid credential,
   or gss_inquire_context to an active context.

   If credential acquisition is time-consuming for a mechanism, the
   mechanism may choose to delay the actual acquisition until the
   credential is required (e.g. by gss_init_sec_context or
   gss_accept_sec_context).  Such mechanism-specific implementation
   decisions should be invisible to the calling application; thus a call
   of gss_inquire_cred immediately following the call of gss_add_cred
   must return valid credential data, and may therefore incur the
   overhead of a deferred credential acquisition.

   This routine can be used to either compose a new credential
   containing all credential-elements of the original in addition to the
   newly-acquire credential-element, or to add the new credential-
   element to an existing credential. If NULL is specified for the
   output_cred_handle parameter argument, the new credential-element
   will be added to the credential identified by input_cred_handle; if a
   valid pointer is specified for the output_cred_handle parameter, a
   new credential handle will be created.

   If GSS_C_NO_CREDENTIAL is specified as the input_cred_handle,
   gss_add_cred will compose a credential (and set the
   output_cred_handle parameter accordingly) based on default behavior.
   That is, the call will have the same effect as if the application had
   first made a call to gss_acquire_cred(), specifying the same usage
   and passing GSS_C_NO_NAME as the desired_name parameter to obtain an
   explicit credential handle embodying default behavior, passed this
   credential handle to gss_add_cred(), and finally called
   gss_release_cred() on the first credential handle.

   If GSS_C_NO_CREDENTIAL is specified as the input_cred_handle
   parameter, a non-NULL output_cred_handle must be supplied.

Top       Page 37 
   Parameters:

   minor_status      Integer, modify
                     Mechanism specific status code.

   input_cred_handle gss_cred_id_t, read, optional
                     The credential to which a credential-element
                     will be added.  If GSS_C_NO_CREDENTIAL is
                     specified, the routine will compose the new
                     credential based on default behavior (see
                     description above).  Note that, while the
                     credential-handle is not modified by
                     gss_add_cred(), the underlying credential
                     will be modified if output_credential_handle
                     is NULL.

   desired_name      gss_name_t, read.
                     Name of principal whose credential
                     should be acquired.

   desired_mech      Object ID, read
                     Underlying security mechanism with which the
                     credential may be used.

   cred_usage        gss_cred_usage_t, read
                     GSS_C_BOTH - Credential may be used
                     either to initiate or accept
                     security contexts.
                     GSS_C_INITIATE - Credential will only be
                                      used to initiate security
                                      contexts.
                     GSS_C_ACCEPT - Credential will only be used to
                                    accept security contexts.

   initiator_time_req Integer, read, optional
                      number of seconds that the credential
                      should remain valid for initiating security
                      contexts.  This argument is ignored if the
                      composed credentials are of type GSS_C_ACCEPT.
                      Specify GSS_C_INDEFINITE to request that the
                      credentials have the maximum permitted
                      initiator lifetime.

   acceptor_time_req Integer, read, optional
                     number of seconds that the credential
                     should remain valid for accepting security
                     contexts.  This argument is ignored if the
                     composed credentials are of type GSS_C_INITIATE.

Top       Page 38 
                     Specify GSS_C_INDEFINITE to request that the
                     credentials have the maximum permitted initiator
                     lifetime.

   output_cred_handle gss_cred_id_t, modify, optional
                      The returned credential handle, containing
                      the new credential-element and all the
                      credential-elements from input_cred_handle.
                      If a valid pointer to a gss_cred_id_t is
                      supplied for this parameter, gss_add_cred
                      creates a new credential handle containing all
                      credential-elements from the input_cred_handle
                      and the newly acquired credential-element; if
                      NULL is specified for this parameter, the newly
                      acquired credential-element will be added
                      to the credential identified by input_cred_handle.

                      The resources associated with any credential
                      handle returned via this parameter must be
                      released by the application after use with a
                      call to gss_release_cred().

   actual_mechs      Set of Object IDs, modify, optional
                     The complete set of mechanisms for which
                     the new credential is valid.  Storage for
                     the returned OID-set must be freed by the
                     application after use with a call to
                     gss_release_oid_set(). Specify NULL if
                     not required.

   initiator_time_rec Integer, modify, optional
                      Actual number of seconds for which the
                      returned credentials will remain valid for
                      initiating contexts using the specified
                      mechanism.  If the implementation or mechanism
                      does not support expiration of credentials, the
                      value GSS_C_INDEFINITE will be returned. Specify
                      NULL if not required

   acceptor_time_rec Integer, modify, optional
                     Actual number of seconds for which the
                     returned credentials will remain valid for
                     accepting security contexts using the specified
                     mechanism.  If the implementation or mechanism
                     does not support expiration of credentials, the
                     value GSS_C_INDEFINITE will be returned. Specify
                     NULL if not required

Top       Page 39 
   Function value:   GSS status code

   GSS_S_COMPLETE    Successful completion

   GSS_S_BAD_MECH    Unavailable mechanism requested

   GSS_S_BAD_NAMETYPE Type contained within desired_name parameter
                     is not supported

   GSS_S_BAD_NAME    Value supplied for desired_name parameter is
                     ill-formed.

   GSS_S_DUPLICATE_ELEMENT The credential already contains an element
                     for the requested mechanism with overlapping
                     usage and validity period.

   GSS_S_CREDENTIALS_EXPIRED The required credentials could not be
                     added because they have expired.

   GSS_S_NO_CRED     No credentials were found for the specified name.

5.4. gss_add_oid_set_member

   OM_uint32 gss_add_oid_set_member (
     OM_uint32       *minor_status,
     const gss_OID   member_oid,
     gss_OID_set     *oid_set)

   Purpose:

   Add an Object Identifier to an Object Identifier set.  This routine
   is intended for use in conjunction with gss_create_empty_oid_set when
   constructing a set of mechanism OIDs for input to gss_acquire_cred.
   The oid_set parameter must refer to an OID-set that was created by
   GSS-API (e.g. a set returned by gss_create_empty_oid_set()). GSS-API
   creates a copy of the member_oid and inserts this copy into the set,
   expanding the storage allocated to the OID-set's elements array if
   necessary.  The routine may add the new member OID anywhere within
   the elements array, and implementations should verify that the new
   member_oid is not already contained within the elements array; if the
   member_oid is already present, the oid_set should remain unchanged.

   Parameters:

      minor_status      Integer, modify
                        Mechanism specific status code

Top       Page 40 
      member_oid        Object ID, read
                        The object identifier to copied into
                        the set.

      oid_set           Set of Object ID, modify
                        The set in which the object identifier
                        should be inserted.

   Function value:   GSS status code

      GSS_S_COMPLETE    Successful completion

5.5. gss_canonicalize_name

   OM_uint32 gss_canonicalize_name (
     OM_uint32        *minor_status,
     const gss_name_t input_name,
     const gss_OID    mech_type,
     gss_name_t       *output_name)

   Purpose:

   Generate a canonical mechanism name (MN) from an arbitrary internal
   name.  The mechanism name is the name that would be returned to a
   context acceptor on successful authentication of a context where the
   initiator used the input_name in a successful call to
   gss_acquire_cred, specifying an OID set containing <mech_type> as its
   only member, followed by a call to gss_init_sec_context, specifying
   <mech_type> as the authentication mechanism.

   Parameters:

   minor_status      Integer, modify
                     Mechanism specific status code

   input_name        gss_name_t, read
                     The name for which a canonical form is
                     desired

   mech_type         Object ID, read
                     The authentication mechanism for which the
                     canonical form of the name is desired.  The
                     desired mechanism must be specified explicitly;
                     no default is provided.

Top       Page 41 
   output_name       gss_name_t, modify
                     The resultant canonical name.  Storage
                     associated with this name must be freed by
                     the application after use with a call to
                     gss_release_name().

   Function value:   GSS status code

   GSS_S_COMPLETE    Successful completion.

   GSS_S_BAD_MECH    The identified mechanism is not supported.

   GSS_S_BAD_NAMETYPE The provided internal name contains no elements
                     that could be processed by the specified
                     mechanism.

   GSS_S_BAD_NAME    The provided internal name was ill-formed.

5.6. gss_compare_name

   OM_uint32 gss_compare_name (
     OM_uint32        *minor_status,
     const gss_name_t name1,
     const gss_name_t name2,
     int              *name_equal)

   Purpose:

   Allows an application to compare two internal-form names to determine
   whether they refer to the same entity.

   If either name presented to gss_compare_name denotes an anonymous
   principal, the routines should indicate that the two names do not
   refer to the same identity.

   Parameters:

   minor_status      Integer, modify
                     Mechanism specific status code.

   name1             gss_name_t, read
                     internal-form name

   name2             gss_name_t, read
                     internal-form name

Top       Page 42 
   name_equal        boolean, modify
                     non-zero - names refer to same entity
                     zero - names refer to different entities
                           (strictly, the names are not known
                           to refer to the same identity).

   Function value:   GSS status code

   GSS_S_COMPLETE    Successful completion

   GSS_S_BAD_NAMETYPE The two names were of incomparable types.

   GSS_S_BAD_NAME    One or both of name1 or name2 was ill-formed.

5.7. gss_context_time

   OM_uint32 gss_context_time (
     OM_uint32          *minor_status,
     const gss_ctx_id_t context_handle,
     OM_uint32          *time_rec)

   Purpose:

   Determines the number of seconds for which the specified context will
   remain valid.

   Parameters:

   minor_status      Integer, modify
                     Implementation specific status code.

   context_handle    gss_ctx_id_t, read
                     Identifies the context to be interrogated.

   time_rec          Integer, modify
                     Number of seconds that the context will remain
                     valid.  If the context has already expired,
                     zero will be returned.

   Function value:   GSS status code

   GSS_S_COMPLETE    Successful completion

   GSS_S_CONTEXT_EXPIRED The context has already expired

   GSS_S_NO_CONTEXT  The context_handle parameter did not identify
                     a valid context

Top       Page 43 
5.8. gss_create_empty_oid_set

   OM_uint32 gss_create_empty_oid_set (
     OM_uint32    *minor_status,
     gss_OID_set  *oid_set)

   Purpose:

   Create an object-identifier set containing no object identifiers, to
   which members may be subsequently added using the
   gss_add_oid_set_member() routine.  These routines are intended to be
   used to construct sets of mechanism object identifiers, for input to
   gss_acquire_cred.

   Parameters:

   minor_status      Integer, modify
                     Mechanism specific status code

   oid_set           Set of Object IDs, modify
                     The empty object identifier set.
                     The routine will allocate the
                     gss_OID_set_desc object, which the
                     application must free after use with
                     a call to gss_release_oid_set().

   Function value:   GSS status code

   GSS_S_COMPLETE    Successful completion

5.9. gss_delete_sec_context

   OM_uint32 gss_delete_sec_context (
     OM_uint32    *minor_status,
     gss_ctx_id_t *context_handle,
     gss_buffer_t output_token)

   Purpose:

   Delete a security context.  gss_delete_sec_context will delete the
   local data structures associated with the specified security context,
   and may generate an output_token, which when passed to the peer
   gss_process_context_token will instruct it to do likewise.  If no
   token is required by the mechanism, the GSS-API should set the length
   field of the output_token (if provided) to zero.  No further security
   services may be obtained using the context specified by
   context_handle.

Top       Page 44 
   In addition to deleting established security contexts,
   gss_delete_sec_context must also be able to delete "half-built"
   security contexts resulting from an incomplete sequence of
   gss_init_sec_context()/gss_accept_sec_context() calls.

   The output_token parameter is retained for compatibility with version
   1 of the GSS-API.  It is recommended that both peer applications
   invoke gss_delete_sec_context passing the value GSS_C_NO_BUFFER for
   the output_token parameter, indicating that no token is required, and
   that gss_delete_sec_context should simply delete local context data
   structures.  If the application does pass a valid buffer to
   gss_delete_sec_context, mechanisms are encouraged to return a zero-
   length token, indicating that no peer action is necessary, and that
   no token should be transferred by the application.

   Parameters:

   minor_status      Integer, modify
                     Mechanism specific status code.

   context_handle    gss_ctx_id_t, modify
                     context handle identifying context to delete.
                     After deleting the context, the GSS-API will set
                     this context handle to GSS_C_NO_CONTEXT.

   output_token      buffer, opaque, modify, optional
                     token to be sent to remote application to
                     instruct it to also delete the context.  It
                     is recommended that applications specify
                     GSS_C_NO_BUFFER for this parameter, requesting
                     local deletion only.  If a buffer parameter is
                     provided by the application, the mechanism may
                     return a token in it;  mechanisms that implement
                     only local deletion should set the length field of
                     this token to zero to indicate to the application
                     that no token is to be sent to the peer.

   Function value:   GSS status code

   GSS_S_COMPLETE    Successful completion

   GSS_S_NO_CONTEXT  No valid context was supplied

Top       Page 45 
5.10. gss_display_name

   OM_uint32 gss_display_name (
     OM_uint32        *minor_status,
     const gss_name_t input_name,
     gss_buffer_t     output_name_buffer,
     gss_OID          *output_name_type)

   Purpose:

   Allows an application to obtain a textual representation of an opaque
   internal-form  name for display purposes.  The syntax of a printable
   name is defined by the GSS-API implementation.

   If input_name denotes an anonymous principal, the implementation
   should return the gss_OID value GSS_C_NT_ANONYMOUS as the
   output_name_type, and a textual name that is syntactically distinct
   from all valid supported printable names in output_name_buffer.

   If input_name was created by a call to gss_import_name, specifying
   GSS_C_NO_OID as the name-type, implementations that employ lazy
   conversion between name types may return GSS_C_NO_OID via the
   output_name_type parameter.

   Parameters:

   minor_status      Integer, modify
                     Mechanism specific status code.

   input_name        gss_name_t, read
                     name to be displayed

   output_name_buffer  buffer, character-string, modify
                     buffer to receive textual name string.
                     The application must free storage associated
                     with this name after use with a call to
                     gss_release_buffer().

   output_name_type  Object ID, modify, optional
                     The type of the returned name.  The returned
                     gss_OID will be a pointer into static storage,
                     and should be treated as read-only by the caller
                     (in particular, the application should not attempt
                     to free it). Specify NULL if not required.

Top       Page 46 
   Function value:   GSS status code

   GSS_S_COMPLETE    Successful completion

   GSS_S_BAD_NAME    input_name was ill-formed

5.11. gss_display_status

   OM_uint32 gss_display_status (
     OM_uint32      *minor_status,
     OM_uint32      status_value,
     int            status_type,
     const gss_OID  mech_type,
     OM_uint32      *message_context,
     gss_buffer_t   status_string)

   Purpose:

   Allows an application to obtain a textual representation of a GSS-API
   status code, for display to the user or for logging purposes.  Since
   some status values may indicate multiple conditions, applications may
   need to call gss_display_status multiple times, each call generating
   a single text string.  The message_context parameter is used by
   gss_display_status to store state information about which error
   messages have already been extracted from a given status_value;
   message_context must be initialized to 0 by the application prior to
   the first call, and gss_display_status will return a non-zero value
   in this parameter if there are further messages to extract.

   The message_context parameter contains all state information required
   by gss_display_status in order to extract further messages from the
   status_value;  even when a non-zero value is returned in this
   parameter, the application is not required to call gss_display_status
   again unless subsequent messages are desired.  The following code
   extracts all messages from a given status code and prints them to
   stderr:

   OM_uint32 message_context;
   OM_uint32 status_code;
   OM_uint32 maj_status;
   OM_uint32 min_status;
   gss_buffer_desc status_string;

          ...

   message_context = 0;

   do {

Top       Page 47 
     maj_status = gss_display_status (
                     &min_status,
                     status_code,
                     GSS_C_GSS_CODE,
                     GSS_C_NO_OID,
                     &message_context,
                     &status_string)

     fprintf(stderr,
             "%.*s\n",
            (int)status_string.length,

            (char *)status_string.value);

     gss_release_buffer(&min_status, &status_string);

   } while (message_context != 0);


   Parameters:

   minor_status      Integer, modify
                     Mechanism specific status code.

   status_value      Integer, read
                     Status value to be converted

   status_type       Integer, read
                     GSS_C_GSS_CODE - status_value is a GSS status
                     code

   GSS_C_MECH_CODE - status_value is a mechanism
                     status code

   mech_type         Object ID, read, optional
                     Underlying mechanism (used to interpret a
                     minor status value) Supply GSS_C_NO_OID to
                     obtain the system default.

   message_context   Integer, read/modify
                     Should be initialized to zero by the
                     application prior to the first call.
                     On return from gss_display_status(),
                     a non-zero status_value parameter indicates
                     that additional messages may be extracted
                     from the status code via subsequent calls

Top       Page 48 
                     to gss_display_status(), passing the same
                     status_value, status_type, mech_type, and
                     message_context parameters.

   status_string     buffer, character string, modify
                     textual interpretation of the status_value.
                     Storage associated with this parameter must
                     be freed by the application after use with
                     a call to gss_release_buffer().

   Function value:   GSS status code

   GSS_S_COMPLETE    Successful completion

   GSS_S_BAD_MECH    Indicates that translation in accordance with
                     an unsupported mechanism type was requested

   GSS_S_BAD_STATUS  The status value was not recognized, or the
                     status type was neither GSS_C_GSS_CODE nor
                     GSS_C_MECH_CODE.

5.12. gss_duplicate_name

   OM_uint32 gss_duplicate_name (
     OM_uint32        *minor_status,
     const gss_name_t src_name,
     gss_name_t       *dest_name)

   Purpose:

   Create an exact duplicate of the existing internal name src_name.
   The new dest_name will be independent of src_name (i.e. src_name and
   dest_name must both be released, and the release of one shall not
   affect the validity of the other).

   Parameters:

   minor_status      Integer, modify
                     Mechanism specific status code.

   src_name          gss_name_t, read
                     internal name to be duplicated.

   dest_name         gss_name_t, modify
                     The resultant copy of <src_name>.
                     Storage associated with this name must
                     be freed by the application after use
                     with a call to gss_release_name().

Top       Page 49 
   Function value:   GSS status code

   GSS_S_COMPLETE    Successful completion

   GSS_S_BAD_NAME    The src_name parameter was ill-formed.

5.13. gss_export_name

   OM_uint32 gss_export_name (
     OM_uint32        *minor_status,
     const gss_name_t input_name,
     gss_buffer_t     exported_name)

   Purpose:

   To produce a canonical contiguous string representation of a
   mechanism name (MN), suitable for direct comparison (e.g. with
   memcmp) for use in authorization functions (e.g. matching entries in
   an access-control list).  The <input_name> parameter must specify a
   valid MN (i.e. an internal name generated by gss_accept_sec_context
   or by gss_canonicalize_name).

   Parameters:

   minor_status      Integer, modify
                     Mechanism specific status code

   input_name        gss_name_t, read
                     The MN to be exported

   exported_name     gss_buffer_t, octet-string, modify
                     The canonical contiguous string form of
                     <input_name>.  Storage associated with
                     this string must freed by the application
                     after use with gss_release_buffer().

   Function value:   GSS status code

   GSS_S_COMPLETE    Successful completion

   GSS_S_NAME_NOT_MN The provided internal name was not a mechanism
                     name.

   GSS_S_BAD_NAME    The provided internal name was ill-formed.

   GSS_S_BAD_NAMETYPE The internal name was of a type not supported
                     by the GSS-API implementation.


Next RFC Part