Top Banner

of 85

Simon Josefsson- GNU Generic Security Service Library

Apr 06, 2018

Download

Documents

White909
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    1/85

    GNU Generic Security Service Library

    GSS-API Library or the GNU systemor version 1.0.1, 20 May 2010

    Simon Josesson

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    2/85

    This manual is last updated 20 May 2010 or version 1.0.1 o GNU GSS.

    Copyright c 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Simon Josesson.

    Permission is granted to copy, distribute and/or modiy this document under theterms o the GNU Free Documentation License, Version 1.3 or any later versionpublished by the Free Sotware Foundation; with no Invariant Sections, noFront-Cover Texts, and no Back-Cover Texts. A copy o the license is includedin the section entitled GNU Free Documentation License.

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    3/85

    i

    Table o Contents

    1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    1.1 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.3 GSS-API Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.4 Supported Platorms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.5 Commercial Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.6 Downloading and Installing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.7 Bug Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.8 Contributing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.9 Planned Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

    2 Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

    2.1 Header. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    72.2 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.3 Version Check. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.4 Building the source. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.5 Out o Memory handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    3 Standard GSS API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    3.1 Simple Data Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.1.1 Integer types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.1.2 String and similar data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    3.1.2.1 Opaque data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    3.1.2.2 Character strings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    93.1.3 Object Identiers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.1.4 Object Identier Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    3.2 Complex Data Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.2.1 Credentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.2.2 Contexts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.2.3 Authentication tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.2.4 Interprocess tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.2.5 Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.2.6 Channel Bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    3.3 Optional Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.4 Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    3.4.1 GSS status codes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    153.4.2 Mechanism-specic status codes . . . . . . . . . . . . . . . . . . . . . . . . . . 18

    3.5 Credential Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183.6 Context-Level Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243.7 Per-Message Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413.8 Name Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453.9 Miscellaneous Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503.10 SASL GS2 Routines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    4/85

    ii

    4 Extended GSS API . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

    5 Invoking gss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

    6 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

    Appendix A Criticism o GSS . . . . . . . . . . . . . . . . . . 59

    Appendix B Copying Inormation . . . . . . . . . . . . . 61

    B.1 GNU Free Documentation License . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61B.2 GNU General Public License. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

    Concept Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80

    API Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    5/85

    Chapter 1: Introduction 1

    1 Introduction

    GSS is an implementation o the Generic Security Service Application Program Interace(GSS-API). GSS-API is used by network servers to provide security services, e.g., to au-

    thenticate SMTP/IMAP clients against SMTP/IMAP servers. GSS consists o a libraryand a manual.

    GSS is developed or the GNU/Linux system, but runs on over 20 platorms includ-ing most major Unix platorms and Windows, and many kind o devices including iPAQhandhelds and S/390 mainrames.

    GSS is a GNU project, and is licensed under the GNU General Public License version 3or later.

    1.1 Getting Started

    This manual documents the GSS programming interace. All unctions and data types

    provided by the library are explained.The reader is assumed to possess basic amiliarity with GSS-API and network program-ming in C or C++. For general GSS-API inormation, and some programming examples,there is a guide available online at http://docs.sun.com/db/doc/816-1331.

    This manual can be used in several ways. I read rom the beginning to the end, it givesa good introduction into the library and how it can be used in an application. Forwardreerences are included where necessary. Later on, the manual can be used as a reerencemanual to get just the inormation needed about any particular interace o the library.Experienced programmers might want to start looking at the examples at the end o themanual, and then only read up those parts o the interace which are unclear.

    1.2 Features

    GSS might have a couple o advantages over other libraries doing a similar job.

    Its Free SotwareAnybody can use, modiy, and redistribute it under the terms o the GNUGeneral Public License version 3 or later.

    Its thread-saeNo global variables are used and multiple library handles and session handlesmay be used in parallell.

    Its internationalizedIt handles non-ASCII names and user visible strings used in the library (e.g.,error messages) can be translated into the users language.

    Its portableIt should work on all Unix like operating systems, including Windows.

    1.3 GSS-API Overview

    This section describes GSS-API rom a protocol point o view.

    The Generic Security Service Application Programming Interace provides security ser-vices to calling applications. It allows a communicating application to authenticate the user

    http://docs.sun.com/db/doc/816-1331http://docs.sun.com/db/doc/816-1331
  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    6/85

    Chapter 1: Introduction 2

    associated with another application, to delegate rights to another application, and to applysecurity services such as condentiality and integrity on a per-message basis.

    There are our stages to using the GSS-API:

    1. The application acquires a set o credentials with which it may prove its identity toother processes. The applications credentials vouch or its global identity, which mayor may not be related to any local username under which it may be running.

    2. A pair o communicating applications establish a joint security context using theircredentials. The security context is a pair o GSS-API data structures that containshared state inormation, which is required in order that per-message security servicesmay be provided. Examples o state that might be shared between applications as parto a security context are cryptographic keys, and message sequence numbers. As parto the establishment o a security context, the context initiator is authenticated to theresponder, and may require that the responder is authenticated in turn. The initiatormay optionally give the responder the right to initiate urther security contexts, actingas an agent or delegate o the initiator. This transer o rights is termed delegation,

    and is achieved by creating a set o credentials, similar to those used by the initiatingapplication, but which may be used by the responder.

    To establish and maintain the shared inormation that makes up the security context,certain GSS-API calls will return a token data structure, which is an opaque datatype that may contain cryptographically protected data. The caller o such a GSS-APIroutine is responsible or transerring the token to the peer application, encapsulatedi necessary in an application- application protocol. On receipt o such a token, thepeer application should pass it to a corresponding GSS-API routine which will decodethe token and extract the inormation, updating the security context state inormationaccordingly.

    3. Per-message services are invoked to apply either: integrity and data origin authenti-

    cation, or condentiality, integrity and data origin authentication to application data,which are treated by GSS-API as arbitrary octet-strings. An application transmit-ting a message that it wishes to protect will call the appropriate GSS-API routine(gss get mic or gss wrap) to apply protection, speciying the appropriate security con-text, and send the resulting token to the receiving application. The receiver will passthe received token (and, in the case o data protected by gss get mic, the accompanyingmessage-data) to the corresponding decoding routine (gss veriy mic or gss unwrap)to remove the protection and validate the data.

    4. At the completion o a communications session (which may extend across several trans-port connections), each application calls a GSS-API routine to delete the security con-text. Multiple contexts may also be used (either successively or simultaneously) within

    a single communications association, at the option o the applications.

    1.4 Supported Platorms

    GSS has at some point in time been tested on the ollowing platorms.

    1. Debian GNU/Linux 3.0 (Woody)

    GCC 2.95.4 and GNU Make. This is the main development platorm. alphaev67-unknown-linux-gnu, alphaev6-unknown-linux-gnu, arm-unknown-linux-gnu,hppa-unknown-linux-gnu, hppa64-unknown-linux-gnu, i686-pc-linux-gnu,

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    7/85

    Chapter 1: Introduction 3

    ia64-unknown-linux-gnu, m68k-unknown-linux-gnu, mips-unknown-linux-gnu,mipsel-unknown-linux-gnu, powerpc-unknown-linux-gnu, s390-ibm-linux-gnu,sparc-unknown-linux-gnu.

    2. Debian GNU/Linux 2.1GCC 2.95.1 and GNU Make. armv4l-unknown-linux-gnu.

    3. Tru64 UNIX

    Tru64 UNIX C compiler and Tru64 Make. alphaev67-dec-osf5.1, alphaev68-dec-osf5.1.

    4. SuSE Linux 7.1

    GCC 2.96 and GNU Make. alphaev6-unknown-linux-gnu, alphaev67-unknown-linux-gnu.

    5. SuSE Linux 7.2a

    GCC 3.0 and GNU Make. ia64-unknown-linux-gnu.

    6. RedHat Linux 7.2GCC 2.96 and GNU Make. alphaev6-unknown-linux-gnu, alphaev67-unknown-linux-gnu, ia64-unknown-linux-gnu.

    7. RedHat Linux 8.0

    GCC 3.2 and GNU Make. i686-pc-linux-gnu.

    8. RedHat Advanced Server 2.1

    GCC 2.96 and GNU Make. i686-pc-linux-gnu.

    9. Slackware Linux 8.0.01

    GCC 2.95.3 and GNU Make. i686-pc-linux-gnu.

    10. Mandrake Linux 9.0

    GCC 3.2 and GNU Make. i686-pc-linux-gnu.11. IRIX 6.5

    MIPS C compiler, IRIX Make. mips-sgi-irix6.5.

    12. AIX 4.3.2

    IBM C or AIX compiler, AIX Make. rs6000-ibm-aix4.3.2.0.

    13. Microsot Windows 2000 (Cygwin)

    GCC 3.2, GNU make. i686-pc-cygwin.

    14. HP-UX 11

    HP-UX C compiler and HP Make. ia64-hp-hpux11.22, hppa2.0w-hp-hpux11.11.

    15. SUN Solaris 2.8

    Sun WorkShop Compiler C 6.0 and SUN Make. sparc-sun-solaris2.8.

    16. NetBSD 1.6

    GCC 2.95.3 and GNU Make. alpha-unknown-netbsd1.6, i386-unknown-netbsdelf1.6.

    17. OpenBSD 3.1 and 3.2

    GCC 2.95.3 and GNU Make. alpha-unknown-openbsd3.1, i386-unknown-openbsd3.1.

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    8/85

    Chapter 1: Introduction 4

    18. FreeBSD 4.7

    GCC 2.95.4 and GNU Make. alpha-unknown-freebsd4.7, i386-unknown-freebsd4.7.

    19. Cross compiled to uClinux/uClibc on Motorola Coldre.GCC 3.4 and GNU Make m68k-uclinux-elf.

    I you use GSS on, or port GSS to, a new platorm please report it to the author.

    1.5 Commercial Support

    Commercial support is available or users o GNU GSS. The kind o support that can bepurchased may include:

    Implement new eatures. Such as a new GSS-API mechanism.

    Port GSS to new platorms. This could include porting to an embedded platorms thatmay need memory or size optimization.

    Integrating GSS as a security environment in your existing project. System design o components related to GSS-API.

    I you are interested, please write to:

    Simon Josefsson Datakonsult AB

    Hagagatan 24

    113 47 Stockholm

    Sweden

    E-mail: [email protected]

    I your company provides support related to GNU GSS and would like to be mentionedhere, contact the author (see Section 1.7 [Bug Reports], page 5).

    1.6 Downloading and Installing

    The package can be downloaded rom several places, including:

    ftp://ftp.gnu.org/gnu/gss/

    The latest version is stored in a le, e.g., gss-1.0.1.tar.gz where the 1.0.1 indicatethe highest version number.

    The package is then extracted, congured and built like many other packages that useAutocon. For detailed inormation on conguring and building it, reer to the INSTALLle that is part o the distribution archive.

    Here is an example terminal session that downloads, congures, builds and installs the

    package. You will need a ew basic tools, such as sh, make and cc.

    $ wget -q ftp://ftp.gnu.org/gnu/gss/gss-1.0.1.tar.gz

    $ tar xfz gss-1.0.1.tar.gz

    $ cd gss-1.0.1/

    $ ./configure

    ...

    $ make

    ...

    ftp://ftp.gnu.org/gnu/gss/ftp://ftp.gnu.org/gnu/gss/
  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    9/85

    Chapter 1: Introduction 5

    $ make install

    ...

    Ater that GSS should be properly installed and ready or use.

    1.7 Bug Reports

    I you think you have ound a bug in GSS, please investigate it and report it.

    Please make sure that the bug is really in GSS, and preerably also check that it hasntalready been xed in the latest version.

    You have to send us a test case that makes it possible or us to reproduce the bug.

    You also have to explain what is wrong; i you get a crash, or i the results printed arenot good and in that case, in what way. Make sure that the bug report includes allinormation you would need to x this kind o bug or someone else.

    Please make an efort to produce a sel-contained report, with something denite that

    can be tested or debugged. Vague queries or piecemeal messages are dicult to act on anddont help the development efort.

    I your bug report is good, we will do our best to help you to get a corrected version othe sotware; i the bug report is poor, we wont do anything about it (apart rom askingyou to send better bug reports).

    I you think something in this manual is unclear, or downright incorrect, or i the languageneeds to be improved, please also send a note.

    Send your bug report to:[email protected]

    1.8 ContributingI you want to submit a patch or inclusion rom solve a typo you discovered, up to addingsupport or a new eature you should submit it as a bug report (see Section 1.7 [BugReports], page 5). There are some things that you can do to increase the chances or it tobe included in the ocial package.

    Unless your patch is very small (say, under 10 lines) we require that you assign thecopyright o your work to the Free Sotware Foundation. This is to protect the reedomo the project. I you have not already signed papers, we will send you the necessaryinormation when you submit your contribution.

    For contributions that doesnt consist o actual programming code, the only guidelinesare common sense. Use it.

    For code contributions, a number o style guides will help you:

    Coding Style. Follow the GNU Standards document (see undened [top], page un-dened).

    I you normally code using another coding standard, there is no problem, but youshould use indent to reormat the code (see undened [top], page undened)beore submitting your work.

    Use the unied dif ormat diff -u.

    http://standards.pdf/http://standards.pdf/http://standards.pdf/http://standards.pdf/http://standards.pdf/http://standards.pdf/http://standards.pdf/http://standards.pdf/http://indent.pdf/http://indent.pdf/http://indent.pdf/http://indent.pdf/http://indent.pdf/http://indent.pdf/http://indent.pdf/http://indent.pdf/http://standards.pdf/http://standards.pdf/
  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    10/85

    Chapter 1: Introduction 6

    Return errors. No reason whatsoever should abort the execution o the library. Evenmemory allocation errors, e.g. when malloc return NULL, should work although resultin an error code.

    Design with thread saety in mind. Dont use global variables. Dont even write toper-handle global variables unless the documented behaviour o the unction you writeis to write to the per-handle global variable.

    Avoid using the C math library. It causes problems or embedded implementations,and in most situations it is very easy to avoid using it.

    Document your unctions. Use comments beore each unction headers, that, i properlyormatted, are extracted into Texino manuals and GTK-DOC web pages.

    Supply a ChangeLog and NEWS entries, where appropriate.

    1.9 Planned Features

    This is also known as the todo list. I you like to start working on anything, please let

    me know so work duplication can be avoided. Support non-blocking mode. This would be an API extension. It could work by

    orking a process and interace to it, or by using a user-specic daemon. E.g., h =START(accept sec context(...)), FINISHED(h), ret = FINISH(h), ABORT(h).

    Support loadable modules via dlopen, ala Solaris GSS.

    Port to Cyclone? CCured?

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    11/85

    Chapter 2: Preparation 7

    2 Preparation

    To use GSS, you have to perorm some changes to your sources and the build system.The necessary changes are small and explained in the ollowing sections. At the end othis chapter, it is described how the library is initialized, and how the requirements o thelibrary are veried.

    A aster way to nd out how to adapt your application or use with GSS may be to lookat the examples at the end o this manual.

    2.1 Header

    All standard interaces (data types and unctions) o the ocial GSS API are dened inthe header le gss/api.h. The le is taken verbatim rom the RFC (ater correcting aew typos) where it is known as gssapi.h. However, to be able to co-exist graceully withother GSS-API implementation, the name gssapi.h was changed.

    The header le gss.h includes gss/api.h, and declares a ew non-standard exten-sions (by including gss/ext.h), takes care o including header les related to all supportedmechanisms (e.g., gss/krb5.h) and nally adds C++ namespace protection o all deni-tions. Thereore, including gss.h in your project is recommended over gss/api.h. I using gss.h instead o gss/api.h causes problems, it should be regarded a bug.

    You must include either le in all programs using the library, either directly or throughsome other header le, like this:

    #include

    The name space o GSS is gss_* or unction names, gss_* or data types and GSS_*or other symbols. In addition the same name prexes with one prepended underscore arereserved or internal use and should never be used by an application.

    Each supported GSS mechanism may want to expose mechanism specic unctionality,and can do so through one or more header les under the gss/ directory. The Kerberos 5mechanism uses the le gss/krb5.h, but again, it is included (with C++ namespace xes)rom gss.h.

    2.2 Initialization

    GSS does not need to be initialized beore it can be used.

    In order to take advantage o the internationalisation eatures in GSS, e.g. translatederror messages, the application must set the current locale using setlocale() beore calling,e.g., gss_display_status(). This is typically done in main() as in the ollowing example.

    #include #include

    ...

    setlocale (LC_ALL, "");

    2.3 Version Check

    It is oten desirable to check that the version o GSS used is indeed one which ts allrequirements. Even with binary compatibility new eatures may have been introduced but

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    12/85

    Chapter 2: Preparation 8

    due to problem with the dynamic linker an old version is actually used. So you may wantto check that the version is okay right ater program startup. The unction is called gss_check_version() and is described ormally in See Chapter 4 [Extended GSS API], page 55.

    The normal way to use the unction is to put something similar to the ollowing early inyour main():

    #include

    ...

    if (!gss_check_version (GSS_VERSION))

    {

    printf ("gss_check_version() failed:\n"

    "Header file incompatible with shared library.\n");

    exit(EXIT_FAILURE);

    }

    2.4 Building the source

    I you want to compile a source le that includes the gss.h header le, you must makesure that the compiler can nd it in the directory hierarchy. This is accomplished by addingthe path to the directory in which the header le is located to the compilers include lesearch path (via the -I option).

    However, the path to the include le is determined at the time the source is congured.To solve this problem, GSS uses the external package pkg-config that knows the path tothe include le and other conguration options. The options that need to be added to thecompiler invocation at compile time are output by the --cflags option to pkg-configgss. The ollowing example shows how it can be used at the command line:

    gcc -c foo.c pkg-config gss --cflags

    Adding the output o pkg-config gss --cflags to the compilers command line willensure that the compiler can nd the gss.h header le.

    A similar problem occurs when linking the program with the library. Again, the compilerhas to nd the library les. For this to work, the path to the library les has to be added tothe library search path (via the -L option). For this, the option --libs to pkg-configgss can be used. For convenience, this option also outputs all other options that arerequired to link the program with the GSS libarary (or instance, the -lshishi option).The example shows how to link foo.o with GSS into a program foo.

    gcc -o foo foo.o pkg-config gss --libs

    O course you can also combine both examples to a single command by speciying bothoptions to pkg-config:

    gcc -o foo foo.c pkg-config gss --cflags --libs

    2.5 Out o Memory handling

    The GSS API does not have a standard error code or the out o memory error condition.This library will return GSS_S_FAILURE and set minor_status to ENOMEM.

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    13/85

    Chapter 3: Standard GSS API 9

    3 Standard GSS API

    3.1 Simple Data Types

    The ollowing conventions are used by the GSS-API C-language bindings:

    3.1.1 Integer types

    GSS-API uses the ollowing integer data type:

    OM_uint32 32-bit unsigned integer

    3.1.2 String and similar data

    Many o the GSS-API routines take arguments and return values that describe contiguousoctet-strings. All such data is passed between the GSS-API and the caller using the gss_buffer_t data type. This data type is a pointer to a bufer descriptor, which consists o a

    length eld that contains the total number o bytes in the datum, and a value eld whichcontains a pointer to the actual datum:

    typedef struct gss_buffer_desc_struct {

    size_t length;

    void *value;

    } gss_buffer_desc, *gss_buffer_t;

    Storage or data returned to the application by a GSS-API routine using the gss_buffer_t conventions is allocated by the GSS-API routine. The application may ree thisstorage by invoking the gss_release_buffer routine. Allocation o the gss_buffer_descobject is always the responsibility o the application; unused gss_buffer_desc objects maybe initialized to the value GSS_C_EMPTY_BUFFER.

    3.1.2.1 Opaque data types

    Certain multiple-word data items are considered opaque data types at the GSS-API, becausetheir internal structure has no signicance either to the GSS-API or to the caller. Exampleso such opaque data types are the input token parameter to gss_init_sec_context (whichis opaque to the caller), and the input message parameter to gss_wrap (which is opaque tothe GSS-API). Opaque data is passed between the GSS-API and the application using thegss_buffer_t datatype.

    3.1.2.2 Character strings

    Certain multiple-word data items may be regarded as simple ISO Latin-1 character strings.Examples are the printable strings passed to gss_import_name via the input name bufer

    parameter. Some GSS-API routines also return character strings. All such characterstrings are passed between the application and the GSS-API implementation using thegss_buffer_t datatype, which is a pointer to a gss_buffer_desc object.

    When a gss_buffer_desc object describes a printable string, the length eld o thegss_buffer_desc should only count printable characters within the string. In particular, atrailing NUL character should NOT be included in the length count, nor should either theGSS-API implementation or the application assume the presence o an uncounted trailingNUL.

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    14/85

    Chapter 3: Standard GSS API 10

    3.1.3 Object Identiers

    Certain GSS-API procedures take parameters o the type gss_OID, or Object identier.This is a type containing ISO-dened tree- structured values, and is used by the GSS-API

    caller to select an underlying security mechanism and to speciy namespaces. A value otype gss_OID has the ollowing structure:

    typedef struct gss_OID_desc_struct {

    OM_uint32 length;

    void *elements;

    } gss_OID_desc, *gss_OID;

    The elements eld o this structure points to the rst byte o an octet string contain-ing the ASN.1 BER encoding o the value portion o the normal BER TLV encoding o thegss_OID. The length eld contains the number o bytes in this value. For example, the gss_OID value corresponding to iso(1) identified-organization(3) icd-ecma(12) member-company(2) dec(1011) cryptoAlgorithms(7) DASS(5), meaning the DASS X.509 authen-tication mechanism, has a length eld o 7 and an elements eld pointing to seven octetscontaining the ollowing octal values: 53,14,2,207,163,7,5. GSS-API implementations shouldprovide constant gss_OID values to allow applications to request any supported mechanism,although applications are encouraged on portability grounds to accept the deault mecha-nism. gss_OID values should also be provided to allow applications to speciy particularname types (see section 3.10). Applications should treat gss_OID_desc values returnedby GSS-API routines as read-only. In particular, the application should not attempt todeallocate them with ree().

    3.1.4 Object Identier Sets

    Certain GSS-API procedures take parameters o the type gss_OID_set. This type rep-resents one or more object identiers (see [Object Identiers], page 10). A gss_OID_setobject has the ollowing structure:

    typedef struct gss_OID_set_desc_struct {

    size_t count;

    gss_OID elements;

    } gss_OID_set_desc, *gss_OID_set;

    The count eld contains the number o OIDs within the set. The elements eld is apointer to an array o gss_OID_desc objects, each o which describes a single OID. gss_OID_set values are used to name the available mechanisms supported by the GSS-API, torequest the use o specic mechanisms, and to indicate which mechanisms a given credential

    supports.

    All OID sets returned to the application by GSS-API are dynamic objects (the gss_OID_set_desc, the "elements" array o the set, and the "elements" array o each memberOID are all dynamically allocated), and this storage must be deallocated by the applicationusing the gss_release_oid_set routine.

    3.2 Complex Data Types

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    15/85

    Chapter 3: Standard GSS API 11

    3.2.1 Credentials

    A credential handle is a caller-opaque atomic datum that identies a GSS-API credentialdata structure. It is represented by the caller- opaque type gss_cred_id_t.

    GSS-API credentials can contain mechanism-specic principal authentication data ormultiple mechanisms. A GSS-API credential is composed o a set o credential-elements,each o which is applicable to a single mechanism. A credential may contain at most onecredential-element or each supported mechanism. A credential-element identies the dataneeded by a single mechanism to authenticate a single principal, and conceptually containstwo credential-reerences that describe the actual mechanism-specic authentication data,one to be used by GSS-API or initiating contexts, and one to be used or accepting contexts.For mechanisms that do not distinguish between acceptor and initiator credentials, bothreerences would point to the same underlying mechanism-specic authentication data.

    Credentials describe a set o mechanism-specic principals, and give their holder theability to act as any o those principals. All principal identities asserted by a single GSS-

    API credential should belong to the same entity, although enorcement o this propertyis an implementation-specic matter. The GSS-API does not make the actual credentialsavailable to applications; instead a credential handle is used to identiy a particular cre-dential, held internally by GSS-API. The combination o GSS-API credential handle andmechanism identies the principal whose identity will be asserted by the credential whenused with that mechanism.

    The gss_init_sec_context and gss_accept_sec_context routines allow the valueGSS_C_NO_CREDENTIAL to be specied as their credential handle parameter. This specialcredential-handle indicates a desire by the application to act as a deault principal.

    3.2.2 Contexts

    The gss_ctx_id_t data type contains a caller-opaque atomic value that identies one endo a GSS-API security context.

    The security context holds state inormation about each end o a peer communication,including cryptographic state inormation.

    3.2.3 Authentication tokens

    A token is a caller-opaque type that GSS-API uses to maintain synchronization between thecontext data structures at each end o a GSS-API security context. The token is a crypto-graphically protected octet-string, generated by the underlying mechanism at one end o aGSS-API security context or use by the peer mechanism at the other end. Encapsulation (irequired) and transer o the token are the responsibility o the peer applications. A tokenis passed between the GSS-API and the application using the gss_buffer_t conventions.

    3.2.4 Interprocess tokens

    Certain GSS-API routines are intended to transer data between processes in multi-processprograms. These routines use a caller-opaque octet-string, generated by the GSS-API in oneprocess or use by the GSS-API in another process. The calling application is responsible ortranserring such tokens between processes in an OS-specic manner. Note that, while GSS-API implementors are encouraged to avoid placing sensitive inormation within interprocesstokens, or to cryptographically protect them, many implementations will be unable to

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    16/85

    Chapter 3: Standard GSS API 12

    avoid placing key material or other sensitive data within them. It is the applicationsresponsibility to ensure that interprocess tokens are protected in transit, and transerredonly to processes that are trustworthy. An interprocess token is passed between the GSS-API and the application using the gss_buffer_t conventions.

    3.2.5 Names

    A name is used to identiy a person or entity. GSS-API authenticates the relationshipbetween a name and the entity claiming the name.

    Since diferent authentication mechanisms may employ diferent namespaces or identi-ying their principals, GSSAPIs naming support is necessarily complex in multi-mechanismenvironments (or even in some single-mechanism environments where the underlying mech-anism supports multiple namespaces).

    Two distinct representations are dened or names:

    An internal orm. This is the GSS-API "native" ormat or names, represented by

    the implementation-specic gss_name_t type. It is opaque to GSS-API callers. Asingle gss_name_t object may contain multiple names rom diferent namespaces, butall names should reer to the same entity. An example o such an internal name wouldbe the name returned rom a call to the gss_inquire_cred routine, when appliedto a credential containing credential elements or multiple authentication mechanismsemploying diferent namespaces. This gss_name_t object will contain a distinct nameor the entity or each authentication mechanism.

    For GSS-API implementations supporting multiple namespaces, objects o type gss_name_t must contain sucient inormation to determine the namespace to which eachprimitive name belongs.

    Mechanism-specic contiguous octet-string orms. A ormat capable o containing asingle name (rom a single namespace). Contiguous string names are always accompa-nied by an object identier speciying the namespace to which the name belongs, andtheir ormat is dependent on the authentication mechanism that employs the name.Many, but not all, contiguous string names will be printable, and may thereore beused by GSS-API applications or communication with their users.

    Routines (gss_import_name and gss_display_name) are provided to convert namesbetween contiguous string representations and the internal gss_name_t type. gss_import_name may support multiple syntaxes or each supported namespace, allowing users thereedom to choose a preerred name representation. gss_display_name should use animplementation-chosen printable syntax or each supported name-type.

    I an application calls gss_display_name, passing the internal name resulting rom a callto gss_import_name, there is no guarantee the resulting contiguous string name will be thesame as the original imported string name. Nor do name-space identiers necessarily surviveunchanged ater a journey through the internal name-orm. An example o this might bea mechanism that authenticates X.500 names, but provides an algorithmic mapping oInternet DNS names into X.500. That mechanisms implementation o gss_import_namemight, when presented with a DNS name, generate an internal name that contained both theoriginal DNS name and the equivalent X.500 name. Alternatively, it might only store theX.500 name. In the latter case, gss_display_name would most likely generate a printableX.500 name, rather than the original DNS name.

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    17/85

    Chapter 3: Standard GSS API 13

    The process o authentication delivers to the context acceptor an internal name. Sincethis name has been authenticated by a single mechanism, it contains only a single name(even i the internal name presented by the context initiator to gss_init_sec_contexthad multiple components). Such names are termed internal mechanism names, or "MN"sand the names emitted by gss_accept_sec_context are always o this type. Since someapplications may require MNs without wanting to incur the overhead o an authenticationoperation, a second unction, gss_canonicalize_name, is provided to convert a generalinternal name into an MN.

    Comparison o internal-orm names may be accomplished via the gss_compare_nameroutine, which returns true i the two names being compared reer to the same entity. Thisremoves the need or the application program to understand the syntaxes o the variousprintable names that a given GSS-API implementation may support. Since GSS-API as-sumes that all primitive names contained within a given internal name reer to the sameentity, gss_compare_name can return true i the two names have at least one primitivename in common. I the implementation embodies knowledge o equivalence relationships

    between names taken rom diferent namespaces, this knowledge may also allow successulcomparison o internal names containing no overlapping primitive elements.

    When used in large access control lists, the overhead o invoking gss_import_name andgss_compare_name on each name rom the ACL may be prohibitive. As an alternativeway o supporting this case, GSS-API denes a special orm o the contiguous string namewhich may be compared directly (e.g. with memcmp()). Contiguous names suitable orcomparison are generated by the gss_export_name routine, which requires an MN as input.Exported names may be re- imported by the gss_import_name routine, and the resultinginternal name will also be an MN. The gss_OID constant GSS_C_NT_EXPORT_NAME indentiesthe "export name" type, and the value o this constant is given in Appendix A. Structurally,an exported name object consists o a header containing an OID identiying the mechanismthat authenticated the name, and a trailer containing the name itsel, where the syntax othe trailer is dened by the individual mechanism specication. The precise ormat o anexport name is dened in the language-independent GSS-API specication [GSSAPI].

    Note that the results obtained by using gss_compare_name will in general be diferentrom those obtained by invoking gss_canonicalize_name and gss_export_name, and thencomparing the exported names. The rst series o operation determines whether two (unau-thenticated) names identiy the same principal; the second whether a particular mechanismwould authenticate them as the same principal. These two operations will in general givethe same results only or MNs.

    The gss_name_t datatype should be implemented as a pointer type. To allow the com-piler to aid the application programmer by perorming type-checking, the use o (void *) isdiscouraged. A pointer to an implementation-dened type is the preerred choice.

    Storage is allocated by routines that return gss_name_t values. A procedure, gss_release_name, is provided to ree storage associated with an internal-orm name.

    3.2.6 Channel Bindings

    GSS-API supports the use o user-specied tags to identiy a given context to the peerapplication. These tags are intended to be used to identiy the particular communicationschannel that carries the context. Channel bindings are communicated to the GSS-API usingthe ollowing structure:

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    18/85

    Chapter 3: Standard GSS API 14

    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 elds denote the type o addresses con-tained in the initiator address and acceptor address bufers. The address type should beone o the ollowing:

    GSS_C_AF_UNSPEC Unspecified address type

    GSS_C_AF_LOCAL Host-local address type

    GSS_C_AF_INET Internet address type (e.g. IP)

    GSS_C_AF_IMPLINK ARPAnet IMP address type

    GSS_C_AF_PUP pup protocols (eg BSP) address typeGSS_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

    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 typeGSS_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 X.25

    GSS_C_AF_NULLADDR No address specified

    Note that these symbols name address amilies rather than specic addressing ormats.For address amilies that contain several alternative address orms, the initiator address andacceptor address elds must contain sucient inormation to determine which address ormis used. When not otherwise specied, addresses should be specied in network byte-order(that is, native byte-ordering or the address amily).

    Conceptually, the GSS-API concatenates the initiator addrtype, initiator address, ac-ceptor addrtype, acceptor address and application data to orm an octet string. The mech-anism calculates a MIC over this octet string, and binds the MIC to the context establish-ment token emitted by gss_init_sec_context. The same bindings are presented by thecontext acceptor to gss_accept_sec_context, and a MIC is calculated in the same way.The calculated MIC is compared with that ound in the token, and i the MICs difer,gss_accept_sec_context will return a GSS_S_BAD_BINDINGS error, and the context willnot be established. Some mechanisms may include the actual channel binding data in the

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    19/85

    Chapter 3: Standard GSS API 15

    token (rather than just a MIC); applications should thereore not use condential data aschannel-binding components.

    Individual mechanisms may impose additional constraints on addresses and address types

    that may appear in channel bindings. For example, a mechanism may veriy that theinitiator address eld o the channel bindings presented to gss_init_sec_context containsthe correct network address o the host system. Portable applications should thereoreensure that they either provide correct inormation or the address elds, or omit addressinginormation, speciying GSS_C_AF_NULLADDR as the address-types.

    3.3 Optional Parameters

    Various parameters are described as optional. This means that they ollow a conventionwhereby a deault value may be requested. The ollowing conventions are used or omittedparameters. These conventions apply only to those parameters that are explicitly docu-mented as optional.

    gss bufer t types. Speciy GSS C NO BUFFER as a value. For an input parameterthis signies that deault behavior is requested, while or an output parameter it indi-cates that the inormation that would be returned via the parameter is not requiredby the application.

    Integer types (input). Individual parameter documentation lists values to be used toindicate deault actions.

    Integer types (output). Speciy NULL as the value or the pointer.

    Pointer types. Speciy NULL as the value.

    Object IDs. Speciy GSS C NO OID as the value.

    Object ID Sets. Speciy GSS C NO OID SET as the value.

    Channel Bindings. Speciy GSS C NO CHANNEL BINDINGS to indicate that chan-nel bindings are not to be used.

    3.4 Error Handling

    Every GSS-API routine returns two distinct values to report status inormation to the caller:GSS status codes and Mechanism status codes.

    3.4.1 GSS status codes

    GSS-API routines return GSS status codes as their OM_uint32 unction value. These codesindicate errors that are independent o the underlying mechanism(s) used to provide thesecurity service. The errors that can be indicated via a GSS status code are either generic

    API routine errors (errors that are dened in the GSS-API specication) or calling errors(errors that are specic to these language bindings).

    A GSS status code can indicate a single atal generic API error rom the routine anda single calling error. In addition, supplementary status inormation may be indicated viathe setting o bits in the supplementary ino eld o a GSS status code.

    These errors are encoded into the 32-bit GSS status code as ollows:

    MSB LSB

    |------------------------------------------------------------|

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    20/85

    Chapter 3: Standard GSS API 16

    | Calling Error | Routine Error | Supplementary Info |

    |------------------------------------------------------------|

    Bit 31 24 23 16 15 0

    Hence i a GSS-API routine returns a GSS status code whose upper 16 bits contain anon-zero value, the call ailed. I the calling error eld is non-zero, the invoking applicationscall o the routine was erroneous. Calling errors are dened in table 3-1. I the routine erroreld is non-zero, the routine ailed or one o the routine- specic reasons listed below intable 3-2. Whether or not the upper 16 bits indicate a ailure or a success, the routine mayindicate additional inormation by setting bits in the supplementary ino eld o the statuscode. The meaning o individual bits is listed below in table 3-3.

    Table 3-1 Calling Errors

    Name Value in field Meaning

    ---- -------------- -------

    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 3-2 Routine Errors

    Name Value in field Meaning

    ---- -------------- -------

    GSS_S_BAD_MECH 1 An unsupported mechanism

    was requested

    GSS_S_BAD_NAME 2 An invalid name was

    suppliedGSS_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_MIC GSS_S_BAD_SIG 6 A token had an invalid MIC

    GSS_S_NO_CRED 7 No credentials were

    supplied, or the

    credentials were

    unavailable or

    inaccessible.

    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

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    21/85

    Chapter 3: Standard GSS API 17

    GSS_S_FAILURE 13 Miscellaneous failure (see

    text)

    GSS_S_BAD_QOP 14 The quality-of-protection

    requested could not be

    provided

    GSS_S_UNAUTHORIZED 15 The operation is forbidden

    by local security policy

    GSS_S_UNAVAILABLE 16 The operation or option is

    unavailable

    GSS_S_DUPLICATE_ELEMENT 17 The requested credential

    element already exists

    GSS_S_NAME_NOT_MN 18 The provided name was not a

    mechanism name

    Table 3-3 Supplementary Status Bits

    Name Bit Number Meaning

    ---- ---------- -------

    GSS_S_CONTINUE_NEEDED 0 (LSB) Returned only by

    gss_init_sec_context or

    gss_accept_sec_context. 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 tokens validity periodhas expired

    GSS_S_UNSEQ_TOKEN 3 A later token has already been

    processed

    GSS_S_GAP_TOKEN 4 An expected per-message token

    was not received

    The routine documentation also uses the name GSS S COMPLETE, which is a zerovalue, to indicate an absence o any API errors or supplementary inormation bits.

    All GSS S xxx symbols equate to complete OM_uint32 status codes, rather than tobiteld values. For example, the actual value o the symbol GSS_S_BAD_NAMETYPE (value3 in the routine error eld) is 3

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    22/85

    Chapter 3: Standard GSS API 18

    A GSS-API implementation may choose to signal calling errors in a platorm-specicmanner instead o, or in addition to the routine value; routine errors and supplementaryino should be returned via major status values only.

    The GSS major status code GSS_S_FAILURE is used to indicate that the underlying mech-anism detected an error or which no specic GSS status code is dened. The mechanism-specic status code will provide more details about the error.

    In addition to the explicit major status codes or each API unction, the codeGSS_S_FAILURE may be returned by any routine, indicating an implementation-specicor mechanism-specic error condition, urther details o which are reported via the

    minor_status parameter.

    3.4.2 Mechanism-specic status codesGSS-API routines return a minor status parameter, which is used to indicate specializederrors rom the underlying security mechanism. This parameter may contain a singlemechanism-specic error, indicated by a OM_uint32 value.

    The minor status parameter will always be set by a GSS-API routine, even i it returnsa calling error or one o the generic API errors indicated above as atal, although mostother output parameters may remain unset in such cases. However, output parametersthat are expected to return pointers to storage allocated by a routine must always be setby the routine, even in the event o an error, although in such cases the GSS-API routinemay elect to set the returned parameter value to NULL to indicate that no storage was

    actually allocated. Any length eld associated with such pointers (as in a gss_buffer_desc structure) should also be set to zero in such cases.

    3.5 Credential Management

    GSS-API Credential-management Routines

    Routine Function

    ------- --------

    gss_acquire_cred Assume a global identity; Obtain

    a GSS-API credential handle for

    pre-existing credentials.

    gss_add_cred Construct credentials

    incrementally.

    gss_inquire_cred Obtain information about a

    credential.

    gss_inquire_cred_by_mech Obtain per-mechanism information

    about a credential.

    gss_release_cred Discard a credential handle.

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    23/85

    Chapter 3: Standard GSS API 19

    gss acquire cred

    [Function]OM_uint32 gss_acquire_cred (OM uint32 * minor_status, constgss 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 )minor status: (integer, modiy) Mechanism specic status code.

    desired name: (gss name t, read) Name o principal whose credential should be ac-quired.

    time req: (Integer, read, optional) Number o seconds that credentials should re-main valid. Speciy GSS C INDEFINITE to request that the credentials have themaximum permitted lietime.

    desired mechs: (Set o Object IDs, read, optional) Set o underlying securitymechanisms that may be used. GSS C NO OID SET may be used to obtain an

    implementation-specic deault.cred usage: (gss cred usage t, read) GSS C BOTH - Credentials may be used eitherto initiate or accept security contexts. GSS C INITIATE - Credentials will only beused to initiate security contexts. GSS C ACCEPT - Credentials will only be usedto accept security contexts.

    output cred handle: (gss cred id t, modiy) The returned credential handle. Re-sources associated with this credential handle must be released by the applicationater use with a call to gss release cred().

    actual mechs: (Set o Object IDs, modiy, optional) The set o mechanisms or whichthe credential is valid. Storage associated with the returned OID-set must be releasedby the application ater use with a call to gss release oid set(). Speciy NULL i not

    required.time rec: (Integer, modiy, optional) Actual number o seconds or which the returnedcredentials will remain valid. I the implementation does not support expiration ocredentials, the value GSS C INDEFINITE will be returned. Speciy NULL i notrequired.

    Allows an application to acquire a handle or a pre-existing credential by name. GSS-API implementations must impose a local access-control policy on callers o thisroutine to prevent unauthorized callers rom acquiring credentials to which they arenot entitled. This routine is not intended to provide a "login to the network" unction,as such a unction would involve the creation o new credentials rather than merelyacquiring a handle to existing credentials. Such unctions, i required, should be

    dened in implementation-specic extensions to the API.I desired name is GSS C NO NAME, the call is interpreted as a request or a cre-dential handle that will invoke deault behavior when passed to gss init sec context()(i cred usage is GSS C INITIATE or GSS C BOTH) or gss accept sec context() (icred usage is GSS C ACCEPT or GSS C BOTH).

    Mechanisms should honor the desired mechs parameter, and return a credential thatis suitable to use only with the requested mechanisms. An exception to this is thecase where one underlying credential element can be shared by multiple mechanisms;

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    24/85

    Chapter 3: Standard GSS API 20

    in this case it is permissible or an implementation to indicate all mechanisms withwhich the credential element may be used. I desired mechs is an empty set, behavioris undened.

    This routine is expected to be used primarily by context acceptors, since implemen-tations are likely to provide mechanism-specic ways o obtaining GSS-API initia-tor credentials rom the system login process. Some implementations may thereorenot support the acquisition o GSS C INITIATE or GSS C BOTH credentials viagss acquire cred or any name other than GSS C NO NAME, or a name producedby applying either gss inquire cred to a valid credential, or gss inquire context to anactive context.

    I credential acquisition is time-consuming or a mechanism, the mechanismmay 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-specicimplementation decisions should be invisible to the calling application; thus a callo gss inquire cred immediately ollowing the call o gss acquire cred must return

    valid credential data, and may thereore incur the overhead o a deerred credentialacquisition.

    Return value:

    GSS_S_COMPLETE: Successul completion.

    GSS_S_BAD_MECH: Unavailable mechanism requested.

    GSS_S_BAD_NAMETYPE: Type contained within desired name parameter is not sup-ported.

    GSS_S_BAD_NAME: Value supplied or desired name parameter is ill ormed.

    GSS_S_CREDENTIALS_EXPIRED: The credentials could not be acquired Because theyhave expired.

    GSS_S_NO_CRED: No credentials were ound or the specied name.

    gss add cred

    [Function]OM_uint32 gss_add_cred (OM uint32 * minor_status, constgss 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 )minor status: (integer, modiy) Mechanism specic status code.

    input cred handle: (gss cred id t, read, optional) The credential to which a

    credential-element will be added. I GSS C NO CREDENTIAL is specied, theroutine will compose the new credential based on deault behavior (see text). Notethat, while the credential-handle is not modied by gss add cred(), the underlyingcredential will be modied i output credential handle is NULL.

    desired name: (gss name t, read.) Name o principal whose credential should beacquired.

    desired mech: (Object ID, read) Underlying security mechanism with which the cre-dential may be used.

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    25/85

    Chapter 3: Standard GSS API 21

    cred usage: (gss cred usage t, read) GSS C BOTH - Credential may be used eitherto initiate or accept security contexts. GSS C INITIATE - Credential will only beused to initiate security contexts. GSS C ACCEPT - Credential will only be used toaccept security contexts.

    initiator time req: (Integer, read, optional) number o seconds that the credentialshould remain valid or initiating security contexts. This argument is ignored i thecomposed credentials are o type GSS C ACCEPT. Speciy GSS C INDEFINITE torequest that the credentials have the maximum permitted initiator lietime.

    acceptor time req: (Integer, read, optional) number o seconds that the credentialshould remain valid or accepting security contexts. This argument is ignored i thecomposed credentials are o type GSS C INITIATE. Speciy GSS C INDEFINITEto request that the credentials have the maximum permitted initiator lietime.

    output cred handle: (gss cred id t, modiy, optional) The returned credential han-dle, containing the new credential-element and all the credential-elements rom in-put cred handle. I a valid pointer to a gss cred id t is supplied or this parameter,gss add cred creates a new credential handle containing all credential-elements romthe input cred handle and the newly acquired credential-element; i NULL is spec-ied or this parameter, the newly acquired credential-element will be added to thecredential identied by input cred handle. The resources associated with any creden-tial handle returned via this parameter must be released by the application ater usewith a call to gss release cred().

    actual mechs: (Set o Object IDs, modiy, optional) The complete set o mechanismsor which the new credential is valid. Storage or the returned OID-set must be reedby the application ater use with a call to gss release oid set(). Speciy NULL i notrequired.

    initiator time rec: (Integer, modiy, optional) Actual number o seconds or whichthe returned credentials will remain valid or initiating contexts using the speciedmechanism. I the implementation or mechanism does not support expiration ocredentials, the value GSS C INDEFINITE will be returned. Speciy NULL i notrequired

    acceptor time rec: (Integer, modiy, optional) Actual number o seconds or whichthe returned credentials will remain valid or accepting security contexts using thespecied mechanism. I the implementation or mechanism does not support expirationo credentials, the value GSS C INDEFINITE will be returned. Speciy NULL i notrequired

    Adds a credential-element to a credential. The credential-element is identied by thename o the principal to which it reers. GSS-API implementations must impose a

    local access-control policy on callers o this routine to prevent unauthorized callersrom acquiring credential-elements to which they are not entitled. This routine is notintended to provide a "login to the network" unction, as such a unction would in-volve the creation o new mechanism-specic authentication data, rather than merelyacquiring a GSS-API handle to existing data. Such unctions, i required, should bedened in implementation-specic extensions to the API.

    I desired name is GSS C NO NAME, the call is interpreted as a request to add a cre-dential element that will invoke deault behavior when passed to gss init sec context()

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    26/85

    Chapter 3: Standard GSS API 22

    (i cred usage is GSS C INITIATE or GSS C BOTH) or gss accept sec context() (icred usage is GSS C ACCEPT or GSS C BOTH).

    This routine is expected to be used primarily by context acceptors, since implemen-

    tations are likely to provide mechanism-specic ways o obtaining GSS-API initia-tor credentials rom the system login process. Some implementations may thereorenot support the acquisition o GSS C INITIATE or GSS C BOTH credentials viagss acquire cred or any name other than GSS C NO NAME, or a name producedby applying either gss inquire cred to a valid credential, or gss inquire context to anactive context.

    I credential acquisition is time-consuming or a mechanism, the mechanismmay 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-specicimplementation decisions should be invisible to the calling application; thus a callo gss inquire cred immediately ollowing the call o gss add cred must return validcredential data, and may thereore incur the overhead o a deerred credentialacquisition.

    This routine can be used to either compose a new credential containing all credential-elements o the original in addition to the newly-acquire credential-element, or to addthe new credential- element to an existing credential. I NULL is specied or theoutput cred handle parameter argument, the new credential-element will be addedto the credential identied by input cred handle; i a valid pointer is specied or theoutput cred handle parameter, a new credential handle will be created.

    I GSS C NO CREDENTIAL is specied as the input cred handle, gss add cred willcompose a credential (and set the output cred handle parameter accordingly) basedon deault behavior. That is, the call will have the same efect as i the application

    had rst made a call to gss acquire cred(), speciying the same usage and passingGSS C NO NAME as the desired name parameter to obtain an explicit credentialhandle embodying deault behavior, passed this credential handle to gss add cred(),and nally called gss release cred() on the rst credential handle.

    I GSS C NO CREDENTIAL is specied as the input cred handle parameter, a non-NULL output cred handle must be supplied.

    Return value:

    GSS_S_COMPLETE: Successul completion.

    GSS_S_BAD_MECH: Unavailable mechanism requested.

    GSS_S_BAD_NAMETYPE: Type contained within desired name parameter is not sup-

    ported.GSS_S_BAD_NAME: Value supplied or desired name parameter is ill-ormed.

    GSS_S_DUPLICATE_ELEMENT: The credential already contains an element or the re-quested mechanism with overlapping usage and validity period.

    GSS_S_CREDENTIALS_EXPIRED: The required credentials could not be added becausethey have expired.

    GSS_S_NO_CRED: No credentials were ound or the specied name.

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    27/85

    Chapter 3: Standard GSS API 23

    gss inquire cred

    [Function]OM_uint32 gss_inquire_cred (OM uint32 * minor_status, constgss cred id t cred_handle, gss name t * name, OM uint32 * lifetime,

    gss cred usage t * cred_usage, gss OID set * mechanisms )minor status: (integer, modiy) Mechanism specic status code.

    cred handle: (gss cred id t, read) A handle that reers to the target credential. Spec-iy GSS C NO CREDENTIAL to inquire about the deault initiator principal.

    name: (gss name t, modiy, optional) The name whose identity the credential asserts.Storage associated with this name should be reed by the application ater use witha call to gss release name(). Speciy NULL i not required.

    lietime: (Integer, modiy, optional) The number o seconds or which the creden-tial will remain valid. I the credential has expired, this parameter will be setto zero. I the implementation does not support credential expiration, the valueGSS C INDEFINITE will be returned. Speciy NULL i not required.

    cred usage: (gss cred usage t, modiy, optional) How the credential may be used.One o the ollowing: GSS C INITIATE, GSS C ACCEPT, GSS C BOTH. SpeciyNULL i not required.

    mechanisms: (gss OID set, modiy, optional) Set o mechanisms supported by thecredential. Storage associated with this OID set must be reed by the applicationater use with a call to gss release oid set(). Speciy NULL i not required.

    Obtains inormation about a credential.

    Return value:

    GSS_S_COMPLETE: Successul completion.

    GSS_S_NO_CRED: The reerenced credentials could not be accessed.GSS_S_DEFECTIVE_CREDENTIAL: The reerenced credentials were invalid.

    GSS_S_CREDENTIALS_EXPIRED: The reerenced credentials have expired. I the lie-time parameter was not passed as NULL, it will be set to 0.

    gss inquire cred by mech

    [Function]OM_uint32 gss_inquire_cred_by_mech (OM uint32 *minor_status, const gss 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 )minor status: (Integer, modiy) Mechanism specic status code.

    cred handle: (gss cred id t, read) A handle that reers to the target credential. Spec-iy GSS C NO CREDENTIAL to inquire about the deault initiator principal.

    mech type: (gss OID, read) The mechanism or which inormation should be re-turned.

    name: (gss name t, modiy, optional) The name whose identity the credential asserts.Storage associated with this name must be reed by the application ater use with acall to gss release name(). Speciy NULL i not required.

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    28/85

    Chapter 3: Standard GSS API 24

    initiator lietime: (Integer, modiy, optional) The number o seconds or which thecredential will remain capable o initiating security contexts under the specied mech-anism. I the credential can no longer be used to initiate contexts, or i the credentialusage or this mechanism is GSS C ACCEPT, this parameter will be set to zero.I the implementation does not support expiration o initiator credentials, the valueGSS C INDEFINITE will be returned. Speciy NULL i not required.

    acceptor lietime: (Integer, modiy, optional) The number o seconds or which thecredential will remain capable o accepting security contexts under the specied mech-anism. I the credential can no longer be used to accept contexts, or i the credentialusage or this mechanism is GSS C INITIATE, this parameter will be set to zero.I the implementation does not support expiration o acceptor credentials, the valueGSS C INDEFINITE will be returned. Speciy NULL i not required.

    cred usage: (gss cred usage t, modiy, optional) How the credential may be used withthe specied mechanism. One o the ollowing: GSS C INITIATE, GSS C ACCEPT,GSS C BOTH. Speciy NULL i not required.

    Obtains per-mechanism inormation about a credential.

    Return value:

    GSS_S_COMPLETE: Successul completion.

    GSS_S_NO_CRED: The reerenced credentials could not be accessed.

    GSS_S_DEFECTIVE_CREDENTIAL: The reerenced credentials were invalid.

    GSS_S_CREDENTIALS_EXPIRED: The reerenced credentials have expired. I the lie-time parameter was not passed as NULL, it will be set to 0.

    gss release cred

    [Function]OM_uint32 gss_release_cred (OM uint32 * minor_status,gss cred id t * cred_handle )

    minor status: (Integer, modiy) Mechanism specic status code.

    cred handle: (gss cred id t, modiy, optional) Opaque handle identiying credentialto be released. I GSS C NO CREDENTIAL is supplied, the routine will completesuccessully, but will do nothing.

    Inorms GSS-API that the specied credential handle is no longer requiredby the application, and rees associated resources. The cred handle is set toGSS C NO CREDENTIAL on successul completion o this call.

    Return value:

    GSS_S_COMPLETE: Successul completion.

    GSS_S_NO_CRED: Credentials could not be accessed.

    3.6 Context-Level Routines

    GSS-API Context-Level Routines

    Routine Function

    ------- --------

    gss_init_sec_context Initiate a security context with

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    29/85

    Chapter 3: Standard GSS API 25

    a peer application.

    gss_accept_sec_context Accept a security context

    initiated by a peer application.

    gss_delete_sec_context Discard a security context.

    gss_process_context_token Process a token on a security

    context from a peer application.

    gss_context_time Determine for how long a context

    will remain valid.

    gss_inquire_context Obtain information about a

    security context.

    gss_wrap_size_limit Determine token-size limit for

    gss_wrap on a context.

    gss_export_sec_context Transfer a security context to

    another process.

    gss_import_sec_context Import a transferred context.

    gss init sec context

    [Function]OM_uint32 gss_init_sec_context (OM uint32 * minor_status,const gss cred id t initiator_cred_handle, gss ctx id t *

    context_handle, const gss name t target_name, const gss OID

    mech_type, OM uint32 req_flags, OM uint32 time_req, constgss channel bindings t input_chan_bindings, const gss bufer t

    input_token, gss OID * actual_mech_type, gss bufer t output_token,

    OM uint32 * ret_flags, OM uint32 * time_rec )minor status: (integer, modiy) Mechanism specic status code.

    initiator cred handle: (gss cred id t, read, optional) Handle or credentials claimed.

    Supply GSS C NO CREDENTIAL to act as a deault initiator principal. I no de-ault initiator is dened, the unction will return GSS S NO CRED.

    context handle: (gss ctx id t, read/modiy) Context handle or new context. SupplyGSS C NO CONTEXT or rst call; use value returned by rst call in continua-tion calls. Resources associated with this context-handle must be released by theapplication ater use with a call to gss delete sec context().

    target name: (gss name t, read) Name o target.

    mech type: (OID, read, optional) Object ID o desired mechanism. SupplyGSS C NO OID to obtain an implementation specic deault.

    req ags: (bit-mask, read) Contains various independent ags, each o which requeststhat the context support a specic service option. Symbolic names are provided or

    each ag, and the symbolic names corresponding to the required ags should belogically-ORed together to orm the bit-mask value. See below or the ags.

    time req: (Integer, read, optional) Desired number o seconds or which contextshould remain valid. Supply 0 to request a deault validity period.

    input chan bindings: (channel bindings, read, optional) Application-specied bind-ings. Allows application to securely bind channel identication inormation to thesecurity context. Speciy GSS C NO CHANNEL BINDINGS i channel bindingsare not used.

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    30/85

    Chapter 3: Standard GSS API 26

    input token: (bufer, opaque, read, optional) Token received rom peer applica-tion. Supply GSS C NO BUFFER, or a pointer to a bufer containing the valueGSS C EMPTY BUFFER on initial call.

    actual mech type: (OID, modiy, optional) Actual mechanism used. The OID re-turned via this parameter will be a pointer to static storage that should be treated asread-only; In particular the application should not attempt to ree it. Speciy NULLi not required.

    output token: (bufer, opaque, modiy) Token to be sent to peer application. I thelength eld o the returned bufer is zero, no token need be sent to the peer application.Storage associated with this bufer must be reed by the application ater use with acall to gss release bufer().

    ret ags: (bit-mask, modiy, optional) Contains various independent ags, each owhich indicates that the context supports a specic service option. Speciy NULLi not required. Symbolic names are provided or each ag, and the symbolic names

    corresponding to the required ags should be logically-ANDed with the ret ags valueto test whether a given option is supported by the context. See below or the ags.

    time rec: (Integer, modiy, optional) Number o seconds or which the context willremain valid. I the implementation does not support context expiration, the valueGSS C INDEFINITE will be returned. Speciy NULL i not required.

    Initiates the establishment o a security context between the application and aremote peer. Initially, the input token parameter should be specied either asGSS C NO BUFFER, or as a pointer to a gss bufer desc object whose lengtheld contains the value zero. The routine may return a output token which shouldbe transerred to the peer application, where the peer application will presentit to gss accept sec context. I no token need be sent, gss init sec context willindicate this by setting the length eld o the output token argument to zero. Tocomplete the context establishment, one or more reply tokens may be requiredrom the peer application; i so, gss init sec context will return a status containingthe supplementary inormation bit GSS S CONTINUE NEEDED. In this case,gss init sec context should be called again when the reply token is received rom thepeer application, passing the reply token to gss init sec context via the input tokenparameters.

    Portable applications should be constructed to use the token length and return statusto determine whether a token needs to be sent or waited or. Thus a typical portablecaller should always invoke gss init sec context within a loop:

    int context_established = 0;

    gss_ctx_id_t context_hdl = GSS_C_NO_CONTEXT;

    ...

    input_token->length = 0;

    while (!context_established) {

    maj_stat = gss_init_sec_context(&min_stat,

    cred_hdl,

    &context_hdl,

    target_name,

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    31/85

    Chapter 3: Standard GSS API 27

    desired_mech,

    desired_services,

    desired_time,

    input_bindings,

    input_token,

    &actual_mech,

    output_token,

    &actual_services,

    &actual_time);

    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;

    };

    if (maj_stat & GSS_S_CONTINUE_NEEDED) {

    receive_token_from_peer(input_token);} else {

    context_established = 1;

    };

    };

    Whenever the routine returns a major status that includes the valueGSS S CONTINUE NEEDED, the context is not ully established and the ollowingrestrictions apply to the output parameters:

    The value returned via the time rec parameter is undened unless the accom-panying ret ags parameter contains the bit GSS C PROT READY FLAG, in-dicating that per-message services may be applied in advance o a successul

    completion status, the value returned via the actual mech type parameter isundened until the routine returns a major status value o GSS S COMPLETE.

    The values o 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 theret ags parameter should contain the values that the implementation expectswould be valid i context establishment were to succeed. In particular, ithe application has requested a service such as delegation or anonymous

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    32/85

    Chapter 3: Standard GSS API 28

    authentication via the req ags argument, and such a service is unavailablerom the underlying mechanism, gss init sec context should generate a tokenthat will not provide the service, and indicate via the ret ags argument thatthe service will not be supported. The application may choose to abort thecontext establishment by calling gss delete sec context (i it cannot continue inthe absence o the service), or it may choose to transmit the token and continuecontext establishment (i the service was merely desired but not mandatory).

    The values o the GSS C PROT READY FLAG and GSS C TRANS FLAGbits within ret ags should indicate the actual state at the timegss init sec context returns, whether or not the context is ully established.

    GSS-API implementations that support per-message protection are encouragedto set the GSS C PROT READY FLAG in the nal ret ags returned to acaller (i.e. when accompanied by a GSS S COMPLETE status code). However,applications should not rely on this behavior as the ag was not dened in Ver-sion 1 o the GSS-API. Instead, applications should determine what per-message

    services are available ater a successul context establishment according to theGSS C INTEG FLAG and GSS C CONF FLAG values.

    All other bits within the ret ags argument should be set to zero.

    I the initial call o gss init sec context() ails, the implementation should not createa context object, and should leave the value o the context handle parameter set toGSS C NO CONTEXT to indicate this. In the event o a ailure on a subsequent call,the implementation is permitted to delete the "hal-built" security context (in whichcase it should set the context handle parameter to GSS C NO CONTEXT), but thepreerred behavior is to leave the security context untouched or the application todelete (using gss delete sec context).

    During context establishment, the inormational status bits GSS S OLD TOKENand GSS S DUPLICATE TOKEN indicate atal errors, and GSS-API mechanismsshould always return them in association with a routine error o GSS S FAILURE.This requirement or pairing did not exist in version 1 o the GSS-API specication,so applications that wish to run over version 1 implementations must special-casethese codes.

    The req_flags values:

    GSS_C_DELEG_FLAG

    True - Delegate credentials to remote peer.

    False - Dont delegate.

    GSS_C_MUTUAL_FLAG True - Request that remote peer authenticate itsel.

    False - Authenticate sel to remote peer only.

    GSS_C_REPLAY_FLAG

    True - Enable replay detection or messages protected with gss wrapor gss get mic.

    False - Dont attempt to detect replayed messages.

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    33/85

    Chapter 3: Standard GSS API 29

    GSS_C_SEQUENCE_FLAG

    True - Enable detection o out-o-sequence protected messages.

    False - Dont attempt to detect out-o-sequence messages.

    GSS_C_CONF_FLAG

    True - Request that condentiality service be made available (viagss wrap).

    False - No per-message condentiality service is required.

    GSS_C_INTEG_FLAG

    True - Request that integrity service be made available (via gss wrapor gss get mic).

    False - No per-message integrity service is required.

    GSS_C_ANON_FLAG

    True - Do not reveal the initiators identity to the acceptor.

    False - Authenticate normally.

    The ret_flags values:

    GSS_C_DELEG_FLAG

    True - Credentials were delegated to the remote peer.

    False - No credentials were delegated.

    GSS_C_MUTUAL_FLAG

    True - The remote peer has authenticated itsel.

    False - Remote peer has not authenticated itsel.

    GSS_C_REPLAY_FLAG True - replay o protected messages will be detected.

    False - replayed messages will not be detected.

    GSS_C_SEQUENCE_FLAG

    True - out-o-sequence protected messages will be detected.

    False - out-o-sequence messages will not be detected.

    GSS_C_CONF_FLAG

    True - Condentiality service may be invoked by calling gss wraproutine.

    False - No condentiality service (via gss wrap) available. gss wrap

    will provide message encapsulation, data-origin authentication andintegrity services only.

    GSS_C_INTEG_FLAG

    True - Integrity service may be invoked by calling either gss get micor gss wrap routines.

    False - Per-message integrity service unavailable.

    GSS_C_ANON_FLAG

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    34/85

    Chapter 3: Standard GSS API 30

    True - The initiators identity has not been revealed, and will not berevealed i any emitted token is passed to the acceptor.

    False - The initiators identity has been or will be authenticatednormally.

    GSS_C_PROT_READY_FLAG

    True - Protection services (as specied by the states o theGSS C CONF FLAG and GSS C INTEG FLAG) are availableor use i the accompanying major status return value is eitherGSS S COMPLETE or GSS S CONTINUE NEEDED.

    False - Protection services (as specied by the states othe GSS C CONF FLAG and GSS C INTEG FLAG) areavailable only i the accompanying major status return value isGSS S COMPLETE.

    GSS_C_TRANS_FLAG

    True - The resultant security context may be transerred to otherprocesses via a call to gss export sec context().

    False - The security context is not transerable.

    All other bits should be set to zero.

    Return value:

    GSS_S_COMPLETE: Successul completion.

    GSS_S_CONTINUE_NEEDED: Indicates that a token rom the peer application is requiredto complete the context, and that gss init sec context must be called again with thattoken.

    GSS_S_DEFECTIVE_TOKEN: Indicates that consistency checks perormed on the in-

    put token ailed.GSS_S_DEFECTIVE_CREDENTIAL: Indicates that consistency checks perormed on thecredential ailed.

    GSS_S_NO_CRED: The supplied credentials were not valid or context initiation, or thecredential handle did not reerence any credentials.

    GSS_S_CREDENTIALS_EXPIRED: The reerenced credentials have expired.

    GSS_S_BAD_BINDINGS: The input token contains diferent channel bindings to thosespecied via the input chan bindings parameter.

    GSS_S_BAD_SIG: The input token contains an invalid MIC, or a MIC that could notbe veried.

    GSS_S_OLD_TOKEN: The input token was too old. This is a atal error during contextestablishment.

    GSS_S_DUPLICATE_TOKEN: The input token is valid, but is a duplicate o a tokenalready processed. This is a atal error during context establishment.

    GSS_S_NO_CONTEXT: Indicates that the supplied context handle did not reer to avalid context.

    GSS_S_BAD_NAMETYPE: The provided target name parameter contained an invalid orunsupported type o name.

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    35/85

    Chapter 3: Standard GSS API 31

    GSS_S_BAD_NAME: The provided target name parameter was ill-ormed.

    GSS_S_BAD_MECH: The specied mechanism is not supported by the provided creden-tial, or is unrecognized by the implementation.

    gss accept sec context

    [Function]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 bufer t input_token_buffer, const

    gss channel bindings t input_chan_bindings, gss name t * src_name,

    gss OID * mech_type, gss bufer t output_token, OM uint32 * ret_flags,

    OM uint32 * time_rec, gss cred id t * delegated_cred_handle )minor status: (Integer, modiy) Mechanism specic status code.

    context handle: (gss ctx id t, read/modiy) Context handle or new context. SupplyGSS C NO CONTEXT or rst call; use value returned in subsequent calls. Once

    gss accept sec context() has returned a value via this parameter, resources have beenassigned to the corresponding context, and must be reed by the application ater usewith a call to gss delete sec context().

    acceptor cred handle: (gss cred id t, read) Credential handle claimed by context ac-ceptor. Speciy GSS C NO CREDENTIAL to accept the context as a deault prin-cipal. I GSS C NO CREDENTIAL is specied, but no deault acceptor principal isdened, GSS S NO CRED will be returned.

    input token bufer: (bufer, opaque, read) Token obtained rom remote application.

    input chan bindings: (channel bindings, read, optional) Application- speciedbindings. Allows application to securely bind channel identication inor-mation to the security context. I channel bindings are not used, speciyGSS C NO CHANNEL BINDINGS.

    src name: (gss name t, modiy, optional) Authenticated name o context initiator.Ater use, this name should be deallocated by passing it to gss release name(). I notrequired, speciy NULL.

    mech type: (Object ID, modiy, optional) Security mechanism used. The returnedOID value will be a pointer into static storage, and should be treated as read-only bythe caller (in particular, it does not need to be reed). I not required, speciy NULL.

    output token: (bufer, opaque, modiy) Token to be passed to peer application. Ithe length eld o the returned token bufer is 0, then no token need be passed to thepeer application. I a non- zero length eld is returned, the associated storage must

    be reed ater use by the application with a call to gss release bufer().ret ags: (bit-mask, modiy, optional) Contains various independent ags, each owhich indicates that the context supports a specic service option. I not needed,speciy NULL. Symbolic names are provided or each ag, and the symbolic namescorresponding to the required ags should be logically-ANDed with the ret ags valueto test whether a given option is supported by the context. See below or the ags.

    time rec: (Integer, modiy, optional) Number o seconds or which the context willremain valid. Speciy NULL i not required.

  • 8/3/2019 Simon Josefsson- GNU Generic Security Service Library

    36/85

    Chapter 3: Standard GSS API 32

    delegated cred handle: (gss cred id t, modiy, optional credential) Handle or cre-dentials received rom context initiator. Only valid i deleg ag in ret ags is true,in which case an explicit credential handle (i.e. not GSS C NO CREDENTIAL) willbe returned; i deleg ag is alse, gss accept sec context() will set this parameterto GSS C NO CREDENTIAL. I a credential handle is returned, the associated re-sources must be released by the application ater use with a call to gss release cred().Speciy NULL i not required.

    Allows a remotely initiated security context between the application and a remotepeer to be established. The routine may return a output token which shouldbe transerred to the peer application, where the peer application will presentit to gss init sec context. I no token need be sent, gss accept sec context willindicate this by setting the length eld o the output token argument to zero. Toco