mirror of
https://github.com/therealpaulgg/ssh-sync-server.git
synced 2026-04-25 07:35:49 +03:00
[PR #37] Add post-quantum cryptography support with ML-DSA-65 #38
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ssh-sync-server#38
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/therealpaulgg/ssh-sync-server/pull/37
Author: @therealpaulgg
Created: 2/13/2026
Status: 🔄 Open
Base:
main← Head:claude/quantum-resistant-key-generation-XTHBx📝 Commits (9)
6e371a5Add quantum-resistant ML-DSA-65 JWT verification and key migration supportc4e4131debugging updates6936a16start using shared library for my sanitya3cccd7remove go work83d5435Pivot to hybrid ECDH P-256 + ML-KEM-768 key exchange scheme98355f2Revert "Pivot to hybrid ECDH P-256 + ML-KEM-768 key exchange scheme"e51e88fno hybrid crypto, MLDSA65 -> MLDSAa3d5ebcPR comments2ff252edeslop📊 Changes
21 files changed (+968 additions, -171 deletions)
View changed files
📝
Dockerfile(+1 -1)➕
Dockerfile.debug(+24 -0)📝
docker-compose.yaml(+1 -1)📝
go.mod(+8 -26)📝
go.sum(+8 -52)➕
pkg/crypto/pqc.go(+151 -0)➕
pkg/crypto/pqc_test.go(+193 -0)📝
pkg/database/repository/machine.go(+11 -0)📝
pkg/database/repository/machinemock.go(+14 -0)📝
pkg/web/live/main.go(+31 -22)📝
pkg/web/middleware/auth.go(+62 -21)📝
pkg/web/middleware/auth_test.go(+164 -28)📝
pkg/web/router/routes/data.go(+1 -1)📝
pkg/web/router/routes/data_test.go(+1 -1)📝
pkg/web/router/routes/machine.go(+42 -1)📝
pkg/web/router/routes/machine_test.go(+108 -1)📝
pkg/web/router/routes/setup.go(+7 -14)📝
pkg/web/router/routes/setup_test.go(+63 -0)📝
pkg/web/router/routes/user.go(+1 -1)📝
pkg/web/router/routes/user_test.go(+1 -1)...and 1 more files
📄 Description
Summary
Adds post-quantum cryptography support using ML-DSA (FIPS 204, MLDSA65 parameter set) for JWT authentication alongside existing ECDSA. The server can now accept, validate, and verify ML-DSA-signed JWTs while maintaining full backward compatibility.
Key Changes
New PQC crypto package (
pkg/crypto/pqc.go)filippo.io/mldsalibrary (not Cloudflare CIRCL)DetectKeyType(): Identifies key type from PEM block ("MLDSA PUBLIC KEY"vs EC)ValidatePublicKey(): Validates both ECDSA and ML-DSA public keysParseMLDSAPublicKey(): Parses ML-DSA public key from PEMDetectJWTAlgorithm(): Extracts algorithm from JWT headerExtractJWTClaims(): Manually parses JWT claims (for algorithms unsupported by lestrrat-go/jwx)VerifyMLDSAJWT(): Verifies ML-DSA signatures and token expirationAuthentication middleware (
pkg/web/middleware/auth.go)ES256/ES512→ lestrrat-go/jwx;MLDSA→ manual verification"MLDSA"(matches the filippo.io/mldsa parameter set naming)Machine key management (
pkg/web/router/routes/machine.go)PUT /api/v1/machines/keyendpoint for updating a machine's public keyValidatePublicKey()(supports both ECDSA and ML-DSA)Setup route (
pkg/web/router/routes/setup.go)ValidatePublicKey()during machine registration to accept both key typesRepository (
pkg/database/repository/machine.go)UpdateMachinePublicKey(id, publicKey)toMachineRepositoryinterface and implementationPublicKey []byte(no separate encapsulation key)WebSocket challenge flow (
pkg/web/live/main.go)pqc.ValidatePublicKey()before storingTest utilities (
pkg/web/testutils/main.go)GenerateMLDSATestKeys(): Creates ML-DSA keypairs for testingEncodeMLDSAToPem(): PEM-encodes ML-DSA public keys ("MLDSA PUBLIC KEY"block type)GenerateMLDSATestToken()/GenerateExpiredMLDSATestToken(): Creates signed ML-DSA JWTsTest coverage
pkg/crypto/pqc_test.go: Tests for key detection, parsing, JWT algorithm detection, claims extraction, and signature verificationImplementation Notes
"MLDSA PUBLIC KEY"for clear identification🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.