diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8357f46eb..7974cbd82 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,11 +4,6 @@ add_subdirectory(std) find_package(SQLite3 REQUIRED) find_package(Iniparser REQUIRED) -if(CMAKE_CROSSCOMPILING) - find_package(OpenSSLCross REQUIRED) -else() - find_package(OpenSSL REQUIRED) -endif() set(CSYNC_PUBLIC_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} @@ -17,7 +12,6 @@ set(CSYNC_PUBLIC_INCLUDE_DIRS ) set(CSYNC_PRIVATE_INCLUDE_DIRS - ${OPENSSL_INCLUDE_DIRS} ${INIPARSER_INCLUDE_DIRS} ${SQLITE3_INCLUDE_DIRS} ${CSTDLIB_PUBLIC_INCLUDE_DIRS} @@ -34,7 +28,6 @@ set(CSYNC_LINK_LIBRARIES ${CSTDLIB_LIBRARY} ${CSYNC_REQUIRED_LIBRARIES} ${INIPARSER_LIBRARIES} - ${OPENSSL_LIBRARIES} ${SQLITE3_LIBRARIES} ) diff --git a/src/csync_util.c b/src/csync_util.c index f4064d16b..66913928c 100644 --- a/src/csync_util.c +++ b/src/csync_util.c @@ -32,14 +32,6 @@ #include "csync_util.h" #include "vio/csync_vio.h" -#if defined(__APPLE__) -# define COMMON_DIGEST_FOR_OPENSSL -# include -# define SHA1 CC_SHA1 -#else -# include -#endif - #define CSYNC_LOG_CATEGORY_NAME "csync.util" #include "csync_log.h" @@ -364,54 +356,4 @@ static char* digest_to_out(unsigned char* digest) return out; } -#define BUF_SIZE 512 - -char* csync_file_md5(const char *filename) -{ - const char *tmpFileName; - int fd; - MD5_CTX c; - char buf[ BUF_SIZE+1 ]; - unsigned char digest[16]; - size_t size; - - tmpFileName = c_multibyte( filename ); - - if ( (fd = _topen( tmpFileName, O_RDONLY )) < 0) { - return NULL; - } else { - MD5_Init(&c); - while( (size=read(fd, buf, BUF_SIZE )) > 0) { - buf[size]='\0'; - MD5_Update(&c, buf, size); - } - close(fd); - MD5_Final(digest, &c); - } - - c_free_multibyte(tmpFileName); - return digest_to_out(digest); -} - -char* csync_buffer_md5(const char *str, int length) -{ - MD5_CTX c; - unsigned char digest[16]; - - MD5_Init(&c); - - while (length > 0) { - if (length > 512) { - MD5_Update(&c, str, 512); - } else { - MD5_Update(&c, str, length); - } - length -= 512; - str += 512; - } - - MD5_Final(digest, &c); - return digest_to_out(digest); -} - /* vim: set ts=8 sw=2 et cindent: */ diff --git a/src/csync_util.h b/src/csync_util.h index 96727b4e6..e7231b85d 100644 --- a/src/csync_util.h +++ b/src/csync_util.h @@ -36,13 +36,5 @@ int csync_unix_extensions(CSYNC *ctx); /* Normalize the uri to / */ uint64_t csync_create_statedb_hash(CSYNC *ctx); -/* Calculate the md5 sum for a file given by filename. - * Caller has to free the memory. */ -char* csync_file_md5(const char *filename); - -/* Create an md5 sum from a data pointer with a given length. - * Caller has to free the memory */ -char* csync_buffer_md5(const char *str, int length); - #endif /* _CSYNC_UTIL_H */ /* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */ diff --git a/tests/ownCloud/mocka/CMakeLists.txt b/tests/ownCloud/mocka/CMakeLists.txt index f329d0e61..338347850 100644 --- a/tests/ownCloud/mocka/CMakeLists.txt +++ b/tests/ownCloud/mocka/CMakeLists.txt @@ -13,8 +13,6 @@ include_directories( add_executable(ocmod_test ocmod_test.c) -add_executable(md5_test md5_test.c) target_link_libraries(ocmod_test ${CMOCKA_LIBRARIES} ${NEON_LIBRARIES} ${CSYNC_LIBRARY} ) -target_link_libraries(md5_test ${CMOCKA_LIBRARIES} ${CSYNC_LIBRARY} ) diff --git a/tests/ownCloud/mocka/md5_test.c b/tests/ownCloud/mocka/md5_test.c deleted file mode 100644 index ae67525af..000000000 --- a/tests/ownCloud/mocka/md5_test.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2012 Klaas Freitag - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - */ - - -#define _GNU_SOURCE /* See feature_test_macros(7) */ -#include - -#include -#include -#include -#include -#include - -#include - -#include - -#include "config_test.h" - - -static void test_testdir_exists(void **state) { - csync_stat_t sb; - const _TCHAR *wuri = c_multibyte( TESTFILES_DIR ); - - (void) state; - assert_int_equal( _tstat(wuri, &sb), 0 ); - assert_true( S_ISDIR(sb.st_mode)); - - c_free_multibyte(wuri); -} - -static void test_md5_buffer(void **state) { - const char *t1 = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."; - const char *t2 = "This is a nice md5 test"; - const char *t3 = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." - "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."; - - (void) state; - assert_string_equal( csync_buffer_md5(t1, strlen(t1)), "dbcb1ed05ecf975f532604f2d2000246"); - assert_string_equal( csync_buffer_md5(t2, strlen(t2)), "65236ae09754bca371fb869384040141"); - assert_string_equal( csync_buffer_md5(t3, strlen(t3)), "651f37892a9df60ed087bc7a1c660fec"); -} - -static void test_md5_files(void **state) { - char path[255]; - (void) state; - - strcpy(path, TESTFILES_DIR); - strcat(path, "test.txt"); - assert_string_equal( csync_file_md5(path), "f3971ce599093756e6018513d0835134"); - - strcpy(path, TESTFILES_DIR); - strcat(path, "red_is_the_rose.jpg"); - assert_string_equal( csync_file_md5(path), "baf8eeb2a36af94f033fa0094c50c2d5"); - -} - - -int main(void) { - const UnitTest tests[] = { - unit_test(test_testdir_exists), - unit_test(test_md5_buffer), - unit_test(test_md5_files) - }; - - return run_tests(tests); -}