Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2b80f89
Integrate ip65 networking stack with ZP time-sharing and test suite
JC-000 Mar 14, 2026
f2c2a55
Add C64 zero page definitive reference
JC-000 Mar 14, 2026
3c4494a
Add crypto modules: ChaCha20-Poly1305 AEAD + SHA-256 + HMAC-DRBG
JC-000 Mar 14, 2026
6bfc36c
Implement HKDF-SHA256 for TLS 1.3 key derivation
JC-000 Mar 14, 2026
f6811c2
Update README project status to reflect completed work
JC-000 Mar 14, 2026
cfb765d
Merge pull request #1 from JC-000/feature/ip65-integration
JC-000 Mar 14, 2026
4cd35c8
Implement TLS 1.3 record layer: encrypt, decrypt, nonce, framing
JC-000 Mar 15, 2026
8dd5970
Merge pull request #2 from JC-000/feature/tls-record-layer
JC-000 Mar 15, 2026
ca655bc
Implement TLS 1.3 handshake: x25519 ECDH, ClientHello, ServerHello, k…
JC-000 Mar 15, 2026
851d2a6
Add consistent VICE PID+port logging to all test files
JC-000 Mar 15, 2026
7639714
Add parallel test runner using ViceInstanceManager
JC-000 Mar 15, 2026
960be53
Update README with TLS handshake status and parallel test runner
JC-000 Mar 15, 2026
c9cfc6b
Fix key schedule and Finished MAC tests: 21/21 handshake tests pass
JC-000 Mar 15, 2026
f873744
Update README: 21/21 handshake tests, 134 total tests
JC-000 Mar 15, 2026
8115f20
Merge pull request #3 from JC-000/feature/tls-handshake
JC-000 Mar 16, 2026
8cf6feb
Add entropy/DRBG initialization: SID voice 3 + CIA timer seeding
JC-000 Mar 16, 2026
e4beb6d
Update README: add entropy/DRBG status and test docs
JC-000 Mar 16, 2026
2e490c6
Merge pull request #4 from JC-000/feature/entropy-init
JC-000 Mar 16, 2026
8f15886
Add X.509 cert parsing + ECDSA P-256/P-384 signature verification
JC-000 Mar 16, 2026
d4adbe9
Fix ECDSA verify bugs and harden test harness for long operations
JC-000 Mar 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
__pycache__/
*.pyc
ip65-build/*.o
ip65-build/*.bin
ip65-build/*.map
3 changes: 3 additions & 0 deletions .gitmodules
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
[submodule "ip65"]
path = ip65
url = https://github.com/cc65/ip65.git
28 changes: 16 additions & 12 deletions Makefile
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,35 +6,39 @@ VICE = x64sc
SRC_DIR = src
BUILD_DIR = build
IP65_BUILD = ip65-build
IP65_SRC = ip65
IP65_DIR = ip65

PRG = $(BUILD_DIR)/c64-https.prg
LABELS = $(BUILD_DIR)/labels.txt
IP65_BIN = $(IP65_BUILD)/ip65-c64.bin

# ACME sources
ASM_SRCS = $(wildcard $(SRC_DIR)/*.asm)

.PHONY: all clean run ip65
.PHONY: all clean run ip65-libs

all: $(PRG)

$(PRG): $(ASM_SRCS) | $(BUILD_DIR)
$(PRG): $(ASM_SRCS) $(IP65_BIN) | $(BUILD_DIR)
cd $(SRC_DIR) && $(ACME) -f cbm -o ../$(PRG) --vicelabels ../$(LABELS) main.asm

$(BUILD_DIR):
mkdir -p $(BUILD_DIR)

# Build ip65 libraries (only if not already built)
ip65-libs:
cd $(IP65_DIR) && $(MAKE) -C ip65 && $(MAKE) -C drivers

# Build ip65 binary blob
$(IP65_BIN): $(IP65_BUILD)/ip65_stub.s $(IP65_BUILD)/ip65.cfg ip65-libs
cd $(IP65_BUILD) && $(CA65) -I ../$(IP65_DIR) ip65_stub.s -o ip65_stub.o
cd $(IP65_BUILD) && $(LD65) -C ip65.cfg -o ip65-c64.bin -m ip65-c64.map \
ip65_stub.o ../$(IP65_DIR)/ip65/ip65_tcp.lib \
../$(IP65_DIR)/drivers/ip65_c64.lib c64.lib

run: $(PRG)
$(VICE) -autostart $(PRG)

# ip65 binary blob build (requires cc65 toolchain + ip65 submodule)
# Uncomment and adjust when ip65 submodule is added:
# ip65: $(IP65_BUILD)/ip65-c64.bin
#
# $(IP65_BUILD)/ip65-c64.bin: $(IP65_SRC)/ip65/*.s $(IP65_SRC)/drivers/*.s
# cd $(IP65_SRC) && make
# # TODO: link ip65_tcp.lib + c64rrnet.lib with custom config
# # $(LD65) -C $(IP65_BUILD)/ip65.cfg -o $@ ...

clean:
rm -f $(BUILD_DIR)/c64-https.prg $(BUILD_DIR)/labels.txt
rm -f $(IP65_BUILD)/ip65_stub.o $(IP65_BUILD)/ip65-c64.bin $(IP65_BUILD)/ip65-c64.map
44 changes: 32 additions & 12 deletions README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -97,28 +97,48 @@ The Makefile automatically builds ip65 from the submodule into a flat binary blo

## Project Status

This project is in early development. Current status:
Current status (24.8 KB binary, 487 labels):

- [x] Project structure and build system
- [ ] ip65 submodule integration and binary blob build
- [ ] Network wrapper with ZP save/restore
- [ ] Copy and adapt crypto primitives from sibling projects
- [ ] HKDF-SHA256 implementation
- [ ] TLS 1.3 record layer
- [ ] TLS 1.3 handshake (ClientHello, key exchange, Finished)
- [ ] TLS 1.3 application data encryption/decryption
- [x] ip65 submodule integration — 6.8 KB binary blob at $2000 (TCP/UDP/DNS/DHCP/ARP + RR-Net CS8900a)
- [x] Network wrapper with ZP time-sharing — save/restore $02-$1B around ip65 calls
- [x] Crypto primitives — ChaCha20, Poly1305, AEAD (from c64-wireguard), SHA-256, HMAC-DRBG (from c64-aes256-ecdsa), x25519/fe25519 (from c64-wireguard)
- [x] HKDF-SHA256 — Extract, Expand, Expand-Label, Derive-Secret (RFC 5869 + TLS 1.3)
- [x] TLS 1.3 record layer — encrypt/decrypt with ChaCha20-Poly1305, nonce construction, sequence numbers
- [x] TLS 1.3 handshake — ClientHello builder (x25519 key_share, SNI), ServerHello parser, streaming transcript hash
- [x] TLS 1.3 key schedule — early/handshake/master secrets, traffic key derivation, Finished MAC (RFC 8446 §7.1)
- [x] ECDHE x25519 key exchange — generate keypair, compute shared secret
- [x] TLS 1.3 key schedule integration testing — all 9 HKDF steps verified against RFC 8448 + Finished MAC
- [x] Entropy/DRBG initialization — SID voice 3 noise + CIA timer seeding at boot, DRBG fills for TLS random values
- [x] X.509 certificate parsing — DER parser extracts TBS, public key, signature (r,s), curve ID for P-256 and P-384
- [x] ECDSA signature verification — P-256 and P-384, full verify (s⁻¹, scalar mul, point add, Jacobian→affine)
- [ ] HTTP/1.1 GET request
- [ ] End-to-end HTTPS GET demo

### Known Issues

- **VICE 3.9 crashes** on 5+ chained HMAC-SHA256 calls within a single continuous execution (confirmed with proper test harness port allocation — not port contention). Workaround: test key schedule step-by-step via individual jsr() calls. All 9 steps produce correct RFC 8448 values. Real C64 hardware is unaffected.

## Test Automation

Tests use the [`c64-test-harness`](../c64-test-harness) package to drive VICE via its remote text monitor, the same infrastructure used by c64-aes256-ecdsa and c64-wireguard.
152 tests across 7 suites + 2 diagnostic suites, using the [`c64-test-harness`](../c64-test-harness) package to drive VICE via its remote text monitor. All tests log VICE PID and port for multi-agent safety.

```bash
pip install -e ../c64-test-harness
python3 tools/test_net.py # Network layer tests (requires VICE + virtual RR-Net)
python3 tools/test_tls.py # TLS handshake tests
python3 tools/test_hkdf.py # HKDF-SHA256 unit tests

# Run all suites in parallel (5 VICE instances, ~2.5 min wall time)
python3 tools/run_all_tests.py --workers 5

# Individual suites
python3 tools/test_net.py # 55 tests: ip65 integration, ZP save/restore, ring buffer
python3 tools/test_sha256.py # 7 tests: NIST vectors, boundary cases, random inputs
python3 tools/test_crypto.py # 22 tests: ChaCha20/Poly1305/AEAD RFC 7539 vectors + random
python3 tools/test_hkdf.py # 12 tests: RFC 5869 vectors, TLS 1.3 key schedule, random
python3 tools/test_tls_record.py # 17 tests: nonce, seq increment, encrypt/decrypt, roundtrips
python3 tools/test_x509.py # 11 tests: DER parse P-256/P-384, ECDSA verify (valid+tampered+boundary)
python3 tools/test_tls_handshake.py # 21 tests: transcript hash, ClientHello, ServerHello, key schedule (RFC 8448), Finished MAC
python3 tools/test_keyschedule_steps.py # 9 tests: key schedule step-by-step (RFC 8448 vectors)
python3 tools/test_entropy.py # 7 tests: SID/CIA hardware init, DRBG seeding, output quality
```

## Related Projects
Expand Down
Binary file modifiedbuild/c64-https.prg
Binary file not shown.
Loading