Skip to content

Commit

Permalink
GCM 还没准备好示例代码,暂时禁用
Browse files Browse the repository at this point in the history
  • Loading branch information
Finb committed Mar 12, 2024
1 parent ab61dda commit 116d8cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Controller/CryptoSettingViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class CryptoSettingViewModel: ViewModel, ViewModelType {
return Output(
initial: Driver.just((
algorithmList: [Algorithm.aes128, Algorithm.aes192, Algorithm.aes256],
modeList: ["CBC", "ECB", "GCM"],
modeList: ["CBC", "ECB", /* "GCM" */], // GCM 还没准备好示例代码,暂时禁用
paddingList: ["pkcs7"],
initialFields: dependencies.settingFieldRelay.value
)),
Expand Down
11 changes: 4 additions & 7 deletions Model/Algorithm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,10 @@ struct AESCryptoModel {

var iv = ""
if ["CBC", "GCM"].contains(cryptoFields.mode) {
var expectIVLength = 0
if cryptoFields.mode == "CBC" {
expectIVLength = 16
}
else if cryptoFields.mode == "GCM" {
expectIVLength = 12
}
let expectIVLength = [
"CBC": 16,
"GCM": 12
][cryptoFields.mode] ?? 0

if let ivField = cryptoFields.iv, ivField.count == expectIVLength {
iv = ivField
Expand Down

0 comments on commit 116d8cf

Please sign in to comment.