Commit 3c9cd072 authored by Ben Sartor's avatar Ben Sartor Committed by johan

updated and added more tests for mandatory algo types

Signed-off-by: johan's avatarJohan Pascal <johan.pascal@belledonne-communications.com>
parent 3fc28f45
......@@ -559,9 +559,11 @@ void test_algoAgreement(void) {
CU_TEST(testAlgoTypeWithContext(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_DH2k}, 1, ZRTP_KEYAGREEMENT_DH2k));
CU_TEST(testAlgoTypeWithContext(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_DH3k}, 1, ZRTP_KEYAGREEMENT_DH3k));
CU_TEST(testAlgoTypeWithContext(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_EC25}, 1, ZRTP_KEYAGREEMENT_DH3k));
CU_TEST(testAlgoTypeWithContext(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_DH2k, ZRTP_KEYAGREEMENT_DH3k}, 2, ZRTP_KEYAGREEMENT_DH2k));
CU_TEST(testAlgoTypeWithContext(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_EC25, ZRTP_KEYAGREEMENT_DH3k}, 2, ZRTP_KEYAGREEMENT_DH3k));
CU_TEST(testAlgoTypeWithContext(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_DH2k, ZRTP_KEYAGREEMENT_EC52}, 2, ZRTP_KEYAGREEMENT_DH2k));
CU_TEST(testAlgoTypeWithContext(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_EC52, ZRTP_KEYAGREEMENT_EC25}, 2, ZRTP_KEYAGREEMENT_DH3k));
CU_TEST(testAlgoTypeWithContext(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_EC25, ZRTP_KEYAGREEMENT_EC52, ZRTP_KEYAGREEMENT_DH3k}, 3, ZRTP_KEYAGREEMENT_DH3k));
CU_TEST(testAlgoTypeWithContext(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_EC52, ZRTP_KEYAGREEMENT_EC25, ZRTP_KEYAGREEMENT_DH3k, ZRTP_KEYAGREEMENT_DH2k}, 4, ZRTP_KEYAGREEMENT_DH3k));
CU_TEST(testAlgoTypeWithContext(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_DH2k, ZRTP_KEYAGREEMENT_DH3k, ZRTP_KEYAGREEMENT_EC25, ZRTP_KEYAGREEMENT_EC52}, 4, ZRTP_KEYAGREEMENT_DH2k));
......@@ -587,10 +589,12 @@ void test_algoAgreement(void) {
CU_TEST(testAlgoTypeWithContext(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_AES1}, 1, ZRTP_CIPHER_AES1));
CU_TEST(testAlgoTypeWithContext(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_AES3}, 1, ZRTP_CIPHER_AES3));
CU_TEST(testAlgoTypeWithContext(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_2FS1}, 1, ZRTP_CIPHER_AES1));
CU_TEST(testAlgoTypeWithContext(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_AES3, ZRTP_CIPHER_AES1}, 2, ZRTP_CIPHER_AES3));
CU_TEST(testAlgoTypeWithContext(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_AES1, ZRTP_CIPHER_AES3}, 2, ZRTP_CIPHER_AES1));
CU_TEST(testAlgoTypeWithContext(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_2FS3, ZRTP_CIPHER_AES1}, 2, ZRTP_CIPHER_AES1));
CU_TEST(testAlgoTypeWithContext(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_AES3, ZRTP_CIPHER_AES2, ZRTP_CIPHER_AES1}, 3, ZRTP_CIPHER_AES3));
CU_TEST(testAlgoTypeWithContext(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_2FS3, ZRTP_CIPHER_2FS2, ZRTP_CIPHER_2FS1}, 3, ZRTP_CIPHER_AES1));
CU_TEST(testAlgoTypeWithContext(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_2FS3, ZRTP_CIPHER_2FS2, ZRTP_CIPHER_2FS1, ZRTP_CIPHER_AES3, ZRTP_CIPHER_AES2, ZRTP_CIPHER_AES1}, 6, ZRTP_CIPHER_AES3));
CU_TEST(testAlgoTypeWithContext(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_2FS3, ZRTP_CIPHER_2FS2, ZRTP_CIPHER_2FS1, ZRTP_CIPHER_AES1, ZRTP_CIPHER_AES2, ZRTP_CIPHER_AES3}, 6, ZRTP_CIPHER_AES1));
......@@ -635,20 +639,20 @@ static int testAlgoSetterGetter(uint8_t algoType, uint8_t contextTypes[7], uint8
void test_algoSetterGetter(void) {
/* key agreement type */
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_DH2k}, 1, (uint8_t []){ZRTP_KEYAGREEMENT_DH2k}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_DH2k}, 1, (uint8_t []){ZRTP_KEYAGREEMENT_DH2k, ZRTP_KEYAGREEMENT_DH3k}, 2));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_DH3k}, 1, (uint8_t []){ZRTP_KEYAGREEMENT_DH3k}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_EC25}, 1, NULL, 0));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_EC38}, 1, NULL, 0));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_EC52}, 1, NULL, 0));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_Prsh}, 1, NULL, 0));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_Mult}, 1, (uint8_t []){ZRTP_KEYAGREEMENT_Mult}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_EC25}, 1, (uint8_t []){ZRTP_KEYAGREEMENT_DH3k}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_EC38}, 1, (uint8_t []){ZRTP_KEYAGREEMENT_DH3k}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_EC52}, 1, (uint8_t []){ZRTP_KEYAGREEMENT_DH3k}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_Prsh}, 1, (uint8_t []){ZRTP_KEYAGREEMENT_DH3k}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_Mult}, 1, (uint8_t []){ZRTP_KEYAGREEMENT_Mult, ZRTP_KEYAGREEMENT_DH3k}, 2));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_DH3k, ZRTP_KEYAGREEMENT_DH2k}, 2, (uint8_t []){ZRTP_KEYAGREEMENT_DH3k, ZRTP_KEYAGREEMENT_DH2k}, 2));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_DH2k, ZRTP_KEYAGREEMENT_DH3k}, 2, (uint8_t []){ZRTP_KEYAGREEMENT_DH2k, ZRTP_KEYAGREEMENT_DH3k}, 2));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_DH3k, ZRTP_KEYAGREEMENT_DH3k}, 2, (uint8_t []){ZRTP_KEYAGREEMENT_DH3k}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_DH3k, ZRTP_KEYAGREEMENT_EC25}, 2, (uint8_t []){ZRTP_KEYAGREEMENT_DH3k}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_EC25, ZRTP_KEYAGREEMENT_DH3k}, 2, (uint8_t []){ZRTP_KEYAGREEMENT_DH3k}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_EC25, ZRTP_KEYAGREEMENT_EC52}, 2, NULL, 0));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_EC25, ZRTP_KEYAGREEMENT_EC52}, 2, (uint8_t []){ZRTP_KEYAGREEMENT_DH3k}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_EC52, ZRTP_KEYAGREEMENT_EC25, ZRTP_KEYAGREEMENT_DH3k, ZRTP_KEYAGREEMENT_DH2k}, 4, (uint8_t []){ZRTP_KEYAGREEMENT_DH3k, ZRTP_KEYAGREEMENT_DH2k}, 2));
CU_TEST(testAlgoSetterGetter(ZRTP_KEYAGREEMENT_TYPE, (uint8_t []){ZRTP_KEYAGREEMENT_Prsh, ZRTP_KEYAGREEMENT_EC52, ZRTP_KEYAGREEMENT_EC38, ZRTP_KEYAGREEMENT_EC25, ZRTP_KEYAGREEMENT_DH3k, ZRTP_KEYAGREEMENT_DH2k}, 6, (uint8_t []){ZRTP_KEYAGREEMENT_DH3k, ZRTP_KEYAGREEMENT_DH2k}, 2));
......@@ -657,18 +661,18 @@ void test_algoSetterGetter(void) {
/* cipher type */
CU_TEST(testAlgoSetterGetter(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_AES1}, 1, (uint8_t []){ZRTP_CIPHER_AES1}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_AES2}, 1, NULL, 0));
CU_TEST(testAlgoSetterGetter(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_AES3}, 1, (uint8_t []){ZRTP_CIPHER_AES3}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_2FS1}, 1, NULL, 0));
CU_TEST(testAlgoSetterGetter(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_2FS2}, 1, NULL, 0));
CU_TEST(testAlgoSetterGetter(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_2FS3}, 1, NULL, 0));
CU_TEST(testAlgoSetterGetter(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_AES2}, 1, (uint8_t []){ZRTP_CIPHER_AES1}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_AES3}, 1, (uint8_t []){ZRTP_CIPHER_AES3, ZRTP_CIPHER_AES1}, 2));
CU_TEST(testAlgoSetterGetter(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_2FS1}, 1, (uint8_t []){ZRTP_CIPHER_AES1}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_2FS2}, 1, (uint8_t []){ZRTP_CIPHER_AES1}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_2FS3}, 1, (uint8_t []){ZRTP_CIPHER_AES1}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_AES3, ZRTP_CIPHER_AES3}, 2, (uint8_t []){ZRTP_CIPHER_AES3}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_AES3, ZRTP_CIPHER_AES3}, 2, (uint8_t []){ZRTP_CIPHER_AES3, ZRTP_CIPHER_AES1}, 2));
CU_TEST(testAlgoSetterGetter(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_AES3, ZRTP_CIPHER_AES1}, 2, (uint8_t []){ZRTP_CIPHER_AES3, ZRTP_CIPHER_AES1}, 2));
CU_TEST(testAlgoSetterGetter(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_AES1, ZRTP_CIPHER_AES3}, 2, (uint8_t []){ZRTP_CIPHER_AES1, ZRTP_CIPHER_AES3}, 2));
CU_TEST(testAlgoSetterGetter(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_AES1, ZRTP_CIPHER_AES2}, 2, (uint8_t []){ZRTP_CIPHER_AES1}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_AES1, ZRTP_CIPHER_2FS3}, 2, (uint8_t []){ZRTP_CIPHER_AES1}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_AES2, ZRTP_CIPHER_2FS3}, 2, NULL, 0));
CU_TEST(testAlgoSetterGetter(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_AES2, ZRTP_CIPHER_2FS3}, 2, (uint8_t []){ZRTP_CIPHER_AES1}, 1));
CU_TEST(testAlgoSetterGetter(ZRTP_CIPHERBLOCK_TYPE, (uint8_t []){ZRTP_CIPHER_2FS3, ZRTP_CIPHER_2FS2, ZRTP_CIPHER_2FS1, ZRTP_CIPHER_AES3, ZRTP_CIPHER_AES2, ZRTP_CIPHER_AES1}, 6, (uint8_t []){ZRTP_CIPHER_AES3, ZRTP_CIPHER_AES1}, 2));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment