Deleted Added
full compact
packetProcessing.c (330106) packetProcessing.c (338530)
1#include "config.h"
2
3#include "sntptest.h"
4#include "networking.h"
5#include "ntp_stdlib.h"
6#include "unity.h"
7
8#define CMAC "AES128CMAC"

--- 450 unchanged lines hidden (view full) ---

459 process_pkt(&testpkt.p, &testsock, pkt_len,
460 MODE_SERVER, &testspkt.p, "UnitTest"));
461}
462
463
464void
465test_CorrectAuthenticatedPacketCMAC(void)
466{
1#include "config.h"
2
3#include "sntptest.h"
4#include "networking.h"
5#include "ntp_stdlib.h"
6#include "unity.h"
7
8#define CMAC "AES128CMAC"

--- 450 unchanged lines hidden (view full) ---

459 process_pkt(&testpkt.p, &testsock, pkt_len,
460 MODE_SERVER, &testspkt.p, "UnitTest"));
461}
462
463
464void
465test_CorrectAuthenticatedPacketCMAC(void)
466{
467#if defined(OPENSSL) && defined(ENABLE_CMAC)
468
467 PrepareAuthenticationTest(30, CMAC_LENGTH, CMAC, "abcdefghijklmnop");
468 TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
469
470 int pkt_len = LEN_PKT_NOMAC;
471
472 /* Prepare the packet. */
473 testpkt.p.exten[0] = htonl(30);
474 int mac_len = make_mac(&testpkt.p, pkt_len,
475 MAX_MAC_LEN, key_ptr,
476 &testpkt.p.exten[1]);
477
478 pkt_len += 4 + mac_len;
479
480 TEST_ASSERT_EQUAL(pkt_len,
481 process_pkt(&testpkt.p, &testsock, pkt_len,
482 MODE_SERVER, &testspkt.p, "UnitTest"));
469 PrepareAuthenticationTest(30, CMAC_LENGTH, CMAC, "abcdefghijklmnop");
470 TEST_ASSERT_TRUE(ENABLED_OPT(AUTHENTICATION));
471
472 int pkt_len = LEN_PKT_NOMAC;
473
474 /* Prepare the packet. */
475 testpkt.p.exten[0] = htonl(30);
476 int mac_len = make_mac(&testpkt.p, pkt_len,
477 MAX_MAC_LEN, key_ptr,
478 &testpkt.p.exten[1]);
479
480 pkt_len += 4 + mac_len;
481
482 TEST_ASSERT_EQUAL(pkt_len,
483 process_pkt(&testpkt.p, &testsock, pkt_len,
484 MODE_SERVER, &testspkt.p, "UnitTest"));
485
486#else
487
488 TEST_IGNORE_MESSAGE("OpenSSL CMAC not used, skipping...");
489
490#endif /* OPENSSL */
483}
484
491}
492