GCM 还没准备好示例代码,暂时禁用

This commit is contained in:
Fin 2024-03-12 15:08:29 +08:00
parent ab61dda125
commit 116d8cf970
2 changed files with 5 additions and 8 deletions

View File

@ -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
)),

View File

@ -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