aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPascal Bühler <pabuhler@cisco.com>2019-07-18 23:42:03 +0200
committerGitHub <noreply@github.com>2019-07-18 23:42:03 +0200
commite8629b718d9efe1ccc254754ca33c88199e1bbf3 (patch)
tree003de0e203f32d09c0c34051ad99af04e43db7f4
parente95cf6937f60e26c41c5416df35d1726939604b3 (diff)
parentadfe809d382658f158cf1e45616fd5bef132cf9c (diff)
downloadlibsrtp2-e8629b718d9efe1ccc254754ca33c88199e1bbf3.tar.gz
Merge pull request #456 from pabuhler/vc2010-support
vc 2010 support
-rw-r--r--CMakeLists.txt6
-rw-r--r--config_in_cmake.h10
-rw-r--r--crypto/cipher/cipher.c14
-rw-r--r--test/test_srtp.c6
-rw-r--r--test/util.c1
5 files changed, 20 insertions, 17 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bb1c8b0..ed8c112 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,6 +9,7 @@ include(TestBigEndian)
include(CheckIncludeFile)
include(CheckFunctionExists)
include(CheckTypeSize)
+include(CheckCSourceCompiles)
test_big_endian(WORDS_BIGENDIAN)
@@ -38,6 +39,11 @@ check_type_size(int32_t INT32_T)
check_type_size("unsigned long" SIZEOF_UNSIGNED_LONG)
check_type_size("unsigned long long" SIZEOF_UNSIGNED_LONG_LONG)
+check_c_source_compiles("inline void func(); void func() { } int main() { func(); return 0; }" HAVE_INLINE)
+if(NOT HAVE_INLINE)
+ check_c_source_compiles("__inline void func(); void func() { } int main() { func(); return 0; }" HAVE___INLINE)
+endif()
+
set(ENABLE_DEBUG_LOGGING OFF CACHE BOOL "Enable debug logging in all modules")
set(ERR_REPORTING_STDOUT OFF CACHE BOOL "Enable logging to stdout")
set(ERR_REPORTING_FILE "" CACHE FILEPATH "Use file for logging")
diff --git a/config_in_cmake.h b/config_in_cmake.h
index bce31c4..57e0864 100644
--- a/config_in_cmake.h
+++ b/config_in_cmake.h
@@ -103,3 +103,13 @@
/* The size of `unsigned long long', as computed by sizeof. */
@SIZEOF_UNSIGNED_LONG_LONG_CODE@
+/* Define inline to what is supported by compiler */
+#cmakedefine HAVE_INLINE 1
+#cmakedefine HAVE___INLINE 1
+#ifndef HAVE_INLINE
+ #ifdef HAVE___INLINE
+ #define inline __inline
+ #else
+ #define inline
+ #endif
+#endif
diff --git a/crypto/cipher/cipher.c b/crypto/cipher/cipher.c
index 88a4a71..354517d 100644
--- a/crypto/cipher/cipher.c
+++ b/crypto/cipher/cipher.c
@@ -171,19 +171,6 @@ int srtp_cipher_get_key_length(const srtp_cipher_t *c)
*/
void srtp_cipher_rand_for_tests(void *dest, uint32_t len)
{
-#if defined(HAVE_RAND_S)
- uint8_t *dst = (uint8_t *)dest;
- while (len) {
- unsigned int val;
- errno_t err = rand_s(&val);
-
- if (err != 0)
- return srtp_err_status_fail;
-
- *dst++ = val & 0xff;
- len--;
- }
-#else
/* Generic C-library (rand()) version */
/* This is a random source of last resort */
uint8_t *dst = (uint8_t *)dest;
@@ -195,7 +182,6 @@ void srtp_cipher_rand_for_tests(void *dest, uint32_t len)
*dst++ = val & 0xff;
len--;
}
-#endif
}
/*
diff --git a/test/test_srtp.c b/test/test_srtp.c
index 05b1e59..0cea1f3 100644
--- a/test/test_srtp.c
+++ b/test/test_srtp.c
@@ -152,14 +152,15 @@ void srtp_calc_aead_iv_srtcp_distinct_iv_per_sequence_number()
srtp_session_keys_t session_keys;
srtcp_hdr_t header;
v128_t output_iv[SAMPLE_COUNT];
- memset(&output_iv, 0, SAMPLE_COUNT * sizeof(v128_t));
uint32_t sequence_num[SAMPLE_COUNT];
+ v128_t final_iv[SAMPLE_COUNT];
+ size_t i = 0;
+ memset(&output_iv, 0, SAMPLE_COUNT * sizeof(v128_t));
sequence_num[0] = 0xFF;
sequence_num[1] = 0xFF00;
sequence_num[2] = 0xFF0000;
// Postconditions
- v128_t final_iv[SAMPLE_COUNT];
memset(&final_iv, 0, SAMPLE_COUNT * sizeof(v128_t));
final_iv[0].v8[11] = 0xFF;
final_iv[1].v8[10] = 0xFF;
@@ -170,7 +171,6 @@ void srtp_calc_aead_iv_srtcp_distinct_iv_per_sequence_number()
memset(&header, 0, sizeof(srtcp_hdr_t));
// When
- size_t i = 0;
for (i = 0; i < SAMPLE_COUNT; i++) {
TEST_CHECK(srtp_calc_aead_iv_srtcp(&session_keys, &output_iv[i],
sequence_num[i],
diff --git a/test/util.c b/test/util.c
index 4465e90..2abc28e 100644
--- a/test/util.c
+++ b/test/util.c
@@ -42,6 +42,7 @@
*
*/
+#include "config.h"
#include "util.h"
#include <string.h>