Files
comet/Makefile
Ken Johnson be07621a50 BinkP: CRYPT, DES-CBC, NR mode, mutual auth, daemon thread fix
Critical fix: outbound TCP connect moved from main loop to session
thread. Main loop was blocking on CometTcpConnect (15s timeout)
preventing inbound connections from being accepted. This caused
the daemon to miss incoming calls while polling outbound nodes.

BinkP security:
- ED25519 mutual auth: originator verifies answerer's pubkey
- Removed self-announced key fallback on answerer
- cetSessionReject fires on all auth failures (ED25519, CRAM, plain)

BinkP CRYPT (binkd-compatible):
- CRC32 stream cipher from binkd crypt.c (Roger Schlafly)
- Activates on CRAM-MD5 auth + both sides advertise CRYPT
- Follows Argus activation rules (CRAM or originator + password)

BinkP DES-CBC (Argus-compatible):
- Pure Pascal DES implementation (FIPS 46-3), 13/13 test vectors
- ENC DES/CBC negotiation via M_ERR per Argus protocol
- Key checksum verification (ECB encrypt + MD5 CRC16)

BinkP NR mode:
- Sender sends M_FILE with offset -1 (resume-capable)
- After sending, doesn't wait for M_GOT
- Activates when both sides advertise NR

Config: added DESKey per-node option for DES-CBC encryption.
Tests: test_des.pas (DES unit), test_binkp.sh (comprehensive suite).
2026-04-08 15:06:01 -07:00

157 lines
4.7 KiB
Makefile

# Comet - Direct TCP File Transfer for FidoNet
# Makefile for Free Pascal Compiler
#
# Targets:
# make Build for Linux x86-64 (default)
# make freebsd Build for FreeBSD x86-64
# make freebsd32 Build for FreeBSD i386
# make win64 Build for Windows x86-64
# make linux32 Build for Linux i386
# make dos Build for DOS (DJGPP) - requires Watt-32
# make test Build and run all tests
# make clean Remove build artifacts
# make all-platforms Build for all available platforms
FPC = /opt/fpcup/fpc/bin/x86_64-linux/fpc
FPCFLAGS = -Mobjfpc -Sh -Se -B
FPCOPT =
# Cross-compiler paths
FPCUP = /opt/fpcup
CROSSBIN = $(FPCUP)/cross/bin
# Directories
SRCDIR = src
TESTDIR = test
BUILDDIR = build
# Source files
UNITS = cometdef cometpath cometcrc cometsha cometlog cometcfg \
comettcp cometfrm cometmd5 cometcram cometcrypt cometdes cometbso cometfile \
cometio cometses cometxfer cometbinkp cometnodelist \
cometed25519 cometed25519sc cometed25519ge cometed25519bp \
cometdaemon
TESTS = test_crc test_sha test_frame test_md5
PROGRAM = comet
SRCDEPS = $(SRCDIR)/comet.pas $(addprefix $(SRCDIR)/,$(addsuffix .pas,$(UNITS)))
# Default target: Linux x86-64 (native)
all: linux
linux: $(SRCDEPS)
@mkdir -p $(BUILDDIR)/linux
$(FPC) $(FPCFLAGS) $(FPCOPT) -FE$(BUILDDIR)/linux -o$(PROGRAM) $(SRCDIR)/comet.pas
# ---- Cross-compilation targets ----
freebsd: $(SRCDEPS)
@mkdir -p $(BUILDDIR)/freebsd
$(FPCUP)/fpc/bin/x86_64-linux/ppcrossx64 $(FPCFLAGS) \
-Tfreebsd -Px86_64 \
-FE$(BUILDDIR)/freebsd \
-FD$(CROSSBIN)/x86_64-freebsd \
-Fl$(FPCUP)/cross/lib/x86_64-freebsd \
-o$(PROGRAM) $(SRCDIR)/comet.pas
freebsd32: $(SRCDEPS)
@mkdir -p $(BUILDDIR)/freebsd32
$(FPCUP)/fpc/bin/x86_64-linux/ppcross386 $(FPCFLAGS) \
-Tfreebsd -Pi386 \
-FE$(BUILDDIR)/freebsd32 \
-XP$(CROSSBIN)/i386-freebsd- \
-Fl$(FPCUP)/cross/lib/i386-freebsd \
-o$(PROGRAM) $(SRCDIR)/comet.pas
win64: $(SRCDEPS)
@mkdir -p $(BUILDDIR)/win
$(FPCUP)/fpc/bin/x86_64-linux/ppcrossx64 $(FPCFLAGS) \
-Twin64 -Px86_64 \
-FE$(BUILDDIR)/win \
-o$(PROGRAM).exe $(SRCDIR)/comet.pas
linux32: $(SRCDEPS)
@mkdir -p $(BUILDDIR)/linux32
$(FPCUP)/fpc/bin/x86_64-linux/ppcross386 $(FPCFLAGS) \
-Tlinux -Pi386 \
-FE$(BUILDDIR)/linux32 \
-XP$(CROSSBIN)/i386-linux- \
-Fl$(FPCUP)/cross/lib/i386-linux \
-o$(PROGRAM) $(SRCDIR)/comet.pas
dos: $(SRCDEPS)
@mkdir -p $(BUILDDIR)/go32v2
$(FPCUP)/fpc/bin/x86_64-linux/ppcross386 $(FPCFLAGS) \
-Tgo32v2 -Pi386 \
-FE$(BUILDDIR)/go32v2 \
-XP$(CROSSBIN)/i386-go32v2- \
-o$(PROGRAM).exe $(SRCDIR)/comet.pas
os2: $(SRCDEPS)
@mkdir -p $(BUILDDIR)/os2
$(FPCUP)/fpc/bin/x86_64-linux/ppcross386 $(FPCFLAGS) \
-Tos2 -Pi386 \
-FE$(BUILDDIR)/os2 \
-FD$(FPCUP)/cross/i386-pc-os2-emx \
-XPi386-os2- \
-o$(PROGRAM).exe $(SRCDIR)/comet.pas
# Build all available platforms
all-platforms: linux freebsd win64 dos os2
@echo "Built for: Linux x86-64, FreeBSD x86-64, Windows x86-64, DOS, OS/2"
# ---- Tests ----
test: $(TESTS)
@echo "=== Running tests ==="
@./test_crc
@./test_sha
@./test_frame
@./test_md5
@echo "=== All tests passed ==="
test_crc: $(TESTDIR)/test_crc.pas $(SRCDIR)/cometcrc.pas
$(FPC) $(FPCFLAGS) $(FPCOPT) -Fu$(SRCDIR) -FE. $(TESTDIR)/test_crc.pas
test_sha: $(TESTDIR)/test_sha.pas $(SRCDIR)/cometsha.pas
$(FPC) $(FPCFLAGS) $(FPCOPT) -Fu$(SRCDIR) -FE. $(TESTDIR)/test_sha.pas
test_frame: $(TESTDIR)/test_frame.pas $(SRCDIR)/cometfrm.pas $(SRCDIR)/comettcp.pas $(SRCDIR)/cometcrc.pas $(SRCDIR)/cometdef.pas $(SRCDIR)/cometlog.pas
$(FPC) $(FPCFLAGS) $(FPCOPT) -Fu$(SRCDIR) -FE. $(TESTDIR)/test_frame.pas
test_md5: $(TESTDIR)/test_md5.pas $(SRCDIR)/cometmd5.pas $(SRCDIR)/cometcram.pas
$(FPC) $(FPCFLAGS) $(FPCOPT) -Fu$(SRCDIR) -FE. $(TESTDIR)/test_md5.pas
# Debug build (with debugging symbols)
debug: FPCOPT += -g -gl -dDEBUG
debug: clean linux
# Clean compiled output
clean:
rm -rf $(BUILDDIR)
rm -f $(SRCDIR)/*.o $(SRCDIR)/*.ppu $(SRCDIR)/*.rsj
rm -f $(TESTDIR)/*.o $(TESTDIR)/*.ppu $(TESTDIR)/*.rsj
rm -f *.o *.ppu *.rsj link.res ppas.sh
rm -f $(TESTS)
# Full clean including backups
distclean: clean
rm -f $(SRCDIR)/*~ $(SRCDIR)/*.bak $(TESTDIR)/*~ $(TESTDIR)/*.bak *~ *.bak
# Install (copy binary to /usr/local/bin)
install: linux
install -m 755 $(BUILDDIR)/linux/$(PROGRAM) /usr/local/bin/$(PROGRAM)
@echo "Installed to /usr/local/bin/$(PROGRAM)"
# Show file statistics
stats:
@echo "=== Source files ==="
@wc -l $(addprefix $(SRCDIR)/,$(addsuffix .pas,$(UNITS))) $(SRCDIR)/comet.pas COMET.SAM
@echo
@echo "=== Builds ==="
@for d in $(BUILDDIR)/*/; do ls -la "$$d"$(PROGRAM)* 2>/dev/null; done || echo "(none built)"
.PHONY: all linux test debug clean distclean install stats
.PHONY: freebsd freebsd32 win64 linux32 dos os2 all-platforms