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( return Output(
initial: Driver.just(( initial: Driver.just((
algorithmList: [Algorithm.aes128, Algorithm.aes192, Algorithm.aes256], algorithmList: [Algorithm.aes128, Algorithm.aes192, Algorithm.aes256],
modeList: ["CBC", "ECB", "GCM"], modeList: ["CBC", "ECB", /* "GCM" */], // GCM
paddingList: ["pkcs7"], paddingList: ["pkcs7"],
initialFields: dependencies.settingFieldRelay.value initialFields: dependencies.settingFieldRelay.value
)), )),

View File

@ -67,13 +67,10 @@ struct AESCryptoModel {
var iv = "" var iv = ""
if ["CBC", "GCM"].contains(cryptoFields.mode) { if ["CBC", "GCM"].contains(cryptoFields.mode) {
var expectIVLength = 0 let expectIVLength = [
if cryptoFields.mode == "CBC" { "CBC": 16,
expectIVLength = 16 "GCM": 12
} ][cryptoFields.mode] ?? 0
else if cryptoFields.mode == "GCM" {
expectIVLength = 12
}
if let ivField = cryptoFields.iv, ivField.count == expectIVLength { if let ivField = cryptoFields.iv, ivField.count == expectIVLength {
iv = ivField iv = ivField