Contents
========
* Description
* Installation
* Documentation
* Build Notes

Description
===========
This is GnuPG 1.4.23 built with DJGPP.  It requires a DPMI host
to run.  It is patched to mitigate CVE-2019-14855.

Also included is NOISE.SYS assembled with NASM and configured to use
a larger 4096 byte entropy pool.

Installation
============
Environment variables:

* GNUPGHOME - either set this or create C:\gnupg\
* RNG_DEVICE - set to override random device used for key generation
* TZ - must be set, use POSIX TZ expanded format

GPG defaults to using C:\gnupg\ for the keyring and /dev/random$ for
key generation.

If the TZ environment variable isn't set, then gnupg may warn about a
time warp or clock problem.  This is DJGPP's fault.  Work around:
     set TZ=DOS0

GPG depends on the NOISE driver for key generation on DOS.  See
noise/noise.txt for instructions to install this driver.  Note that
this driver does not work in DOSBox.  FreeDOS FDCONFIG.SYS example:
    DEVICEHIGH=C:\GPG\NOISE\NOISE386.SYS /o /d

The NOISE driver must have enough random bytes available before you
generate crypto keys.  As i understand it, the entropy must be
collected ahead of time because DOS is a single-task OS, and it can't
collect enough new entropy in the middle of creating keys.

Example: Suppose you wish to create a 4096 bit key.  Since it is
actually a pair of keys, gpg will need 8096 bits of random data,
or 1024 bytes.  If the NOISE.SYS entropy pool has fewer than 1024
bytes waiting, then gpg will block on reading /dev/random$ and fail
to generate the key.  You can use the CHKNOIS.COM utility to check
whether the entropy pool has enough bytes waiting.

The default configuration file is in the GNUPGHOME directory.  The
configuration file is named either gpg.con or gpg.conf depending on
whther long file names are enabled.  This configuration file should
be in DOS text format.

Documentation
=============
doc/faq.txt     - GnuPG Frequently Asked Questions
doc/gph.txt     - GNU privacy handbook
doc/gpg.txt     - GnuPG manual
doc/info.txt    - GnuPG texinfo
doc/options.txt - gpg.conf options
doc/rfc4880.txt - OpenPGP Request For Comments
noise/noise.txt - NOISE.SYS /dev/random$ driver manual

GPG Best Practices
<https://help.riseup.net/en/security/message-security/openpgp/
gpg-best-practices>

An Introduction To Cryptography
<http://pgpkeys.org/docs/7.0/IntroToCrypto.pdf>

Build Notes
===========
I installed the following cross-compiler:
<https://github.com/andrewwutw/build-djgpp>

    git clone https://github.com/andrewwutw/build-djgpp.git
    cd build-djgpp
    DJGPP_PREFIX=$HOME/local/cross-djgpp ./build-djgpp.sh 10.3.0

I extracted zlb1212b.zip into: ~/local/cross-djgpp/zlib

I downloaded gnupg-1.4.23 source code from:
<https://www.gnupg.org/ftp/gcrypt/gnupg/gnupg-1.4.23.tar.bz2>

I extracted the source code:
    tar jxvf gnupg-1.4.23.tar.bz2

I applied my local changes:
    patch -p1 <../gnupg-djgpp.diff

I re-generated the autocrud, ignoring the errors.
    autoreconf
    automake

I configured gnupg to build with the cross-compiler.
    mkdir dos
    ./configure --prefix=$(pwd)/dos --host=i586-pc-msdosdjgpp \
        --build=x86_64-slackware-linux --disable-silent-rules \
        --disable-dependency-tracking --disable-gnupg-iconv \
        --disable-large-secmem --disable-card-support \
        --disable-agent-support --disable-bzip2 --disable-exec \
        --disable-photo-viewers --disable-keyserver-helpers \
        --disable-ldap --disable-hkp --disable-finger --disable-generic \
        --disable-keyserver-path --disable-largefile --disable-dns-srv \
        --disable-dns-cert --disable-nls --disable-threads \
        --disable-rpath --disable-regex --enable-dev-random \
        --enable-static-rnd=linux \
        --with-zlib=$HOME/local/cross-djgpp/zlib

I built and installed gnupg.
    make
    make install

I built and installed NOISE.SYS
    cd noise/src
    sh build.sh
    cp *.sys *.com demo/*.exe ..
    sh clean.sh
    cd -

I copied the bits into place.
    mkdir -p gpg14g/doc gpg14g/src
    cp ../gnupg-djgpp.diff gpg14g/src/
    cp dos/bin/*.exe gpg14g/
    cp djgpp.txt gpg14g/doc/
    cp dos/share/gnupg/options.skel gpg14g/doc/options.txt
    cp dos/share/info/gnupg1.info gpg14g/doc/info.txt
    GROFF_NO_SGR=1 TERM=dumb groff -Tascii -man dos/share/man/man1/gpgv.1 |\
        col -b >gpg14g/doc/gpgv.txt
    GROFF_NO_SGR=1 TERM=dumb groff -Tascii -man dos/share/man/man1/gpg.1 |\
        col -b >gpg14g/doc/gpg.txt
    curl -o gpg14g/doc/faq.txt ftp://ftp.gnupg.org/gcrypt/gnupg/GnuPG-FAQ.txt
    cp ../gph.txt doc/
    cp ../rfc4880.txt doc/
    cp -R noise gpg14g/
    cd gpg14g
    i586-pc-msdosdjgpp-strip *.exe
