[code-style] apply clang-format

This commit is contained in:
Jonathan Hui
2018-02-09 21:43:42 +00:00
parent f8e866c65c
commit 69d98d4a53
401 changed files with 13393 additions and 13112 deletions
+38 -74
View File
@@ -41,49 +41,30 @@
*/
void TestMacBeaconFrame(void)
{
uint8_t key[] =
{
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
uint8_t key[] = {
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
};
uint8_t test[] =
{
0x08, 0xD0, 0x84, 0x21, 0x43, 0x01, 0x00, 0x00,
0x00, 0x00, 0x48, 0xDE, 0xAC, 0x02, 0x05, 0x00,
0x00, 0x00, 0x55, 0xCF, 0x00, 0x00, 0x51, 0x52,
0x53, 0x54, 0x22, 0x3B, 0xC1, 0xEC, 0x84, 0x1A,
0xB5, 0x53
};
uint8_t test[] = {0x08, 0xD0, 0x84, 0x21, 0x43, 0x01, 0x00, 0x00, 0x00, 0x00, 0x48, 0xDE,
0xAC, 0x02, 0x05, 0x00, 0x00, 0x00, 0x55, 0xCF, 0x00, 0x00, 0x51, 0x52,
0x53, 0x54, 0x22, 0x3B, 0xC1, 0xEC, 0x84, 0x1A, 0xB5, 0x53};
uint8_t encrypted[] =
{
0x08, 0xD0, 0x84, 0x21, 0x43, 0x01, 0x00, 0x00,
0x00, 0x00, 0x48, 0xDE, 0xAC, 0x02, 0x05, 0x00,
0x00, 0x00, 0x55, 0xCF, 0x00, 0x00, 0x51, 0x52,
0x53, 0x54, 0x22, 0x3B, 0xC1, 0xEC, 0x84, 0x1A,
0xB5, 0x53
};
uint8_t encrypted[] = {0x08, 0xD0, 0x84, 0x21, 0x43, 0x01, 0x00, 0x00, 0x00, 0x00, 0x48, 0xDE,
0xAC, 0x02, 0x05, 0x00, 0x00, 0x00, 0x55, 0xCF, 0x00, 0x00, 0x51, 0x52,
0x53, 0x54, 0x22, 0x3B, 0xC1, 0xEC, 0x84, 0x1A, 0xB5, 0x53};
uint8_t decrypted[] =
{
0x08, 0xD0, 0x84, 0x21, 0x43, 0x01, 0x00, 0x00,
0x00, 0x00, 0x48, 0xDE, 0xAC, 0x02, 0x05, 0x00,
0x00, 0x00, 0x55, 0xCF, 0x00, 0x00, 0x51, 0x52,
0x53, 0x54, 0x22, 0x3B, 0xC1, 0xEC, 0x84, 0x1A,
0xB5, 0x53
};
uint8_t decrypted[] = {0x08, 0xD0, 0x84, 0x21, 0x43, 0x01, 0x00, 0x00, 0x00, 0x00, 0x48, 0xDE,
0xAC, 0x02, 0x05, 0x00, 0x00, 0x00, 0x55, 0xCF, 0x00, 0x00, 0x51, 0x52,
0x53, 0x54, 0x22, 0x3B, 0xC1, 0xEC, 0x84, 0x1A, 0xB5, 0x53};
otInstance *instance = testInitInstance();
otInstance * instance = testInitInstance();
ot::Crypto::AesCcm aesCcm;
uint32_t headerLength = sizeof(test) - 8;
uint32_t payloadLength = 0;
uint8_t tagLength = 8;
uint32_t headerLength = sizeof(test) - 8;
uint32_t payloadLength = 0;
uint8_t tagLength = 8;
uint8_t nonce[] =
{
0xAC, 0xDE, 0x48, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x05, 0x02,
uint8_t nonce[] = {
0xAC, 0xDE, 0x48, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x02,
};
VerifyOrQuit(instance != NULL, "Null OpenThread instance");
@@ -93,15 +74,13 @@ void TestMacBeaconFrame(void)
aesCcm.Header(test, headerLength);
aesCcm.Finalize(test + headerLength, &tagLength);
VerifyOrQuit(memcmp(test, encrypted, sizeof(encrypted)) == 0,
"TestMacBeaconFrame encrypt failed");
VerifyOrQuit(memcmp(test, encrypted, sizeof(encrypted)) == 0, "TestMacBeaconFrame encrypt failed");
aesCcm.Init(headerLength, payloadLength, tagLength, nonce, sizeof(nonce));
aesCcm.Header(test, headerLength);
aesCcm.Finalize(test + headerLength, &tagLength);
VerifyOrQuit(memcmp(test, decrypted, sizeof(decrypted)) == 0,
"TestMacBeaconFrame decrypt failed");
VerifyOrQuit(memcmp(test, decrypted, sizeof(decrypted)) == 0, "TestMacBeaconFrame decrypt failed");
testFreeInstance(instance);
}
@@ -111,46 +90,33 @@ void TestMacBeaconFrame(void)
*/
void TestMacCommandFrame()
{
uint8_t key[] =
{
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
uint8_t key[] = {
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
};
uint8_t test[] =
{
0x2B, 0xDC, 0x84, 0x21, 0x43, 0x02, 0x00, 0x00,
0x00, 0x00, 0x48, 0xDE, 0xAC, 0xFF, 0xFF, 0x01,
0x00, 0x00, 0x00, 0x00, 0x48, 0xDE, 0xAC, 0x06,
0x05, 0x00, 0x00, 0x00, 0x01, 0xCE, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
uint8_t test[] = {
0x2B, 0xDC, 0x84, 0x21, 0x43, 0x02, 0x00, 0x00, 0x00, 0x00, 0x48, 0xDE, 0xAC,
0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x48, 0xDE, 0xAC, 0x06, 0x05, 0x00,
0x00, 0x00, 0x01, 0xCE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
uint32_t headerLength = 29, payloadLength = 1;
uint8_t tagLength = 8;
uint8_t tagLength = 8;
uint8_t encrypted[] =
{
0x2B, 0xDC, 0x84, 0x21, 0x43, 0x02, 0x00, 0x00,
0x00, 0x00, 0x48, 0xDE, 0xAC, 0xFF, 0xFF, 0x01,
0x00, 0x00, 0x00, 0x00, 0x48, 0xDE, 0xAC, 0x06,
0x05, 0x00, 0x00, 0x00, 0x01, 0xD8, 0x4F, 0xDE,
0x52, 0x90, 0x61, 0xF9, 0xC6, 0xF1,
uint8_t encrypted[] = {
0x2B, 0xDC, 0x84, 0x21, 0x43, 0x02, 0x00, 0x00, 0x00, 0x00, 0x48, 0xDE, 0xAC,
0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x48, 0xDE, 0xAC, 0x06, 0x05, 0x00,
0x00, 0x00, 0x01, 0xD8, 0x4F, 0xDE, 0x52, 0x90, 0x61, 0xF9, 0xC6, 0xF1,
};
uint8_t decrypted[] =
{
0x2B, 0xDC, 0x84, 0x21, 0x43, 0x02, 0x00, 0x00,
0x00, 0x00, 0x48, 0xDE, 0xAC, 0xFF, 0xFF, 0x01,
0x00, 0x00, 0x00, 0x00, 0x48, 0xDE, 0xAC, 0x06,
0x05, 0x00, 0x00, 0x00, 0x01, 0xCE, 0x4F, 0xDE,
0x52, 0x90, 0x61, 0xF9, 0xC6, 0xF1,
uint8_t decrypted[] = {
0x2B, 0xDC, 0x84, 0x21, 0x43, 0x02, 0x00, 0x00, 0x00, 0x00, 0x48, 0xDE, 0xAC,
0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x48, 0xDE, 0xAC, 0x06, 0x05, 0x00,
0x00, 0x00, 0x01, 0xCE, 0x4F, 0xDE, 0x52, 0x90, 0x61, 0xF9, 0xC6, 0xF1,
};
uint8_t nonce[] =
{
0xAC, 0xDE, 0x48, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x05, 0x06,
uint8_t nonce[] = {
0xAC, 0xDE, 0x48, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x06,
};
ot::Crypto::AesCcm aesCcm;
@@ -159,16 +125,14 @@ void TestMacCommandFrame()
aesCcm.Header(test, headerLength);
aesCcm.Payload(test + headerLength, test + headerLength, payloadLength, true);
aesCcm.Finalize(test + headerLength + payloadLength, &tagLength);
VerifyOrQuit(memcmp(test, encrypted, sizeof(encrypted)) == 0,
"TestMacCommandFrame encrypt failed\n");
VerifyOrQuit(memcmp(test, encrypted, sizeof(encrypted)) == 0, "TestMacCommandFrame encrypt failed\n");
aesCcm.Init(headerLength, payloadLength, tagLength, nonce, sizeof(nonce));
aesCcm.Header(test, headerLength);
aesCcm.Payload(test + headerLength, test + headerLength, payloadLength, false);
aesCcm.Finalize(test + headerLength + payloadLength, &tagLength);
VerifyOrQuit(memcmp(test, decrypted, sizeof(decrypted)) == 0,
"TestMacCommandFrame decrypt failed\n");
VerifyOrQuit(memcmp(test, decrypted, sizeof(decrypted)) == 0, "TestMacCommandFrame decrypt failed\n");
}
#ifdef ENABLE_TEST_MAIN