This is gnutls.info, produced by makeinfo version 6.8 from gnutls.texi.
This manual is last updated 9 February 2023 for version 3.7.9 of GnuTLS.
Copyright (C) 2001-2023 Free Software Foundation, Inc.\\ Copyright (C)
2001-2023 Nikos Mavrogiannopoulos
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License,
Version 1.3 or any later version published by the Free Software
Foundation; with no Invariant Sections, no Front-Cover Texts, and
no Back-Cover Texts. A copy of the license is included in the
section entitled "GNU Free Documentation License".
INFO-DIR-SECTION Software libraries
START-INFO-DIR-ENTRY
* GnuTLS: (gnutls). GNU Transport Layer Security Library.
END-INFO-DIR-ENTRY
INFO-DIR-SECTION System Administration
START-INFO-DIR-ENTRY
* certtool: (gnutls)certtool Invocation. Manipulate certificates and keys.
* gnutls-serv: (gnutls)gnutls-serv Invocation. GnuTLS test server.
* gnutls-cli: (gnutls)gnutls-cli Invocation. GnuTLS test client.
* gnutls-cli-debug: (gnutls)gnutls-cli-debug Invocation. GnuTLS debug client.
* psktool: (gnutls)psktool Invocation. Simple TLS-Pre-Shared-Keys manager.
* srptool: (gnutls)srptool Invocation. Simple SRP password tool.
END-INFO-DIR-ENTRY
File: gnutls.info, Node: Top, Next: Preface, Up: (dir)
GnuTLS
******
This manual is last updated 9 February 2023 for version 3.7.9 of GnuTLS.
Copyright (C) 2001-2023 Free Software Foundation, Inc.\\ Copyright (C)
2001-2023 Nikos Mavrogiannopoulos
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License,
Version 1.3 or any later version published by the Free Software
Foundation; with no Invariant Sections, no Front-Cover Texts, and
no Back-Cover Texts. A copy of the license is included in the
section entitled "GNU Free Documentation License".
* Menu:
* Preface::
* Introduction to GnuTLS::
* Introduction to TLS::
* Authentication methods::
* Hardware security modules and abstract key types::
* How to use GnuTLS in applications::
* GnuTLS application examples::
* System-wide configuration of the library::
* Using GnuTLS as a cryptographic library::
* Other included programs::
* Internal architecture of GnuTLS::
* Upgrading from previous versions::
* Support::
* Error codes::
* Supported ciphersuites::
* API reference::
* Copying Information::
* Bibliography::
* Function and Data Index::
* Concept Index::
File: gnutls.info, Node: Preface, Next: Introduction to GnuTLS, Prev: Top, Up: Top
1 Preface
*********
This document demonstrates and explains the GnuTLS library API. A brief
introduction to the protocols and the technology involved is also
included so that an application programmer can better understand the
GnuTLS purpose and actual offerings. Even if GnuTLS is a typical
library software, it operates over several security and cryptographic
protocols which require the programmer to make careful and correct usage
of them. Otherwise it is likely to only obtain a false sense of
security. The term of security is very broad even if restricted to
computer software, and cannot be confined to a single cryptographic
library. For that reason, do not consider any program secure just
because it uses GnuTLS; there are several ways to compromise a program
or a communication line and GnuTLS only helps with some of them.
Although this document tries to be self contained, basic network
programming and public key infrastructure (PKI) knowledge is assumed in
most of it. A good introduction to networking can be found in [*note
STEVENS::], to public key infrastructure in [*note GUTPKI::] and to
security engineering in [*note ANDERSON::].
Updated versions of the GnuTLS software and this document will be
available from <https://www.gnutls.org/>.
File: gnutls.info, Node: Introduction to GnuTLS, Next: Introduction to TLS, Prev: Preface, Up: Top
2 Introduction to GnuTLS
************************
In brief GnuTLS can be described as a library which offers an API to
access secure communication protocols. These protocols provide privacy
over insecure lines, and were designed to prevent eavesdropping,
tampering, or message forgery.
Technically GnuTLS is a portable ANSI C based library which implements
the protocols ranging from SSL 3.0 to TLS 1.3 (see *note Introduction to
TLS::, for a detailed description of the protocols), accompanied with
the required framework for authentication and public key infrastructure.
Important features of the GnuTLS library include:
* Support for TLS 1.3, TLS 1.2, TLS 1.1, TLS 1.0 and optionally SSL
3.0 protocols.
* Support for Datagram TLS 1.0 and 1.2.
* Support for handling and verification of X.509 certificates.
* Support for password authentication using TLS-SRP.
* Support for keyed authentication using TLS-PSK.
* Support for TPM, PKCS #11 tokens and smart-cards.
The GnuTLS library consists of three independent parts, namely the "TLS
protocol part", the "Certificate part", and the "Cryptographic back-end"
part. The "TLS protocol part" is the actual protocol implementation,
and is entirely implemented within the GnuTLS library. The "Certificate
part" consists of the certificate parsing, and verification functions
and it uses functionality from the libtasn1 library. The "Cryptographic
back-end" is provided by the nettle and gmplib libraries.
* Menu:
* Downloading and installing::
* Installing for a software distribution::
* Document overview::
File: gnutls.info, Node: Downloading and installing, Next: Installing for a software distribution, Up: Introduction to GnuTLS
2.1 Downloading and installing
==============================
GnuTLS is available for download at:
<https://www.gnutls.org/download.html>
GnuTLS uses a development cycle where even minor version numbers
indicate a stable release and a odd minor version number indicate a
development release. For example, GnuTLS 1.6.3 denote a stable release
since 6 is even, and GnuTLS 1.7.11 denote a development release since 7
is odd.
GnuTLS depends on 'nettle' and 'gmplib', and you will need to install it
before installing GnuTLS. The 'nettle' library is available from
<https://www.lysator.liu.se/~nisse/nettle/>, while 'gmplib' is available
from <https://www.gmplib.org/>. Don't forget to verify the
cryptographic signature after downloading source code packages.
The package is then extracted, configured and built like many other
packages that use Autoconf. For detailed information on configuring and
building it, refer to the 'INSTALL' file that is part of the
distribution archive. Typically you invoke './configure' and then 'make
check install'. There are a number of compile-time parameters, as
discussed below.
Several parts of GnuTLS require ASN.1 functionality, which is provided
by a library called libtasn1. A copy of libtasn1 is included in GnuTLS.
If you want to install it separately (e.g., to make it possibly to use
libtasn1 in other programs), you can get it from
<https://www.gnu.org/software/libtasn1/>.
The compression library, 'libz', the PKCS #11 helper library 'p11-kit',
the TPM library 'trousers', as well as the IDN library 'libidn'(1) are
optional dependencies. Check the README file in the distribution on how
to obtain these libraries.
A few 'configure' options may be relevant, summarized below. They
disable or enable particular features, to create a smaller library with
only the required features. Note however, that although a smaller
library is generated, the included programs are not guaranteed to
compile if some of these options are given.
--disable-srp-authentication
--disable-psk-authentication
--disable-anon-authentication
--disable-dhe
--disable-ecdhe
--disable-openssl-compatibility
--disable-dtls-srtp-support
--disable-alpn-support
--disable-heartbeat-support
--disable-libdane
--without-p11-kit
--without-tpm
--without-zlib
For the complete list, refer to the output from 'configure --help'.
---------- Footnotes ----------
(1) Needed to use RFC6125 name comparison in internationalized
domains.
File: gnutls.info, Node: Installing for a software distribution, Next: Document overview, Prev: Downloading and installing, Up: Introduction to GnuTLS
2.2 Installing for a software distribution
==========================================
When installing for a software distribution, it is often desirable to
preconfigure GnuTLS with the system-wide paths and files. There two
important configuration options, one sets the trust store in system,
which are the CA certificates to be used by programs by default (if they
don't override it), and the other sets to DNSSEC root key file used by
unbound for DNSSEC verification.
For the latter the following configuration option is available, and if
not specified GnuTLS will try to auto-detect the location of that file.
--with-unbound-root-key-file
To set the trust store the following options are available.
--with-default-trust-store-file
--with-default-trust-store-dir
--with-default-trust-store-pkcs11
The first option is used to set a PEM file which contains a list of
trusted certificates, while the second will read all certificates in the
given path. The recommended option is the last, which allows to use a
PKCS #11 trust policy module. That module not only provides the trusted
certificates, but allows the categorization of them using purpose, e.g.,
CAs can be restricted for e-mail usage only, or administrative
restrictions of CAs, for examples by restricting a CA to only issue
certificates for a given DNS domain using NameConstraints. A publicly
available PKCS #11 trust module is p11-kit's trust module(1).
---------- Footnotes ----------
(1) <https://p11-glue.github.io/p11-glue/trust-module.html>
File: gnutls.info, Node: Document overview, Prev: Installing for a software distribution, Up: Introduction to GnuTLS
2.3 Overview
============
In this document we present an overview of the supported security
protocols in *note Introduction to TLS::, and continue by providing more
information on the certificate authentication in *note Certificate
authentication::, and shared-key as well anonymous authentication in
*note Shared-key and anonymous authentication::. We elaborate on
certificate authentication by demonstrating advanced usage of the API in
*note More on certificate authentication::. The core of the TLS library
is presented in *note How to use GnuTLS in applications:: and example
applications are listed in *note GnuTLS application examples::. In
*note Other included programs:: the usage of few included programs that
may assist debugging is presented. The last chapter is *note Internal
architecture of GnuTLS:: that provides a short introduction to GnuTLS'
internal architecture.
File: gnutls.info, Node: Introduction to TLS, Next: Authentication methods, Prev: Introduction to GnuTLS, Up: Top
3 Introduction to TLS and DTLS
******************************
TLS stands for "Transport Layer Security" and is the successor of SSL,
the Secure Sockets Layer protocol [*note SSL3::] designed by Netscape.
TLS is an Internet protocol, defined by IETF(1), described in [*note
RFC5246::]. The protocol provides confidentiality, and authentication
layers over any reliable transport layer. The description, above,
refers to TLS 1.0 but applies to all other TLS versions as the
differences between the protocols are not major.
The DTLS protocol, or "Datagram TLS" [*note RFC4347::] is a protocol
with identical goals as TLS, but can operate under unreliable transport
layers such as UDP. The discussions below apply to this protocol as
well, except when noted otherwise.
* Menu:
* TLS layers::
* The transport layer::
* The TLS record protocol::
* The TLS Alert Protocol::
* The TLS Handshake Protocol::
* TLS Extensions::
* How to use TLS in application protocols::
* On SSL 2 and older protocols::
---------- Footnotes ----------
(1) IETF, or Internet Engineering Task Force, is a large open
international community of network designers, operators, vendors, and
researchers concerned with the evolution of the Internet architecture
and the smooth operation of the Internet. It is open to any interested
individual.
File: gnutls.info, Node: TLS layers, Next: The transport layer, Up: Introduction to TLS
3.1 TLS Layers
==============
TLS is a layered protocol, and consists of the record protocol, the
handshake protocol and the alert protocol. The record protocol is to
serve all other protocols and is above the transport layer. The record
protocol offers symmetric encryption, and data authenticity(1). The
alert protocol offers some signaling to the other protocols. It can
help informing the peer for the cause of failures and other error
conditions. *Note The Alert Protocol::, for more information. The
alert protocol is above the record protocol.
The handshake protocol is responsible for the security parameters'
negotiation, the initial key exchange and authentication. *Note The
Handshake Protocol::, for more information about the handshake protocol.
The protocol layering in TLS is shown in *note Figure 3.1:
fig-tls-layers.
[image src="gnutls-layers.png"