|
33 | 33 | import com.ibm.engine.model.context.AlgorithmParameterContext; |
34 | 34 | import com.ibm.engine.model.context.CipherContext; |
35 | 35 | import com.ibm.engine.model.context.SecretKeyContext; |
| 36 | +import com.ibm.mapper.model.AuthenticatedEncryption; |
36 | 37 | import com.ibm.mapper.model.BlockCipher; |
37 | 38 | import com.ibm.mapper.model.BlockSize; |
38 | 39 | import com.ibm.mapper.model.DigestSize; |
39 | 40 | import com.ibm.mapper.model.INode; |
40 | 41 | import com.ibm.mapper.model.KeyLength; |
41 | 42 | import com.ibm.mapper.model.Mac; |
42 | 43 | import com.ibm.mapper.model.MessageDigest; |
| 44 | +import com.ibm.mapper.model.Mode; |
43 | 45 | import com.ibm.mapper.model.Oid; |
44 | 46 | import com.ibm.mapper.model.PasswordBasedKeyDerivationFunction; |
45 | 47 | import com.ibm.mapper.model.PasswordLength; |
@@ -290,91 +292,102 @@ public void asserts( |
290 | 292 | assertThat(value0_1_1.asString()).isEqualTo("AES"); |
291 | 293 |
|
292 | 294 | DetectionStore<JavaCheck, Tree, Symbol, JavaFileScannerContext> store_1_2 = |
293 | | - getStoreOfValueType(TagSize.class, store_1.getChildren()); |
294 | | - assertThat(store_1_2.getDetectionValues()).hasSize(1); |
| 295 | + getStoreOfValueType(com.ibm.engine.model.Mode.class, store_1.getChildren()); |
| 296 | + assertThat(store_1_2.getDetectionValues()).hasSize(2); |
295 | 297 | assertThat(store_1_2.getDetectionValueContext()) |
296 | 298 | .isInstanceOf(AlgorithmParameterContext.class); |
297 | 299 | IValue<Tree> value0_1_2 = store_1_2.getDetectionValues().get(0); |
298 | | - assertThat(value0_1_2).isInstanceOf(TagSize.class); |
299 | | - assertThat(value0_1_2.asString()).isEqualTo("128"); |
| 300 | + assertThat(value0_1_2).isInstanceOf(com.ibm.engine.model.Mode.class); |
| 301 | + assertThat(value0_1_2.asString()).isEqualTo("GCM"); |
| 302 | + |
| 303 | + IValue<Tree> value1_1_2 = store_1_2.getDetectionValues().get(1); |
| 304 | + assertThat(value1_1_2).isInstanceOf(TagSize.class); |
| 305 | + assertThat(value1_1_2.asString()).isEqualTo("128"); |
300 | 306 |
|
301 | 307 | /* |
302 | 308 | * Translation |
303 | 309 | */ |
304 | 310 |
|
305 | 311 | assertThat(nodes).hasSize(1); |
306 | 312 |
|
307 | | - // BlockCipher |
308 | | - INode blockCipherNode1 = nodes.get(0); |
309 | | - assertThat(blockCipherNode1.getKind()).isEqualTo(BlockCipher.class); |
310 | | - assertThat(blockCipherNode1.getChildren()).hasSize(6); |
311 | | - assertThat(blockCipherNode1.asString()).isEqualTo("AES128"); |
| 313 | + // AuthenticatedEncryption |
| 314 | + INode authenticatedEncryptionNode = nodes.get(0); |
| 315 | + assertThat(authenticatedEncryptionNode.getKind()) |
| 316 | + .isEqualTo(AuthenticatedEncryption.class); |
| 317 | + assertThat(authenticatedEncryptionNode.getChildren()).hasSize(7); |
| 318 | + assertThat(authenticatedEncryptionNode.asString()).isEqualTo("AES128-GCM"); |
| 319 | + |
| 320 | + // KeyLength under AuthenticatedEncryption |
| 321 | + INode keyLengthNode = authenticatedEncryptionNode.getChildren().get(KeyLength.class); |
| 322 | + assertThat(keyLengthNode).isNotNull(); |
| 323 | + assertThat(keyLengthNode.getChildren()).isEmpty(); |
| 324 | + assertThat(keyLengthNode.asString()).isEqualTo("128"); |
312 | 325 |
|
313 | | - // TagLength under BlockCipher |
314 | | - INode tagLengthNode = blockCipherNode1.getChildren().get(TagLength.class); |
| 326 | + // TagLength under AuthenticatedEncryption |
| 327 | + INode tagLengthNode = authenticatedEncryptionNode.getChildren().get(TagLength.class); |
315 | 328 | assertThat(tagLengthNode).isNotNull(); |
316 | 329 | assertThat(tagLengthNode.getChildren()).isEmpty(); |
317 | 330 | assertThat(tagLengthNode.asString()).isEqualTo("128"); |
318 | 331 |
|
319 | | - // Oid under BlockCipher |
320 | | - INode oidNode2 = blockCipherNode1.getChildren().get(Oid.class); |
321 | | - assertThat(oidNode2).isNotNull(); |
322 | | - assertThat(oidNode2.getChildren()).isEmpty(); |
323 | | - assertThat(oidNode2.asString()).isEqualTo("2.16.840.1.101.3.4.1"); |
| 332 | + // Oid under AuthenticatedEncryption |
| 333 | + INode oidNode = authenticatedEncryptionNode.getChildren().get(Oid.class); |
| 334 | + assertThat(oidNode).isNotNull(); |
| 335 | + assertThat(oidNode.getChildren()).isEmpty(); |
| 336 | + assertThat(oidNode.asString()).isEqualTo("2.16.840.1.101.3.4.1"); |
324 | 337 |
|
325 | | - // Decrypt under BlockCipher |
326 | | - INode decryptNode = blockCipherNode1.getChildren().get(Decrypt.class); |
| 338 | + // Decrypt under AuthenticatedEncryption |
| 339 | + INode decryptNode = authenticatedEncryptionNode.getChildren().get(Decrypt.class); |
327 | 340 | assertThat(decryptNode).isNotNull(); |
328 | 341 | assertThat(decryptNode.getChildren()).isEmpty(); |
329 | 342 | assertThat(decryptNode.asString()).isEqualTo("DECRYPT"); |
330 | 343 |
|
331 | | - // SecretKey under BlockCipher |
332 | | - INode secretKeyNode2 = blockCipherNode1.getChildren().get(SecretKey.class); |
333 | | - assertThat(secretKeyNode2).isNotNull(); |
334 | | - assertThat(secretKeyNode2.getChildren()).hasSize(1); |
335 | | - assertThat(secretKeyNode2.asString()).isEqualTo("AES"); |
336 | | - |
337 | | - // BlockCipher under SecretKey under BlockCipher |
338 | | - INode blockCipherNode2 = secretKeyNode2.getChildren().get(BlockCipher.class); |
339 | | - assertThat(blockCipherNode2).isNotNull(); |
340 | | - assertThat(blockCipherNode2.getChildren()).hasSize(4); |
341 | | - assertThat(blockCipherNode2.asString()).isEqualTo("AES128"); |
342 | | - |
343 | | - // Oid under BlockCipher under SecretKey under BlockCipher |
344 | | - INode oidNode3 = blockCipherNode2.getChildren().get(Oid.class); |
345 | | - assertThat(oidNode3).isNotNull(); |
346 | | - assertThat(oidNode3.getChildren()).isEmpty(); |
347 | | - assertThat(oidNode3.asString()).isEqualTo("2.16.840.1.101.3.4.1"); |
348 | | - |
349 | | - // KeyGeneration under BlockCipher under SecretKey under BlockCipher |
350 | | - INode keyGenerationNode2 = blockCipherNode2.getChildren().get(KeyGeneration.class); |
351 | | - assertThat(keyGenerationNode2).isNotNull(); |
352 | | - assertThat(keyGenerationNode2.getChildren()).isEmpty(); |
353 | | - assertThat(keyGenerationNode2.asString()).isEqualTo("KEYGENERATION"); |
354 | | - |
355 | | - // KeyLength under BlockCipher under SecretKey under BlockCipher |
356 | | - INode keyLengthNode2 = blockCipherNode2.getChildren().get(KeyLength.class); |
357 | | - assertThat(keyLengthNode2).isNotNull(); |
358 | | - assertThat(keyLengthNode2.getChildren()).isEmpty(); |
359 | | - assertThat(keyLengthNode2.asString()).isEqualTo("128"); |
360 | | - |
361 | | - // BlockSize under BlockCipher under SecretKey under BlockCipher |
362 | | - INode blockSizeNode2 = blockCipherNode2.getChildren().get(BlockSize.class); |
363 | | - assertThat(blockSizeNode2).isNotNull(); |
364 | | - assertThat(blockSizeNode2.getChildren()).isEmpty(); |
365 | | - assertThat(blockSizeNode2.asString()).isEqualTo("128"); |
366 | | - |
367 | | - // KeyLength under BlockCipher |
368 | | - INode keyLengthNode3 = blockCipherNode1.getChildren().get(KeyLength.class); |
369 | | - assertThat(keyLengthNode3).isNotNull(); |
370 | | - assertThat(keyLengthNode3.getChildren()).isEmpty(); |
371 | | - assertThat(keyLengthNode3.asString()).isEqualTo("128"); |
372 | | - |
373 | | - // BlockSize under BlockCipher |
374 | | - INode blockSizeNode3 = blockCipherNode1.getChildren().get(BlockSize.class); |
375 | | - assertThat(blockSizeNode3).isNotNull(); |
376 | | - assertThat(blockSizeNode3.getChildren()).isEmpty(); |
377 | | - assertThat(blockSizeNode3.asString()).isEqualTo("128"); |
| 344 | + // Mode under AuthenticatedEncryption |
| 345 | + INode modeNode = authenticatedEncryptionNode.getChildren().get(Mode.class); |
| 346 | + assertThat(modeNode).isNotNull(); |
| 347 | + assertThat(modeNode.getChildren()).isEmpty(); |
| 348 | + assertThat(modeNode.asString()).isEqualTo("GCM"); |
| 349 | + |
| 350 | + // SecretKey under AuthenticatedEncryption |
| 351 | + INode secretKeyNode = authenticatedEncryptionNode.getChildren().get(SecretKey.class); |
| 352 | + assertThat(secretKeyNode).isNotNull(); |
| 353 | + assertThat(secretKeyNode.getChildren()).hasSize(1); |
| 354 | + assertThat(secretKeyNode.asString()).isEqualTo("AES"); |
| 355 | + |
| 356 | + // BlockCipher under SecretKey under AuthenticatedEncryption |
| 357 | + INode blockCipherNode = secretKeyNode.getChildren().get(BlockCipher.class); |
| 358 | + assertThat(blockCipherNode).isNotNull(); |
| 359 | + assertThat(blockCipherNode.getChildren()).hasSize(4); |
| 360 | + assertThat(blockCipherNode.asString()).isEqualTo("AES128"); |
| 361 | + |
| 362 | + // KeyLength under BlockCipher under SecretKey under AuthenticatedEncryption |
| 363 | + INode keyLengthNode1 = blockCipherNode.getChildren().get(KeyLength.class); |
| 364 | + assertThat(keyLengthNode1).isNotNull(); |
| 365 | + assertThat(keyLengthNode1.getChildren()).isEmpty(); |
| 366 | + assertThat(keyLengthNode1.asString()).isEqualTo("128"); |
| 367 | + |
| 368 | + // Oid under BlockCipher under SecretKey under AuthenticatedEncryption |
| 369 | + INode oidNode1 = blockCipherNode.getChildren().get(Oid.class); |
| 370 | + assertThat(oidNode1).isNotNull(); |
| 371 | + assertThat(oidNode1.getChildren()).isEmpty(); |
| 372 | + assertThat(oidNode1.asString()).isEqualTo("2.16.840.1.101.3.4.1"); |
| 373 | + |
| 374 | + // KeyGeneration under BlockCipher under SecretKey under AuthenticatedEncryption |
| 375 | + INode keyGenerationNode = blockCipherNode.getChildren().get(KeyGeneration.class); |
| 376 | + assertThat(keyGenerationNode).isNotNull(); |
| 377 | + assertThat(keyGenerationNode.getChildren()).isEmpty(); |
| 378 | + assertThat(keyGenerationNode.asString()).isEqualTo("KEYGENERATION"); |
| 379 | + |
| 380 | + // BlockSize under BlockCipher under SecretKey under AuthenticatedEncryption |
| 381 | + INode blockSizeNode = blockCipherNode.getChildren().get(BlockSize.class); |
| 382 | + assertThat(blockSizeNode).isNotNull(); |
| 383 | + assertThat(blockSizeNode.getChildren()).isEmpty(); |
| 384 | + assertThat(blockSizeNode.asString()).isEqualTo("128"); |
| 385 | + |
| 386 | + // BlockSize under AuthenticatedEncryption |
| 387 | + INode blockSizeNode1 = authenticatedEncryptionNode.getChildren().get(BlockSize.class); |
| 388 | + assertThat(blockSizeNode1).isNotNull(); |
| 389 | + assertThat(blockSizeNode1.getChildren()).isEmpty(); |
| 390 | + assertThat(blockSizeNode1.asString()).isEqualTo("128"); |
378 | 391 | } |
379 | 392 | } |
380 | 393 | } |
0 commit comments