feat(e2e): 端对端加密完全对齐老项目 — cipher_guard_sdk 修正 + EncryptionManager 集成
Some checks failed
CI / Lint (push) Has been cancelled
Some checks failed
CI / Lint (push) Has been cancelled
修正 cipher_guard_sdk 4 个关键密码学差异使其与老 Flutter 项目 (im-client-im-dev) 和 iOS
EncryptionManager 完全互操作:
1. AES: 显式 SIC/CTR 模式 + 16 zero-byte IV(原 SDK 用随机 IV + KDF 派生密钥)
2. RSA: bare RSAEngine 无 PKCS1 padding(原 SDK 用 PKCS1Encoding)
3. Session key: 32-char alphanumeric ASCII(原 SDK 用 base64 random bytes)
4. Wire format: base64(ciphertext) 无 IV 前缀
新增 EncryptionManager:
- Per-chat round-based key chain(最多 10 rounds/chat,FIFO 淘汰)
- 登录后自动 setup:RSA 密钥对生成/存储 + 公钥上传 + chat 密钥拉取解密
- API 集成:cipher/v2/key/my, key/set, chat/my
- 消息加密返回 JSON envelope {"round":N,"data":"<base64>"}
- 消息解密兼容 JSON envelope + legacy raw base64
集成到消息流:
- SendMessageUseCase: 发送前加密 content → wireContent
- WsMessageService: 收到消息后解密 content + lastMsg
- 无密钥时 fallback 到明文(对齐 iOS 行为)
注意:/app/api/cipher/v2/key/set 仍为预发布接口,仅测试阶段使用
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -56,6 +56,18 @@ class ApiPaths {
|
||||
static const favoriteFetchByIds = '/app/api/favorite/favorite';
|
||||
static const favoriteTags = '/app/api/favorite/tags';
|
||||
|
||||
// ── Cipher (E2E Encryption) ──
|
||||
// 注意:/app/api/cipher/v2/key/set 是预发布接口,仅测试阶段使用
|
||||
static const cipherKeyMy = '/app/api/cipher/v2/key/my';
|
||||
static const cipherKeySet = '/app/api/cipher/v2/key/set';
|
||||
static const cipherKeyGets = '/app/api/cipher/v2/key/gets';
|
||||
static const cipherChatGet = '/app/api/cipher/v2/chat/get';
|
||||
static const cipherChatMy = '/app/api/cipher/v2/chat/my';
|
||||
static const cipherChatUpdate = '/app/api/cipher/v2/chat/update';
|
||||
static const cipherChatRequest = '/app/api/cipher/v2/chat/request';
|
||||
static const cipherChatSessionsExist =
|
||||
'/app/api/cipher/v2/chat/sessions_exist';
|
||||
|
||||
// ── WebSocket ──
|
||||
static const wsConnect = '/websock/open';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user