Skip to main content

Annex B - Support of the GSSAPI

Support of the GSSAPI

In order to support applications which need to be portable across a variety of underlying security mechanisms, a "Generic Security Service API" (or GSSAPI) was designed which gives access to a common core of security services expected to be provided by several mechanisms. The GSSAPI was designed with DASS, Kerberos V4, and Kerberos V5 in mind, and could be written as a front end to any or all of those systems. It is hoped that it could serve as an interface to other security systems as well.

Application portability requires that the security services supported

be comparable. Applications using the GSSAPI will not be able to access all of the features of the underlying security mechanisms. For example, the GSSAPI does not allow access to the "node authentication" features of DASS. To the extent the underlying security mechanisms do not support all the features of GSSAPI, applications using those features will not be portable to those security mechanisms. For example, Kerberos V4 does not support delegation, so applications using that feature of the GSSAPI will not be portable to Kerberos V4.

This annex explains how the GSSAPI can be implemented using the primitive services provided by DASS.

B.1 Summary of GSSAPI​

The latest draft of the GSSAPI specification is available as an internet draft. The following is a brief summary of that evolving document and should not be taken as definitive. Included here are only those aspects of GSSAPI whose implementation would be DASS specific.

The GSSAPI provides four classes of functions: Credential Management, Context-Level Calls, Per-message calls, and Support Calls; two types of objects: Credentials and Contexts; and two kinds of data structures to be transmitted as opaque byte strings: Tokens and Messages. Credentials hold keys and support information used in creating tokens. Contexts hold keys and support information used in signing and encrypting messages.

The Credential Management functions of GSSAPI are "incomplete" in the sense that one could not build a useful security implementation using only GSSAPI. Functions which create credentials based on passwords or smart cards are needed but not provided by GSSAPI. It is envisioned that such functions would be invoked by security mechanism specific functions at user login or via some separate utility rather than from within applications intended to be portable. The Credential Management functions available to portable applications are:

  • GSS_Acquire_cred: get a handle to an existing credential structure based on a name or process default.

  • GSS_Release_cred: release credentials after use.

The Context-Level Calls use credentials to establish contexts. Contexts are like connections: they are created in pairs and are generally used at the two ends of a connection to process messages associated with that connection. The Context-Level Calls of interest

are:

  • GSS_Init_sec_context: given credentials and the name of a destination, create a new context and a token which will permit the destination to create a corresponding context.

  • GSS_Accept_sec_context: given credentials and an incoming token, create a context corresponding to the one at the initiating end and provide information identifying the initiator.

  • GSS_Delete_sec_context: delete a context after use.

The Per-Message Calls use contexts to sign, verify, encrypt, and decrypt messages between the holders of matching contexts. The Per- Message Calls are:

  • GSS_Sign: Given a context and a message, produces a string of bytes which constitute a signature on a provided message.

  • GSS_Verify: Given a context, a message, and the bytes returned by GSS_Sign, verifies the message to be authentic (unaltered since it was signed by the corresponding context).

  • GSS_Seal: Given a context and a message, produces a string of bytes which include the message and a signature; the message may optionally be encrypted.

  • GSS_Unseal: Given a context and the string of bytes from GSS_Seal, returns the original message and a status indicating its authenticity.

The Support Calls provide utilities like translating names and status codes into printable strings.

B.2 Implementation of GSSAPI over DASS​

B.2.1 Data Structures​

The objects and data structures of the GSSAPI do not map neatly into the objects and data structures of the DASS architecture.

This section describes how those data structures can be implemented using the DASS data structures and primitives

Credential handles correspond to the credentials structures in DASS, where the portable API assumes that the credential structures themselves are kept from applications and handles are passed to and

from the various subroutines.

Context initialization tokens correspond to the tokens of DASS. The GSSAPI prescribes a particular ASN.1 encoded form for tokens which includes a mechanism specific bit string within it. An implementation of GSSAPI should enclose the DASS token within the GSSAPI "wrapper".

Context handles have no corresponding structure in DASS. The Create_token and Accept_token calls of DASS return a shared key and instance identifier. An implementation of the GSSAPI must take those values along with some other status information and package it as a "context" opaque structure. These data structures must be allocated and freed with the appropriate calls.

Per-message tokens and sealed messages have no corresponding data structure within DASS. To fully support the GSSAPI functionality, DASS must be extended to include this functionality. These data structures are created by cryptographic routines given the keys and status information in context structures and the messages passed to them. While not properly part of the DASS architecture, the formats of these data structures are included in section C.3.

B.2.2 Procedures​

This section explains how the functions of the GSSAPI can be provided in terms of the Services Provided by DASS. Not all of the DASS features are accessible through the GSSAPI.

B.2.2.1 GSS_Acquire_cred​

The GSSAPI does not provide a mechanism for logging in users or establishing server credentials. It assumes that some system specific mechanism created those credentials and that applications need some mechanism for getting at them. A model implementation might save all credentials in a node-global pool indexed by some sort of credential name. The credentials in the pool would be access controlled by some local policy which is not concern of portable applications. Those applications would simply call GSS_Acquire_cred and if they passed the access control check, they would get a handle to the credentials which could be used in subsequent calls.

B.2.2.2 GSS_Release_cred​

This call corresponds to the "delete_credentials" call of DASS.

B.2.2.3 GSS_Init_sec_context​

In the course of a normal mutual authentication, this routine will be called twice. The procedure can determine whether this is the first or second call by seeing whether the "input_context_handle" is zero (it will be on the first call). On the first call, it will use the DASS Create_token service to create a token and it will also allocate and populate a "context" structure. That structure will hold the key, instance identifier, and mutual authentication token returned by Create_token and will in addition hold the flags which were passed into the Init_sec_context call. The token returned by Init_sec_context will be the DASS token included in the GSSAPI token "wrapper". The DASS token will include the optional principal name.

If mutual authentication is not requested in the GSSAPI call, the mutual authentication token returned by DASS will be ignored and the initial call will return a COMPLETE status. If mutual authentication is requested, the mutual authentication token will be stored in the context information and a CONTINUE_NEEDED status returned.

On the second call to GSS_Init_sec_context (with input_context_handle non-zero), the returned token will be compared to the one in the context information using the Compare_mutual_token procedure and a COMPLETE status will be returned if they match.

B.2.2.4 GSS_Accept_sec_context​

This routine in GSSAPI accepts an incoming token and creates a context. It combines the effects of a series of DASS functions. It could be implemented as follows:

  • Remove the GSSAPI "wrapper" from the incoming token and pass the rest and the credentials to "Accept_token". Accept_token produces a mutual authentication token and a new credentials structure. If delegation was requested, the new credentials structure will be an output of GSS_Accept_sec_context. In any case, it will be used in the subsequent steps of this procedure.

  • Use the DASS Get_principal_name function to extract the principal name from the credentials produced by Accept_token. This name is one of the outputs of "GSS_Accept_sec_context.

  • Apply the DASS Verify_principal_name to the new credentials and the retrieved name to authenticate the token as having come from the named principal.

  • Create and populate a context structure with the key and

timestamp returned by Accept_token and a status of COMPLETE. Return a handle to that context.

  • If delegation was requested, return the new credentials from GSS_Accept_sec_context. Otherwise, call Delete_credentials.

  • If mutual authentication was requested, wrap the mutual authentication token from Accept_token in a GSSAPI "wrapper" and return it. Otherwise return a null string.

B.2.2.5 GSS_Delete_sec_context​

This routine simply deletes the context state. No calls to DASS are required.

B.2.2.6 GSS_Sign​

This routine takes as input a context handle and a message. It creates a per_msg_token by computing a digital signature on the message using the key and timestamp in the context block. No DASS services are required. If additional cryptographic services were requested (replay detection or sequencing), a timestamp or sequence number must be prepended to the message and sent with the signature. The syntax for this message is listed in section C.3.

B.2.2.7 GSS_Verify​

This routine repeats the calculation of the sign routine and verifies the signature provided. If replay detection or sequencing services are provided, the context must maintain as part of its state information containing the sequence numbers or timestamps of messages already received and this one must be checked for acceptability.

B.2.2.8 GSS_Seal​

This routine performs the same functions as Sign but also optionally encrypts the message for privacy using the shared key and encapsulates the whole thing in a GSSAPI specified ASN.1 wrapper.

B.2.2.9 GSS_Unseal​

This routine performs the same functions as GSS_Verify but also parses the data structure including the signature and message and decrypts the message if necessary.

B.3 Syntax​

The GSSAPI specification recommends the following ASN.1 encoding for the tokens and messages generated through the GSSAPI:

--optional top-level token definitions to frame -- different mechanisms

        GSSAPI DEFINITIONS ::=
        BEGIN

        MechType ::= OBJECT IDENTIFIER
        -- data structure definitions
        ContextToken ::=
        -- option indication (delegation, etc.) indicated
        -- within mechanism-specific token
        [APPLICATION 0] IMPLICIT SEQUENCE {
             thisMech MechType,
             responseExpected BOOLEAN,
             innerContextToken ANY DEFINED BY MechType
               -- contents mechanism-specific
             }

        PerMsgToken ::=
        -- as emitted by GSS_Sign and processed by
        -- GSS_Verify
        [APPLICATION 1] IMPLICIT SEQUENCE {
             thisMech MechType,
             innerMsgToken ANY DEFINED BY MechType
               -- contents mechanism-specific
             }
        SealedMessage ::=
        -- as emitted by GSS_Seal and processed by
        -- GSS_Unseal
        [APPLICATION 2] IMPLICIT SEQUENCE {
             sealingToken PERMSGTOKEN,
             confFlag BOOLEAN,
             userData OCTET STRING
               -- encrypted if confFlag TRUE
             }

   The object identifier for the DASS MechType is 1.3.12.2.1011.7.5.

   The innerContextToken of a token is a DASS token or mutual
   authentication token.

   The innerMsgToken is a null string in the case where the message is
   encrypted and the token is included as part of a SealedMessage.






   Otherwise, it is an eight octet sequence computed as the CBC residue
   computed using a key and string of bytes defined as follows:

    - Pad the message provided by the application with 1-8 bytes of
      pad to produce a string whose length is a multiple of 8
      octets.  Each pad byte has a value equal to the number of pad
      bytes.

    - Compute the key by taking the timestamp of the association
      (two four byte integers laid out in big endian order with the
      most significant integer first), complementing the high order
      bit (to avoid aliasing with mutual authenticators), and
      encrypting the block in ECB mode with the shared key of the
      association.

   The userData field of a SealedMessage is exactly the application
   provided byte string if confFlag=FALSE.  Otherwise, it is the
   application supplied message encrypted as follows:

    - Pad the message provided by the application with 1-8 bytes of
      pad to produce a string whose length = 4 (mod 8).  Each pad
      byte has a value equal to the number of pad bytes.

    - Append a four byte CRC32 computed over the message + pad.

    - Compute a key by taking the timestamp of the association (two
      four byte integers laid out in big endian order with the most
      significant integer first), complementing the high order bit
      (to avoid aliasing with mutual authenticators), and encrypting
      the block in ECB mode with the shared key of the association.

    - Encrypt the message + pad + CRC32 using CBC and the key
      computed in the previous step.

   A note of the logic behind the above:

    - Because the shared key of an association may be reused by many
      associations between the same pair of principals, it is
      necessary to bind the association timestamp into the messages
      somehow to prevent messages from a previous association being
      replayed into a new sequence.  The technique above of
      generating an association key accomplishes this and has a side
      benefit.  An implementation may with to keep the long term
      keys out of the hands of applications for purposes of
      confinement but may wish to put the encryption associated with
      an association in process context for reasons of performance.
      Defining an association key makes that possible.







    - The reason that the association specific key is not specified
      as the output of Create_token and Accept_token is that the DCE
      RPC security implementation requires that a series of
      associations between two principals always have the same key
      and we did not want to have to support a different interface
      in that application.

    - The CRC32 after pad constitutes a cheap integrity check when
      data is encrypted.
    - The fact that padding is done differently for encrypted and
      signed messages means that there are no threats related to
      sending the same message encrypted and unencrypted and using
      the last block of the encrypted message as a signature on the
      unencrypted one.