2. GSSAPI Routines
This section lists the functions performed by each of the GSSAPI routines and discusses their major parameters, describing how they are to be passed to the routines. The routines are listed in figure 4-1.
Figure 4-1 GSSAPI Routines
Routine Function
gss_acquire_cred Assume a global identity
gss_release_cred Discard credentials
gss_init_sec_context Initiate a security context
with a peer application
gss_accept_sec_context Accept a security context
initiated by a peer
application
gss_process_context_token Process a token on a security
context from a peer
application
gss_delete_sec_context Discard a security context
gss_context_time Determine for how long a
context will remain valid
gss_sign Sign a message; integrity
service
gss_verify Check signature on a message
gss_seal Sign (optionally encrypt) a
message; confidentiality
service
gss_unseal Verify (optionally decrypt)
message
gss_display_status Convert an API status code
to text
gss_indicate_mechs Determine underlying
authentication mechanism
gss_compare_name Compare two internal-form
names
gss_display_name Convert opaque name to text
gss_import_name Convert a textual name to
internal-form
gss_release_name Discard an internal-form
name
gss_release_buffer Discard a buffer
gss_release_oid_set Discard a set of object
identifiers
gss_inquire_cred Determine information about
a credential
Individual GSSAPI implementations may augment these routines by providing additional mechanism-specific routines if required functionality is not available from the generic forms. Applications are encouraged to use the generic routines wherever possible on portability grounds.
2.1. Data Types and Calling Conventions
The following conventions are used by the GSSAPI:
2.1.1. Structured data types
Wherever these GSSAPI C-bindings describe structured data, only fields that must be provided by all GSSAPI implementation are documented. Individual implementations may provide additional fields, either for internal use within GSSAPI routines, or for use by non-portable applications.
2.1.2. Integer types
GSSAPI defines the following integer data type:
OM_uint32 32-bit unsigned integer
Where guaranteed minimum bit-count is important, this portable data type is used by the GSSAPI routine definitions. Individual GSSAPI implementations will include appropriate typedef definitions to map this type onto a built-in data type.
2.1.3. String and similar data
Many of the GSSAPI routines take arguments and return values that describe contiguous multiple-byte data. All such data is passed between the GSSAPI and the caller using the gss_buffer_t data type.
This data type is a pointer to a buffer descriptor, which consists of a length field that contains the total number of bytes in the datum, and a value field which contains a pointer to the actual datum:
typedef struct gss_buffer_desc_struct {
size_t length;
void *value;
} gss_buffer_desc, *gss_buffer_t;
Storage for data passed to the application by a GSSAPI routine using the gss_buffer_t conventions is allocated by the GSSAPI routine. The application may free this storage by invoking the gss_release_buffer routine. Allocation of the gss_buffer_desc object is always the responsibility of the application; Unused gss_buffer_desc objects may be initialized to the value GSS_C_EMPTY_BUFFER.
2.1.3.1. Opaque data types
Certain multiple-word data items are considered opaque data types at the GSSAPI, because their internal structure has no significance either to the GSSAPI or to the caller. Examples of such opaque data types are the input_token parameter to gss_init_sec_context (which is opaque to the caller), and the input_message parameter to gss_seal (which is opaque to the GSSAPI). Opaque data is passed between the GSSAPI and the application using the gss_buffer_t datatype.
2.1.3.2. Character strings
Certain multiple-word data items may be regarded as simple ISO Latin-1 character strings. An example of this is the input_name_buffer parameter to gss_import_name. Some GSSAPI routines also return character strings. Character strings are passed between the application and the GSSAPI using the gss_buffer_t datatype, defined earlier.
2.1.4. Object Identifiers
Certain GSSAPI procedures take parameters of the type gss_OID, or Object identifier. This is a type containing ISO-defined tree-structured values, and is used by the GSSAPI caller to select an underlying security mechanism. A value of type gss_OID has the following structure:
typedef struct gss_OID_desc_struct {
OM_uint32 length;
void *elements;
} gss_OID_desc, *gss_OID;
The elements field of this structure points to the first byte of an octet string containing the ASN.1 BER encoding of the value of the gss_OID. The length field contains the number of bytes in this value. For example, the gss_OID value corresponding to {iso(1) identified- oganization(3) icd-ecma(12) member-company(2) dec(1011) cryptoAlgorithms(7) SPX(5)} meaning SPX (Digital's X.509 authentication mechanism) has a length field of 7 and an elements field pointing to seven octets containing the following octal values: 53,14,2,207,163,7,5. GSSAPI implementations should provide constant gss_OID values to allow callers to request any supported mechanism, although applications are encouraged on portability grounds to accept the default mechanism. gss_OID values should also be provided to allow applications to specify particular name types (see section 2.1.10). Applications should treat gss_OID_desc values returned by GSSAPI routines as read-only. In particular, the application should not attempt to deallocate them. The gss_OID_desc datatype is equivalent to the X/Open OM_object_identifier datatype [2].
2.1.5. Object Identifier Sets
Certain GSSAPI procedures take parameters of the type gss_OID_set. This type represents one or more object identifiers (section 2.1.4). A gss_OID_set object has the following structure:
typedef struct gss_OID_set_desc_struct {
int count;
gss_OID elements;
} gss_OID_set_desc, *gss_OID_set;
The count field contains the number of OIDs within the set. The elements field is a pointer to an array of gss_OID_desc objects, each of which describes a single OID. gss_OID_set values are used to name the available mechanisms supported by the GSSAPI, to request the use of specific mechanisms, and to indicate which mechanisms a given credential supports. Storage associated with gss_OID_set values returned to the application by the GSSAPI may be deallocated by the gss_release_oid_set routine.
2.1.6. Credentials
A credential handle is a caller-opaque atomic datum that identifies a GSSAPI credential data structure. It is represented by the caller-opaque type gss_cred_id_t, which may be implemented as either an arithmetic or a pointer type. Credentials describe a principal, and they give their holder the ability to act as that principal. The GSSAPI does not make the actual credentials available to applications; instead the credential handle is used to identify a particular credential, held internally by GSSAPI or underlying
mechanism. Thus the credential handle contains no security-relavent information, and requires no special protection by the application. Depending on the implementation, a given credential handle may refer to different credentials when presented to the GSSAPI by different callers. Individual GSSAPI implementations should define both the scope of a credential handle and the scope of a credential itself (which must be at least as wide as that of a handle). Possibilities for credential handle scope include the process that acquired the handle, the acquiring process and its children, or all processes sharing some local identification information (e.g., UID). If no handles exist by which a given credential may be reached, the GSSAPI may delete the credential.
Certain routines allow credential handle parameters to be omitted to indicate the use of a default credential. The mechanism by which a default credential is established and its scope should be defined by the individual GSSAPI implementation.
2.1.7. Contexts
The gss_ctx_id_t data type contains a caller-opaque atomic value that identifies one end of a GSSAPI security context. It may be implemented as either an arithmetic or a pointer type. Depending on the implementation, a given gss_ctx_id_t value may refer to different GSSAPI security contexts when presented to the GSSAPI by different callers. The security context holds state information about each end of a peer communication, including cryptographic state information. Individual GSSAPI implementations should define the scope of a context. Since no way is provided by which a new gss_ctx_id_t value may be obtained for an existing context, the scope of a context should be the same as the scope of a gss_ctx_id_t.
2.1.8. Authentication tokens
A token is a caller-opaque type that GSSAPI uses to maintain synchronization between the context data structures at each end of a GSSAPI security context. The token is a cryptographically protected bit-string, generated by the underlying mechanism at one end of a GSSAPI security context for use by the peer mechanism at the other end. Encapsulation (if required) and transfer of the token are the responsibility of the peer applications. A token is passed between the GSSAPI and the application using the gss_buffer_t conventions.
2.1.9. Status values
One or more status codes are returned by each GSSAPI routine. Two
distinct sorts of status codes are returned. These are termed GSS
status codes and Mechanism status codes.
2.1.9.1. GSS status codes
GSSAPI routines return GSS status codes as their OM_uint32 function value. These codes indicate errors that are independent of the underlying mechanism used to provide the security service. The errors that can be indicated via a GSS status code are either generic API routine errors (errors that are defined in the GSSAPI specification) or calling errors (errors that are specific to these bindings).
A GSS status code can indicate a single fatal generic API error from the routine and a single calling error. In addition, supplementary status information may be indicated via the setting of bits in the supplementary info field of a GSS status code.
These errors are encoded into the 32-bit GSS status code as follows:
MSB LSB
|------------------------------------------------------------|
| Calling Error | Routine Error | Supplementary Info |
|------------------------------------------------------------|
Bit 31 24 23 16 15 0
Hence if a GSSAPI routine returns a GSS status code whose upper 16 bits contain a non-zero value, the call failed. If the calling error field is non-zero, the invoking application's call of the routine was erroneous. Calling errors are defined in table 5-1. If the routine error field is non-zero, the routine failed for one of the routine-specific reasons listed below in table 5-2. Whether or not the upper 16 bits indicate a failure or a success, the routine may indicate additional information by setting bits in the supplementary info field of the status code. The meaning of individual bits is listed below in table 5-3.
Table 5-1 Calling Errors
Name Value in Meaning
Field
GSS_S_CALL_INACCESSIBLE_READ 1 A required input
parameter could
not be read.
GSS_S_CALL_INACCESSIBLE_WRITE 2 A required output
parameter could
not be written.
GSS_S_CALL_BAD_STRUCTURE 3 A parameter was
malformed
Table 5-2 Routine Errors
Name Value in Meaning
Field
GSS_S_BAD_MECH 1 An unsupported mechanism was
requested
GSS_S_BAD_NAME 2 An invalid name was supplied
GSS_S_BAD_NAMETYPE 3 A supplied name was of an
unsupported type
GSS_S_BAD_BINDINGS 4 Incorrect channel bindings
were supplied
GSS_S_BAD_STATUS 5 An invalid status code was
supplied
GSS_S_BAD_SIG 6 A token had an invalid
signature
GSS_S_NO_CRED 7 No credentials were supplied
GSS_S_NO_CONTEXT 8 No context has been
established
GSS_S_DEFECTIVE_TOKEN 9 A token was invalid
GSS_S_DEFECTIVE_CREDENTIAL 10 A credential was invalid
GSS_S_CREDENTIALS_EXPIRED 11 The referenced credentials
have expired
GSS_S_CONTEXT_EXPIRED 12 The context has expired
GSS_S_FAILURE 13 Miscellaneous failure
(see text)
Table 5-3 Supplementary Status Bits
Name Bit Number Meaning
GSS_S_CONTINUE_NEEDED 0 (LSB) The routine must be called
again to complete its
function.
See routine documentation for
detailed description.
GSS_S_DUPLICATE_TOKEN 1 The token was a duplicate of
an earlier token
GSS_S_OLD_TOKEN 2 The token's validity period
has expired
GSS_S_UNSEQ_TOKEN 3 A later token has already been
processed
The routine documentation also uses the name GSS_S_COMPLETE, which is
a zero value, to indicate an absence of any API errors or
supplementary information bits.
All GSS_S_xxx symbols equate to complete OM_uint32 status codes, rather than to bitfield values. For example, the actual value of the symbol GSS_S_BAD_NAMETYPE (value 3 in the routine error field) is 3 << 16.
The macros GSS_CALLING_ERROR(), GSS_ROUTINE_ERROR() and GSS_SUPPLEMENTARY_INFO() are provided, each of which takes a GSS status code and removes all but the relevant field. For example, the value obtained by applying GSS_ROUTINE_ERROR to a status code removes the calling errors and supplementary info fields, leaving only the routine errors field. The values delivered by these macros may be directly compared with a GSS_S_xxx symbol of the appropriate type. The macro GSS_ERROR() is also provided, which when applied to a GSS status code returns a non-zero value if the status code indicated a calling or routine error, and a zero value otherwise.
A GSSAPI implementation may choose to signal calling errors in a platform-specific manner instead of, or in addition to the routine value; routine errors and supplementary info should be returned via routine status values only.
2.1.9.2. Mechanism-specific status codes
GSSAPI routines return a minor_status parameter, which is used to indicate specialized errors from the underlying security mechanism. This parameter may contain a single mechanism-specific error, indicated by a OM_uint32 value.
The minor_status parameter will always be set by a GSSAPI routine, even if it returns a calling error or one of the generic API errors indicated above as fatal, although other output parameters may remain unset in such cases. However, output parameters that are expected to return pointers to storage allocated by a routine must always set set by the routine, even in the event of an error, although in such cases the GSSAPI routine may elect to set the returned parameter value to NULL to indicate that no storage was actually allocated. Any length field associated with such pointers (as in a gss_buffer_desc structure) should also be set to zero in such cases.
The GSS status code GSS_S_FAILURE is used to indicate that the underlying mechanism detected an error for which no specific GSS status code is defined. The mechanism status code will provide more details about the error.
2.1.10. Names
A name is used to identify a person or entity. GSSAPI authenticates
the relationship between a name and the entity claiming the name.
Two distinct representations are defined for names:
(a) A printable form, for presentation to a user
(b) An internal form, for presentation at the API
The syntax of a printable name is defined by the GSSAPI implementation, and may be dependent on local system configuration, or on individual user preference. The internal form provides a canonical representation of the name that is independent of configuration.
A given GSSAPI implementation may support names drawn from multiple namespaces. In such an implementation, the internal form of the name must include fields that identify the namespace from which the name is drawn. The namespace from which a printable name is drawn is specified by an accompanying object identifier.
Routines (gss_import_name and gss_display_name) are provided to convert names between their printable representations and the gss_name_t type. gss_import_name may support multiple syntaxes for each supported namespace, allowing users the freedom to choose a preferred name representation. gss_display_name should use an implementation-chosen preferred syntax for each supported name-type.
Comparison of internal-form names is accomplished via the gss_compare_names routine. This removes the need for the application program to understand the syntaxes of the various printable names that a given GSSAPI implementation may support.
Storage is allocated by routines that return gss_name_t values. A
procedure, gss_release_name, is provided to free storage associated
with a name.
2.1.11. Channel Bindings
GSSAPI supports the use of user-specified tags to identify a given context to the peer application. These tags are used to identify the particular communications channel that carries the context. Channel bindings are communicated to the GSSAPI using the following structure:
typedef struct gss_channel_bindings_struct {
OM_uint32 initiator_addrtype;
gss_buffer_desc initiator_address;
OM_uint32 acceptor_addrtype;
gss_buffer_desc acceptor_address;
gss_buffer_desc application_data;
} *gss_channel_bindings_t;
The initiator_addrtype and acceptor_addrtype fields denote the type of addresses contained in the initiator_address and acceptor_address buffers. The address type should be one of the following:
GSS_C_AF_UNSPEC Unspecified address type
GSS_C_AF_LOCAL Host-local address type
GSS_C_AF_INET DARPA Internet address type
GSS_C_AF_IMPLINK ARPAnet IMP address type (eg IP)
GSS_C_AF_PUP pup protocols (eg BSP) address type
GSS_C_AF_CHAOS MIT CHAOS protocol address type
GSS_C_AF_NS XEROX NS address type
GSS_C_AF_NBS nbs address type
GSS_C_AF_ECMA ECMA address type
GSS_C_AF_DATAKIT datakit protocols address type
GSS_C_AF_CCITT CCITT protocols (eg X.25)
GSS_C_AF_SNA IBM SNA address type
GSS_C_AF_DECnet DECnet address type
GSS_C_AF_DLI Direct data link interface address type
GSS_C_AF_LAT LAT address type
GSS_C_AF_HYLINK NSC Hyperchannel address type
GSS_C_AF_APPLETALK AppleTalk address type
GSS_C_AF_BSC BISYNC 2780/3780 address type
GSS_C_AF_DSS Distributed system services address type
GSS_C_AF_OSI OSI TP4 address type
GSS_C_AF_X25 X25
GSS_C_AF_NULLADDR No address specified
Note that these name address families rather than specific addressing formats. For address families that contain several alternative address forms, the initiator_address and acceptor_address fields must contain sufficient information to determine which address form is used. When not otherwise specified, addresses should be specified in network byte-order.
Conceptually, the GSSAPI concatenates the initiator_addrtype, initiator_address, acceptor_addrtype, acceptor_address and application_data to form an octet string. The mechanism signs this octet string, and binds the signature to the context establishment token emitted by gss_init_sec_context. The same bindings are presented by the context acceptor to gss_accept_sec_context, and a
signature is calculated in the same way. The calculated signature is compared with that found in the token, and if the signatures differ, gss_accept_sec_context will return a GSS_S_BAD_BINDINGS error, and the context will not be established. Some mechanisms may include the actual channel binding data in the token (rather than just a signature); applications should therefore not use confidential data as channel-binding components. Individual mechanisms may impose additional constraints on addresses and address types that may appear in channel bindings. For example, a mechanism may verify that the initiator_address field of the channel bindings presented to gss_init_sec_context contains the correct network address of the host system.
2.1.12. Optional parameters
Various parameters are described as optional. This means that they follow a convention whereby a default value may be requested. The following conventions are used for omitted parameters. These conventions apply only to those parameters that are explicitly documented as optional.
2.1.12.1. gss_buffer_t types
Specify GSS_C_NO_BUFFER as a value. For an input parameter this signifies that default behavior is requested, while for an output parameter it indicates that the information that would be returned via the parameter is not required by the application.
2.1.12.2. Integer types (input)
Individual parameter documentation lists values to be used to
indicate default actions.
2.1.12.3. Integer types (output)
Specify NULL as the value for the pointer.
2.1.12.4. Pointer types
Specify NULL as the value.
2.1.12.5. Object IDs
Specify GSS_C_NULL_OID as the value.
2.1.12.6. Object ID Sets
Specify GSS_C_NULL_OID_SET as the value.
2.1.12.7. Credentials
Specify GSS_C_NO_CREDENTIAL to use the default credential handle.
2.1.12.8. Channel Bindings
Specify GSS_C_NO_CHANNEL_BINDINGS to indicate that channel bindings
are not to be used.