Last active
March 24, 2018 05:26
-
-
Save KevinWMatthews/9e57aa78e6f706c12071e533e42ca8c4 to your computer and use it in GitHub Desktop.
Overview and example of mocking an AES encryption library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bird's-eye view of overall production code | |
Cmac_Calculate() | |
{ | |
aes_handle = Aes128_Create(key, iv) | |
// Perform several technical operations (CmacOps) per the CMAC spec. | |
CmacOps_GenerateSubkeys(aes_handle, *subkey1, *subkey2) | |
//... | |
CmacOps_ApplyCbcMac(aes_handle, <relevant_parameters>) | |
//... | |
} | |
// The individual steps are internally complex - test each. | |
// Test an individual operation; high level view | |
TEST(generate_subkeys) | |
{ | |
// Setup | |
aes_handle = Aes128_Create(key, iv) | |
// Test | |
CmacOps_GenerateSubkeys(aes_handle, *subkey1, *subkey2) | |
// Verify | |
CHECK(expected, subkey1) | |
CHECK(expected, subkey2) | |
// Teardown | |
Aes128_Destroy(aes_handle) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment