skip book previous and next navigation links
go up to top of book: HP Open Source Security for OpenVMS Volume 3:... HP Open Source Security for OpenVMS Volume 3:...
go to beginning of chapter: GSSAPI (Generic Security Services Application... GSSAPI (Generic Security Services Application...
 
go to next page: gss_acquire_cred  Acquire credential handlegss_acquire_cred Acquire credential handle
end of book navigation links

gss_accept_sec_context -- Establish a security context  



C Prototype 

OM_uint32 gss_accept_sec_context(
      OM_uint32                 minor_status,
      gss_ctx_id_t              context_handle,
      gss_cred_id_t             acceptor_cred_handle,
      gss_buffer_t              input_token_buffer,
      gss_channel_bindings_t    input_chan_bindings,
      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 );

Arguments 

minor_status
(output)
 Mechanism-specific status code.
context_handle (input/output)
 The context handle for the new context. Supply GSS_C_NO_CONTEXT for the first call; use the value returned in subsequent calls. Once gss_accept_sec_context has returned a value via this argument, 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 (input)
 The credential handle claimed by the context acceptor. Specify GSS_C_NO_CREDENTIAL to accept the context as a default principal. If GSS_S_NO_CREDENTIAL is specified, but no default acceptor principal is defined, GSS_S_NO_CRED will be returned.
input_token_buffer (input)
 The token obtained from the remote application.
input_chan_bindings (input)
 Application-specified bindings. Allows the 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 (output) The authenticated name of the context initiator. After use, this name should be deallocated by passing it to gss_release_name. If not required, specify NULL.
mech_type (output) The 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 (output) The token to be passed to the peer application. If the length field of the returned token buffer is zero, then no token need be passed to the peer application. If a nonzero length field is returned, the associated storage must be freed after use by the application with a call to gss_release_buffer.
ret_flags (output) A bit mask which contains various independent flags, each of which indicates that the context supports a specific service option. 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 argument.

FALSE -- No credentials were delegated.

GSS_C_MUTUAL_FLAG

TRUE -- The remote peer asked for mutual authentication.

FALSE -- The 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) is available. The gss_wrap routine will provide message encapsulation, data-origination authentication and integrity services only.

GSS_C_INTEG_FLAG

TRUE -- Integrity service may be invoked by calling either the gss_get_mic or gss_wrap routine.

FALSE -- Per-message integrity service is unavailable.

GSS_C_ANON_FLAG

TRUE -- The initiator does not wish to be authenticated; the src_name argument (if requested) contains 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 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 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 zero.
time_rec (output) The number of seconds for which the context will remain valid. Specify NULL if not required.
delegated_cred_handle (output)
 The credential handle for credentials received from the context initiator. Only valid if deleg_flag in ret_flags is TRUE, in which case an explicit credential handle (that is, not GSS_C_NO_CREDENTIAL) will be returned; if deleg_flag is false, gss_accept_context will set this argument 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.

Description 

This routine allows a remotely initiated security context between the application and a remote peer to be established. The routine may return an output_token that 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 arguments.

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. A typical portable caller should always invoke gss_accept_sec_context within a loop. For example:

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 status that includes the value GSS_S_CONTINUE_NEEDED, the context is not fully established and the following restrictions apply to the output arguments:

Return Values 

This routine returns one of the following GSS status codes:

GSS_S_COMPLETE
Successful completion.
GSS_S_CONTINUE_NEEDED
The service completed successfully and synchronously (returned only if the DDTM$M_SYNCH flag is set).
GSS_S_DEFECTIVE_TOKEN
Indicates that consistency checks performed on the input_token failed.
GSS_S_DEFECTIVE_CREDENTIAL
The options flags were invalid or the TID argument was omitted and the bid argument was not 0.
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 argument.
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.


 
go to next page: gss_acquire_cred  Acquire credential handlegss_acquire_cred Acquire credential handle