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>
82 lines
2.6 KiB
YAML
82 lines
2.6 KiB
YAML
name: cipher_guard_sdk
|
|
description: "CipherGuard SDK - 端對端加密 Flutter 插件,提供 RSA/AES 加密解密功能"
|
|
version: 0.0.2
|
|
resolution: workspace
|
|
homepage:
|
|
|
|
environment:
|
|
sdk: ^3.11.0
|
|
flutter: '>=3.38.4'
|
|
|
|
dependencies:
|
|
flutter:
|
|
sdk: flutter
|
|
plugin_platform_interface: ^2.0.2
|
|
pointycastle: ^3.9.1
|
|
encrypt: ^5.0.3
|
|
asn1lib: ^1.5.3
|
|
shared_preferences: ^2.5.3
|
|
# crypto removed — MD5 implemented inline to avoid extra dependency
|
|
|
|
dev_dependencies:
|
|
freezed: ^3.0.0
|
|
json_serializable: ^6.7.1
|
|
build_runner: ^2.4.6
|
|
flutter_test:
|
|
sdk: flutter
|
|
flutter_lints: ^6.0.0
|
|
|
|
# For information on the generic Dart part of this file, see the
|
|
# following page: https://dart.dev/tools/pub/pubspec
|
|
|
|
# The following section is specific to Flutter packages.
|
|
flutter:
|
|
# This section identifies this Flutter project as a plugin project.
|
|
# The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.)
|
|
# which should be registered in the plugin registry. This is required for
|
|
# using method channels.
|
|
# The Android 'package' specifies package in which the registered class is.
|
|
# This is required for using method channels on Android.
|
|
# The 'ffiPlugin' specifies that native code should be built and bundled.
|
|
# This is required for using `dart:ffi`.
|
|
# All these are used by the tooling to maintain consistency when
|
|
# adding or updating assets for this project.
|
|
plugin:
|
|
platforms:
|
|
android:
|
|
package: com.example.cipher_guard_sdk
|
|
pluginClass: CipherGuardSdkPlugin
|
|
ios:
|
|
pluginClass: CipherGuardSdkPlugin
|
|
|
|
# To add assets to your plugin package, add an assets section, like this:
|
|
# assets:
|
|
# - images/a_dot_burr.jpeg
|
|
# - images/a_dot_ham.jpeg
|
|
#
|
|
# For details regarding assets in packages, see
|
|
# https://flutter.dev/to/asset-from-package
|
|
#
|
|
# An image asset can refer to one or more resolution-specific "variants", see
|
|
# https://flutter.dev/to/resolution-aware-images
|
|
|
|
# To add custom fonts to your plugin package, add a fonts section here,
|
|
# in this "flutter" section. Each entry in this list should have a
|
|
# "family" key with the font family name, and a "fonts" key with a
|
|
# list giving the asset and other descriptors for the font. For
|
|
# example:
|
|
# fonts:
|
|
# - family: Schyler
|
|
# fonts:
|
|
# - asset: fonts/Schyler-Regular.ttf
|
|
# - asset: fonts/Schyler-Italic.ttf
|
|
# style: italic
|
|
# - family: Trajan Pro
|
|
# fonts:
|
|
# - asset: fonts/TrajanPro.ttf
|
|
# - asset: fonts/TrajanPro_Bold.ttf
|
|
# weight: 700
|
|
#
|
|
# For details regarding fonts in packages, see
|
|
# https://flutter.dev/to/font-from-package
|