fix: correct keyring fallback logic in try_decrypt_data#70
Open
yahao333 wants to merge 1 commit into
Open
Conversation
The try_decrypt_data function had a critical bug where both step 1 and step 2 called load_key_from_file(), causing the same key to be tried twice while the keyring key was never attempted. This prevented successful decryption of data encrypted with the keyring key. Now the function: 1. First tries the file key 2. On failure, falls back to the keyring key Fixes data decryption failures for bot.enc and mcp_config.enc files when the encryption key is stored in the system keyring.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改动
修复 try_decrypt_data 函数的密钥回退逻辑错误
在
src/crypto/keystore.rs中,try_decrypt_data函数存在致命 bug:第1步和第2步都调用load_key_from_file(),导致完全相同的密钥被尝试两次,而 keyring 中的密钥从未被尝试。当使用系统 keyring 存储加密密钥时,加密的数据将无法被解密。问题分析
修复前:
问题:
load_key_from_file()修复后:
影响范围
此 bug 影响以下加密数据的解密:
bot.enc- 企业微信机器人凭证mcp_config.enc- MCP 配置缓存关联 Issue: #
检查项