Skip to content

Commit 0906ef5

Browse files
committed
aes teset changes
1 parent 425dd92 commit 0906ef5

1 file changed

Lines changed: 28 additions & 20 deletions

File tree

cas-dotnet-sdk-tests/AES/AESWrapperTests.cs

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,12 @@ public void Aes256MatchesNistEncryptVectors(byte[] nonce, byte[] key, byte[] pla
165165

166166
public static IEnumerable<object[]> AES128NistVectors()
167167
{
168-
return LoadGcmEncryptVectors("gcmEncryptExtIV128.rsp");
168+
return LoadGcmEncryptVectors("gcmDecrypt128.rsp");
169169
}
170170

171171
public static IEnumerable<object[]> AES256NistVectors()
172172
{
173-
return LoadGcmEncryptVectors("gcmEncryptExtIV256.rsp");
173+
return LoadGcmEncryptVectors("gcmDecrypt256.rsp");
174174
}
175175

176176
private static IEnumerable<object[]> LoadGcmEncryptVectors(string fileName)
@@ -183,6 +183,7 @@ private static IEnumerable<object[]> LoadGcmEncryptVectors(string fileName)
183183
string? ptHex = null;
184184
int? ivBitLength = null;
185185
int? aadBitLength = null;
186+
bool isFailureCase = false;
186187

187188
foreach (string rawLine in File.ReadLines(path))
188189
{
@@ -216,6 +217,7 @@ private static IEnumerable<object[]> LoadGcmEncryptVectors(string fileName)
216217
ref ivHex,
217218
ref ctHex,
218219
ref ptHex);
220+
isFailureCase = false;
219221
continue;
220222
}
221223

@@ -234,24 +236,6 @@ private static IEnumerable<object[]> LoadGcmEncryptVectors(string fileName)
234236
if (line.StartsWith("CT =", StringComparison.Ordinal))
235237
{
236238
ctHex = line["CT =".Length..].Trim();
237-
238-
if (ivBitLength != 96 || aadBitLength != 0)
239-
{
240-
continue;
241-
}
242-
243-
if (string.IsNullOrEmpty(keyHex) || string.IsNullOrEmpty(ivHex) || string.IsNullOrEmpty(ctHex) || string.IsNullOrEmpty(ptHex))
244-
{
245-
continue;
246-
}
247-
248-
yield return new object[]
249-
{
250-
HexToBytes(ivHex),
251-
HexToBytes(keyHex),
252-
HexToBytes(ptHex),
253-
HexToBytes(ctHex)
254-
};
255239
continue;
256240
}
257241

@@ -260,12 +244,36 @@ private static IEnumerable<object[]> LoadGcmEncryptVectors(string fileName)
260244
continue;
261245
}
262246

247+
if (line.Equals("FAIL", StringComparison.Ordinal))
248+
{
249+
isFailureCase = true;
250+
continue;
251+
}
252+
263253
if (!line.StartsWith("PT =", StringComparison.Ordinal))
264254
{
265255
continue;
266256
}
267257

268258
ptHex = line["PT =".Length..].Trim();
259+
260+
if (isFailureCase || ivBitLength != 96 || aadBitLength != 0)
261+
{
262+
continue;
263+
}
264+
265+
if (string.IsNullOrEmpty(keyHex) || string.IsNullOrEmpty(ivHex) || ctHex is null || ptHex is null)
266+
{
267+
continue;
268+
}
269+
270+
yield return new object[]
271+
{
272+
HexToBytes(ivHex),
273+
HexToBytes(keyHex),
274+
HexToBytes(ptHex),
275+
HexToBytes(ctHex)
276+
};
269277
}
270278
}
271279

0 commit comments

Comments
 (0)