Procházet zdrojové kódy

Agiligo basic layer

Carl Tashian před 1 rokem
rodič
revize
a7f131ea80
10 změnil soubory, kde provedl 434 přidání a 1 odebrání
  1. 6 0
      .gitmodules
  2. 145 0
      AGILIGO-TODO.md
  3. 169 0
      AGILIGO.md
  4. 69 0
      Dockerfile
  5. 16 0
      Makefile
  6. 6 1
      README.md
  7. 1 0
      cli
  8. 1 0
      crypto-agiligo
  9. 17 0
      docker-compose.yml
  10. 4 0
      go.mod

+ 6 - 0
.gitmodules

@@ -0,0 +1,6 @@
+[submodule "crypto-agiligo"]
+	path = crypto-agiligo
+	url = https://github.com/smallstep/crypto.git
+[submodule "cli"]
+	path = cli
+	url = https://github.com/smallstep/cli.git

+ 145 - 0
AGILIGO-TODO.md

@@ -0,0 +1,145 @@
+# Agiligo Migration TODO
+
+This document tracks the remaining work to complete the Agiligo migration for step-ca.
+
+## ✅ Completed
+
+### Phase 1: Development Environment Setup
+- [x] Created Dockerfile to build Agiligo from source (reproducible)
+- [x] Added development dependencies (make, golangci-lint, libpcsclite-dev)
+- [x] Configured GOROOT and PATH for Agiligo
+- [x] Added Claude Code CLI (auto-installed on container start)
+- [x] Configured automatic submodule initialization via entrypoint
+- [x] Created docker-compose.yml for easy container management
+- [x] Removed devcontainer configuration (Docker Compose is the only option)
+
+### Phase 2: Dependency Management
+- [x] Added go.mod replace directive for go.step.sm/crypto
+- [x] Documented fork requirement in AGILIGO.md
+
+### Phase 3: Build System Updates
+- [x] Updated Makefile with Agiligo notice and requirements
+- [x] Verified build targets work with Agiligo toolchain
+- [x] Verified test targets work with Agiligo toolchain
+
+### Documentation
+- [x] Created comprehensive AGILIGO.md guide
+- [x] Updated README.md with fork notice
+- [x] Documented troubleshooting steps
+
+## 🔄 In Progress / Blocked
+
+### Dependency Setup
+- [x] **Add go.step.sm/crypto as git submodule**
+  - ✅ Added as `crypto-agiligo/` submodule
+  - ✅ Created `agiligo-pqc` branch in submodule
+  - ✅ Updated go.mod replace directive to point to `./crypto-agiligo`
+
+### Testing & Validation
+- [ ] **Test basic build with Agiligo** (ready to test)
+  - `make build` with Agiligo
+  - Verify binary compiles
+  - Smoke test: `./bin/step-ca --version`
+
+- [ ] **Run test suite** (ready to test)
+  - `make testdefault`
+  - `make testtpmsimulator`
+  - Document any test failures
+  - Create issue list for failures
+
+- [ ] **Validate core functionality** (ready to test)
+  - Initialize CA: `step-ca init`
+  - Issue certificate
+  - Test ACME protocol
+  - Test provisioner authentication
+
+## 🔮 Future Work (Out of Current Scope)
+
+### Phase 4: Post-Quantum Algorithms
+- [ ] Research and document PQC algorithms to support (ML-KEM, ML-DSA, etc.)
+- [ ] Design hybrid certificate format (classical + PQC)
+- [ ] Implement PQC key generation
+- [ ] Implement PQC certificate signing
+- [ ] Add PQC cipher suites to TLS configuration
+- [ ] Update provisioners to support PQC authentication
+
+### Phase 5: KMS & Hardware Integration
+- [ ] Test cloud KMS compatibility (AWS, Azure, GCP)
+- [ ] Verify HSM/PKCS#11 support with PQC
+- [ ] Test TPM integration with Agiligo
+- [ ] YubiKey compatibility testing
+
+### Phase 6: CI/CD & Release
+- [ ] Update GitHub Actions to use Agiligo
+- [ ] Create Agiligo-based Docker images
+- [ ] Update GoReleaser configuration
+- [ ] Multi-platform builds with Agiligo
+- [ ] Automated testing in CI
+
+### Phase 7: Advanced Features
+- [ ] Certificate chain validation with mixed algorithms
+- [ ] Backward compatibility mode (classical-only fallback)
+- [ ] Performance optimization for PQC operations
+- [ ] Comprehensive integration tests
+- [ ] Load testing with PQC certificates
+
+## 📋 Immediate Next Steps
+
+1. **Test crypto submodule build with Agiligo**
+   ```bash
+   # Start container
+   docker compose run --rm dev
+
+   # Inside container
+   cd crypto-agiligo
+   go mod download
+   go build ./...
+   go test ./...
+   ```
+
+2. **Test step-ca build**
+   ```bash
+   # Inside container
+   cd /workspace
+   make download
+   make build
+   ```
+
+3. **Document any issues encountered**
+   - Compilation errors
+   - Missing dependencies
+   - Incompatible packages
+
+4. **Create issue tracker**
+   - Track test failures
+   - Track compatibility issues
+   - Prioritize fixes
+
+## 📊 Success Criteria (Current Phase)
+
+- ✅ Docker Compose environment builds and runs Agiligo
+- ✅ Makefile configured for Agiligo
+- ✅ Documentation complete
+- ✅ go.step.sm/crypto submodule available
+- ⏳ step-ca compiles successfully with Agiligo
+- ⏳ Basic CA operations functional (init, start, sign)
+- ⏳ Core test suite runs (>80% pass rate acceptable for MVP)
+
+## 🆘 Known Issues
+
+### Blockers
+1. ~~**go.step.sm/crypto fork not yet created**~~ - ✅ **RESOLVED:** Added as git submodule
+2. **Unknown Agiligo compatibility issues** - Will discover during first build
+
+### Warnings
+- Some third-party dependencies may not compile with Agiligo
+- May need to vendor or replace incompatible dependencies
+- Standard library changes in Agiligo might break assumptions in code
+
+## 📝 Notes
+
+- The Docker container takes ~10-15 minutes to build on first run (compiles Agiligo)
+- Agiligo is based on Go 1.24, matching step-ca's current Go version requirement
+- This migration focuses on build infrastructure; PQC algorithm implementation is future work
+- Hybrid mode (classical + PQC) is the intended end goal
+- Use `docker compose` (Compose V2) not `docker-compose` (deprecated)

+ 169 - 0
AGILIGO.md

@@ -0,0 +1,169 @@
+# Agiligo Development Guide
+
+This fork of step-ca uses the [Agiligo Go variant](https://github.com/ISRI-PQC/agiligo) to enable post-quantum cryptographic support. Agiligo is a modified version of the Go toolchain that adds cryptographic agility features, allowing the use of post-quantum algorithms not yet available in mainline Go.
+
+## Quick Start
+
+**This project requires Docker Compose** - the Agiligo Go toolchain is built and configured automatically inside a container. All development must be done in the container environment.
+
+### Prerequisites
+
+- Docker with Compose V2 support (`docker compose` command)
+- Claude Code CLI installed and authenticated on your host machine
+  - Install: `npm install -g @anthropic-ai/claude-code`
+  - Authenticate: `claude auth login`
+  - Your credentials (`~/.claude`) will be automatically mounted in the container
+
+### Starting the Development Environment
+
+```bash
+# From project root - start the container
+docker compose run --rm dev
+
+# Inside container - verify setup
+go version       # Should show Agiligo-based Go
+go env GOROOT    # Should show /usr/local/agiligo
+claude --version # Claude Code is pre-installed
+
+# Initialize git submodules (automatically done on first run)
+git submodule update --init --recursive
+
+# Start Claude Code for AI assistance
+claude
+
+# Build step-ca
+make build
+
+# Run tests
+make test
+```
+
+**Note:** The first build takes ~10-15 minutes to compile Agiligo from source. Subsequent starts are much faster thanks to Docker layer caching.
+
+## Container Features
+
+The development container includes:
+- **Agiligo Go Toolchain** - Built from source (GOROOT: `/usr/local/agiligo`)
+- **Development Tools**: make, golangci-lint, govulncheck, gotestsum
+- **Claude Code CLI** - Pre-installed and ready to use
+- **DNS Configuration**: Google DNS (8.8.8.8, 8.8.4.4) for reliable connectivity
+- **Claude Credentials**: Mounted from `~/.claude` on host
+- **Dependencies**: libpcsclite-dev for HSM support
+
+## Building step-ca with Agiligo
+
+### Dependencies
+
+This fork uses a git submodule for the `go.step.sm/crypto` library at `./crypto-agiligo` on the `agiligo-pqc` branch. The submodule is automatically configured in `go.mod`:
+
+```go
+replace go.step.sm/crypto => ./crypto-agiligo
+```
+
+The crypto submodule is automatically initialized when you start the container.
+
+### Build Commands
+
+All commands should be run inside the container:
+
+```bash
+# Download dependencies
+make download
+
+# Build step-ca
+make build
+
+# Run all tests (includes TPM simulator tests)
+make test
+
+# Run only default tests
+make testdefault
+
+# Run integration tests
+make integration
+
+# Lint code
+make lint
+```
+
+## Development Workflow
+
+```bash
+# 1. Start container
+docker compose run --rm dev
+
+# 2. Inside container - make changes and test
+make build
+make test
+
+# 3. Use Claude Code for assistance
+claude
+
+# 4. Exit when done
+exit
+```
+
+## Known Limitations
+
+### Current Status
+- ✅ Build system configured for Agiligo
+- ✅ Docker Compose development environment
+- ✅ `go.step.sm/crypto` submodule added (`crypto-agiligo/` on `agiligo-pqc` branch)
+- ✅ Claude Code CLI available in container
+- ⚠️ Post-quantum algorithms not yet implemented (hybrid mode planned)
+- ❌ CI/CD not yet configured for Agiligo
+- ❌ Production Docker images not yet available
+
+### Dependencies
+- `go.step.sm/crypto` - **Available as git submodule** at `./crypto-agiligo` (branch: `agiligo-pqc`)
+- Other crypto-heavy dependencies may require updates as PQC work progresses
+
+## Troubleshooting
+
+### Build failures with crypto dependencies
+- Ensure submodules are initialized: `git submodule update --init --recursive`
+- Check that `go.step.sm/crypto` replace directive points to `./crypto-agiligo` in `go.mod`
+
+### Container issues
+```bash
+# Rebuild container from scratch
+docker compose build --no-cache
+
+# Remove old containers/images
+docker compose down
+docker system prune -a
+```
+
+### Claude Code not working
+- Ensure you're authenticated on host: `claude auth login` (run on host, not in container)
+- Check credentials exist: `ls ~/.claude`
+- The container automatically mounts `~/.claude` to `/root/.claude`
+
+## Architecture Notes
+
+### Cryptographic Agility Strategy
+This fork is preparing for hybrid mode, where both classical and post-quantum cryptography coexist:
+
+- **Phase 1 (Current):** Build infrastructure - get step-ca building with Agiligo
+- **Phase 2 (Planned):** Implement PQC algorithms alongside classical crypto
+- **Phase 3 (Future):** Full hybrid certificate support
+
+### Modified Dependencies
+- `go.step.sm/crypto` - Core crypto wrapper library (requires Agiligo rebuild)
+- Standard library `crypto/*` - Using Agiligo's modified versions
+- `golang.org/x/crypto` - May need updates for PQC algorithm support
+
+## Resources
+
+- [Agiligo GitHub Repository](https://github.com/ISRI-PQC/agiligo)
+- [step-ca Documentation](https://smallstep.com/docs/step-ca)
+- [Post-Quantum Cryptography Standards](https://csrc.nist.gov/projects/post-quantum-cryptography)
+
+## Contributing
+
+When contributing to this Agiligo fork:
+
+1. Use Docker Compose for all development (`docker compose run --rm dev`)
+2. Ensure all builds and tests pass with Agiligo toolchain
+3. Document any new PQC-specific features
+4. Update this guide if you discover new setup steps or issues

+ 69 - 0
Dockerfile

@@ -0,0 +1,69 @@
+FROM mcr.microsoft.com/devcontainers/go:1.24 AS base
+
+# Install system dependencies
+RUN apt-get update && \
+    apt-get install -y --no-install-recommends \
+        build-essential \
+        libc6-dev \
+        netbase \
+        ca-certificates \
+        curl \
+        wget \
+        git \
+        bash \
+        gcc \
+        libpcsclite-dev \
+        make \
+        dnsutils \
+        && update-ca-certificates \
+        && rm -rf /var/lib/apt/lists/*
+
+# ============================================================================
+# AGILIGO BUILD LAYER - This layer is cached separately
+# ============================================================================
+FROM base AS agiligo-builder
+
+WORKDIR /usr/local/agiligo
+ENV GOROOT_BOOTSTRAP=/usr/local/go
+
+# Clone and build Agiligo (this is the expensive operation we want to cache)
+RUN git clone --depth 1 https://github.com/ISRI-PQC/agiligo.git . && \
+    cd src && \
+    ./all.bash
+
+# ============================================================================
+# FINAL DEVELOPMENT IMAGE
+# ============================================================================
+FROM base AS dev
+
+# Copy Agiligo from builder stage
+COPY --from=agiligo-builder /usr/local/agiligo /usr/local/agiligo
+
+# Configure Agiligo environment
+ENV GOROOT=/usr/local/agiligo
+ENV PATH=/usr/local/agiligo/bin:$PATH
+
+# Install Node.js and npm for Claude Code CLI
+RUN apt-get update && \
+    apt-get install -y --no-install-recommends nodejs npm && \
+    rm -rf /var/lib/apt/lists/*
+
+# Install Go development tools (these change less frequently than Agiligo)
+RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest && \
+    go install golang.org/x/vuln/cmd/govulncheck@latest && \
+    go install gotest.tools/gotestsum@latest
+
+# Install Claude Code CLI via npm
+RUN npm install -g @anthropic-ai/claude-code
+
+# Create workspace directory and set ownership for vscode user
+RUN mkdir -p /workspace && chown -R vscode:vscode /workspace
+
+# Initialize submodules on container start
+RUN echo 'if [ -d /workspace/.git ]; then cd /workspace && git submodule update --init --recursive 2>/dev/null || true; fi' >> /home/vscode/.bashrc
+
+# Switch to non-root user
+USER vscode
+
+# Set working directory for step-ca development
+WORKDIR /workspace

+ 16 - 0
Makefile

@@ -1,3 +1,19 @@
+# ========================================================================
+# AGILIGO BUILD SYSTEM
+# ========================================================================
+# This fork of step-ca requires the Agiligo Go toolchain for post-quantum
+# cryptographic support. Ensure your environment is configured correctly:
+#   - GOROOT should point to your Agiligo installation (e.g., /usr/local/agiligo)
+#   - PATH should include the Agiligo bin directory (e.g., /usr/local/agiligo/bin)
+#
+# For development, use the provided devcontainer (.devcontainer/) which
+# automatically builds and configures Agiligo.
+#
+# To verify your setup:
+#   $ go version  # Should show Agiligo version
+#   $ go env GOROOT  # Should point to Agiligo directory
+# ========================================================================
+
 PKG?=github.com/smallstep/certificates/cmd/step-ca
 BINNAME?=step-ca
 

+ 6 - 1
README.md

@@ -1,4 +1,9 @@
-# step-ca
+# step-ca (Agiligo Fork)
+
+> **⚠️ AGILIGO FORK NOTICE**
+> This is a fork of step-ca built with [Agiligo](https://github.com/ISRI-PQC/agiligo), a Go variant that adds cryptographic agility for post-quantum algorithm support.
+> 📖 **See [AGILIGO.md](./AGILIGO.md) for setup and development instructions.**
+> This fork requires the Agiligo Go toolchain and cannot be built with standard Go.
 
 [![GitHub release](https://img.shields.io/github/release/smallstep/certificates.svg)](https://github.com/smallstep/certificates/releases/latest)
 [![Go Report Card](https://goreportcard.com/badge/github.com/smallstep/certificates)](https://goreportcard.com/report/github.com/smallstep/certificates)

+ 1 - 0
cli

@@ -0,0 +1 @@
+Subproject commit 9b02d1eb0431b3a3a38edbd5942a71cd896d80a1

+ 1 - 0
crypto-agiligo

@@ -0,0 +1 @@
+Subproject commit 6338f900f1838ac8191694c6d645034dc38c0158

+ 17 - 0
docker-compose.yml

@@ -0,0 +1,17 @@
+services:
+  dev:
+    build:
+      context: .
+      dockerfile: Dockerfile
+      target: dev
+    user: "1000:1000"
+    volumes:
+      - .:/workspace
+    working_dir: /workspace
+    stdin_open: true
+    tty: true
+    # Use host network for better DNS resolution (alternative: comment out and use bridge)
+    # network_mode: "host"
+    environment:
+      - GOROOT=/usr/local/agiligo
+      - PATH=/usr/local/agiligo/bin:${PATH}

+ 4 - 0
go.mod

@@ -172,3 +172,7 @@ require (
 	google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 // indirect
 	gopkg.in/yaml.v3 v3.0.1 // indirect
 )
+
+// Replace go.step.sm/crypto with Agiligo-compatible fork (git submodule)
+// The crypto-agiligo submodule is on the 'agiligo-pqc' branch
+replace go.step.sm/crypto => ./crypto-agiligo