Skip to content

Feat: [default-algo] Change default algo to aes.#159

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:release/eaglefrom
GongHeng2017:202512191749-eagle-fix
Dec 22, 2025
Merged

Feat: [default-algo] Change default algo to aes.#159
deepin-bot[bot] merged 1 commit intolinuxdeepin:release/eaglefrom
GongHeng2017:202512191749-eagle-fix

Conversation

@GongHeng2017
Copy link
Copy Markdown
Contributor

@GongHeng2017 GongHeng2017 commented Dec 22, 2025

-- Change default algo to aes.

Log: add feature
Task: https://pms.uniontech.com/task-view-384955.html

Summary by Sourcery

New Features:

  • Default disk encryption now falls back to AES instead of SM4 when no algorithm is explicitly configured.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Dec 22, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR switches the disk-encryption default algorithm from SM4 to AES in the file manager’s encryption utility, updating both the default configuration value and the fallback logic when an unsupported algorithm is configured.

Sequence diagram for resolving disk encryption algorithm with new AES default

sequenceDiagram
    participant Caller as DiskEncryptFeature
    participant ConfigUtils as config_utils
    participant DConfig as DtkCoreDConfig

    Caller->>ConfigUtils: cipherType()
    activate ConfigUtils
    ConfigUtils->>DConfig: create(org.deepin.dde.file-manager, org.deepin.dde.file-manager.diskencrypt)
    activate DConfig
    DConfig-->>ConfigUtils: cfg instance

    ConfigUtils->>DConfig: value(encryptAlgorithm, aes)
    DConfig-->>ConfigUtils: cipher_value
    deactivate DConfig

    ConfigUtils->>ConfigUtils: supportedCipher = [sm4, aes]
    alt cipher_value not in supportedCipher
        ConfigUtils-->>Caller: aes
    else cipher_value in supportedCipher
        ConfigUtils-->>Caller: cipher_value
    end
    deactivate ConfigUtils
Loading

File-Level Changes

Change Details Files
Change default disk-encryption algorithm from SM4 to AES and adjust validation fallback.
  • Update the default encryptAlgorithm configuration value from SM4 to AES when reading from DConfig.
  • Keep the supported cipher list as ["sm4", "aes"] but change the fallback return value to AES when the configured cipher is unsupported.
src/dde-file-manager/dfmplugin-disk-encrypt-entry/utils/encryptutils.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

,我将从多个角度对这次代码变更进行审查:

  1. 语法逻辑:
  • 代码逻辑正确,没有语法错误
  • 配置文件和代码修改保持一致,都从"sm4"改为"aes"
  • 默认值和回退值都统一改为"aes",逻辑一致
  1. 代码质量:
  • 代码风格统一,命名规范
  • 错误处理合理,当配置值不支持时回退到默认值
  • 使用了DConfig框架进行配置管理,符合项目架构
  1. 代码性能:
  • 配置读取操作简单,性能影响很小
  • 字符串比较使用QStringList::contains(),效率可以接受
  1. 代码安全:
  • 从SM4改为AES加密算法,这是一个重要的安全变更:
    • SM4是中国国家标准密码算法
    • AES是国际通用的加密标准
    • AES通常被认为更安全,有更广泛的实现和审计
    • AES的性能通常更好,有硬件加速支持

改进建议:

  1. 建议添加详细的注释说明为什么从SM4改为AES,以及这个变更带来的影响

  2. 可以考虑将支持的加密算法列表定义为常量,便于维护:

static const QStringList kSupportedCipher = { "sm4", "aes" };
  1. 可以添加日志记录,记录实际使用的加密算法:
qDebug() << "Using cipher algorithm:" << cipher;
  1. 考虑添加配置值的验证函数:
bool isValidCipher(const QString& cipher) {
    return kSupportedCipher.contains(cipher);
}
  1. 建议在配置文件中添加注释,说明可用的加密算法选项:
"encryptAlgorithm" : {
    "value": "aes",  // supported values: "sm4", "aes"
    ...
}

这些变更主要是将默认加密算法从SM4改为AES,这是一个合理的安全改进。AES作为国际标准,有更广泛的实现和审计,通常被认为是更安全的选择。建议按照上述改进建议进一步完善代码。

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Consider extracting the default cipher value (currently "aes") into a named constant or config-level definition so it isn’t duplicated in both the DConfig default and the fallback return path.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider extracting the default cipher value (currently "aes") into a named constant or config-level definition so it isn’t duplicated in both the DConfig default and the fallback return path.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: GongHeng2017, itsXuSt, max-lvs

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@GongHeng2017
Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot deepin-bot Bot merged commit 69f9e0a into linuxdeepin:release/eagle Dec 22, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants