ssl_init.c revision 1.1.1.1
1#include "config.h" 2 3#include "ntp.h" 4 5#ifdef OPENSSL 6# include "openssl/err.h" 7# include "openssl/rand.h" 8# include "openssl/evp.h" 9#endif 10 11#include "unity.h" 12 13 14static const size_t TEST_MD5_DIGEST_LENGTH = 16; 15static const size_t TEST_SHA1_DIGEST_LENGTH = 20; 16 17 18// keytype_from_text() 19void test_MD5KeyTypeWithoutDigestLength() { 20 TEST_ASSERT_EQUAL(KEY_TYPE_MD5, keytype_from_text("MD5", NULL)); 21} 22 23void test_MD5KeyTypeWithDigestLength() { 24 size_t digestLength; 25 size_t expected = TEST_MD5_DIGEST_LENGTH; 26 27 TEST_ASSERT_EQUAL(KEY_TYPE_MD5, keytype_from_text("MD5", &digestLength)); 28 TEST_ASSERT_EQUAL(expected, digestLength); 29} 30 31 32void test_SHA1KeyTypeWithDigestLength() { 33#ifdef OPENSSL 34 size_t digestLength; 35 size_t expected = TEST_SHA1_DIGEST_LENGTH; 36 37 TEST_ASSERT_EQUAL(NID_sha, keytype_from_text("SHA", &digestLength)); 38 TEST_ASSERT_EQUAL(expected, digestLength); 39 /* OPENSSL */ 40#else 41 TEST_IGNORE_MESSAGE("Skipping because OPENSSL isn't defined"); 42#endif 43} 44 45 46// keytype_name() 47void test_MD5KeyName() { 48 TEST_ASSERT_EQUAL_STRING("MD5", keytype_name(KEY_TYPE_MD5)); 49} 50 51void test_SHA1KeyName() { 52#ifdef OPENSSL 53 TEST_ASSERT_EQUAL_STRING("SHA", keytype_name(NID_sha)); 54#else 55 TEST_IGNORE_MESSAGE("Skipping because OPENSSL isn't defined"); 56#endif /* OPENSSL */ 57} 58 59