---
name: "gss_krb5_import_ccache"
section: "3"
platform: "linux"
package: "heimdal-dev"
version: "7.8.git20221117.28daf24+dfsg-9+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/gss_krb5_import_ccache"
---

# gss\_krb5\_import\_ccache(3)

Generic Security Service Application Program Interface library

## NAME

**gss\_accept\_sec\_context**, **gss\_acquire\_cred**, **gss\_add\_cred**, **gss\_add\_oid\_set\_member**, **gss\_canonicalize\_name**, **gss\_compare\_name**, **gss\_context\_time**, **gss\_create\_empty\_oid\_set**, **gss\_delete\_sec\_context**, **gss\_display\_name**, **gss\_display\_status**, **gss\_duplicate\_name**, **gss\_export\_name**, **gss\_export\_sec\_context**, **gss\_get\_mic**, **gss\_import\_name**, **gss\_import\_sec\_context**, **gss\_indicate\_mechs**, **gss\_init\_sec\_context**, **gss\_inquire\_context**, **gss\_inquire\_cred**, **gss\_inquire\_cred\_by\_mech**, **gss\_inquire\_mechs\_for\_name**, **gss\_inquire\_names\_for\_mech**, **gss\_krb5\_ccache\_name**, **gss\_krb5\_compat\_des3\_mic**, **gss\_krb5\_copy\_ccache**, **gss\_krb5\_import\_cred** **gsskrb5\_extract\_authz\_data\_from\_sec\_context**, **gsskrb5\_register\_acceptor\_identity**, **gss\_krb5\_import\_ccache**, **gss\_krb5\_get\_tkt\_flags**, **gss\_process\_context\_token**, **gss\_release\_buffer**, **gss\_release\_cred**, **gss\_release\_name**, **gss\_release\_oid\_set**, **gss\_seal**, **gss\_sign**, **gss\_test\_oid\_set\_member**, **gss\_unseal**, **gss\_unwrap**, **gss\_verify**, **gss\_verify\_mic**, **gss\_wrap**, **gss\_wrap\_size\_limit** – Generic Security Service Application Program Interface library

## LIBRARY

GSS-API library (libgssapi, -lgssapi)

## SYNOPSIS

**#include \<gssapi.h\>**

*OM\_uint32*\

**gss\_accept\_sec\_context**(*OM\_uint32 \* minor\_status*, *gss\_ctx\_id\_t \* context\_handle*, *gss\_const\_cred\_id\_t acceptor\_cred\_handle*, *const gss\_buffer\_t input\_token\_buffer*, *const 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*);

*OM\_uint32*\

**gss\_acquire\_cred**(*OM\_uint32 \* minor\_status*, *gss\_const\_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*);

*OM\_uint32*\

**gss\_add\_cred**(*OM\_uint32 \*minor\_status*, *gss\_const\_cred\_id\_t input\_cred\_handle*, *gss\_const\_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*);

*OM\_uint32*\

**gss\_add\_oid\_set\_member**(*OM\_uint32 \* minor\_status*, *const gss\_OID member\_oid*, *gss\_OID\_set \* oid\_set*);

*OM\_uint32*\

**gss\_canonicalize\_name**(*OM\_uint32 \* minor\_status*, *gss\_const\_name\_t input\_name*, *const gss\_OID mech\_type*, *gss\_name\_t \* output\_name*);

*OM\_uint32*\

**gss\_compare\_name**(*OM\_uint32 \* minor\_status*, *gss\_const\_name\_t name1*, *gss\_const\_name\_t name2*, *int \* name\_equal*);

*OM\_uint32*\

**gss\_context\_time**(*OM\_uint32 \* minor\_status*, *gss\_const\_ctx\_id\_t context\_handle*, *OM\_uint32 \* time\_rec*);

*OM\_uint32*\

**gss\_create\_empty\_oid\_set**(*OM\_uint32 \* minor\_status*, *gss\_OID\_set \* oid\_set*);

*OM\_uint32*\

**gss\_delete\_sec\_context**(*OM\_uint32 \* minor\_status*, *gss\_ctx\_id\_t \* context\_handle*, *gss\_buffer\_t output\_token*);

*OM\_uint32*\

**gss\_display\_name**(*OM\_uint32 \* minor\_status*, *gss\_const\_name\_t input\_name*, *gss\_buffer\_t output\_name\_buffer*, *gss\_OID \* output\_name\_type*);

*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*);

*OM\_uint32*\

**gss\_duplicate\_name**(*OM\_uint32 \* minor\_status*, *gss\_const\_name\_t src\_name*, *gss\_name\_t \* dest\_name*);

*OM\_uint32*\

**gss\_export\_name**(*OM\_uint32 \* minor\_status*, *gss\_const\_name\_t input\_name*, *gss\_buffer\_t exported\_name*);

*OM\_uint32*\

**gss\_export\_sec\_context**(*OM\_uint32 \* minor\_status*, *gss\_ctx\_id\_t \* context\_handle*, *gss\_buffer\_t interprocess\_token*);

*OM\_uint32*\

**gss\_get\_mic**(*OM\_uint32 \* minor\_status*, *gss\_const\_ctx\_id\_t context\_handle*, *gss\_qop\_t qop\_req*, *const gss\_buffer\_t message\_buffer*, *gss\_buffer\_t message\_token*);

*OM\_uint32*\

**gss\_import\_name**(*OM\_uint32 \* minor\_status*, *const gss\_buffer\_t input\_name\_buffer*, *const gss\_OID input\_name\_type*, *gss\_name\_t \* output\_name*);

*OM\_uint32*\

**gss\_import\_sec\_context**(*OM\_uint32 \* minor\_status*, *const gss\_buffer\_t interprocess\_token*, *gss\_ctx\_id\_t \* context\_handle*);

*OM\_uint32*\

**gss\_indicate\_mechs**(*OM\_uint32 \* minor\_status*, *gss\_OID\_set \* mech\_set*);

*OM\_uint32*\

**gss\_init\_sec\_context**(*OM\_uint32 \* minor\_status*, *gss\_const\_cred\_id\_t initiator\_cred\_handle*, *gss\_ctx\_id\_t \* context\_handle*, *gss\_const\_name\_t target\_name*, *const gss\_OID mech\_type*, *OM\_uint32 req\_flags*, *OM\_uint32 time\_req*, *const gss\_channel\_bindings\_t input\_chan\_bindings*, *const gss\_buffer\_t input\_token*, *gss\_OID \* actual\_mech\_type*, *gss\_buffer\_t output\_token*, *OM\_uint32 \* ret\_flags*, *OM\_uint32 \* time\_rec*);

*OM\_uint32*\

**gss\_inquire\_context**(*OM\_uint32 \* minor\_status*, *gss\_const\_ctx\_id\_t context\_handle*, *gss\_name\_t \* src\_name*, *gss\_name\_t \* targ\_name*, *OM\_uint32 \* lifetime\_rec*, *gss\_OID \* mech\_type*, *OM\_uint32 \* ctx\_flags*, *int \* locally\_initiated*, *int \* open\_context*);

*OM\_uint32*\

**gss\_inquire\_cred**(*OM\_uint32 \* minor\_status*, *gss\_const\_cred\_id\_t cred\_handle*, *gss\_name\_t \* name*, *OM\_uint32 \* lifetime*, *gss\_cred\_usage\_t \* cred\_usage*, *gss\_OID\_set \* mechanisms*);

*OM\_uint32*\

**gss\_inquire\_cred\_by\_mech**(*OM\_uint32 \* minor\_status*, *gss\_const\_cred\_id\_t cred\_handle*, *const gss\_OID mech\_type*, *gss\_name\_t \* name*, *OM\_uint32 \* initiator\_lifetime*, *OM\_uint32 \* acceptor\_lifetime*, *gss\_cred\_usage\_t \* cred\_usage*);

*OM\_uint32*\

**gss\_inquire\_mechs\_for\_name**(*OM\_uint32 \* minor\_status*, *gss\_const\_name\_t input\_name*, *gss\_OID\_set \* mech\_types*);

*OM\_uint32*\

**gss\_inquire\_names\_for\_mech**(*OM\_uint32 \* minor\_status*, *const gss\_OID mechanism*, *gss\_OID\_set \* name\_types*);

*OM\_uint32*\

**gss\_krb5\_ccache\_name**(*OM\_uint32 \*minor*, *const char \*name*, *const char \*\*old\_name*);

*OM\_uint32*\

**gss\_krb5\_copy\_ccache**(*OM\_uint32 \*minor*, *gss\_cred\_id\_t cred*, *krb5\_ccache out*);

*OM\_uint32*\

**gss\_krb5\_import\_cred**(*OM\_uint32 \*minor\_status*, *krb5\_ccache id*, *krb5\_principal keytab\_principal*, *krb5\_keytab keytab*, *gss\_cred\_id\_t \*cred*);

*OM\_uint32*\

**gss\_krb5\_compat\_des3\_mic**(*OM\_uint32 \* minor\_status*, *gss\_ctx\_id\_t context\_handle*, *int onoff*);

*OM\_uint32*\

**gsskrb5\_extract\_authz\_data\_from\_sec\_context**(*OM\_uint32 \*minor\_status*, *gss\_ctx\_id\_t context\_handle*, *int ad\_type*, *gss\_buffer\_t ad\_data*);

*OM\_uint32*\

**gsskrb5\_register\_acceptor\_identity**(*const char \*identity*);

*OM\_uint32*\

**gss\_krb5\_import\_cache**(*OM\_uint32 \*minor*, *krb5\_ccache id*, *krb5\_keytab keytab*, *gss\_cred\_id\_t \*cred*);

*OM\_uint32*\

**gss\_krb5\_get\_tkt\_flags**(*OM\_uint32 \*minor\_status*, *gss\_ctx\_id\_t context\_handle*, *OM\_uint32 \*tkt\_flags*);

*OM\_uint32*\

**gss\_process\_context\_token**(*OM\_uint32 \* minor\_status*, *gss\_const\_ctx\_id\_t context\_handle*, *const gss\_buffer\_t token\_buffer*);

*OM\_uint32*\

**gss\_release\_buffer**(*OM\_uint32 \* minor\_status*, *gss\_buffer\_t buffer*);

*OM\_uint32*\

**gss\_release\_cred**(*OM\_uint32 \* minor\_status*, *gss\_cred\_id\_t \* cred\_handle*);

*OM\_uint32*\

**gss\_release\_name**(*OM\_uint32 \* minor\_status*, *gss\_name\_t \* input\_name*);

*OM\_uint32*\

**gss\_release\_oid\_set**(*OM\_uint32 \* minor\_status*, *gss\_OID\_set \* set*);

*OM\_uint32*\

**gss\_seal**(*OM\_uint32 \* minor\_status*, *gss\_ctx\_id\_t context\_handle*, *int conf\_req\_flag*, *int qop\_req*, *gss\_buffer\_t input\_message\_buffer*, *int \* conf\_state*, *gss\_buffer\_t output\_message\_buffer*);

*OM\_uint32*\

**gss\_sign**(*OM\_uint32 \* minor\_status*, *gss\_ctx\_id\_t context\_handle*, *int qop\_req*, *gss\_buffer\_t message\_buffer*, *gss\_buffer\_t message\_token*);

*OM\_uint32*\

**gss\_test\_oid\_set\_member**(*OM\_uint32 \* minor\_status*, *const gss\_OID member*, *const gss\_OID\_set set*, *int \* present*);

*OM\_uint32*\

**gss\_unseal**(*OM\_uint32 \* minor\_status*, *gss\_ctx\_id\_t context\_handle*, *gss\_buffer\_t input\_message\_buffer*, *gss\_buffer\_t output\_message\_buffer*, *int \* conf\_state*, *int \* qop\_state*);

*OM\_uint32*\

**gss\_unwrap**(*OM\_uint32 \* minor\_status*, *gss\_const\_ctx\_id\_t context\_handle*, *const gss\_buffer\_t input\_message\_buffer*, *gss\_buffer\_t output\_message\_buffer*, *int \* conf\_state*, *gss\_qop\_t \* qop\_state*);

*OM\_uint32*\

**gss\_verify**(*OM\_uint32 \* minor\_status*, *gss\_ctx\_id\_t context\_handle*, *gss\_buffer\_t message\_buffer*, *gss\_buffer\_t token\_buffer*, *int \* qop\_state*);

*OM\_uint32*\

**gss\_verify\_mic**(*OM\_uint32 \* minor\_status*, *gss\_const\_ctx\_id\_t context\_handle*, *const gss\_buffer\_t message\_buffer*, *const gss\_buffer\_t token\_buffer*, *gss\_qop\_t \* qop\_state*);

*OM\_uint32*\

**gss\_wrap**(*OM\_uint32 \* minor\_status*, *gss\_const\_ctx\_id\_t context\_handle*, *int conf\_req\_flag*, *gss\_qop\_t qop\_req*, *const gss\_buffer\_t input\_message\_buffer*, *int \* conf\_state*, *gss\_buffer\_t output\_message\_buffer*);

*OM\_uint32*\

**gss\_wrap\_size\_limit**(*OM\_uint32 \* minor\_status*, *gss\_const\_ctx\_id\_t context\_handle*, *int conf\_req\_flag*, *gss\_qop\_t qop\_req*, *OM\_uint32 req\_output\_size*, *OM\_uint32 \* max\_input\_size*);

## DESCRIPTION

Generic Security Service API (GSS-API) version 2, and its C binding, is described in RFC2743 and RFC2744. Version 1 (deprecated) of the C binding is described in RFC1509.

Heimdals GSS-API implementation supports the following mechanisms

- GSS\_KRB5\_MECHANISM

- GSS\_SPNEGO\_MECHANISM

GSS-API have generic name types that all mechanism are supposed to implement (if possible):

- GSS\_C\_NT\_USER\_NAME

- GSS\_C\_NT\_MACHINE\_UID\_NAME

- GSS\_C\_NT\_STRING\_UID\_NAME

- GSS\_C\_NT\_HOSTBASED\_SERVICE

- GSS\_C\_NT\_ANONYMOUS

- GSS\_C\_NT\_EXPORT\_NAME

GSS-API implementations that supports Kerberos 5 have some additional name types:

- GSS\_KRB5\_NT\_PRINCIPAL\_NAME

- GSS\_KRB5\_NT\_USER\_NAME

- GSS\_KRB5\_NT\_MACHINE\_UID\_NAME

- GSS\_KRB5\_NT\_STRING\_UID\_NAME

In GSS-API, names have two forms, internal names and contiguous string names.

- Internal name and mechanism name

  Internal names are implementation specific representation of a GSS-API name. Mechanism names special form of internal names corresponds to one and only one mechanism.

  In GSS-API an internal name is stored in a gss\_name\_t.

- Contiguous string name and exported name

  Contiguous string names are gssapi names stored in a OCTET STRING that together with a name type identifier (OID) uniquely specifies a gss-name. A special form of the contiguous string name is the exported name that have a OID embedded in the string to make it unique. Exported name have the nametype GSS\_C\_NT\_EXPORT\_NAME.

  In GSS-API an contiguous string name is stored in a gss\_buffer\_t.

  Exported names also have the property that they are specified by the mechanism itself and compatible between different GSS-API implementations.

## ACCESS CONTROL

There are two ways of comparing GSS-API names, either comparing two internal names with each other or two contiguous string names with either other.

To compare two internal names with each other, import (if needed) the names with **gss\_import\_name**() into the GSS-API implementation and the compare the imported name with **gss\_compare\_name**().

Importing names can be slow, so when its possible to store exported names in the access control list, comparing contiguous string name might be better.

when comparing contiguous string name, first export them into a GSS\_C\_NT\_EXPORT\_NAME name with **gss\_export\_name**() and then compare with [memcmp(3)](/memcmp/3.md).

Note that there are might be a difference between the two methods of comparing names. The first (using **gss\_compare\_name**()) will compare to (unauthenticated) names are the same. The second will compare if a mechanism will authenticate them as the same principal.

For example, if **gss\_import\_name**() name was used with GSS\_C\_NO\_OID the default syntax is used for all mechanism the GSS-API implementation supports. When compare the imported name of GSS\_C\_NO\_OID it may match several mechanism names (MN).

The resulting name from **gss\_display\_name**() must not be used for acccess control.

## FUNCTIONS

**gss\_display\_name**() takes the gss name in *input\_name* and puts a printable form in *output\_name\_buffer*. *output\_name\_buffer* should be freed when done using **gss\_release\_buffer**(). *output\_name\_type* can either be NULL or a pointer to a gss\_OID and will in the latter case contain the OID type of the name. The name must only be used for printing. If access control is needed, see section ACCESS CONTROL.

**gss\_inquire\_context**() returns information about the context. Information is available even after the context have expired. *lifetime\_rec* argument is set to GSS\_C\_INDEFINITE (don't expire) or the number of seconds that the context is still valid. A value of 0 means that the context is expired. *mech\_type* argument should be considered readonly and must not be released. *src\_name* and **dest\_name**() are both mechanims names and must be released with **gss\_release\_name**() when no longer used.

**gss\_context\_time** will return the amount of time (in seconds) of the context is still valid. If its expired *time\_rec* will be set to 0 and GSS\_S\_CONTEXT\_EXPIRED returned.

**gss\_sign**(), **gss\_verify**(), **gss\_seal**(), and **gss\_unseal**() are part of the GSS-API V1 interface and are obsolete. The functions should not be used for new applications. They are provided so that version 1 applications can link against the library.

## EXTENSIONS

**gss\_krb5\_ccache\_name**() sets the internal kerberos 5 credential cache name to *name*. The old name is returned in *old\_name*, and must not be freed. The data allocated for *old\_name* is free upon next call to **gss\_krb5\_ccache\_name**(). This function is not threadsafe if *old\_name* argument is used.

**gss\_krb5\_copy\_ccache**() will extract the krb5 credentials that are transferred from the initiator to the acceptor when using token delegation in the Kerberos mechanism. The acceptor receives the delegated token in the last argument to **gss\_accept\_sec\_context**().

**gss\_krb5\_import\_cred**() will import the krb5 credentials (both keytab and/or credential cache) into gss credential so it can be used withing GSS-API. The *ccache* is copied by reference and thus shared, so if the credential is destroyed with *krb5\_cc\_destroy*, all users of thep *gss\_cred\_id\_t* returned by **gss\_krb5\_import\_ccache**() will fail.

**gsskrb5\_register\_acceptor\_identity**() sets the Kerberos 5 filebased keytab that the acceptor will use.  The *identifier* is the file name.

**gsskrb5\_extract\_authz\_data\_from\_sec\_context**() extracts the Kerberos authorizationdata that may be stored within the context. Tha caller must free the returned buffer *ad\_data* with **gss\_release\_buffer**() upon success.

**gss\_krb5\_get\_tkt\_flags**() return the ticket flags for the kerberos ticket receive when authenticating the initiator. Only valid on the acceptor context.

**gss\_krb5\_compat\_des3\_mic**() turns on or off the compatibility with older version of Heimdal using des3 get and verify mic, this is way to programmatically set the \[gssapi\]broken\_des3\_mic and \[gssapi\]correct\_des3\_mic flags (see COMPATIBILITY section in [gssapi(3)](/gssapi/3.md)). If the CPP symbol GSS\_C\_KRB5\_COMPAT\_DES3\_MIC is present, **gss\_krb5\_compat\_des3\_mic**() exists. **gss\_krb5\_compat\_des3\_mic**() will be removed in a later version of the GSS-API library.

## SEE ALSO

[gssapi(3)](/gssapi/3.md), [krb5(3)](/krb5/3.md), [krb5\_ccache(3)](/krb5_ccache/3.md), [kerberos(8)](/kerberos/8.md)
