]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
doc: Revise outdated text in the manual.
authorNiels Möller <nisse@lysator.liu.se>
Sun, 18 Jan 2026 15:28:23 +0000 (16:28 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Sun, 18 Jan 2026 15:28:23 +0000 (16:28 +0100)
ChangeLog
nettle.texinfo

index 689ccb9def2b505a4029c5d93f093340460c009e..b33ded467512389dfc84beb7dc65fe5b85817845 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2026-01-18  Niels Möller  <nisse@lysator.liu.se>
+
+       * nettle.texinfo (Hash functions): Update hash intro.
+       (Authenticated encryption): Revise intro.
+       (Randomness): Recommend using operating system randomness
+       facilities.
+
 2026-01-14  Niels Möller  <nisse@lysator.liu.se>
 
        * nettle.texinfo (OCB): Update OCB documentation.
index 85b71eaef2c179f84ec022af4d29ecc5ee5a4d1a..e019f74e197a824b09c44d9e05e2ec599d00fbc4 100644 (file)
@@ -15,7 +15,7 @@
 This manual is for the Nettle library (version @value{UPDATED-FOR}), a
 low-level cryptographic library.
 
-Originally written 2001 by @value{AUTHOR}, updated 2025.
+Originally written 2001 by @value{AUTHOR}, updated 2026.
 
 @quotation
 This manual is placed in the public domain. You may freely copy it, in
@@ -410,13 +410,11 @@ Hash functions are useful as building blocks for digital signatures,
 message authentication codes, pseudo random generators, association of
 unique ids to documents, and many other things.
 
-The most commonly used hash functions are MD5 and SHA1. Unfortunately,
-both these fail the collision-resistance requirement; cryptologists have
-found ways to construct colliding inputs. The recommended hash functions
-for new applications are SHA2 (with main variants SHA256 and SHA512). At
-the time of this writing (Autumn 2015), SHA3 has recently been
-standardized, and the new SHA3 and other top SHA3 candidates may also be
-reasonable alternatives.
+The SHA1 hash function is still quite commonly used, even though it
+fails the collision-resistance requirement; cryptologists have found
+ways to construct colliding inputs. The recommended hash functions for
+new applications are SHA2 (with main variants SHA256 and SHA512) and
+SHA3 (several variants, including SHA3-256, SHAKE256 and SHA3-512).
 
 @menu
 * Recommended hash functions::
@@ -877,7 +875,7 @@ This function also resets the context in the same way as
 SM3 is a cryptographic hash function standard adopted by the government of the
 People's Republic of China, which was issued by the Cryptography Standardization
 Technical Committee of China on December 17, 2010. The corresponding standard
-is GM/T 0004-2012 "SM3 Cryptographic Hash Algorithm".
+is GM/T 0004-2012 ``SM3 Cryptographic Hash Algorithm''.
 
 SM3 algorithm is a hash algorithm in ShangMi cryptosystems. SM3 is mainly used
 for digital signature and verification, message authentication code generation
@@ -2153,7 +2151,7 @@ Analogous to @code{serpent_encrypt}
 
 SM4 is a block cipher standard adopted by the government of the People's
 Republic of China, and it was issued by the State Cryptography Administration
-on March 21, 2012. The standard is GM/T 0002-2012 "SM4 block cipher algorithm".
+on March 21, 2012. The standard is GM/T 0002-2012 ``SM4 block cipher algorithm''.
 Nettle defines it in @file{<nettle/sm4.h>}.
 
 @deftp {Context struct} {struct sm4_ctx}
@@ -2804,8 +2802,8 @@ structure.
 @cindex AEAD
 @cindex Authenticated encryption
 
-Since there are some subtle design choices to be made when combining a
-block cipher mode with out authentication with a @acronym{MAC}. In
+There are some subtle design choices to be made when combining a
+block cipher mode without authentication with a @acronym{MAC}. In
 recent years, several constructions that combine encryption and
 authentication have been defined. These constructions typically also
 have an additional input, the ``associated data'', which is
@@ -2818,8 +2816,7 @@ messages. This family of building blocks are therefore called
 The aim is to provide building blocks that it is easier for designers of
 protocols and applications to use correctly. There is also some
 potential for improved performance, if encryption and authentication can
-be done in a single step, although that potential is not realized for
-the constructions currently supported by Nettle.
+be done in a single step.
 
 For encryption, the inputs are:
 
@@ -2845,9 +2842,9 @@ A digest or ``authentication tag''.
 @end itemize
 
 Decryption works the same, but with cleartext and ciphertext
-interchanged. All currently supported @acronym{AEAD} algorithms always
+interchanged. Most of the currently supported @acronym{AEAD} algorithms
 use the encryption function of the underlying block cipher, for both
-encryption and decryption.
+encryption and decryption (OCB being a notable exception).
 
 Usually, the authentication tag should be appended at the end of the
 ciphertext, producing an encrypted message which is slightly longer than
@@ -2863,16 +2860,18 @@ use a length that is a multiple of the block size, although some
 mode is a bit special in that it requires the message lengths up front,
 other @acronym{AEAD} constructions don't have this restriction.
 
-The supported @acronym{AEAD} constructions are Galois/Counter mode
-(@acronym{GCM}), @acronym{EAX}, ChaCha-Poly1305, and Counter with
-@acronym{CBC}-@acronym{MAC} (@acronym{CCM}). There are some weaknesses
-in @acronym{GCM} authentication, see
-@url{https://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments@//CWC-GCM/Ferguson2.pdf}.
-@acronym{CCM} and @acronym{EAX} use the same building blocks, but the
+Of the supported @acronym{AEAD} constructions in Nettle, Galois/Counter
+mode (@acronym{GCM}) is widely used, and was originally designed for
+high performance in hardware implementations. Software performance is
+rather poor unless there's an efficient ``carry-less multiplication''
+instruction that can be used. Both @acronym{CCM} and @acronym{EAX} use
+the same building blocks, @acronym{CTR} and @acronym{CMAC}, but the
 @acronym{EAX} design is cleaner and avoids a couple of inconveniences of
 @acronym{CCM}. Therefore, @acronym{EAX} seems like a good conservative
-choice. The more recent ChaCha-Poly1305 may also be an attractive but
-more adventurous alternative, in particular if performance is important.
+choice. The ChaCha-Poly1305 scheme is designed for high performance,
+also on machines without specialized crypto acceleration instructions.
+The Synthetic Initialization Vector (@acronym{SIV}) modes are designed
+to not fail catastrophically if a nonce is reused.
 
 @menu
 * EAX::
@@ -4482,9 +4481,9 @@ attacks by using salting and expensive computation.
 HKDF is a key derivation function used as a building block of
 higher-level protocols like TLS 1.3. It is a derivation function
 based on HMAC described in @cite{RFC 5869},
-and is split into two logical modules, called 'extract' and 'expand'.
+and is split into two logical modules, called ``extract'' and ``expand''.
 The extract module takes an initial secret and a random
-salt to "extract" a fixed-length pseudorandom key (PRK). The second stage
+salt to extract a fixed-length pseudorandom key (PRK). The second stage
 takes as input the previous PRK and some informational data (e.g.,
 text) and expands them into multiple keys.
 
@@ -5907,6 +5906,14 @@ If this assumption is not true in practice, systems that are otherwise
 perfectly secure, can be broken. Randomness has often turned out to be
 the weakest link in the chain.
 
+Building a good randomness source is subtle, in particular if your
+program may run inside several layers of virtualization. Today, most
+operating system provides a good randomness source, e.g.,
+@file{/dev/random} and the @code{getrandom} syscall on GNU/Linux. Please
+use that, possibly in combination with a @acronym{KDF}! If for some
+reason that is not possible and you @emph{have} to roll your own, the
+rest of this section provides some advice.
+
 In non-cryptographic applications, such as games as well as scientific
 simulation, a good randomness generator usually means a generator that
 has good statistical properties, and is seeded by some simple function
@@ -5915,7 +5922,6 @@ of things like the current time, process id, and host name.
 However, such a generator is inadequate for cryptography, for at least
 two reasons:
 
-
 @itemize
 
 @item
@@ -6024,16 +6030,17 @@ attackers that we care about (typically, we must at the very least
 assume that no attacker has root privileges on our machine).
 
 How do we generate output from this seed, and how much can we get? Some
-generators (notably the Linux @file{/dev/random} generator) tries to
-estimate available entropy and restrict the amount of output. The goal
-is that if you read 128 bits from @file{/dev/random}, you should get 128
-``truly random'' bits. This is a property that is useful in some
-specialized circumstances, for instance when generating key material for
-a one time pad, or when working with unconditional blinding, but in most
-cases, it doesn't matter much. For most application, there's no limit on
-the amount of useful ``random'' data that we can generate from a small
-seed; what matters is that the seed is unguessable and that the
-generator has good cryptographic properties.
+generators (notably older versions of the Linux @file{/dev/random}
+generator) tries to estimate available entropy and restrict the amount
+of output. The goal was that if you read 512 bits from
+@file{/dev/random}, you should get 512 ``truly random'' bits. This is a
+property that is useful in some specialized circumstances, for instance
+when generating key material for a one time pad, or when working with
+unconditional blinding, but in most cases, it doesn't matter much. For
+most application, there's no limit on the amount of useful ``random''
+data that we can generate from a small seed; what matters is that the
+seed is unguessable and that the generator has good cryptographic
+properties.
 
 At the heart of all generators lies its internal state. Future output
 is determined by the internal state alone. Let's call it the generator's
@@ -6502,7 +6509,8 @@ Servera med kokta ägghalvor.
 @node Installation
 @chapter Installation
 
-Nettle uses @command{autoconf}. To build it, unpack the source and run
+Nettle uses @command{autoconf}, and the generated Makefile requires GNU
+make. To build Nettle, unpack the source and run
 
 @example
 ./configure
@@ -6512,18 +6520,19 @@ make install
 @end example
 
 @noindent
-to install it under the default prefix, @file{/usr/local}. Using GNU
-make is strongly recommended. By default, both static and shared
-libraries are built and installed.
+to install it under the default prefix, @file{/usr/local}. By default,
+both static and shared libraries are built and installed.
 
 To get a list of configure options, use @code{./configure --help}. Some
 of the more interesting are:
 
 @table @option
-@item --enable-fat
-Include multiple versions of certain functions in the library, and
-select the ones to use at run-time, depending on available processor
-features. Supported for ARM and x86_64.
+@item --prefix
+Change install location.
+
+@item --disable-fat
+Disable run-time detection of available processor features. Additional
+configure options can be used to select which features to require.
 
 @item --enable-mini-gmp
 Use the smaller and slower ``mini-gmp'' implementation of the bignum
@@ -6536,10 +6545,6 @@ information.
 @item --disable-shared
 Omit building the shared libraries.
 
-@item --disable-dependency-tracking
-Disable the automatic dependency tracking. You will likely need this
-option to be able to build with BSD make.
-
 @end table
 
 @node Index