8.105. Nettle-3.10.1

8.105.1. Introduction to Nettle

The Nettle package contains a low-level cryptographic library that is designed to fit easily in many contexts.

Approximate build time: 0.2 SBU
Required disk space: 100 MB

8.105.2. Installation of Nettle

Create the PKGBUILD for the Nettle package with the following commands:

mkdir /sources/nettle
cd /sources/nettle
cat > PKGBUILD << "REALEOF"
# Maintainer: Linux From Scratch <lfs-dev@lists.linuxfromscratch.org>

pkgname="nettle"
pkgver="3.10.1"
pkgrel="1"
pkgdesc="The Nettle package contains a low-level cryptographic library."
arch=('x86'
      'x86_64')
url="https://www.gnu.org/nettle/"
groups=('core')
license=('LGPLv3')
depends=('glibc'
         'gmp'
         'rootfs'))
makedepends=('bash'
             'binutils'
             'coreutils'
             'gawk'
             'gcc'
             'grep'
             'make'
             'sed')
source=('https://ftp.gnu.org/gnu/nettle/nettle-3.10.1.tar.gz')
md5sums=('c3dc1729cfa65fcabe2023dfbff60beb')
 
build(){
  cd "${pkgname}-${pkgver}"
  ./configure --prefix=/usr --disable-static
  make
}

package(){
  make DESTDIR="${pkgdir}" install
  chmod -v 755 "${pkgdir}"/usr/lib/lib{hogweed,nettle}.so
  install -vdm755 -d "${pkgdir}/usr/share/doc/nettle-${pkgver}"
  install -vm644 nettle.{html,pdf} "${pkgdir}/usr/share/doc/nettle-${pkgver}"
}
REALEOF

Prepare the build directory for the pacman user and build the package:

chown -R root:pacman .
chmod 2775 .
chmod 664 PKGBUILD
su pacman -c 'makepkg -L --nodeps'

Add the newly created package to the central package repository:

cp nettle-3.10.1-1-$(uname -m).pkg.tar.xz \
   /srv/pacman/repos/LFS/
repo-add /srv/pacman/repos/LFS/LFS.db.tar.xz \
         /srv/pacman/repos/LFS/nettle-3.10.1-1-$(uname -m).pkg.tar.xz

Update the local cache and install the Nettle package:

pacman -Syu
pacman -S nettle --overwrite \* -dd --noconfirm

Finally, copy the source files into the source repository and clean up the build directory:

mkdir /srv/pacman/source/LFS/nettle
cp PKGBUILD /srv/pacman/source/LFS/nettle
cd /sources
rm -rf nettle

8.105.3. Contents

Installed Programs: nettle-hash, nettle-lfib-stream, nettle-pbkdf2, pkcs1-conv and sexp-conv
Installed Libraries: libhogweed.so and libnettle.so
Installed Directory: /usr/include/nettle and /usr/share/doc/nettle-3.10.1

Short Descriptions

nettle-hash

calculates a hash value using a specified algorithm

nettle-lfib-stream

outputs a sequence of pseudorandom (non-cryptographic) bytes, using Knuth's lagged fibonacci generator. The stream is useful for testing, but should not be used to generate cryptographic keys or anything else that needs real randomness

nettle-pbkdf2

is a password-based key derivation function that takes a password or a passphrase as input and returns a strengthened password, which is protected against pre-computation attacks by using salting and other expensive computations.

pkcs1-conv

converts private and public RSA keys from PKCS #1 format to sexp format

sexp-conv

converts an s-expression to a different encoding