这是一个实验性项目,尚未经过正式安全审计。请勿将其用于任何关键仓库。
git-remote-pqcrypt 是一个加密的 Git 远程助手,类似于 gcrypt。它以加密形式存储 Git packfile 和仓库元数据。访问时使用抗量子 XWing 封装。
当前 crate 版本:0.2.0。
git-remote-pqcrypt init 创建仓库主密钥。git-remote-pqcrypt 远程助手使用 pqcrypt。远程存储的示例文件:
keys.json
manifest.enc
objects/
pack-.....pack.enc
keys.json 包含元数据和加密的主密钥封装信息。
从 Git 安装默认构建:
cargo install --git https://github.com/Torm0r/git-remote-pqcrypt --locked
此命令将 git-remote-pqcrypt 安装到 Cargo 的二进制目录,通常是 ~/.cargo/bin。
确保 Cargo 的二进制目录在您的 PATH 中,然后检查是否正常工作:
git-remote-pqcrypt --help
默认构建包含本地文件系统和 Git 后端存储支持。
要在类 Unix 系统上安装 SFTP 支持:
cargo install --git https://github.com/Torm0r/git-remote-pqcrypt --locked --features sftp
sftp 功能目前不支持 Windows。
使用默认后端支持构建:
cargo build --release
此构建包含本地文件系统和 Git 后端存储支持。
要在类 Unix 系统上构建 SFTP 支持:
cargo build --release --features sftp
将二进制文件安装到您的 PATH:
sudo cp target/release/git-remote-pqcrypt /usr/local/bin/
二进制文件名必须保持为 git-remote-pqcrypt,因为 Git 通过查找 git-remote-[name] 来发现远程助手。
检查是否正常工作:
git-remote-pqcrypt --help
git--features sftp 构建,且目前仅适用于类 Unix 系统进入现有的 Git 仓库或创建一个新仓库。
初始化 pqcrypt 存储。
本地路径:
git-remote-pqcrypt init pqcrypt:///path/to/encrypted-store
SFTP 需要以 sftp 功能构建,且目前仅支持类 Unix 系统:
git-remote-pqcrypt init pqcrypt::sftp://[email protected]/path/to/store
Git 后端:
git-remote-pqcrypt init pqcrypt::[email protected]:org/store.git
如果没有私钥,则会在 ~/.config/pqcrypt/key 生成一个,并打印公钥。
系统会提示输入一个可选的密钥备注,例如 personal 或 work-laptop。
初始化后,会添加一个名为 pqcrypt 的 Git 远程:
git remote -v
示例:
pqcrypt pqcrypt::/path/to/encrypted-store (fetch)
pqcrypt pqcrypt::/path/to/encrypted-store (push)
git push pqcrypt main
git clone pqcrypt::[email protected]:Torm0r/pqcrypt-test.git my-clone
他们需要使用以下命令生成密钥对:
git-remote-pqcrypt keygen
他们可以通过以下方式获取公钥:
git-remote-pqcrypt pubgen ~/.config/pqcrypt/key
或者复制 keygen 打印的公钥。
然后,一个现有的已授权用户将他们添加到仓库中:
git-remote-pqcrypt add-user <base64-public-key>
运行此命令查看更多选项:
git-remote-pqcrypt add-user -h
默认情况下,add-user 会在本地查找 URL 以 pqcrypt 开头的 Git 远程,并将公钥添加到底层存储中。
pqcrypt 根据 Git refspec 区分普通推送和强制推送。
普通推送会进行快进检查,如果会覆盖远程历史则会被拒绝。
Git 通过 git-remote-pqcrypt 二进制文件将 pqcrypt 作为远程助手调用。
当被 Git 调用时,助手期望使用 Git 使用的远程助手参数格式,例如:
git-remote-pqcrypt origin pqcrypt::/path/to/store
直接 CLI 子命令,如 init、add-user、keygen、pubgen 和 help,被视为普通用户命令,而非远程助手调用。
二进制入口点将任务委托给库运行时,因此应用程序逻辑可通过 crate 库以及已安装的二进制文件进行测试。
对于 Git 后端存储 URL,pqcrypt 在系统缓存目录下维护一个本地缓存,例如:
~/.cache/pqcrypt/
pqcrypt 在操作前从后端 Git 仓库获取加密状态,并在更新后推送加密状态。
如果检测到缓存损坏或缓存丢失,pqcrypt 会通过从后端 Git 仓库重新获取来自动重建缓存。
pqcrypt::、pqcrypt:// 和 pqcrypt: 均可接受,并在内部归一化为 pqcrypt::。
以下格式等效:
git-remote-pqcrypt init pqcrypt:///path/to/store
git-remote-pqcrypt init pqcrypt::/path/to/store
git-remote-pqcrypt init pqcrypt:/path/to/store
后端类型由存储路径决定:
示例:
pqcrypt::/tmp/store
pqcrypt:///tmp/store
pqcrypt:/tmp/store
pqcrypt::[email protected]:org/store.git
pqcrypt::https://github.com/org/store.git
pqcrypt::sftp://[email protected]/path/to/store
解密时,pqcrypt 按以下顺序查找私钥:
PQCRYPT_KEY_PATH 环境变量git config pqcrypt.keypath.pqcrypt/key~/.config/pqcrypt 中的任何匹配密钥文件(将全部尝试)对于多密钥设置,例如工作密钥和个人密钥:
git config pqcrypt.keypath ~/.config/pqcrypt/work-key
该密钥必须是 init 期间使用过的或通过 add-user 添加的密钥。
运行完整测试套件:
cargo test
在类 Unix 系统上启用 SFTP 运行:
cargo test --features sftp
某些依赖于类 Unix 本地路径行为的端到端测试会在 Windows 上被忽略。
GitHub Actions 在 Linux、macOS 和 Windows 上构建项目。工作流工件可能包含来自 CI 运行的二进制文件,但这些并非正式发布版本。
XChaCha20Poly1305 加密。XWing 为每个用户封装。0600。sftp 功能之后,目前不支持 Windows。ssh 和 git。| 模式 | 后端类型 | 备注 |
|---|
/local/path | 本地文件系统 | 默认 |
git@host:、*.git、https://git* | Git 后端 | 默认 |
sftp:// 或 ssh:// | SFTP | 需要 --features sftp;仅支持类 Unix 系统 |