From 670f61be4d48c2abc8d3b0c649e1e5f73f9c0f73 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Wed, 13 Jun 2012 15:44:48 +0300 Subject: [PATCH 01/49] Ignore Eclipse project Ignore local eclipse cdt project used for libzrtp development. Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/.gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/libzrtp/.gitignore b/libs/libzrtp/.gitignore index 4bb1123214..89bab134d9 100644 --- a/libs/libzrtp/.gitignore +++ b/libs/libzrtp/.gitignore @@ -1,2 +1,4 @@ # -*- mode:conf -*- +/.cproject +/.project /include/zrtp_config_unix.h From fc4047503739840d3964356734dc667d6905edcd Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Tue, 26 Jun 2012 17:58:07 +0000 Subject: [PATCH 02/49] Build from the root directory Move all the GNU build files to the root directory so that we look like a normal *NIX-centric project. Thanks to Viktor Krikrun for an initial patch here. For this commit, I ended up redoing the move from scratch to separate out this move from other changes. --- libs/libzrtp/.gitignore | 4 +++ libs/libzrtp/{projects/gnu => }/COPYING | 0 libs/libzrtp/{projects/gnu => }/INSTALL | 0 libs/libzrtp/{projects/gnu => }/Makefile.am | 8 ++--- libs/libzrtp/{projects/gnu => }/NEWS | 0 libs/libzrtp/{projects/gnu => }/acinclude.m4 | 0 libs/libzrtp/{projects/gnu => }/bootstrap.sh | 2 +- .../{projects/gnu => }/build/Makefile.am | 2 +- .../{projects/gnu => }/build/test/Makefile.am | 2 +- libs/libzrtp/{projects/gnu => }/configure.in | 6 ++-- .../libzrtp/{projects/gnu => }/create_docs.sh | 2 -- .../libzrtp/{projects/gnu => }/create_pack.pl | 0 libs/libzrtp/projects/gnu/.gitignore | 10 ------- libs/libzrtp/projects/gnu/AUTHORS | 30 ------------------- libs/libzrtp/projects/gnu/ChangeLog | 1 - libs/libzrtp/projects/gnu/README | 0 16 files changed, 14 insertions(+), 53 deletions(-) rename libs/libzrtp/{projects/gnu => }/COPYING (100%) rename libs/libzrtp/{projects/gnu => }/INSTALL (100%) rename libs/libzrtp/{projects/gnu => }/Makefile.am (90%) rename libs/libzrtp/{projects/gnu => }/NEWS (100%) rename libs/libzrtp/{projects/gnu => }/acinclude.m4 (100%) rename libs/libzrtp/{projects/gnu => }/bootstrap.sh (77%) rename libs/libzrtp/{projects/gnu => }/build/Makefile.am (98%) rename libs/libzrtp/{projects/gnu => }/build/test/Makefile.am (98%) rename libs/libzrtp/{projects/gnu => }/configure.in (96%) rename libs/libzrtp/{projects/gnu => }/create_docs.sh (81%) rename libs/libzrtp/{projects/gnu => }/create_pack.pl (100%) delete mode 100644 libs/libzrtp/projects/gnu/.gitignore delete mode 100644 libs/libzrtp/projects/gnu/AUTHORS delete mode 100644 libs/libzrtp/projects/gnu/ChangeLog delete mode 100644 libs/libzrtp/projects/gnu/README diff --git a/libs/libzrtp/.gitignore b/libs/libzrtp/.gitignore index 89bab134d9..ea9c7b1f3d 100644 --- a/libs/libzrtp/.gitignore +++ b/libs/libzrtp/.gitignore @@ -1,4 +1,8 @@ # -*- mode:conf -*- /.cproject /.project +/Makefile +/Makefile.in +/_configs.sed +/config/ /include/zrtp_config_unix.h diff --git a/libs/libzrtp/projects/gnu/COPYING b/libs/libzrtp/COPYING similarity index 100% rename from libs/libzrtp/projects/gnu/COPYING rename to libs/libzrtp/COPYING diff --git a/libs/libzrtp/projects/gnu/INSTALL b/libs/libzrtp/INSTALL similarity index 100% rename from libs/libzrtp/projects/gnu/INSTALL rename to libs/libzrtp/INSTALL diff --git a/libs/libzrtp/projects/gnu/Makefile.am b/libs/libzrtp/Makefile.am similarity index 90% rename from libs/libzrtp/projects/gnu/Makefile.am rename to libs/libzrtp/Makefile.am index 48b8c578a5..d4916e3cf8 100644 --- a/libs/libzrtp/projects/gnu/Makefile.am +++ b/libs/libzrtp/Makefile.am @@ -5,9 +5,9 @@ # Viktor Krikun # -TEST_DIR=$(top_srcdir)/../../test -TOP_SRCDIR=$(top_srcdir)/../../include -THIRD_DIR=$(top_srcdir)/../../third_party +TEST_DIR=$(top_srcdir)/test +TOP_SRCDIR=$(top_srcdir)/include +THIRD_DIR=$(top_srcdir)/third_party libzrtp_includedir=$(includedir)/libzrtp @@ -49,7 +49,7 @@ if ZRTP_BUILD_ENTERPRISE libzrtp_include_HEADERS += $(TOP_SRCDIR)/zrtp_ec.h endif -SUBDIRS = ../../third_party/bnlib +SUBDIRS = third_party/bnlib SUBDIRS += build uninstall: diff --git a/libs/libzrtp/projects/gnu/NEWS b/libs/libzrtp/NEWS similarity index 100% rename from libs/libzrtp/projects/gnu/NEWS rename to libs/libzrtp/NEWS diff --git a/libs/libzrtp/projects/gnu/acinclude.m4 b/libs/libzrtp/acinclude.m4 similarity index 100% rename from libs/libzrtp/projects/gnu/acinclude.m4 rename to libs/libzrtp/acinclude.m4 diff --git a/libs/libzrtp/projects/gnu/bootstrap.sh b/libs/libzrtp/bootstrap.sh similarity index 77% rename from libs/libzrtp/projects/gnu/bootstrap.sh rename to libs/libzrtp/bootstrap.sh index 1559388ad1..dfa3cc3652 100755 --- a/libs/libzrtp/projects/gnu/bootstrap.sh +++ b/libs/libzrtp/bootstrap.sh @@ -9,6 +9,6 @@ reconf () { automake --no-force --add-missing --copy } -(cd ../../third_party/bnlib && ./bootstrap.sh) +(cd third_party/bnlib && ./bootstrap.sh) reconf diff --git a/libs/libzrtp/projects/gnu/build/Makefile.am b/libs/libzrtp/build/Makefile.am similarity index 98% rename from libs/libzrtp/projects/gnu/build/Makefile.am rename to libs/libzrtp/build/Makefile.am index 8d6e0a0a45..4252e672ec 100644 --- a/libs/libzrtp/projects/gnu/build/Makefile.am +++ b/libs/libzrtp/build/Makefile.am @@ -5,7 +5,7 @@ # Viktor Krikun # -TOP_SRCDIR=$(top_srcdir)/../.. +TOP_SRCDIR=$(top_srcdir) INCLUDES = -I$(TOP_SRCDIR)/include \ -I$(TOP_SRCDIR)/. \ -I$(TOP_SRCDIR)/third_party/bgaes \ diff --git a/libs/libzrtp/projects/gnu/build/test/Makefile.am b/libs/libzrtp/build/test/Makefile.am similarity index 98% rename from libs/libzrtp/projects/gnu/build/test/Makefile.am rename to libs/libzrtp/build/test/Makefile.am index 558b2b9e5a..b8f9a9abb9 100644 --- a/libs/libzrtp/projects/gnu/build/test/Makefile.am +++ b/libs/libzrtp/build/test/Makefile.am @@ -7,7 +7,7 @@ -TOP_SRCDIR=$(top_srcdir)/../.. +TOP_SRCDIR=$(top_srcdir) INCLUDES = -I$(TOP_SRCDIR)/include \ -I$(TOP_SRCDIR)/include/enterprise \ -I$(TOP_SRCDIR)/. \ diff --git a/libs/libzrtp/projects/gnu/configure.in b/libs/libzrtp/configure.in similarity index 96% rename from libs/libzrtp/projects/gnu/configure.in rename to libs/libzrtp/configure.in index 7d97319a76..34feb59a91 100644 --- a/libs/libzrtp/projects/gnu/configure.in +++ b/libs/libzrtp/configure.in @@ -33,15 +33,15 @@ esac AM_INIT_AUTOMAKE([libzrtp], [1.15]) -AX_PREFIX_CONFIG_H(../../include/zrtp_config_unix.h,ZRTP,config/config.h) +AX_PREFIX_CONFIG_H(include/zrtp_config_unix.h,ZRTP,config/config.h) CFLAGS="$CFLAGS -Wno-unused-parameter -fno-strict-aliasing -fPIC -DZRTP_AUTOMAKE=1" # Configuring external libraries echo "========================= configuring bnlib ==============================" -cd ./../../third_party/bnlib +cd third_party/bnlib ./configure CFLAGS="$CFLAGS" -cd ../../projects/gnu +cd ../.. echo "================================ done ===================================" # Checks for programs. diff --git a/libs/libzrtp/projects/gnu/create_docs.sh b/libs/libzrtp/create_docs.sh similarity index 81% rename from libs/libzrtp/projects/gnu/create_docs.sh rename to libs/libzrtp/create_docs.sh index 1999a1b14a..a30c7c256b 100755 --- a/libs/libzrtp/projects/gnu/create_docs.sh +++ b/libs/libzrtp/create_docs.sh @@ -7,5 +7,3 @@ mkdir libzrtp-doc cp -Rf ./out/html/* ./libzrtp-doc tar -zcvf ./libzrtp-doc.tar.gz ./libzrtp-doc >> /dev/null rm -rf libzrtp-doc -mv libzrtp-doc.tar.gz ../projects/gnu -cd ../projects/gnu diff --git a/libs/libzrtp/projects/gnu/create_pack.pl b/libs/libzrtp/create_pack.pl similarity index 100% rename from libs/libzrtp/projects/gnu/create_pack.pl rename to libs/libzrtp/create_pack.pl diff --git a/libs/libzrtp/projects/gnu/.gitignore b/libs/libzrtp/projects/gnu/.gitignore deleted file mode 100644 index 0920c730f6..0000000000 --- a/libs/libzrtp/projects/gnu/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -# -*- mode:conf -*- -/Makefile -/Makefile.in -/_configs.sed -/build/Makefile -/build/Makefile.in -/build/test/Makefile -/build/test/Makefile.in -/config/config.h -/config/stamp-h1 diff --git a/libs/libzrtp/projects/gnu/AUTHORS b/libs/libzrtp/projects/gnu/AUTHORS deleted file mode 100644 index 5d67c092cd..0000000000 --- a/libs/libzrtp/projects/gnu/AUTHORS +++ /dev/null @@ -1,30 +0,0 @@ -libzrtp betta -Copyright (c) 2005-2008 Philip Zimmermann. All rights reserved. -Contact Phil at: www.philzimmermann.com -Visit the Zfone Project Home Page http://zfoneproject.com/ -Report bugs via the Zfone Bugs Page http://zfoneproject.com/bugs.html - -Created by Phil Zimmermann. - -Developers: - Viktor Krikun - Nikolay Popok - Vitaly Rozhkov - Andrey Rozinko - Bryce Wilcox-O'Hearn - -Thanks to: - Alan Johnston - Jon Callas - Hal Finney - Colin Plumb - Sagar Pai - Werner Dittmann - L. Amber Wilcox-O'Hearn - Ariel Boston - Donovan Preston - -Software development services provided by Svitla Systems and http://www.soft-industry.com/en. - -Portions of this software are available under open source licenses from other authors. -Notably, Brian Gladman's AES implementation, and David McGrew's libSRTP package. diff --git a/libs/libzrtp/projects/gnu/ChangeLog b/libs/libzrtp/projects/gnu/ChangeLog deleted file mode 100644 index 709dcbe6f8..0000000000 --- a/libs/libzrtp/projects/gnu/ChangeLog +++ /dev/null @@ -1 +0,0 @@ -Change Log is available at [https://developers.zfoneproject.com/libzrtp/wiki/LibzrtpChangeLog] \ No newline at end of file diff --git a/libs/libzrtp/projects/gnu/README b/libs/libzrtp/projects/gnu/README deleted file mode 100644 index e69de29bb2..0000000000 From 5176df4615c9b79ed724d5e288dc84f4553bd3f0 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Wed, 13 Jun 2012 15:23:30 +0300 Subject: [PATCH 03/49] Remove old Windows CE tests Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/test/win_ce/ReadMe.txt | 81 --- libs/libzrtp/test/win_ce/libzrtp_test_GUI.cpp | 492 ------------------ libs/libzrtp/test/win_ce/libzrtp_test_GUI.h | 16 - libs/libzrtp/test/win_ce/libzrtp_test_GUI.ico | Bin 23558 -> 0 bytes .../test/win_ce/libzrtp_test_GUIppc.rc | 183 ------- .../test/win_ce/libzrtp_test_GUIppc.rc2 | 35 -- .../libzrtp/test/win_ce/libzrtp_test_GUIsp.rc | 95 ---- .../test/win_ce/libzrtp_test_GUIsp.rc2 | 31 -- libs/libzrtp/test/win_ce/resourceppc.h | 36 -- libs/libzrtp/test/win_ce/resourcesp.h | 28 - libs/libzrtp/test/win_ce/stdafx.cpp | 18 - libs/libzrtp/test/win_ce/stdafx.h | 61 --- 12 files changed, 1076 deletions(-) delete mode 100644 libs/libzrtp/test/win_ce/ReadMe.txt delete mode 100644 libs/libzrtp/test/win_ce/libzrtp_test_GUI.cpp delete mode 100644 libs/libzrtp/test/win_ce/libzrtp_test_GUI.h delete mode 100644 libs/libzrtp/test/win_ce/libzrtp_test_GUI.ico delete mode 100644 libs/libzrtp/test/win_ce/libzrtp_test_GUIppc.rc delete mode 100644 libs/libzrtp/test/win_ce/libzrtp_test_GUIppc.rc2 delete mode 100644 libs/libzrtp/test/win_ce/libzrtp_test_GUIsp.rc delete mode 100644 libs/libzrtp/test/win_ce/libzrtp_test_GUIsp.rc2 delete mode 100644 libs/libzrtp/test/win_ce/resourceppc.h delete mode 100644 libs/libzrtp/test/win_ce/resourcesp.h delete mode 100644 libs/libzrtp/test/win_ce/stdafx.cpp delete mode 100644 libs/libzrtp/test/win_ce/stdafx.h diff --git a/libs/libzrtp/test/win_ce/ReadMe.txt b/libs/libzrtp/test/win_ce/ReadMe.txt deleted file mode 100644 index a219d013c6..0000000000 --- a/libs/libzrtp/test/win_ce/ReadMe.txt +++ /dev/null @@ -1,81 +0,0 @@ -======================================================================== - WIN32 APPLICATION : libzrtp_test_GUI Project Overview -======================================================================== - -AppWizard has created this libzrtp_test_GUI application for you. - -This file contains a summary of what you will find in each of the files that -make up your libzrtp_test_GUI application. - - -libzrtp_test_GUI.vcproj - This is the main project file for VC++ projects generated using an Application Wizard. - It contains information about the version of Visual C++ that generated the file, and - information about the platforms, configurations, and project features selected with the - Application Wizard. - -libzrtp_test_GUI.cpp - This is the main application source file. - -///////////////////////////////////////////////////////////////////////////// -AppWizard has created the following resources: - - -libzrtp_test_GUIppc.rc - This is a listing of all of the Microsoft Windows resources that the - program uses when compiling for the Pocket PC 2003 platform, or a platform - that supports the same user interface model. It includes the icons, bitmaps, - and cursors that are stored in the RES subdirectory. This file can be - directly edited in Microsoft Visual C++. When the .rc file is persisted, - the defines in the data section are persisted as the hexadecimal version - of the numeric value they are defined to rather than the friendly name of - the define. - -libzrtp_test_GUIppc.rc2 - This file contains resources that are not edited by Microsoft - Visual C++. You should place all resources not editable by - the resource editor in this file. - -Resourceppc.h - This is the standard header file, which defines new resource IDs. - Microsoft Visual C++ reads and updates this file. - -libzrtp_test_GUIsp.rc - This is a listing of all of the Microsoft Windows resources that the - program uses when compiling for the Smartphone 2003 platform, or a - platform that supports the same user interface model. It includes the - icons, bitmaps, and cursors that are stored in the RES subdirectory. - This file can be directly edited in Microsoft Visual C++. When the - .rc file is persisted, the defines in the data section are persisted - as the hexadecimal version of the numeric value they are defined to - rather than the friendly name of the define. - -libzrtp_test_GUIsp.rc2 - This file contains resources that are not edited by Microsoft - Visual C++. You should place all resources not editable by - the resource editor in this file. - -Resourcesp.h - This is the standard header file, which defines new resource IDs. - Microsoft Visual C++ reads and updates this file. - - - -libzrtp_test_GUI.ico - This is an icon file, which is used as the application's icon (32x32). - This icon is included by the main resource file libzrtp_test_GUI.rc. - -///////////////////////////////////////////////////////////////////////////// -Other standard files: - -StdAfx.h, StdAfx.cpp - These files are used to build a precompiled header (PCH) file - named libzrtp_test_GUI.pch and a precompiled types file named StdAfx.obj. - -///////////////////////////////////////////////////////////////////////////// -Other notes: - -AppWizard uses "TODO:" comments to indicate parts of the source code you -should add to or customize. - -/////////////////////////////////////////////////////////////////////////////s \ No newline at end of file diff --git a/libs/libzrtp/test/win_ce/libzrtp_test_GUI.cpp b/libs/libzrtp/test/win_ce/libzrtp_test_GUI.cpp deleted file mode 100644 index 2e8407e363..0000000000 --- a/libs/libzrtp/test/win_ce/libzrtp_test_GUI.cpp +++ /dev/null @@ -1,492 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Nikolay Popok mailto: - */ - -#include "stdafx.h" -#include "libzrtp_test_GUI.h" -#include -#include - -//#include "resourcesp.h" - -#include - - -extern "C" -{ - #include "zrtp.h" - #include "zrtp_test_core.h" -} - -#define MAX_LOADSTRING 100 - -// Global Variables: -HINSTANCE g_hInst; // current instance -HWND g_hWndMenuBar; // menu bar handle -HWND hWndList; -HWND g_hWnd; - -HFONT font; - -int action_id = 0; - -static void do_action(); -static void print_log_ce(int level, const char *data, int len, int offset); -static DWORD WINAPI destroy_func(void *param); - -static FILE *log_file = NULL; - -typedef struct zrtp_test_command -{ - int32_t code; - int first_conn; - int last_conn; - uint32_t extra, extra2; -} zrtp_test_command_t; - -typedef enum zrtp_test_code -{ - ZRTP_TEST_CREATE = 0, - ZRTP_TEST_DESTROY, - ZRTP_TEST_ZSTART, - ZRTP_TEST_ZSECURE, - ZRTP_TEST_QUIT, - ZRTP_TEST_INC, - ZRTP_TEST_DEC, - ZRTP_TEST_CLEAR, - ZRTP_TEST_SLEEP, - ZRTP_TEST_LOGS, - ZRTP_TEST_INFO, - ZRTP_TEST_HELP, - ZRTP_TEST_CMD_SIZE -} zrtp_test_code_t; - -extern "C" { - void do_quit(); - int zrtp_test_zrtp_init(); - void zrtp_test_crypto(zrtp_global_t* zrtp); - int zrtp_add_system_state(zrtp_global_t* zrtp, MD_CTX *ctx); -} - -// Forward declarations of functions included in this code module: -ATOM MyRegisterClass(HINSTANCE, LPTSTR); -BOOL InitInstance(HINSTANCE, int); -LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); -#ifndef WIN32_PLATFORM_WFSP -INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); -#endif // !WIN32_PLATFORM_WFSP - -int WINAPI WinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPTSTR lpCmdLine, - int nCmdShow) -{ - MSG msg; - - // Perform application initialization: - if (!InitInstance(hInstance, nCmdShow)) - { - return FALSE; - } - -#ifndef WIN32_PLATFORM_WFSP - HACCEL hAccelTable; - hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_LIBZRTP_TEST_GUI)); -#endif // !WIN32_PLATFORM_WFSP - - // Main message loop: - while (GetMessage(&msg, NULL, 0, 0)) - { - if ( msg.message == WM_KEYDOWN ) - { - switch ( msg.wParam ) - { - case VK_LEFT: - { - msg.wParam = 0; - break; - } - case VK_RIGHT: - { - msg.wParam = 0; - break; - } - } - } - -#ifndef WIN32_PLATFORM_WFSP - if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) -#endif // !WIN32_PLATFORM_WFSP - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - - return (int) msg.wParam; -} - -// -// FUNCTION: MyRegisterClass() -// -// PURPOSE: Registers the window class. -// -// COMMENTS: -// -ATOM MyRegisterClass(HINSTANCE hInstance, LPTSTR szWindowClass) -{ - WNDCLASS wc; - - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_LIBZRTP_TEST_GUI)); - wc.hCursor = 0; - wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); - wc.lpszMenuName = 0; - wc.lpszClassName = szWindowClass; - - return RegisterClass(&wc); -} - -// -// FUNCTION: InitInstance(HINSTANCE, int) -// -// PURPOSE: Saves instance handle and creates main window -// -// COMMENTS: -// -// In this function, we save the instance handle in a global variable and -// create and display the main program window. -// -BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) -{ - HWND hWnd; - TCHAR szTitle[MAX_LOADSTRING]; // title bar text - TCHAR szWindowClass[MAX_LOADSTRING]; // main window class name - - g_hInst = hInstance; // Store instance handle in our global variable - -#if defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP) - // SHInitExtraControls should be called once during your application's initialization to initialize any - // of the device specific controls such as CAPEDIT and SIPPREF. - SHInitExtraControls(); -#endif // WIN32_PLATFORM_PSPC || WIN32_PLATFORM_WFSP - - LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); - LoadString(hInstance, IDC_LIBZRTP_TEST_GUI, szWindowClass, MAX_LOADSTRING); - -#if defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP) - //If it is already running, then focus on the window, and exit - hWnd = FindWindow(szWindowClass, szTitle); - if (hWnd) - { - // set focus to foremost child window - // The "| 0x00000001" is used to bring any owned windows to the foreground and - // activate them. - SetForegroundWindow((HWND)((ULONG) hWnd | 0x00000001)); - return 0; - } -#endif // WIN32_PLATFORM_PSPC || WIN32_PLATFORM_WFSP - - if (!MyRegisterClass(hInstance, szWindowClass)) - { - return FALSE; - } - - hWnd = CreateWindow(szWindowClass, szTitle, WS_VISIBLE, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); - - if (!hWnd) - { - return FALSE; - } - - g_hWnd = hWnd; -#ifdef WIN32_PLATFORM_PSPC - // When the main window is created using CW_USEDEFAULT the height of the menubar (if one - // is created is not taken into account). So we resize the window after creating it - // if a menubar is present - if (g_hWndMenuBar) - { - RECT rc; - RECT rcMenuBar; - - GetWindowRect(hWnd, &rc); - GetWindowRect(g_hWndMenuBar, &rcMenuBar); - rc.bottom -= (rcMenuBar.bottom - rcMenuBar.top); - - MoveWindow(hWnd, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, FALSE); - } -#endif // WIN32_PLATFORM_PSPC - - ShowWindow(hWnd, nCmdShow); - UpdateWindow(hWnd); - - return TRUE; -} - -// -// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) -// -// PURPOSE: Processes messages for the main window. -// -// WM_COMMAND - process the application menu -// WM_PAINT - Paint the main window -// WM_DESTROY - post a quit message and return -// -// -LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - int wmId, wmEvent; - PAINTSTRUCT ps; - HDC hdc; - -#if defined(SHELL_AYGSHELL) && !defined(WIN32_PLATFORM_WFSP) - static SHACTIVATEINFO s_sai; -#endif // SHELL_AYGSHELL && !WIN32_PLATFORM_WFSP - - switch (message) - { - case WM_COMMAND: - wmId = LOWORD(wParam); - wmEvent = HIWORD(wParam); - // Parse the menu selections: - switch (wmId) - { -#ifndef WIN32_PLATFORM_WFSP - case IDM_HELP_ABOUT: - DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, About); - break; -#endif // !WIN32_PLATFORM_WFSP -#ifdef WIN32_PLATFORM_WFSP - case IDM_OK: - do_action(); - - break; -#endif // WIN32_PLATFORM_WFSP -#ifdef WIN32_PLATFORM_PSPC - case IDM_OK: - do_action(); - break; -#endif // WIN32_PLATFORM_PSPC - default: - return DefWindowProc(hWnd, message, wParam, lParam); - } - break; - case WM_CREATE: -#ifdef SHELL_AYGSHELL - SHMENUBARINFO mbi; - - memset(&mbi, 0, sizeof(SHMENUBARINFO)); - mbi.cbSize = sizeof(SHMENUBARINFO); - mbi.hwndParent = hWnd; - mbi.nToolBarId = IDR_MENU; - mbi.hInstRes = g_hInst; - - if (!SHCreateMenuBar(&mbi)) - { - g_hWndMenuBar = NULL; - } - else - { - g_hWndMenuBar = mbi.hwndMB; - } - -#ifndef WIN32_PLATFORM_WFSP - // Initialize the shell activate info structure - memset(&s_sai, 0, sizeof (s_sai)); - s_sai.cbSize = sizeof (s_sai); -#endif // !WIN32_PLATFORM_WFSP -#endif // SHELL_AYGSHELL - -#ifdef WIN32_PLATFORM_WFSP - hWndList = CreateWindow(TEXT("listbox"),NULL, WS_CHILD| - WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|WS_TABSTOP, 0,0, 300, 200, hWnd, - (HMENU)"", g_hInst, NULL); -#else - hWndList = CreateWindow(TEXT("listbox"),NULL, WS_CHILD| - WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|WS_TABSTOP, 0,0, 250, 200, hWnd, - (HMENU)"", g_hInst, NULL); -#endif // !WIN32_PLATFORM_WFSP - - font = CreateFont(10, // height of font - 0, // average character width - 0, // angle of escapement - 0, // base-line orientation angle - 400, // font weight - 0, // italic attribute option - FALSE, // underline attribute option - FALSE, // strikeout attribute option - ANSI_CHARSET, // character set identifier - OUT_DEFAULT_PRECIS, // output precision - CLIP_DEFAULT_PRECIS, // clipping precision - ANTIALIASED_QUALITY, // output quality - FF_DONTCARE, // pitch and family - TEXT("Times New Roman")); - - SendMessage(hWndList, WM_SETFONT, (WPARAM)font, (LPARAM)TRUE); - - SetFocus(hWndList); - break; - case WM_PAINT: - hdc = BeginPaint(hWnd, &ps); - - EndPaint(hWnd, &ps); - break; - case WM_DESTROY: -#ifdef SHELL_AYGSHELL - CommandBar_Destroy(g_hWndMenuBar); -#endif // SHELL_AYGSHELL - PostQuitMessage(0); - break; - -#if defined(SHELL_AYGSHELL) && !defined(WIN32_PLATFORM_WFSP) - case WM_ACTIVATE: - // Notify shell of our activate message - SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE); - break; - case WM_SETTINGCHANGE: - SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai); - break; -#endif // SHELL_AYGSHELL && !WIN32_PLATFORM_WFSP - - default: - return DefWindowProc(hWnd, message, wParam, lParam); - } - return 0; -} - -HWND hwndAbout = NULL; - -#ifndef WIN32_PLATFORM_WFSP -// Message handler for about box. -INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_INITDIALOG: -#ifdef SHELL_AYGSHELL - { - // Create a Done button and size it. - SHINITDLGINFO shidi; - shidi.dwMask = SHIDIM_FLAGS; - shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN | SHIDIF_EMPTYMENU; - shidi.hDlg = hDlg; - SHInitDialog(&shidi); - } -#endif // SHELL_AYGSHELL - - return (INT_PTR)TRUE; - - case WM_COMMAND: -#ifdef SHELL_AYGSHELL - if (LOWORD(wParam) == IDOK) -#endif - { - return (INT_PTR)TRUE; - } - break; - - case WM_CLOSE: - EndDialog(hDlg, message); - return (INT_PTR)TRUE; - -#ifdef _DEVICE_RESOLUTION_AWARE - case WM_SIZE: - { - DRA::RelayoutDialog( - g_hInst, - hDlg, - DRA::GetDisplayMode() != DRA::Portrait ? MAKEINTRESOURCE(IDD_ABOUTBOX_WIDE) : MAKEINTRESOURCE(IDD_ABOUTBOX)); - } - break; -#endif - } - return (INT_PTR)FALSE; -} -#endif // !WIN32_PLATFORM_WFSP - -static void do_action() -{ - switch (action_id) - { - case 0: - { - int status; - - zrtp_log_set_log_engine((zrtp_log_engine*)print_log_ce); - status = zrtp_test_zrtp_init(); - if (0 != status) { - return; - } - - zrtp_test_crypto(zrtp_global); - - { - zrtp_test_channel_id_t id; - zrtp_test_channel_config_t sconfig; - - sconfig.is_autosecure = 0; - sconfig.is_preshared = 0; - sconfig.streams_count = 1; - - status = zrtp_test_channel_create(&sconfig, &id); - - if (0 == status) { - zrtp_test_channel_start(id); - } - } - break; - } - case 1: - { - zrtp_thread_create(destroy_func, NULL); - break; - } - case 2: - { - DeleteObject(font); - if (log_file) fclose(log_file); -#ifdef WIN32_PLATFORM_WFSP - DestroyWindow(g_hWnd); -#endif -#ifdef WIN32_PLATFORM_PSPC - SendMessage(g_hWnd, WM_CLOSE, 0, 0); -#endif // WIN32_PLATFORM_PSPC - break; - } - } - - action_id++; -} - -static DWORD WINAPI destroy_func(void *param) -{ - do_quit(); - return 0; -} - -static void print_log_ce(int level, const char *data, int len, int offset) -{ - if ( !log_file ) - log_file = fopen("zrtp_test.log", "a"); - - fprintf(log_file, "%s", data); - - if (level < 3 || 1) - { - CString strUnicode = data; - SendMessage(hWndList, LB_ADDSTRING, 0, (LPARAM)strUnicode.GetBuffer(100)); - SendMessage(hWndList, WM_VSCROLL, SB_BOTTOM, 0L); - } - -} - diff --git a/libs/libzrtp/test/win_ce/libzrtp_test_GUI.h b/libs/libzrtp/test/win_ce/libzrtp_test_GUI.h deleted file mode 100644 index 6219d3f68d..0000000000 --- a/libs/libzrtp/test/win_ce/libzrtp_test_GUI.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Nikolay Popok mailto: - */ - -#pragma once -#ifdef POCKETPC2003_UI_MODEL -#include "resourceppc.h" -#endif -#ifdef SMARTPHONE2003_UI_MODEL -#include "resourcesp.h" -#endif diff --git a/libs/libzrtp/test/win_ce/libzrtp_test_GUI.ico b/libs/libzrtp/test/win_ce/libzrtp_test_GUI.ico deleted file mode 100644 index d551aa3aaf80adf9b7760e2eb8de95a5c3e53df6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 23558 zcmeI430zgx+QuJHKtxbe5gbu*030B5$VyGcDGSFOalkY&2LuvC5pp(7&2XNl96=@z zNXGH2`|DO#nx)3nwUq43A>_N=+wHsYe$U#6ePmShD&p^B>2uySylbs@uYIPy&-w#c zpc-6UYC)x+ErDgUwQ8BlZ7hIURRB*7exZ#T}AXG2* z=^weGTI5~Inq#r?3QZRh5>Vvy7AqDy*^i;1p6BY7;LQSXZ{;g>M z?fm5AM!1uJ~14CP5-;mbWJGeF0 z_iurN!(6GBI54yo4h(CB{j~e(6Em$hj*V=Fqpvo{5$e#07L+U2`wvFkn8s8S#Efo= z^|!}o{tozLT1|Z7UlaSMxZ(5FgK^Rilm(Khv|vko7i5X}36?lI))Ggklas69 zVxSe$=33+10BfA^v%)uXY;b;dHGCaV4e6oPadwt1PEE7L#SjO4G`kKy33kG#^P1yK zcx(J^Ra<Ti+?95-JJvGIWK0JnTs;vs^DcXy)=jK$w z=lme~e0CM~SM61i7E+Zy6!Vv8(?YCpX|5H%3$bS21{dbq;8I96Tne>C8jm-9o*mM| z?2r~#1K&~U^BwT@ygK+I#1UDG8sIO%&iE*}A+E1$jbGNa!S(fRas9ovxba>)TBY{5 zxxo`Rq9|oIDtY0?rjE#1t!!u9+}s5>w|2#i&D55z%y+}h?JrQ>af9~O4zA^n9=Nr$ z7jEt9gPXg&@$23JxV49(y|Q~4emOiI-)H_6dH=qKoBYhlq5e+&PW_AegZf|U-_)N} z9@RJC3MS7vp?yXL1qC4>AOQaU{+Kjr5++WZhzS!Wz}MFoW5Wxo&I+1!G$zZHn#$;`!98-<yjHIyy#~ zd!^|5sm6LSF)_!K%8;V#rWzZU(N_%@(#Q5Ewg{KRHI95 zY?=LIo2D9@#Ky*zb^O>SmHu~IE44l?Dgh-;K81z)WLJ`;4wqn z_ZrZ%LmzL?wy3kD_lL%jZ@l`n*YIJJ=8o?=KVm^dc=tK8XTNSrUK1xwofb5!|4WPJ z4;&O=5uecStt8`&$o&U)@7lX>*XEsj-g|fBj_upFZrx%^n^vq{{r0M5OP8-%`Odni z4ek1_pUw~WS3(xf3w~KkBmDdVRSL~dfr0)bOf7sI@n%@?lm1=c0pd4Z&T02Hm@RH2 z)we;5{I7(S*0d0%twR;wLsA|##n-X4buN70s`TsBg@MbpxknH6!QPjfV-K~P+VA6v z_lLE?{$Xwi?eB?&gE}IlpC>|?5A<%2&;edpIl33d4IhkA?7Qcs#@NdnYWsbf({dao zjuAS*69M!eGt37G)4CyX#*2ub-V>ij1>vuo!mzs+z)KgL@b7{zHqOE48v-$!zJ3#Y zv6uJbc6$T6dQ*KU=65px!K_Y5n$a2Cr*_9zn`Ys&O+gqt+y{pT0q+l>1_JwOKM87w zj|1D|zXCjwI@=4Ewok|DRTFSw+Z#B)bq3CDnTav%mol33yacQq;D9qB?)YqOTV(8< zhO{02IO`82u>Hs|UYpK$#ksIn_%f8&v3sW=YtK}ip9y^Z1~r3H`B~I#;2iDQ=@jeE zsP;Kl_%^%|E=9QF`(^IPTIr6TH*`S`ui5^ww+}9?dJfr}dg8{OA;>xEhiiu?LYUzwb+T)8Ci=PAZtkjWKvm68X{|HBivlm3|Y&X;^sP6+GhB5eJk92w>5I2 z+$j(Ix}hC1827D>9dK(?2jp()h@8zG@!QT$$l2N%x3+e|?QJ|JOre?J8PhnJ%Ni~CLrzWB&44|iS%zyB8@if zn`DaR3m@|O^QyPhwX#dzrgIKY+OQIBHLeiIw|EP z&VT0+jvL~&)rdRJe}-vnAIJ6*Q-ZDH1N-*w-gRv2&ZLw99b3D3xO=#{xw*T!wQ+Oz@bGBcd0?|n&$#sN_2S8-lrFX#RqEa{~iIg60Iwp0)kazxeJo zgX#N&>G3k(9Zpk`k46?8yGp_NR9<~gx%0b2>EBc6h6N*s;*a0{2Wy6O#7ZA8q(u55 zXmAg#9`ZC+QBk9x#nSQpa4CKpR!sCp#>stnXRBl-)qQFW^fsryy=(Z?FI2AS<5;lV$HB*W zpm$$$hhFu3THa~z+qYL;AE$u>2QZl)2G;Ru)3f^vUAny3rOUHDp6~jct50i}CXE|6 zZPK7&qvp+?vT*b1+^M5y`wmZgdAPT0`%H^xiXL6DvWOu*60xx;u6V#Q2{0r8adCy( zEn;IuV&g28p4jI>W#CW53OF&!CsAr~RottogHM>&s@S>DKq|7h|3SD9 zqF9XiYwfgmNUJRFhY%(1o6xLY)@?;QKJMM%9Zv1};>0~2!r#}0zp0zW`xNH9UeDj( zg}=XRQtjm}{_d~Eq+;bB6m$ICmr^L!lH$^jp`^CQQOEr>=J>f^rrg)^KRssd^D)QI zeLuo|80KTp^Sb>{=X%)v)pLRSmCW&T|B@EJinpT1Tyzb%m&zPJ_g4w`z?hFg`Rd1_ z>Wj7&9jm;{DmLy1Gsn+8Vp@!PtSTNouWWh8cdz+W{M_4Sj-PwjDs;R>k4LR3_uiS~ z=YBll{weJklr8FC(aI`*?jJPA&pn00ytW2@1pNNmFr)z)}MRaMZIsT^P*Jr zd{v~ficiI=V%Fb3xlf-prc}}2|5bcSDrP-?@&@_Qn~c8Rs-)*Df-M*%`H0H+%lZ72 zvi{EGQOr#h;dxS84CWx2AwMJBn{b$~fyU%&3N}@!=X}9qDHtRuG5tUm68j-~fkG1sqOUyGmYlwPgb z2OYaS`ssnHnDzL{f$7y1HvU2ZvOsRl96y=1qRkb)O#V)fzZuy)A>;K#iJYK%{YIx)`7mahDM1B1t%cm9kaZNYkD4X_DC9qd+$8->B5TQhB} zPLpFP(T5^y$$V8IA1dTRh5V#84>?gGBg(O=3b|S#mnh^Cg)FI%vsB;THmdl^aSGW> zA@3;U9fcgEkcSj)tKX)y|CMyJ9 zWMGAisgNZVGNwZIRLI7bES?uKuA0cIN->306SAtME58p}SdPK5N}H!(y?QQ$SPR)# zEw=cH;9p8myVEOE~ZJrY}3iIg?0rP&%LTBp=}8h@I%TXv<9-xUO`%}-uWt5a*E=2Z6^)Nip$4?6}mrb=W3r9pMm{N(?%I<=0f{ZX!iK0oKQ1d^EdG#^%`N>O4Lp#&)lc_BC`N?cbBh&ou z$Ha>#mE4>Z3XbJ2L!+Nt++W%XmzCnEDKwe#1XEVN#&9kX7z*Ba>aDt~p(O7d58 ztNMbLMIj4qo}V1Gs?t)?V|bWl{j*<9L>}8bKN)V*HyMT)&Xn7jpKpqbGz6zmVk@{(S%;moMb= zg`B=PIy$QPUCF}>xq2agFXZoq+`W*w*DN`FAuBIr%G&-D!IW`F9}` zFJ#_@jJ%MQmz-@~sV+i3UdYL7B1xFE+kg*rC_sn}}eaYVo*?J*YFZ>$;!oOJ{ z{QCgB-)1FF4i?imzkPZz{4Rvr{h7I>sgUu{%LsSK%b0JUml0-1RnN;GSP!(-+jpO%JopO`B((dnpK-(&yRaUJ6F; zchnE_k$Wv1f4{oG;*T$8Vx5|ss!Wf01@yO_$nuNBLZ4Gvb)Vu6x9f7RD3t3{RPFna z@~=**zWfUs8kYPPZCSL4e)B1xT|TXnSM+U>y|{O?8%m4vtzIr_BVKg5vCP}`*3dR} z&a!{N#n>%>kU18z!$Q_q$meQ#RW3=oZ=knFmg=8&V&`qOUg~p1N&lWwnpHmPb9YW3 zw+z)kIP(xwOMAJX5{|A*v__uZdtvV;w2rOkgeCCc1i z#a5Q%Amc3IgIa3+fBIm(x&OWTs_~Un|HxNN{coH$#m{POUDev^Dy>e{FMhe1Y5iiu zZ - */ - - -// stdafx.cpp : source file that includes just the standard includes -// libzrtp_test_GUI.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/libs/libzrtp/test/win_ce/stdafx.h b/libs/libzrtp/test/win_ce/stdafx.h deleted file mode 100644 index e1c44d13fb..0000000000 --- a/libs/libzrtp/test/win_ce/stdafx.h +++ /dev/null @@ -1,61 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#pragma comment(linker, "/nodefaultlib:libc.lib") -#pragma comment(linker, "/nodefaultlib:libcd.lib") - -// NOTE - this value is not strongly correlated to the Windows CE OS version being targeted -#define WINVER _WIN32_WCE - -#include -#if defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP) -#define SHELL_AYGSHELL -#endif - -#ifdef _CE_DCOM -#define _ATL_APARTMENT_THREADED -#endif - -#ifdef SHELL_AYGSHELL -#include -#pragma comment(lib, "aygshell.lib") -#endif // SHELL_AYGSHELL - - -// Windows Header Files: -#include - -// C RunTime Header Files -#include -#include -#include -#include - -#if defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP) -#ifndef _DEVICE_RESOLUTION_AWARE -#define _DEVICE_RESOLUTION_AWARE -#endif -#endif - -#ifdef _DEVICE_RESOLUTION_AWARE -#include "DeviceResolutionAware.h" -#endif - -#if _WIN32_WCE < 0x500 && ( defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP) ) - #pragma comment(lib, "ccrtrtti.lib") - #ifdef _X86_ - #if defined(_DEBUG) - #pragma comment(lib, "libcmtx86d.lib") - #else - #pragma comment(lib, "libcmtx86.lib") - #endif - #endif -#endif - -#include - -// TODO: reference additional headers your program requires here From 7bca61ff0cd5d2ad1d1211b5d5398c9a2af11f40 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Wed, 13 Jun 2012 15:23:30 +0300 Subject: [PATCH 04/49] Remove empty README file Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/test/README | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 libs/libzrtp/test/README diff --git a/libs/libzrtp/test/README b/libs/libzrtp/test/README deleted file mode 100644 index e69de29bb2..0000000000 From 73fabdfea5aeccd4d60383496d3a29147d76cd86 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Wed, 13 Jun 2012 15:23:30 +0300 Subject: [PATCH 05/49] Refactor libzrtp unit tests Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/test/cipher_test.c | 122 +++++++ libs/libzrtp/test/dh_test.c | 52 +++ libs/libzrtp/test/dk_test.c | 140 ++++++++ libs/libzrtp/test/ecdh_test.c | 60 ++++ libs/libzrtp/test/hash_test.c | 80 +++++ libs/libzrtp/test/pc/zrtp_test_crypto.c | 447 ------------------------ libs/libzrtp/test/srtp_replay_test.c | 240 +++++++++++++ 7 files changed, 694 insertions(+), 447 deletions(-) create mode 100644 libs/libzrtp/test/cipher_test.c create mode 100644 libs/libzrtp/test/dh_test.c create mode 100644 libs/libzrtp/test/dk_test.c create mode 100644 libs/libzrtp/test/ecdh_test.c create mode 100644 libs/libzrtp/test/hash_test.c delete mode 100644 libs/libzrtp/test/pc/zrtp_test_crypto.c create mode 100644 libs/libzrtp/test/srtp_replay_test.c diff --git a/libs/libzrtp/test/cipher_test.c b/libs/libzrtp/test/cipher_test.c new file mode 100644 index 0000000000..4098d8b16e --- /dev/null +++ b/libs/libzrtp/test/cipher_test.c @@ -0,0 +1,122 @@ +/* + * libZRTP SDK library, implements the ZRTP secure VoIP protocol. + * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. + * Contact: http://philzimmermann.com + * For licensing and other legal details, see the file zrtp_legal.c. + * + * Viktor Krykun + */ + +#include +#include + +#include "zrtp.h" +#include "cmockery/cmockery.h" + +zrtp_global_t *zrtp; + +void setup() { + zrtp_status_t s; + zrtp_config_t zrtp_config; + + zrtp_config_defaults(&zrtp_config); + + s = zrtp_init(&zrtp_config, &zrtp); + assert_int_equal(s, zrtp_status_ok); +} + +void teardown() { + zrtp_down(zrtp); +} + +static void aes128_ctr_test() { + zrtp_cipher_t *cipher = zrtp_comp_find(ZRTP_CC_CIPHER, ZRTP_CIPHER_AES128, zrtp); + assert_non_null(cipher); + cipher->self_test(cipher, ZRTP_CIPHER_MODE_CTR); +} + +static void aes128_cfb_test() { + zrtp_cipher_t *cipher = zrtp_comp_find(ZRTP_CC_CIPHER, ZRTP_CIPHER_AES128, zrtp); + assert_non_null(cipher); + cipher->self_test(cipher, ZRTP_CIPHER_MODE_CFB); +} + +static void aes256_ctr_test() { + zrtp_cipher_t *cipher = zrtp_comp_find(ZRTP_CC_CIPHER, ZRTP_CIPHER_AES256, zrtp); + assert_non_null(cipher); + cipher->self_test(cipher, ZRTP_CIPHER_MODE_CTR); +} + +static void aes256_cfb_test() { + zrtp_cipher_t *cipher = zrtp_comp_find(ZRTP_CC_CIPHER, ZRTP_CIPHER_AES256, zrtp); + assert_non_null(cipher); + cipher->self_test(cipher, ZRTP_CIPHER_MODE_CFB); +} +/* +static void aes256_cfb_test2() { + rtp_aes_cfb_ctx_t *ctx = (zrtp_aes_cfb_ctx_t*)self->start( self, + aes_cfb_test_key, + NULL, + ZRTP_CIPHER_MODE_CFB); + if (NULL == ctx) { + return zrtp_status_fail; + } + + ZRTP_LOG(3, (_ZTU_,"256 bit AES CFB\n")); + ZRTP_LOG(3, (_ZTU_, "1st test...\n")); + + zrtp_memcpy(aes_cfb_test_buf2b, aes_cfb_test_buf2a, sizeof(aes_cfb_test_buf2a)); + zrtp_memcpy(&tmp_iv, aes_cfb_test_iv, sizeof(tmp_iv)); + + ZRTP_LOG(3, (_ZTU_, "\tencryption... ")); + + self->set_iv(self, ctx, &tmp_iv); + err = self->encrypt(self, ctx, aes_cfb_test_buf2b, sizeof(aes_cfb_test_buf2b)); + if (zrtp_status_ok != err) { + ZRTP_LOGC(1, ("ERROR! 256-bit AES CFB encrypt returns error %d\n", err)); + self->stop(self, ctx); + return err; + } + + for (i=0; i<16; i++) { + if (aes_cfb_test_buf2b[i] != 0x00) { + ZRTP_LOGC(1, ("ERROR! 256-bit AES CFB failed on encrypt test\n")); + self->stop(self, ctx); + return zrtp_status_fail; + } + } + ZRTP_LOGC(3, ("OK\n")); + + ZRTP_LOG(3, (_ZTU_, "\tdecryption... ")); + + zrtp_memcpy(&tmp_iv, aes_cfb_test_iv, sizeof(tmp_iv)); + self->set_iv(self, ctx, &tmp_iv); + + err = self->decrypt(self, ctx, aes_cfb_test_buf2b, sizeof(aes_cfb_test_buf2b)); + if (zrtp_status_ok != err) { + ZRTP_LOGC(1, ("ERROR! 256-bit AES CFB decrypt returns error %d\n", err)); + self->stop(self, ctx); + return err; + } + for (i=0; istop(self, ctx); + return zrtp_status_fail; + } + } + self->stop(self, ctx); + ZRTP_LOGC(3, ("OK\n")); + +} +*/ +int main(void) { + const UnitTest tests[] = { + unit_test_setup_teardown(aes128_ctr_test, setup, teardown), + unit_test_setup_teardown(aes128_cfb_test, setup, teardown), + unit_test_setup_teardown(aes256_ctr_test, setup, teardown), + unit_test_setup_teardown(aes256_cfb_test, setup, teardown), + }; + + return run_tests(tests); +} diff --git a/libs/libzrtp/test/dh_test.c b/libs/libzrtp/test/dh_test.c new file mode 100644 index 0000000000..0047bb53db --- /dev/null +++ b/libs/libzrtp/test/dh_test.c @@ -0,0 +1,52 @@ +/* + * libZRTP SDK library, implements the ZRTP secure VoIP protocol. + * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. + * Contact: http://philzimmermann.com + * For licensing and other legal details, see the file zrtp_legal.c. + * + * Viktor Krykun + */ + +#include +#include + +#include "zrtp.h" +#include "cmockery/cmockery.h" + +zrtp_global_t *zrtp; + +void setup() { + zrtp_status_t s; + zrtp_config_t zrtp_config; + + zrtp_config_defaults(&zrtp_config); + + s = zrtp_init(&zrtp_config, &zrtp); + assert_int_equal(s, zrtp_status_ok); +} + +void teardown() { + zrtp_down(zrtp); +} + +static void dh2k_test() { + zrtp_pk_scheme_t *pks = zrtp_comp_find(ZRTP_CC_PKT, ZRTP_PKTYPE_DH2048, zrtp); + assert_non_null(pks); + pks->self_test(pks); +} + +static void dh3k_test() { + zrtp_pk_scheme_t *pks = zrtp_comp_find(ZRTP_CC_PKT, ZRTP_PKTYPE_DH3072, zrtp); + assert_non_null(pks); + pks->self_test(pks); +} + + +int main(void) { + const UnitTest tests[] = { + unit_test_setup_teardown(dh2k_test, setup, teardown), + unit_test_setup_teardown(dh3k_test, setup, teardown), + }; + + return run_tests(tests); +} diff --git a/libs/libzrtp/test/dk_test.c b/libs/libzrtp/test/dk_test.c new file mode 100644 index 0000000000..81fa60673b --- /dev/null +++ b/libs/libzrtp/test/dk_test.c @@ -0,0 +1,140 @@ +/* + * libZRTP SDK library, implements the ZRTP secure VoIP protocol. + * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. + * Contact: http://philzimmermann.com + * For licensing and other legal details, see the file zrtp_legal.c. + * + * Viktor Krykun + */ + +#include +#include + +#include "zrtp.h" +#include "cmockery/cmockery.h" + +zrtp_global_t *zrtp; + +extern zrtp_dk_ctx *zrtp_dk_init(zrtp_cipher_t *cipher, zrtp_stringn_t *key, zrtp_stringn_t *salt); +extern zrtp_status_t zrtp_derive_key(zrtp_dk_ctx *ctx, zrtp_srtp_prf_label label, zrtp_stringn_t *result_key); +extern void zrtp_dk_deinit(zrtp_dk_ctx *ctx); + +static uint8_t dk_master_key[16] = { + 0xE1, 0xF9, 0x7A, 0x0D, 0x3E, 0x01, 0x8B, 0xE0, + 0xD6, 0x4F, 0xA3, 0x2C, 0x06, 0xDE, 0x41, 0x39 +}; + +static uint8_t dk_master_salt[14] = { + 0x0E, 0xC6, 0x75, 0xAD, 0x49, 0x8A, 0xFE, 0xEB, + 0xB6, 0x96, 0x0B, 0x3A, 0xAB, 0xE6 +}; + + +static uint8_t dk_cipher_key[16] = { + 0xC6, 0x1E, 0x7A, 0x93, 0x74, 0x4F, 0x39, 0xEE, + 0x10, 0x73, 0x4A, 0xFE, 0x3F, 0xF7, 0xA0, 0x87 +}; + +static uint8_t dk_cipher_salt[14] = { + 0x30, 0xCB, 0xBC, 0x08, 0x86, 0x3D, 0x8C, 0x85, + 0xD4, 0x9D, 0xB3, 0x4A, 0x9A, 0xE1 +}; + +static uint8_t dk_auth_key[94] = { + 0xCE, 0xBE, 0x32, 0x1F, 0x6F, 0xF7, 0x71, 0x6B, + 0x6F, 0xD4, 0xAB, 0x49, 0xAF, 0x25, 0x6A, 0x15, + 0x6D, 0x38, 0xBA, 0xA4, 0x8F, 0x0A, 0x0A, 0xCF, + 0x3C, 0x34, 0xE2, 0x35, 0x9E, 0x6C, 0xDB, 0xCE, + 0xE0, 0x49, 0x64, 0x6C, 0x43, 0xD9, 0x32, 0x7A, + 0xD1, 0x75, 0x57, 0x8E, 0xF7, 0x22, 0x70, 0x98, + 0x63, 0x71, 0xC1, 0x0C, 0x9A, 0x36, 0x9A, 0xC2, + 0xF9, 0x4A, 0x8C, 0x5F, 0xBC, 0xDD, 0xDC, 0x25, + 0x6D, 0x6E, 0x91, 0x9A, 0x48, 0xB6, 0x10, 0xEF, + 0x17, 0xC2, 0x04, 0x1E, 0x47, 0x40, 0x35, 0x76, + 0x6B, 0x68, 0x64, 0x2C, 0x59, 0xBB, 0xFC, 0x2F, + 0x34, 0xDB, 0x60, 0xDB, 0xDF, 0xB2 +}; + + +void setup() { + zrtp_status_t s; + zrtp_config_t zrtp_config; + + zrtp_config_defaults(&zrtp_config); + + s = zrtp_init(&zrtp_config, &zrtp); + assert_int_equal(s, zrtp_status_ok); +} + +void teardown() { + zrtp_down(zrtp); +} + +zrtp_status_t hex_cmp(uint8_t *a, uint8_t *b, uint32_t len) +{ + uint32_t i; + zrtp_status_t res = zrtp_status_ok; + for (i = 0; i + */ + +#include +#include + +#include "zrtp.h" +#include "cmockery/cmockery.h" + +zrtp_global_t *zrtp; + +void setup() { + zrtp_status_t s; + zrtp_config_t zrtp_config; + + zrtp_config_defaults(&zrtp_config); + + s = zrtp_init(&zrtp_config, &zrtp); + assert_int_equal(s, zrtp_status_ok); +} + +void teardown() { + zrtp_down(zrtp); +} + + +static void ecdh256_test() { + zrtp_pk_scheme_t *pks = zrtp_comp_find(ZRTP_CC_PKT, ZRTP_PKTYPE_EC256P, zrtp); + assert_non_null(pks); + pks->self_test(pks); +} + +static void ecdh384_test() { + zrtp_pk_scheme_t *pks = zrtp_comp_find(ZRTP_CC_PKT, ZRTP_PKTYPE_EC384P, zrtp); + assert_non_null(pks); + pks->self_test(pks); +} + +static void ecdh512_test() { + zrtp_pk_scheme_t *pks = zrtp_comp_find(ZRTP_CC_PKT, ZRTP_PKTYPE_EC521P, zrtp); + assert_non_null(pks); + pks->self_test(pks); +} + + +int main(void) { + const UnitTest tests[] = { + unit_test_setup_teardown(ecdh256_test, setup, teardown), + unit_test_setup_teardown(ecdh384_test, setup, teardown), + unit_test_setup_teardown(ecdh512_test, setup, teardown), + }; + + return run_tests(tests); +} diff --git a/libs/libzrtp/test/hash_test.c b/libs/libzrtp/test/hash_test.c new file mode 100644 index 0000000000..4f9b3733d2 --- /dev/null +++ b/libs/libzrtp/test/hash_test.c @@ -0,0 +1,80 @@ +/* + * libZRTP SDK library, implements the ZRTP secure VoIP protocol. + * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. + * Contact: http://philzimmermann.com + * For licensing and other legal details, see the file zrtp_legal.c. + * + * Viktor Krykun + */ + +#include +#include + +#include "zrtp.h" +#include "cmockery/cmockery.h" + +zrtp_global_t *zrtp; + +void setup() { + zrtp_status_t s; + zrtp_config_t zrtp_config; + + zrtp_config_defaults(&zrtp_config); + + s = zrtp_init(&zrtp_config, &zrtp); + assert_int_equal(s, zrtp_status_ok); +} + +void teardown() { + zrtp_down(zrtp); +} + +static void sha1_hash_test() { + zrtp_hash_t *hash = zrtp_comp_find(ZRTP_CC_HASH, ZRTP_SRTP_HASH_HMAC_SHA1, zrtp); + assert_non_null(hash); + hash->hash_self_test(hash); +} + +static void sha1_hmac_test() { + zrtp_hash_t *hash = zrtp_comp_find(ZRTP_CC_HASH, ZRTP_SRTP_HASH_HMAC_SHA1, zrtp); + assert_non_null(hash); + hash->hmac_self_test(hash); +} + +static void sha256_hash_test() { + zrtp_hash_t *hash = zrtp_comp_find(ZRTP_CC_HASH, ZRTP_HASH_SHA256, zrtp); + assert_non_null(hash); + hash->hash_self_test(hash); +} + +static void sha256_hmac_test() { + zrtp_hash_t *hash = zrtp_comp_find(ZRTP_CC_HASH, ZRTP_HASH_SHA256, zrtp); + assert_non_null(hash); + hash->hmac_self_test(hash); +} + +static void sha384_hash_test() { + zrtp_hash_t *hash = zrtp_comp_find(ZRTP_CC_HASH, ZRTP_HASH_SHA384, zrtp); + assert_non_null(hash); + hash->hash_self_test(hash); +} + +static void sha384_hmac_test() { + zrtp_hash_t *hash = zrtp_comp_find(ZRTP_CC_HASH, ZRTP_HASH_SHA384, zrtp); + assert_non_null(hash); + hash->hmac_self_test(hash); +} + + +int main(void) { + const UnitTest tests[] = { + unit_test_setup_teardown(sha1_hash_test, setup, teardown), + unit_test_setup_teardown(sha1_hmac_test, setup, teardown), + unit_test_setup_teardown(sha256_hash_test, setup, teardown), + unit_test_setup_teardown(sha256_hmac_test, setup, teardown), + unit_test_setup_teardown(sha384_hash_test, setup, teardown), + unit_test_setup_teardown(sha384_hmac_test, setup, teardown), + }; + + return run_tests(tests); +} diff --git a/libs/libzrtp/test/pc/zrtp_test_crypto.c b/libs/libzrtp/test/pc/zrtp_test_crypto.c deleted file mode 100644 index 0a838fef96..0000000000 --- a/libs/libzrtp/test/pc/zrtp_test_crypto.c +++ /dev/null @@ -1,447 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#include "zrtp.h" - -#define _ZTU_ "libzrtp_test" - -/*---------------------------------------------------------------------------*/ -static void cipher_test(zrtp_global_t *zrtp) -{ - zrtp_cipher_t *cipher = zrtp_comp_find(ZRTP_CC_CIPHER, ZRTP_CIPHER_AES128, zrtp); - if (NULL == cipher) { - ZRTP_LOG(1, (_ZTU_,"ERROR! can't find ZRTP_CIPHER_AES128 cipher component\n")); - } else { - cipher->self_test(cipher, ZRTP_CIPHER_MODE_CFB); - cipher->self_test(cipher, ZRTP_CIPHER_MODE_CTR); - } - - cipher = zrtp_comp_find(ZRTP_CC_CIPHER, ZRTP_CIPHER_AES256, zrtp); - if (NULL == cipher) { - ZRTP_LOG(1, (_ZTU_,"ERROR! can't find ZRTP_CIPHER_AES256 cipher component\n")); - } else { - cipher->self_test(cipher, ZRTP_CIPHER_MODE_CFB); - cipher->self_test(cipher, ZRTP_CIPHER_MODE_CTR); - } -} - -/*---------------------------------------------------------------------------*/ -static zrtp_status_t hash_test(zrtp_global_t *zrtp) -{ - zrtp_hash_t *hash = zrtp_comp_find(ZRTP_CC_HASH, ZRTP_SRTP_HASH_HMAC_SHA1, zrtp); - if (NULL == hash) { - ZRTP_LOG(1, (_ZTU_,"ERROR! can't find ZRTP_SRTP_HASH_HMAC_SHA1 component\n")); - } else { - hash->hash_self_test(hash); - hash->hmac_self_test(hash); - } - - hash = zrtp_comp_find(ZRTP_CC_HASH, ZRTP_HASH_SHA256, zrtp); - if (NULL == hash) { - ZRTP_LOG(1, (_ZTU_,"ERROR! can't find ZRTP_HASH_SHA256 component\n")); - } else { - hash->hash_self_test(hash); - hash->hmac_self_test(hash); - } - - hash = zrtp_comp_find(ZRTP_CC_HASH, ZRTP_HASH_SHA384, zrtp); - if (NULL == hash) { - ZRTP_LOG(1, (_ZTU_,"ERROR! can't find ZRTP_HASH_SHA384 component\n")); - } else { - hash->hash_self_test(hash); - hash->hmac_self_test(hash); - } - - return zrtp_status_ok; -} - -/*---------------------------------------------------------------------------*/ -static zrtp_status_t dh_test(zrtp_global_t *zrtp) -{ - zrtp_pk_scheme_t *pks = zrtp_comp_find(ZRTP_CC_PKT, ZRTP_PKTYPE_DH2048, zrtp); - if (!pks) { - ZRTP_LOG(1, (_ZTU_,"ERROR! can't find ZRTP_PKTYPE_DH2048 component\n")); - } else { - pks->self_test(pks); - } - - pks = zrtp_comp_find(ZRTP_CC_PKT, ZRTP_PKTYPE_DH3072, zrtp); - if (!pks) { - ZRTP_LOG(1, (_ZTU_,"ERROR! can't find ZRTP_PKTYPE_DH3072 component\n")); - } else { - pks->self_test(pks); - } - - return zrtp_status_ok; -} - -/*---------------------------------------------------------------------------*/ -static zrtp_status_t ecdh_test(zrtp_global_t *zrtp) -{ - zrtp_pk_scheme_t *pks = zrtp_comp_find(ZRTP_CC_PKT, ZRTP_PKTYPE_EC256P, zrtp); - if (!pks) { - ZRTP_LOG(1, (_ZTU_,"ERROR! can't find ZRTP_PKTYPE_EC256P component\n")); - } else { - pks->self_test(pks); - } - - pks = zrtp_comp_find(ZRTP_CC_PKT, ZRTP_PKTYPE_EC384P, zrtp); - if (!pks) { - ZRTP_LOG(1, (_ZTU_,"ERROR! can't find ZRTP_PKTYPE_EC384P component\n")); - } else { - pks->self_test(pks); - } - - pks = zrtp_comp_find(ZRTP_CC_PKT, ZRTP_PKTYPE_EC521P, zrtp); - if (!pks) { - ZRTP_LOG(1, (_ZTU_,"ERROR! can't find ZRTP_PKTYPE_EC521P component\n")); - } else { - pks->self_test(pks); - } - - return zrtp_status_ok; -} - -/*---------------------------------------------------------------------------*/ -#if (defined(ZRTP_USE_EXTERN_SRTP) && (ZRTP_USE_EXTERN_SRTP == 1)) -#else - -static uint8_t dk_master_key[16] = { - 0xE1, 0xF9, 0x7A, 0x0D, 0x3E, 0x01, 0x8B, 0xE0, - 0xD6, 0x4F, 0xA3, 0x2C, 0x06, 0xDE, 0x41, 0x39 -}; - -static uint8_t dk_master_salt[14] = { - 0x0E, 0xC6, 0x75, 0xAD, 0x49, 0x8A, 0xFE, 0xEB, - 0xB6, 0x96, 0x0B, 0x3A, 0xAB, 0xE6 -}; - - -static uint8_t dk_cipher_key[16] = { - 0xC6, 0x1E, 0x7A, 0x93, 0x74, 0x4F, 0x39, 0xEE, - 0x10, 0x73, 0x4A, 0xFE, 0x3F, 0xF7, 0xA0, 0x87 -}; - -static uint8_t dk_cipher_salt[14] = { - 0x30, 0xCB, 0xBC, 0x08, 0x86, 0x3D, 0x8C, 0x85, - 0xD4, 0x9D, 0xB3, 0x4A, 0x9A, 0xE1 -}; - -static uint8_t dk_auth_key[94] = { - 0xCE, 0xBE, 0x32, 0x1F, 0x6F, 0xF7, 0x71, 0x6B, - 0x6F, 0xD4, 0xAB, 0x49, 0xAF, 0x25, 0x6A, 0x15, - 0x6D, 0x38, 0xBA, 0xA4, 0x8F, 0x0A, 0x0A, 0xCF, - 0x3C, 0x34, 0xE2, 0x35, 0x9E, 0x6C, 0xDB, 0xCE, - 0xE0, 0x49, 0x64, 0x6C, 0x43, 0xD9, 0x32, 0x7A, - 0xD1, 0x75, 0x57, 0x8E, 0xF7, 0x22, 0x70, 0x98, - 0x63, 0x71, 0xC1, 0x0C, 0x9A, 0x36, 0x9A, 0xC2, - 0xF9, 0x4A, 0x8C, 0x5F, 0xBC, 0xDD, 0xDC, 0x25, - 0x6D, 0x6E, 0x91, 0x9A, 0x48, 0xB6, 0x10, 0xEF, - 0x17, 0xC2, 0x04, 0x1E, 0x47, 0x40, 0x35, 0x76, - 0x6B, 0x68, 0x64, 0x2C, 0x59, 0xBB, 0xFC, 0x2F, - 0x34, 0xDB, 0x60, 0xDB, 0xDF, 0xB2 -}; - -extern zrtp_dk_ctx *zrtp_dk_init(zrtp_cipher_t *cipher, zrtp_stringn_t *key, zrtp_stringn_t *salt); -extern zrtp_status_t zrtp_derive_key(zrtp_dk_ctx *ctx, zrtp_srtp_prf_label label, zrtp_stringn_t *result_key); -extern void zrtp_dk_deinit(zrtp_dk_ctx *ctx); - -zrtp_status_t hex_cmp(uint8_t *a, uint8_t *b, uint32_t len) -{ - uint32_t i; - zrtp_status_t res = zrtp_status_ok; - for (i = 0; i= 0; i--) { - ZRTP_LOGC(3, ("%i%i%i%i%i%i%i%i", - zrtp_bitmap_get_bit(map, 8*i+7), - zrtp_bitmap_get_bit(map, 8*i+6), - zrtp_bitmap_get_bit(map, 8*i+5), - zrtp_bitmap_get_bit(map, 8*i+4), - zrtp_bitmap_get_bit(map, 8*i+3), - zrtp_bitmap_get_bit(map, 8*i+2), - zrtp_bitmap_get_bit(map, 8*i+1), - zrtp_bitmap_get_bit(map, 8*i+0))); - } - ZRTP_LOG(3, (_ZTU_, "\n")); -} - -void init_random_map(uint8_t *map, int width, zrtp_global_t *zrtp) -{ - int i; - for(i=0; irp_ctx, RP_INCOMING_DIRECTION, ssrc); - if (NULL == rp_node) { - return; - } - - for (i=0; i< width; i++) { - if (1 == zrtp_bitmap_get_bit(src_map, i)) { - pkt.seq = i; - if (zrtp_status_ok == zrtp_srtp_rp_check(&rp_node->rtp_rp, &pkt)) { - zrtp_bitmap_set_bit(dst_map, i); - zrtp_srtp_rp_add(&rp_node->rtp_rp, &pkt); - } - } - } -} - -/*---------------------------------------------------------------------------*/ -int srtp_replay_protection_test(zrtp_global_t *zrtp) -{ - int res = 0; - uint32_t ssrc = 1; - int i = 0; - uint8_t test_map[TEST_MAP_WIDTH_BYTES]; - uint8_t result_map[TEST_MAP_WIDTH_BYTES]; - uint8_t tmp_window[ZRTP_SRTP_WINDOW_WIDTH_BYTES]; - uint32_t tmp_seq; - int delta, shift; - - zrtp_rp_node_t *rp_node; - zrtp_srtp_global_t *srtp = zrtp->srtp_global; - - rp_node = add_rp_node(NULL, srtp->rp_ctx, RP_INCOMING_DIRECTION, ssrc); - if (NULL == rp_node) { - return -1; - } - - for (i=0; i< TEST_MAP_WIDTH_BYTES; i++) { - test_map[i] = 0; - result_map[i] = 0; - } - /* - * 1st test - * ---------------------------------------------------------------------- - */ - init_random_map(test_map, FIRST_TEST_MAP_INIT_WIDTH, zrtp); - inject_from_map(srtp, ssrc, test_map, result_map, TEST_MAP_WIDTH); - - ZRTP_LOG(3, (_ZTU_,"1st test. Wnd[%i]...\n", ZRTP_SRTP_WINDOW_WIDTH)); - - tmp_seq = rp_node->rtp_rp.seq; - for (i=0; irtp_rp.window[i]; - } - - delta = tmp_seq-ZRTP_SRTP_WINDOW_WIDTH + 1; - if (delta > 0) { - ZRTP_LOG(3, (_ZTU_,"after wnd: (%i;0]\n", delta)); - ZRTP_LOG(3, (_ZTU_,"inside wnd: [%i;%i]\n", tmp_seq, delta)); - } else { - ZRTP_LOG(3, (_ZTU_,"after wnd: (0;0)\n")); - ZRTP_LOG(3, (_ZTU_,"inside wnd: [%i;0]\n", tmp_seq)); - } - - ZRTP_LOG(3, (_ZTU_,"before wnd: [%i;%i)\n", TEST_MAP_WIDTH-1, tmp_seq)); - - ZRTP_LOG(3, (_ZTU_,"Test map: ")); - print_map(test_map, TEST_MAP_WIDTH_BYTES); - - ZRTP_LOG(3, (_ZTU_,"Res map: ")); - print_map(result_map, TEST_MAP_WIDTH_BYTES); - - shift = TEST_MAP_WIDTH; - shift -= rp_node->rtp_rp.seq + 1; - - ZRTP_LOG(3, (_ZTU_,"Window : ")); - for(i=shift; i > 0; i--){ - ZRTP_LOGC(3, (" ")); - } - print_map(rp_node->rtp_rp.window, ZRTP_SRTP_WINDOW_WIDTH_BYTES); - - /* - * 2nd test - * ---------------------------------------------------------------------- - */ - for(i=0; i< TEST_MAP_WIDTH_BYTES; i++){ - test_map[i] = 0; - result_map[i] = 0; - } - - init_random_map(test_map, TEST_MAP_WIDTH, zrtp); - inject_from_map(srtp, ssrc, test_map, result_map, TEST_MAP_WIDTH); - - ZRTP_LOG(3, (_ZTU_,"2nd test. Wnd[%i]...\n", ZRTP_SRTP_WINDOW_WIDTH)); - ZRTP_LOG(3, (_ZTU_,"Test map: ")); - print_map(test_map, TEST_MAP_WIDTH_BYTES); - - ZRTP_LOG(3, (_ZTU_,"Res map: ")); - print_map(result_map, TEST_MAP_WIDTH_BYTES); - - shift = TEST_MAP_WIDTH; - shift -= rp_node->rtp_rp.seq + 1; - - ZRTP_LOG(3, (_ZTU_,"Window : ")); - for (i=shift; i > 0; i--) { - //zrtp_print_log(ZRTP_LOG_DEBUG, " "); - } - print_map(rp_node->rtp_rp.window, ZRTP_SRTP_WINDOW_WIDTH_BYTES); - - - /* - in result map: - - after window we should to have all zeroes - - into the window we should have ones only if window have zero at appropriate position - - before window we should have equal values of test map and result map bits - */ - for (i=0; i < TEST_MAP_WIDTH; i++) { - if (delta > 0 && i < delta) { - /* After window */ - if (0 != zrtp_bitmap_get_bit(result_map, i)) { - ZRTP_LOG(3, (_ZTU_,"After window. %i bit should be 0\n", i)); - res = -1; - } - } else if (i <= (int)tmp_seq && i >= delta) { - /* inside window */ - - /* check window filtering */ - if(1 == zrtp_bitmap_get_bit(result_map, i)) { - if (1 == zrtp_bitmap_get_bit(tmp_window, i - (tmp_seq-ZRTP_SRTP_WINDOW_WIDTH) - 1)) { - ZRTP_LOG(3, (_ZTU_,"Inside window. Window filtering fail. %i bit should be 0\n", i)); - res = -1; - } - } - /* check test vs result maps */ - if ( zrtp_bitmap_get_bit(result_map, i) != zrtp_bitmap_get_bit(test_map, i) && - !zrtp_bitmap_get_bit(tmp_window, i - (tmp_seq-ZRTP_SRTP_WINDOW_WIDTH) - 1)) { - ZRTP_LOG(3, (_ZTU_, "Inside window. Test map isn't equal to result at bit %i\n", i)); - res = -1; - } - - } else { - /* after window */ - if (zrtp_bitmap_get_bit(result_map, i) != zrtp_bitmap_get_bit(test_map, i)) { - ZRTP_LOG(3, (_ZTU_,"Before window. Test map isn't equal to result at bit %i\n", i)); - res = -1; - } - } - } - if (0 == res) { - ZRTP_LOG(3, (_ZTU_,"Test passed successfully\n")); - } - - return res; -} - -#endif - - -/*---------------------------------------------------------------------------*/ -void zrtp_test_crypto(zrtp_global_t* zrtp) -{ - ZRTP_LOG(3, (_ZTU_,"====================CIPHERS TESTS====================\n")); - cipher_test(zrtp); - ZRTP_LOG(3, (_ZTU_,"=====================HASHES TESTS====================\n")); - hash_test(zrtp); - ZRTP_LOG(3, (_ZTU_,"================PUBLIC KEY SCHEMES TESTS==============\n")); - dh_test(zrtp); - ecdh_test(zrtp); - ZRTP_LOG(3, (_ZTU_,"===============SRTP Key derivation TESTS==============\n")); - dk_test(zrtp); - ZRTP_LOG(3, (_ZTU_,"==============SRTP Replay protection TESTS============\n")) ; - srtp_replay_protection_test(zrtp); -} diff --git a/libs/libzrtp/test/srtp_replay_test.c b/libs/libzrtp/test/srtp_replay_test.c new file mode 100644 index 0000000000..67c94a87b7 --- /dev/null +++ b/libs/libzrtp/test/srtp_replay_test.c @@ -0,0 +1,240 @@ +/* + * libZRTP SDK library, implements the ZRTP secure VoIP protocol. + * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. + * Contact: http://philzimmermann.com + * For licensing and other legal details, see the file zrtp_legal.c. + * + * Viktor Krykun + */ + +#include +#include + +#include "zrtp.h" +#include "cmockery/cmockery.h" + +#define _ZTU_ "srtp replay test" + +zrtp_global_t *zrtp; + +#define TEST_MAP_WIDTH 64 +#if TEST_MAP_WIDTH%8 +# define TEST_MAP_WIDTH_BYTES TEST_MAP_WIDTH/8+1 +#else +# define TEST_MAP_WIDTH_BYTES TEST_MAP_WIDTH/8 +#endif + +#define FIRST_TEST_MAP_INIT_WIDTH 24 + +extern zrtp_rp_node_t *get_rp_node_non_lock(zrtp_rp_ctx_t *ctx, uint8_t direction, uint32_t ssrc); +extern zrtp_rp_node_t *add_rp_node(zrtp_srtp_ctx_t *srtp_ctx, zrtp_rp_ctx_t *ctx, uint8_t direction, uint32_t ssrc); +extern zrtp_status_t zrtp_srtp_rp_check(zrtp_srtp_rp_t *srtp_rp, zrtp_rtp_info_t *packet); +extern zrtp_status_t zrtp_srtp_rp_add(zrtp_srtp_rp_t *srtp_rp, zrtp_rtp_info_t *packet); + + +void setup() { + zrtp_status_t s; + zrtp_config_t zrtp_config; + + zrtp_config_defaults(&zrtp_config); + + s = zrtp_init(&zrtp_config, &zrtp); + assert_int_equal(s, zrtp_status_ok); +} + +void teardown() { + zrtp_down(zrtp); +} + +static void print_map(uint8_t *map, int width_bytes) +{ + int i; + for(i=width_bytes-1; i >= 0; i--) { + ZRTP_LOGC(3, ("%i%i%i%i%i%i%i%i", + zrtp_bitmap_get_bit(map, 8*i+7), + zrtp_bitmap_get_bit(map, 8*i+6), + zrtp_bitmap_get_bit(map, 8*i+5), + zrtp_bitmap_get_bit(map, 8*i+4), + zrtp_bitmap_get_bit(map, 8*i+3), + zrtp_bitmap_get_bit(map, 8*i+2), + zrtp_bitmap_get_bit(map, 8*i+1), + zrtp_bitmap_get_bit(map, 8*i+0))); + } + ZRTP_LOG(3, (_ZTU_, "\n")); +} + +static void init_random_map(uint8_t *map, int width, zrtp_global_t *zrtp) { + int i; + for(i=0; irp_ctx, RP_INCOMING_DIRECTION, ssrc); + if (NULL == rp_node) { + return; + } + + for (i=0; i< width; i++) { + if (1 == zrtp_bitmap_get_bit(src_map, i)) { + pkt.seq = i; + if (zrtp_status_ok == zrtp_srtp_rp_check(&rp_node->rtp_rp, &pkt)) { + zrtp_bitmap_set_bit(dst_map, i); + zrtp_srtp_rp_add(&rp_node->rtp_rp, &pkt); + } + } + } +} + +// TODO: split test into several, more atomic tests +static void srtp_replay_test() { + int res = 0; + uint32_t ssrc = 1; + int i = 0; + uint8_t test_map[TEST_MAP_WIDTH_BYTES]; + uint8_t result_map[TEST_MAP_WIDTH_BYTES]; + uint8_t tmp_window[ZRTP_SRTP_WINDOW_WIDTH_BYTES]; + uint32_t tmp_seq; + int delta, shift; + + zrtp_rp_node_t *rp_node; + zrtp_srtp_global_t *srtp = zrtp->srtp_global; + + rp_node = add_rp_node(NULL, srtp->rp_ctx, RP_INCOMING_DIRECTION, ssrc); + assert_non_null(rp_node); + + for (i=0; i< TEST_MAP_WIDTH_BYTES; i++) { + test_map[i] = 0; + result_map[i] = 0; + } + /* + * 1st test + * ---------------------------------------------------------------------- + */ + init_random_map(test_map, FIRST_TEST_MAP_INIT_WIDTH, zrtp); + inject_from_map(srtp, ssrc, test_map, result_map, TEST_MAP_WIDTH); + + ZRTP_LOG(3, (_ZTU_,"1st test. Wnd[%i]...\n", ZRTP_SRTP_WINDOW_WIDTH)); + + tmp_seq = rp_node->rtp_rp.seq; + for (i=0; irtp_rp.window[i]; + } + + delta = tmp_seq-ZRTP_SRTP_WINDOW_WIDTH + 1; + if (delta > 0) { + ZRTP_LOG(3, (_ZTU_,"after wnd: (%i;0]\n", delta)); + ZRTP_LOG(3, (_ZTU_,"inside wnd: [%i;%i]\n", tmp_seq, delta)); + } else { + ZRTP_LOG(3, (_ZTU_,"after wnd: (0;0)\n")); + ZRTP_LOG(3, (_ZTU_,"inside wnd: [%i;0]\n", tmp_seq)); + } + + ZRTP_LOG(3, (_ZTU_,"before wnd: [%i;%i)\n", TEST_MAP_WIDTH-1, tmp_seq)); + + ZRTP_LOG(3, (_ZTU_,"Test map: ")); + print_map(test_map, TEST_MAP_WIDTH_BYTES); + + ZRTP_LOG(3, (_ZTU_,"Res map: ")); + print_map(result_map, TEST_MAP_WIDTH_BYTES); + + shift = TEST_MAP_WIDTH; + shift -= rp_node->rtp_rp.seq + 1; + + ZRTP_LOG(3, (_ZTU_,"Window : ")); + for(i=shift; i > 0; i--){ + ZRTP_LOGC(3, (" ")); + } + print_map(rp_node->rtp_rp.window, ZRTP_SRTP_WINDOW_WIDTH_BYTES); + + /* + * 2nd test + * ---------------------------------------------------------------------- + */ + for(i=0; i< TEST_MAP_WIDTH_BYTES; i++){ + test_map[i] = 0; + result_map[i] = 0; + } + + init_random_map(test_map, TEST_MAP_WIDTH, zrtp); + inject_from_map(srtp, ssrc, test_map, result_map, TEST_MAP_WIDTH); + + ZRTP_LOG(3, (_ZTU_,"2nd test. Wnd[%i]...\n", ZRTP_SRTP_WINDOW_WIDTH)); + ZRTP_LOG(3, (_ZTU_,"Test map: ")); + print_map(test_map, TEST_MAP_WIDTH_BYTES); + + ZRTP_LOG(3, (_ZTU_,"Res map: ")); + print_map(result_map, TEST_MAP_WIDTH_BYTES); + + shift = TEST_MAP_WIDTH; + shift -= rp_node->rtp_rp.seq + 1; + + ZRTP_LOG(3, (_ZTU_,"Window : ")); + for (i=shift; i > 0; i--) { + //zrtp_print_log(ZRTP_LOG_DEBUG, " "); + } + print_map(rp_node->rtp_rp.window, ZRTP_SRTP_WINDOW_WIDTH_BYTES); + + + /* + in result map: + - after window we should to have all zeroes + - into the window we should have ones only if window have zero at appropriate position + - before window we should have equal values of test map and result map bits + */ + for (i=0; i < TEST_MAP_WIDTH; i++) { + if (delta > 0 && i < delta) { + /* After window */ + if (0 != zrtp_bitmap_get_bit(result_map, i)) { + ZRTP_LOG(3, (_ZTU_,"After window. %i bit should be 0\n", i)); + res = -1; + } + } else if (i <= (int)tmp_seq && i >= delta) { + /* inside window */ + + /* check window filtering */ + if(1 == zrtp_bitmap_get_bit(result_map, i)) { + if (1 == zrtp_bitmap_get_bit(tmp_window, i - (tmp_seq-ZRTP_SRTP_WINDOW_WIDTH) - 1)) { + ZRTP_LOG(3, (_ZTU_,"Inside window. Window filtering fail. %i bit should be 0\n", i)); + res = -1; + } + } + /* check test vs result maps */ + if ( zrtp_bitmap_get_bit(result_map, i) != zrtp_bitmap_get_bit(test_map, i) && + !zrtp_bitmap_get_bit(tmp_window, i - (tmp_seq-ZRTP_SRTP_WINDOW_WIDTH) - 1)) { + ZRTP_LOG(3, (_ZTU_, "Inside window. Test map isn't equal to result at bit %i\n", i)); + res = -1; + } + + } else { + /* after window */ + if (zrtp_bitmap_get_bit(result_map, i) != zrtp_bitmap_get_bit(test_map, i)) { + ZRTP_LOG(3, (_ZTU_,"Before window. Test map isn't equal to result at bit %i\n", i)); + res = -1; + } + } + } + + assert_int_equal(res, 0); +} + +int main(void) { + const UnitTest tests[] = { + unit_test_setup_teardown(srtp_replay_test, setup, teardown), + }; + + return run_tests(tests); +} From a7286bff1a99cec44b553fdbdcaee016692992e2 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Tue, 26 Jun 2012 19:11:29 +0000 Subject: [PATCH 06/49] Improve .gitignore --- libs/libzrtp/.gitignore | 9 ++++++++- libs/libzrtp/third_party/bnlib/.gitignore | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libs/libzrtp/.gitignore b/libs/libzrtp/.gitignore index ea9c7b1f3d..f45d0ca054 100644 --- a/libs/libzrtp/.gitignore +++ b/libs/libzrtp/.gitignore @@ -4,5 +4,12 @@ /Makefile /Makefile.in /_configs.sed -/config/ +/aclocal.m4 +/autom4te.cache/* +/build/ +/config.* +/config/* +/configure /include/zrtp_config_unix.h +!/build/Makefile.am +!/build/test/Makefile.am diff --git a/libs/libzrtp/third_party/bnlib/.gitignore b/libs/libzrtp/third_party/bnlib/.gitignore index 93a51e214c..49dd32a5b0 100644 --- a/libs/libzrtp/third_party/bnlib/.gitignore +++ b/libs/libzrtp/third_party/bnlib/.gitignore @@ -1,3 +1,8 @@ # -*- mode:conf -*- +/*.a +/*.o /Makefile +/autom4te.cache/* /bnconfig.h +/config.* +/configure From 2664e0ee709dda8039ee11774a001b5f9cd1e9c2 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Wed, 13 Jun 2012 15:23:30 +0300 Subject: [PATCH 07/49] Add high-level test engine Remove some old tests and implement a few test-cases to emulate zrtp enrollment and sasrelay logic Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/build/test/Makefile.am | 10 - libs/libzrtp/test/enroll_test_helpers.c | 81 ++ libs/libzrtp/test/enrollment_test.c | 100 ++ libs/libzrtp/test/go_secure_test.c | 91 ++ libs/libzrtp/test/pc/zrtp_test_core.c | 866 ----------------- libs/libzrtp/test/pc/zrtp_test_core.h | 38 - libs/libzrtp/test/pc/zrtp_test_ui.c | 75 -- .../test/{pc/zrtp_test_queue.c => queue.c} | 22 +- .../test/{pc/zrtp_test_queue.h => queue.h} | 3 +- libs/libzrtp/test/sasrelay_test.c | 123 +++ libs/libzrtp/test/test_engine.c | 871 ++++++++++++++++++ libs/libzrtp/test/test_engine.h | 130 +++ 12 files changed, 1406 insertions(+), 1004 deletions(-) create mode 100644 libs/libzrtp/test/enroll_test_helpers.c create mode 100644 libs/libzrtp/test/enrollment_test.c create mode 100644 libs/libzrtp/test/go_secure_test.c delete mode 100644 libs/libzrtp/test/pc/zrtp_test_core.c delete mode 100644 libs/libzrtp/test/pc/zrtp_test_core.h delete mode 100644 libs/libzrtp/test/pc/zrtp_test_ui.c rename libs/libzrtp/test/{pc/zrtp_test_queue.c => queue.c} (85%) rename libs/libzrtp/test/{pc/zrtp_test_queue.h => queue.h} (96%) create mode 100644 libs/libzrtp/test/sasrelay_test.c create mode 100644 libs/libzrtp/test/test_engine.c create mode 100644 libs/libzrtp/test/test_engine.h diff --git a/libs/libzrtp/build/test/Makefile.am b/libs/libzrtp/build/test/Makefile.am index b8f9a9abb9..4a9321c69f 100644 --- a/libs/libzrtp/build/test/Makefile.am +++ b/libs/libzrtp/build/test/Makefile.am @@ -17,7 +17,6 @@ INCLUDES = -I$(TOP_SRCDIR)/include \ -I$(TOP_SRCDIR)/third_party/bnlib -#check_PROGRAMS = cache_test libzrtp_test check_PROGRAMS = cache_test ### ZRTP Cache testing @@ -27,15 +26,6 @@ cache_test_SOURCES = $(TOP_SRCDIR)/test/cmockery/cmockery.c \ cache_test_LDADD = ../libzrtp.a $(TOP_SRCDIR)/third_party/bnlib/libbn.a -lpthread -### ZRTP high-level test-case - -libzrtp_test_SOURCES = $(TOP_SRCDIR)/test/pc/zrtp_test_core.c \ - $(TOP_SRCDIR)/test/pc/zrtp_test_crypto.c \ - $(TOP_SRCDIR)/test/pc/zrtp_test_queue.c \ - $(TOP_SRCDIR)/test/pc/zrtp_test_ui.c - -libzrtp_test_LDADD = ../libzrtp.a $(TOP_SRCDIR)/third_party/bnlib/libbn.a -lpthread - SUBDIRS = . check: diff --git a/libs/libzrtp/test/enroll_test_helpers.c b/libs/libzrtp/test/enroll_test_helpers.c new file mode 100644 index 0000000000..ef0973b9f3 --- /dev/null +++ b/libs/libzrtp/test/enroll_test_helpers.c @@ -0,0 +1,81 @@ + +static zrtp_test_id_t g_alice, g_bob, g_pbx; +static zrtp_test_id_t g_alice_sid, g_bob_sid, g_pbxa_sid, g_pbxb_sid; +static zrtp_test_id_t g_alice2pbx_channel, g_bob2pbx_channel; + +static void pbx_setup() { + zrtp_status_t s; + + zrtp_test_endpoint_cfg_t endpoint_cfg; + zrtp_test_endpoint_config_defaults(&endpoint_cfg); + + s = zrtp_test_endpoint_create(&endpoint_cfg, "Alice", &g_alice); + assert_int_equal(zrtp_status_ok, s); + assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_alice); + + s = zrtp_test_endpoint_create(&endpoint_cfg, "Bob", &g_bob); + assert_int_equal(zrtp_status_ok, s); + assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_bob); + + endpoint_cfg.zrtp.is_mitm = 1; + s = zrtp_test_endpoint_create(&endpoint_cfg, "PBX", &g_pbx); + assert_int_equal(zrtp_status_ok, s); + assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_pbx); +} + +static void pbx_teardown() { + zrtp_test_endpoint_destroy(g_alice); + zrtp_test_endpoint_destroy(g_bob); + zrtp_test_endpoint_destroy(g_pbx); +} + + +static void prepare_alice_pbx_bob_setup(zrtp_test_session_cfg_t *alice_sconfig, + zrtp_test_session_cfg_t *bob_sconfig, + zrtp_test_session_cfg_t *pbxa_sconfig, + zrtp_test_session_cfg_t *pbxb_sconfig) { + zrtp_status_t s; + + if (alice_sconfig) { + assert_non_null(pbxa_sconfig); + + s = zrtp_test_session_create(g_alice, alice_sconfig, &g_alice_sid); + assert_int_equal(zrtp_status_ok, s); + assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_alice_sid); + + s = zrtp_test_session_create(g_pbx, pbxa_sconfig, &g_pbxa_sid); + assert_int_equal(zrtp_status_ok, s); + assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_pbxa_sid); + + s = zrtp_test_channel_create2(g_alice_sid, g_pbxa_sid, 0, &g_alice2pbx_channel); + assert_int_equal(zrtp_status_ok, s); + assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_alice2pbx_channel); + } + + if (bob_sconfig) { + assert_non_null(pbxb_sconfig); + + s = zrtp_test_session_create(g_bob, bob_sconfig, &g_bob_sid); + assert_int_equal(zrtp_status_ok, s); + assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_bob_sid); + + s = zrtp_test_session_create(g_pbx, pbxb_sconfig, &g_pbxb_sid); + assert_int_equal(zrtp_status_ok, s); + assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_pbxb_sid); + + s = zrtp_test_channel_create2(g_bob_sid, g_pbxb_sid, 0, &g_bob2pbx_channel); + assert_int_equal(zrtp_status_ok, s); + assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_bob2pbx_channel); + } +} + +static void cleanup_alice_pbx_bob_setup() { + zrtp_test_session_destroy(g_alice_sid); + zrtp_test_session_destroy(g_bob_sid); + zrtp_test_session_destroy(g_pbxa_sid); + zrtp_test_session_destroy(g_pbxb_sid); + + zrtp_test_channel_destroy(g_alice2pbx_channel); + zrtp_test_channel_destroy(g_bob2pbx_channel); +} + diff --git a/libs/libzrtp/test/enrollment_test.c b/libs/libzrtp/test/enrollment_test.c new file mode 100644 index 0000000000..5d54c55478 --- /dev/null +++ b/libs/libzrtp/test/enrollment_test.c @@ -0,0 +1,100 @@ +/* + * libZRTP SDK library, implements the ZRTP secure VoIP protocol. + * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. + * Contact: http://philzimmermann.com + * For licensing and other legal details, see the file zrtp_legal.c. + * + * Viktor Krykun + */ + +#include /*chmockery dependency*/ +#include /*chmockery dependency*/ +#include /*for usleep*/ + +#include "cmockery/cmockery.h" +#include "test_engine.h" + +#include "enroll_test_helpers.c" + +static void enrollment_test() { + zrtp_status_t s; + + zrtp_test_channel_info_t a2pbx_channel_info; + zrtp_test_session_cfg_t session_config, session_config_enroll; + zrtp_test_session_config_defaults(&session_config); + zrtp_test_session_config_defaults(&session_config_enroll); + + session_config_enroll.is_enrollment = 1; + + /************************************************************************** + * Enroll Alice to PBX and check triggered events. + */ + prepare_alice_pbx_bob_setup(&session_config, NULL, &session_config_enroll, NULL); + + /* Everything is ready. Let's start the stream and give it few seconds to switch secure. */ + s = zrtp_test_channel_start(g_alice2pbx_channel); + assert_int_equal(zrtp_status_ok, s); + + int i = 30; + for (; i>0; i--) { + usleep(100*1000); + } + + s = zrtp_test_channel_get(g_alice2pbx_channel, &a2pbx_channel_info); + assert_int_equal(zrtp_status_ok, s); + + /* Both, Alice and PBX should switch secure */ + assert_true(a2pbx_channel_info.is_secure); + + /* Alice should receive Enrollment notification */ + zrtp_test_id_t alice2pbx_stream = zrtp_test_session_get_stream_by_idx(g_alice_sid, 0); + assert_true(zrtp_stream_did_event_receive(alice2pbx_stream, ZRTP_EVENT_IS_CLIENT_ENROLLMENT)); + + /* PBX streams should receive incoming enrollment notification */ + zrtp_test_id_t pbx2alice_stream = zrtp_test_session_get_stream_by_idx(g_pbxa_sid, 0); + assert_true(zrtp_stream_did_event_receive(pbx2alice_stream, ZRTP_EVENT_NEW_USER_ENROLLED)); + + /* Clean-up */ + cleanup_alice_pbx_bob_setup(); + + + /************************************************************************** + * Try to make one more enrollment call. This time it should say "Already enrolled" + */ + prepare_alice_pbx_bob_setup(&session_config, NULL, &session_config_enroll, NULL); + + /* Everything is ready. Let's start the stream and give it few seconds to switch secure. */ + s = zrtp_test_channel_start(g_alice2pbx_channel); + assert_int_equal(zrtp_status_ok, s); + + i = 30; + for (; i>0; i--) { + usleep(100*1000); + } + + s = zrtp_test_channel_get(g_alice2pbx_channel, &a2pbx_channel_info); + assert_int_equal(zrtp_status_ok, s); + + assert_true(a2pbx_channel_info.is_secure); + + /* Alice should receive Enrollment notification */ + alice2pbx_stream = zrtp_test_session_get_stream_by_idx(g_alice_sid, 0); + assert_true(zrtp_stream_did_event_receive(alice2pbx_stream, ZRTP_EVENT_IS_CLIENT_ENROLLMENT)); + + /* PBX streams should receive incoming enrollment notification */ + pbx2alice_stream = zrtp_test_session_get_stream_by_idx(g_pbxa_sid, 0); + assert_true(zrtp_stream_did_event_receive(pbx2alice_stream, ZRTP_EVENT_USER_ALREADY_ENROLLED)); + + // TODO: check if we have PBX secret cached + // TODO: test zrtp_is_user_enrolled() + + // TODO: use zrtp_register_with_trusted_mitm() +} + +int main(void) { + const UnitTest tests[] = { + unit_test_setup_teardown(enrollment_test, pbx_setup, pbx_teardown), + }; + + return run_tests(tests); +} diff --git a/libs/libzrtp/test/go_secure_test.c b/libs/libzrtp/test/go_secure_test.c new file mode 100644 index 0000000000..ab6740d3cc --- /dev/null +++ b/libs/libzrtp/test/go_secure_test.c @@ -0,0 +1,91 @@ +/* + * libZRTP SDK library, implements the ZRTP secure VoIP protocol. + * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. + * Contact: http://philzimmermann.com + * For licensing and other legal details, see the file zrtp_legal.c. + * + * Viktor Krykun + */ + +#include /*chmockery dependency*/ +#include /*chmockery dependency*/ +#include /*for usleep*/ + +#include "cmockery/cmockery.h" +#include "test_engine.h" + +static zrtp_test_id_t g_alice, g_bob; +static zrtp_test_id_t g_alice_sid, g_bob_sid; +static zrtp_test_id_t g_secure_audio_channel; + +static void setup() { + zrtp_status_t s; + + zrtp_test_endpoint_cfg_t endpoint_cfg; + zrtp_test_endpoint_config_defaults(&endpoint_cfg); + + s = zrtp_test_endpoint_create(&endpoint_cfg, "Alice", &g_alice); + assert_int_equal(zrtp_status_ok, s); + assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_alice); + + s = zrtp_test_endpoint_create(&endpoint_cfg, "Bob", &g_bob); + assert_int_equal(zrtp_status_ok, s); + assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_bob); +} + +static void teardown() { + zrtp_test_endpoint_destroy(g_alice); + zrtp_test_endpoint_destroy(g_bob); +} + +static void go_secure_test() { + zrtp_status_t s; + + zrtp_test_channel_info_t channel_info; + zrtp_test_session_cfg_t session_config; + zrtp_test_session_config_defaults(&session_config); + + /* + * Create two test sessions, one for Alice and one for Bob and link them + * into test secure channel + */ + s = zrtp_test_session_create(g_alice, &session_config, &g_alice_sid); + assert_int_equal(zrtp_status_ok, s); + assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_alice_sid); + + s = zrtp_test_session_create(g_bob, &session_config, &g_bob_sid); + assert_int_equal(zrtp_status_ok, s); + assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_bob_sid); + + s = zrtp_test_channel_create2(g_alice_sid, g_bob_sid, 0, &g_secure_audio_channel); + assert_int_equal(zrtp_status_ok, s); + assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_secure_audio_channel); + + /* Everything is ready. Let's start the stream and give it few seconds to switch secure. */ + s = zrtp_test_channel_start(g_secure_audio_channel); + assert_int_equal(zrtp_status_ok, s); + + int i = 30; + for (; i>0; i--) { + usleep(100*1000); + } + + s = zrtp_test_channel_get(g_secure_audio_channel, &channel_info); + assert_int_equal(zrtp_status_ok, s); + + /* Both, Alice and Bob should switch secure */ + assert_true(channel_info.is_secure); + + zrtp_test_session_destroy(g_alice_sid); + zrtp_test_session_destroy(g_bob_sid); + + zrtp_test_channel_destroy(g_secure_audio_channel); +} + +int main(void) { + const UnitTest tests[] = { + unit_test_setup_teardown(go_secure_test, setup, teardown), + }; + + return run_tests(tests); +} diff --git a/libs/libzrtp/test/pc/zrtp_test_core.c b/libs/libzrtp/test/pc/zrtp_test_core.c deleted file mode 100644 index ae3a7ec7c1..0000000000 --- a/libs/libzrtp/test/pc/zrtp_test_core.c +++ /dev/null @@ -1,866 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#include "zrtp.h" - -#include "zrtp_test_core.h" -#include "zrtp_test_queue.h" - -#if (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WINCE) -#include -#elif (ZRTP_PLATFORM == ZP_DARWIN) || (ZRTP_PLATFORM == ZP_LINUX) -#include -#include -#endif - -#define _ZTU_ "TEST" -#define ZRTP_TEST_PACKET_MAX_SIZE 256 -#define ZRTP_TEST_STREAMS_COUNT 1 - -#define ZRTP_ENABLE_TEST 0 - -extern uint8_t hash_word_list_odd[256][12]; -extern uint8_t hash_word_list_even[256][10]; - -/*! Global data storage */ -typedef struct zrtp_test_global -{ - mlist_t channels_head; /*! List of test channels*/ - zrtp_mutex_t* channels_protector; /*! Protector from list modifications */ - unsigned char is_log_enabled; /*! Allows debug messages logging */ - unsigned packets_rate; /*! Delay in miliseconds between RTP injection */ - unsigned channels_count; /*! Active channels count */ - unsigned secure_count; /*! Active channels count */ - zrtp_queue_t* queue; /*! Queue which emulate communication channel between ZRTP endpoints */ - unsigned char is_running; /*! Main test loop work while this is not 0 */ -} zrtp_test_global_t; - -zrtp_test_global_t test_global; /*! zrtp test global data */ -zrtp_global_t* zrtp_global; /*! libzrtp global data */ - - -typedef struct zrtp_test_session zrtp_test_session_t; -typedef struct zrtp_test_stream zrtp_test_stream_t; -typedef struct zrtp_test_channel zrtp_test_channel_t; - -#define ZRTP_TEST_PACKET_HEADER_LENGTH 16 - - -typedef struct zrtp_test_packet -{ - uint32_t is_rtp; /*! Defines is packet RTP or RTCP */ - uint32_t length; /*! Packet Length in bytes */ - char body[1024]; /*! Packet body */ -} zrtp_test_packet_t; - -struct zrtp_test_stream -{ - zrtp_stream_t* zrtp_stream; /*! ZRTP stream associated test stream */ - zrtp_test_session_t* session; /*! Pointer to the parent test session */ - uint16_t seq; /*! RTP sequence number for media packets construction */ - uint32_t ssrc; /*! RTP local SSRC for media packets exchanging */ - uint32_t peer_ssrc; /*! RTP remote SSRC for media packets exchanging */ -}; - -struct zrtp_test_session -{ - zrtp_test_stream_t streams[ZRTP_MAX_STREAMS_PER_SESSION]; /*! Streams array */ - unsigned streams_count; /*! Active streams counter */ - zrtp_session_t* zrtp_session; /*! ZRTP session associated test session */ - zrtp_test_channel_t *channel; - mlist_t _list; -}; - -struct zrtp_test_channel -{ - zrtp_test_channel_id_t id; /*! Channel ID*/ - zrtp_test_session_t ses_left; /*! Left test session */ - zrtp_test_session_t ses_right; /*! Right test session */ - mlist_t _mlist; -}; - - -zrtp_test_channel_t* find_channel_by_index(zrtp_test_channel_id_t chan_id); -zrtp_test_channel_t* find_channel_with_closest_index(zrtp_test_channel_id_t chan_id); -zrtp_test_stream_t* find_peer_stream_by_ssrc(uint32_t ssrc); - - -/*============================================================================*/ -/* ZRTP Interfaces */ -/*============================================================================*/ - -static void on_zrtp_protocol_event(zrtp_stream_t *ctx, zrtp_protocol_event_t event) -{ -} - -static void on_zrtp_security_event(zrtp_stream_t *ctx, zrtp_security_event_t event) -{ -} - -static void on_zrtp_secure(zrtp_stream_t *ctx) -{ - zrtp_test_stream_t *stream = (zrtp_test_stream_t*) zrtp_stream_get_userdata(ctx); - zrtp_test_channel_t *channel = stream->session->channel; - unsigned i = 0; - unsigned char not_secure = 0; - - ZRTP_LOG(1, (_ZTU_,"Stream is SECURE ssrc=%u ctx=%d\n", ctx->media_ctx.ssrc, ctx)); - - for (i=0; ises_left.streams_count; i++) { - if (ZRTP_STATE_SECURE != channel->ses_left.streams[i].zrtp_stream->state) { - not_secure = 1; - } - } - if (0 == not_secure) { - for (i=0; ises_right.streams_count; i++) { - if (ZRTP_STATE_SECURE != channel->ses_right.streams[i].zrtp_stream->state) { - not_secure = 1; - } - } - } - - if (0 == not_secure) { - zrtp_session_info_t session_info; - zrtp_stream_info_t a_stream_info; - - test_global.secure_count++; - - ZRTP_LOG(1, (_ZTU_,"===================================================\n")); - ZRTP_LOG(1, (_ZTU_,"Entire Channel is SECURE. Total Secure count=%d\n", test_global.secure_count)); - ZRTP_LOG(1, (_ZTU_,"===================================================\n")); - - zrtp_session_get(channel->ses_left.zrtp_session, &session_info); - zrtp_stream_get(channel->ses_left.streams[0].zrtp_stream , &a_stream_info); - - zrtp_log_print_sessioninfo(&session_info); - zrtp_log_print_streaminfo(&a_stream_info); - } -} - -static int on_send_packet(const zrtp_stream_t* ctx, char* message, unsigned int length) -{ - zrtp_queue_elem_t* elem = zrtp_sys_alloc(sizeof(zrtp_queue_elem_t)); - if (elem) { - zrtp_test_packet_t* packet = (zrtp_test_packet_t*) elem->data; - elem->size = length; - - packet->is_rtp = 1; - packet->length = length; - zrtp_memcpy(packet->body, message, length); - - ZRTP_LOG(1, (_ZTU_,"\tSend message to ssrc=%u length=%d\n", ctx->media_ctx.ssrc, length)); - zrtp_test_queue_push(test_global.queue, elem); - return zrtp_status_ok; - } else { - return zrtp_status_alloc_fail; - } -} - -void zrtp_def_get_cache_path(char *path, uint32_t length) -{ -#if (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WINCE) - strncpy_s(path, length, "./zrtp_test_cache.dat", length); -#else - strncpy(path, "./zrtp_test_cache.dat", length); -#endif -} - - -/*============================================================================*/ -/* Sessions Life-Cycle Logic */ -/*============================================================================*/ - -/*----------------------------------------------------------------------------*/ -#if (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WINCE) -DWORD WINAPI process_incoming(void *param) -#else -void *process_incoming(void *param) -#endif -{ - ZRTP_LOG(1, (_ZTU_,"======> STARTING Incoming processor\n")); - while (test_global.is_running) - { - zrtp_test_packet_t* packet = NULL; - zrtp_queue_elem_t* elem = NULL; - zrtp_status_t s = zrtp_status_fail; - zrtp_test_stream_t *stream = NULL; - int is_protocol = 0; - - /* Get packet from the "Network" and find aapropriate stream to process it */ - elem = zrtp_test_queue_pop(test_global.queue); - packet = (zrtp_test_packet_t*) elem->data; - - /* We have ssrc in the packet, which indetifies stream that had send it to us. - * so now we have to find appropriate stream which has to process that packet. - */ - if (packet->is_rtp) { - ZRTP_UNALIGNED(zrtp_rtp_hdr_t) *hdr = (zrtp_rtp_hdr_t*) (packet->body); - if (ZRTP_PACKETS_MAGIC == zrtp_ntoh32(hdr->ts)) { - is_protocol = 1; - ZRTP_LOG(1, (_ZTU_,"\n")); - } - stream = find_peer_stream_by_ssrc(hdr->ssrc); - } else { - ZRTP_UNALIGNED(zrtp_rtcp_hdr_t) *hdr = (zrtp_rtcp_hdr_t*) (packet->body); - stream = find_peer_stream_by_ssrc(hdr->ssrc); - } - - if (!stream) { - zrtp_sys_free(elem); - ZRTP_LOG(1, (_ZTU_,"process_incoming(): ERROR! can't found peer stream!\n")); - continue; - } - - /* - * Process incoming packet by libzrtp. Is this a RTP media packet - copy it to the buffer - * to print out later. - */ - if (packet->is_rtp) { - s = zrtp_process_srtp(stream->zrtp_stream, packet->body, &packet->length); - } else { - s = zrtp_process_srtcp(stream->zrtp_stream, packet->body, &packet->length); - } - - - if (!is_protocol) - { - char *body; - if (packet->is_rtp) { - body = packet->body + sizeof(zrtp_rtp_hdr_t); - body[packet->length - sizeof(zrtp_rtp_hdr_t)] = 0; - } else { - body = packet->body + sizeof(zrtp_rtcp_hdr_t); - body[packet->length - sizeof(zrtp_rtcp_hdr_t)] = 0; - } - - switch (s) - { - case zrtp_status_ok: { - ZRTP_LOG(1, (_ZTU_,"Incoming: (%s) [%p:ssrc=%u] INPUT. <%s> decrypted %d bytes.\n", - zrtp_log_state2str(stream->zrtp_stream->state), stream->zrtp_stream, stream->ssrc, body, packet->length)); - } break; - - case zrtp_status_drop: { - ZRTP_LOG(1, (_ZTU_,"Incoming: (%s) [%p:ssrc=%u] INPUT DROPPED. <%s>\n", - zrtp_log_state2str(stream->zrtp_stream->state), stream->zrtp_stream, stream->ssrc, body)); - } break; - - case zrtp_status_fail: { - ZRTP_LOG(1, (_ZTU_,"Incoming: (%s) [%p:ssrc=%u] DECRYPT FAILED. <%s>\n", - zrtp_log_state2str(stream->zrtp_stream->state), stream->zrtp_stream, stream->ssrc, body)); - } break; - - default: - break; - } - } - - zrtp_sys_free(elem); - - /* - * When zrtp_stream is in the pending clear state and other side wants to send plain - * traffic. We have to call zrtp_clear_stream(). - */ - if (stream->zrtp_stream->state == ZRTP_STATE_PENDINGCLEAR) { - zrtp_stream_clear(stream->zrtp_stream); - } - } /* while is running */ - -#if (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WINCE) - return 0; -#else - return NULL; -#endif -} - -/*----------------------------------------------------------------------------*/ -#if (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WINCE) -DWORD WINAPI process_outgoing(void *param) -#else -void *process_outgoing(void *param) -#endif -{ - unsigned packets_counter = 0; - - ZRTP_LOG(1, (_ZTU_,"======> STARTING Outgoing processor\n")); - while (test_global.is_running) - { - zrtp_test_channel_id_t channel_id = 0; - zrtp_test_channel_t* channel = NULL; - zrtp_test_session_t* session = NULL; - unsigned i; - - zrtp_sleep(test_global.packets_rate); - - if ((0 == test_global.channels_count) || (0 == test_global.secure_count)) { - continue; - } - - /* Get random channel to operate with and select random peer */ - zrtp_randstr(zrtp_global, (unsigned char*)&channel_id, sizeof(zrtp_test_channel_id_t)); - channel = find_channel_with_closest_index(channel_id); - if (!channel) { - continue; - } - - ZRTP_LOG(1, (_ZTU_,"\n")); - ZRTP_LOG(1, (_ZTU_,"Out. Generate packet by channel N=%u and %s session.\n", - channel->id, ((channel_id % 100) > 50) ? "RIGHT": "LEFT")); - - session = ((channel_id % 100) > 50) ? &channel->ses_right : &channel->ses_left; - - /* Generate RTP or RTCP packet for every stream within the session */ - for (i=0; istreams_count; i++) - { - zrtp_status_t s = zrtp_status_fail; - zrtp_test_packet_t* packet; - zrtp_queue_elem_t* elem; - zrtp_test_stream_t* stream = &session->streams[i]; - char* word = NULL; - - elem = zrtp_sys_alloc(sizeof(zrtp_queue_elem_t)); - if (!elem) { - break; - } - packet = (zrtp_test_packet_t*) elem->data; - packet->is_rtp = (packets_counter++ % 20); /* Every 20-th packet is RTCP */ - - /* - * Construct RTP/RTCP Packet - */ - if (packet->is_rtp) - { - ZRTP_UNALIGNED(zrtp_rtp_hdr_t) *rtp_hdr = (zrtp_rtp_hdr_t*)packet->body; - - /* Fill RTP Header according to the specification */ - zrtp_memset(rtp_hdr, 0, sizeof(zrtp_rtp_hdr_t)); - rtp_hdr->version = 2; /* Current RTP version 2 */ - rtp_hdr->pt = 0; /* PCMU padding type */ - rtp_hdr->ssrc = stream->ssrc; /* Use ssrc for addressing like in real RTP */ - if (stream->seq >= 0xFFFF) { - stream->seq = 0; - } - rtp_hdr->seq = zrtp_hton16(stream->seq++); - rtp_hdr->ts = zrtp_hton32((uint32_t)(zrtp_time_now()/1000)); - - /* Get RTP body from PGP words lists */ - word = (char*)(i ? hash_word_list_odd[packets_counter % 256] : hash_word_list_even[packets_counter % 256]); - - zrtp_memcpy(packet->body + sizeof(zrtp_rtp_hdr_t), word, (uint32_t)strlen(word)); - packet->length = sizeof(zrtp_rtp_hdr_t) + (uint32_t)strlen(word); - - /* Process RTP media with libzrtp */ - s = zrtp_process_rtp(stream->zrtp_stream, packet->body, &packet->length); - } - else - { - ZRTP_UNALIGNED(zrtp_rtcp_hdr_t) *rtcp_hdr = (zrtp_rtcp_hdr_t*)packet->body; - - /* Fill RTCP Header according to the specification */ - rtcp_hdr->rc = 0; - rtcp_hdr->version = 2; - rtcp_hdr->ssrc = stream->ssrc; - - /* Get RTP body from PGP words lists. Put RTCP marker at the beginning */ - zrtp_memcpy(packet->body + sizeof(zrtp_rtcp_hdr_t), "RTCP", 4); - word = (char*)( i ? hash_word_list_odd[packets_counter % 256] : hash_word_list_even[packets_counter % 256]); - - zrtp_memcpy(packet->body + sizeof(zrtp_rtcp_hdr_t) + 4, word, (uint32_t)strlen(word)); - packet->length = sizeof(zrtp_rtcp_hdr_t) + (uint32_t)strlen(word) + 4; - /* RTCP packets sould be 32 byes aligned */ - packet->length += (packet->length % 4) ? (4 - packet->length % 4) : 0; - - /* Process RTCP control with libzrtp */ - s = zrtp_process_rtcp(stream->zrtp_stream, packet->body, &packet->length); - } - - /* Handle zrtp_process_xxx() instructions */ - switch (s) - { - /* Put the packet to the queue ==> send packet to the other side pear */ - case zrtp_status_ok: { - ZRTP_LOG(3, (_ZTU_,"Outgoing: (%s) [%p:ssrc=%u] OUTPUT. <%s%s> encrypted %d bytes.\n", - zrtp_log_state2str(stream->zrtp_stream->state), stream->zrtp_stream, stream->ssrc, packet->is_rtp ? "" : "RTCP", word, packet->length)); - zrtp_test_queue_push(test_global.queue, elem); - } break; - - case zrtp_status_drop: { - ZRTP_LOG(1, (_ZTU_,"Outgoing: (%s) [%p:ssrc=%u] OUTPUT DROPPED.\n", - zrtp_log_state2str(stream->zrtp_stream->state), stream->zrtp_stream, stream->ssrc)); - } break; - - case zrtp_status_fail: { - ZRTP_LOG(1, (_ZTU_,"Outgoing: (%s) [%p:ssrc=%u] ENCRYPT FAILED.\n", - zrtp_log_state2str(stream->zrtp_stream->state), stream->zrtp_stream, stream->ssrc)); - } break; - - default: - break; - } - - if (zrtp_status_ok != s) { - zrtp_sys_free(packet); - } - - } /* for (every stream within the session) */ - } /* while is running */ - -#if (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WINCE) - return 0; -#else - return NULL; -#endif -} - -/*----------------------------------------------------------------------------*/ -static zrtp_status_t init_test_session( zrtp_test_session_t *session, - zrtp_profile_t *zrtp_profile, - unsigned nstreams) -{ - unsigned i = 0; - g_zrtp_cfg zid; - zrtp_status_t s = zrtp_status_fail; - - session->streams_count = nstreams; - - /* Allocate ZRTP session */ - zrtp_randstr(zrtp_global, (unsigned char*)&zid, sizeof(g_zrtp_cfg)); - - ZRTP_LOG(3, (_ZTU_,"INITIALIZE NEW SESSION ctx=%p:\n", session)); - ZRTP_LOG(3, (_ZTU_,"---------------------------------------------------\n")); - - s = zrtp_session_init(zrtp_global, zrtp_profile, zid, 1, &session->zrtp_session); - if (zrtp_status_ok != s) { - ZRTP_LOG(3, (_ZTU_,"ERROR! can't initalize ZRTP session d=%d.\n", s)); - return s; - } - - zrtp_session_set_userdata(session->zrtp_session, session); - - ZRTP_LOG(3, (_ZTU_,"Attach %d ZRTP streams.\n", session->streams_count)); - /* ZRTP session is ready for use. Now it's time to attach streams to it */ - for (i=0; istreams_count; i++) - { - zrtp_test_stream_t *stream = &session->streams[i]; - - /* Create random sequence number and ssrc for packets generation */ - zrtp_randstr(zrtp_global, (unsigned char*)&stream->seq, sizeof(stream->seq)); - zrtp_randstr(zrtp_global, (unsigned char*)&stream->ssrc, sizeof(stream->ssrc)); - - ZRTP_LOG(3, (_ZTU_,"Created stream N%d ssrc=%u seq=%d ctx=%p\n", i, stream->ssrc, stream->seq, stream)); - - /* Attach zrtp_stream to zrtp_session */ - s = zrtp_stream_attach(session->zrtp_session, &stream->zrtp_stream); - if (zrtp_status_ok != s) { - ZRTP_LOG(3, (_ZTU_,"ERROR! can't attach ZRTP stream.\n")); - break; - } - zrtp_stream_set_userdata(stream->zrtp_stream, stream); - stream->session = session; - } - - if (i != session->streams_count) { - zrtp_session_down(session->zrtp_session); - return zrtp_status_fail; - } - - return zrtp_status_ok; -}; - -/*----------------------------------------------------------------------------*/ -int zrtp_test_channel_create( const zrtp_test_channel_config_t* config, - zrtp_test_channel_id_t* chan_id) -{ - zrtp_status_t s = zrtp_status_fail; - zrtp_test_channel_t* channel = NULL; - unsigned streams_number = 1; - - - /* - * Create two connection for each side of the call. - * They will have the same id in order to simplify calls managing. - */ - channel = zrtp_sys_alloc(sizeof(zrtp_test_channel_t)); - if (!channel) { - return -1; - } - zrtp_memset(channel, 0, sizeof(zrtp_test_channel_t)); - - /* Generate new unique ID for the channel */ - zrtp_randstr(zrtp_global, (unsigned char*)chan_id, sizeof(zrtp_test_channel_id_t)); - - ZRTP_LOG(1, (_ZTU_,"=====> CREATE NEW CHANNEL ID=%u ctx=%p.\n", chan_id, channel)); - - /* - * Alloacte and initalize ZRTP crypto stuffs - */ - do { - zrtp_profile_t zrtp_profile; - unsigned i = 0; - - /* - * Use default ZRTP configuration with slitely changes: - * - enable "allowclear" to be able to test more scenarios - */ - zrtp_profile_defaults(&zrtp_profile, zrtp_global); - zrtp_profile.allowclear = 1; - zrtp_profile.autosecure = 1; - - channel->ses_left.streams_count = streams_number; -#if (ZRTP_ENABLE_TEST == 1) - zrtp_profile.pk_schemes[0] = ZRTP_PKTYPE_EC384P; - zrtp_profile.pk_schemes[1] = ZRTP_PKTYPE_DH3072; - zrtp_profile.pk_schemes[2] = ZRTP_PKTYPE_MULT; - zrtp_profile.pk_schemes[3] = 0; -#endif - s = init_test_session(&channel->ses_left, &zrtp_profile, 1); - if (zrtp_status_ok != s) { - break; - } - channel->ses_left.channel = channel; - - channel->ses_right.streams_count = streams_number; -#if (ZRTP_ENABLE_TEST == 1) - zrtp_profile.autosecure = 1; - zrtp_profile.pk_schemes[0] = ZRTP_PKTYPE_EC384P; - zrtp_profile.pk_schemes[1] = ZRTP_PKTYPE_DH2048; - zrtp_profile.pk_schemes[2] = ZRTP_PKTYPE_DH3072; - zrtp_profile.pk_schemes[3] = ZRTP_PKTYPE_MULT; - zrtp_profile.pk_schemes[4] = 0; -#endif - s = init_test_session(&channel->ses_right, &zrtp_profile, 1); - if (zrtp_status_ok != s) { - break; - } - channel->ses_right.channel = channel; - - /* Make cross-references to allow left stream to communicate with the right one. */ - for (i=0; ises_left.streams[i].peer_ssrc = channel->ses_right.streams[i].ssrc; - channel->ses_right.streams[i].peer_ssrc = channel->ses_left.streams[i].ssrc; - } - } while (0); - - if (zrtp_status_ok != s) { - zrtp_sys_free(channel); - } else { - channel->id = *chan_id; - zrtp_mutex_lock(test_global.channels_protector); - mlist_add(&test_global.channels_head, &channel->_mlist); - zrtp_mutex_unlock(test_global.channels_protector); - } - - test_global.channels_count++; - - return s; -} - -/*----------------------------------------------------------------------------*/ -static void down_test_session(zrtp_test_session_t *session) -{ - zrtp_session_down(session->zrtp_session); -}; - -int zrtp_test_channel_delete(zrtp_test_channel_id_t chan_id) -{ - zrtp_test_channel_t* channel = find_channel_by_index(chan_id); - if (channel) - { - test_global.channels_count--; - - zrtp_mutex_lock(test_global.channels_protector); - mlist_del(&channel->_mlist); - zrtp_mutex_unlock(test_global.channels_protector); - - down_test_session(&channel->ses_left); - down_test_session(&channel->ses_right); - - zrtp_sys_free(channel); - return 0; - } else { - return -1; - } -} - -/*----------------------------------------------------------------------------*/ -typedef enum -{ - TEST_ACTION_START = 0, - TEST_ACTION_SECURE, - TEST_ACTION_CLEAR, - TEST_ACTION_STOP -} zrtp_test_session_action_t; - -static void test_session_do_action(zrtp_test_session_t *session, zrtp_test_session_action_t action) -{ - unsigned i = 0; - if (session->zrtp_session) - { - for (i=0; istreams_count; i++) { - switch (action) { - case TEST_ACTION_START: - { - char buff[65]; - ZRTP_LOG(1, (_ZTU_,"=====> START TEST SESSION ID=%u ctx=%p.\n", session->channel->id, session->channel)); - zrtp_stream_start(session->streams[i].zrtp_stream, zrtp_ntoh32(session->streams[i].ssrc)); - zrtp_signaling_hash_get(session->streams[i].zrtp_stream, buff, sizeof(buff)); - break; - } - case TEST_ACTION_STOP: - ZRTP_LOG(1, (_ZTU_,"=====> STOP TEST SESSION ID=%u ctx=%p.\n", session->channel->id, session->channel)); - zrtp_stream_stop(session->streams[i].zrtp_stream); - break; - case TEST_ACTION_SECURE: - ZRTP_LOG(1, (_ZTU_,"=====> SECURE TEST SESSION ID=%u ctx=%p.\n", session->channel->id, session->channel)); - zrtp_stream_secure(session->streams[i].zrtp_stream); - break; - case TEST_ACTION_CLEAR: - ZRTP_LOG(1, (_ZTU_,"=====> CLEAR TEST SESSION ID=%u ctx=%p.\n", session->channel->id, session->channel)); - zrtp_stream_clear(session->streams[i].zrtp_stream); - break; - } - } - } -}; - -static int test_channel_do_action(zrtp_test_channel_id_t chan_id, zrtp_test_session_action_t action) -{ - zrtp_test_channel_t* channel = find_channel_by_index(chan_id); - if (channel) { - test_session_do_action(&channel->ses_left, action); - test_session_do_action(&channel->ses_right, action); - return 0; - } else { - return -1; - } -} - -int zrtp_test_channel_start(zrtp_test_channel_id_t chan_id) { - return test_channel_do_action(chan_id, TEST_ACTION_START); -} - -int zrtp_test_channel_secure(zrtp_test_channel_id_t chan_id) { - return test_channel_do_action(chan_id, TEST_ACTION_SECURE); -} - -int zrtp_test_channel_clear(zrtp_test_channel_id_t chan_id) { - return test_channel_do_action(chan_id, TEST_ACTION_CLEAR); -} - -int zrtp_test_channel_stop(zrtp_test_channel_id_t chan_id) { - return test_channel_do_action(chan_id, TEST_ACTION_STOP); -} - - -/*============================================================================*/ -/* Test Routine */ -/*============================================================================*/ - -/*---------------------------------------------------------------------------*/ -static int start_processors(int count) -{ - int32_t i; - for (i = 0; iStart ZRTP Test-Unite Core initalization.\n")); - - zrtp_memset(&test_global, 0, sizeof(test_global)); - - ZRTP_LOG(1, (_ZTU_,"Create internal components...\n")); - do { - /* Create global objects: channels list and communication queue */ - init_mlist(&test_global.channels_head); - - s = zrtp_mutex_init(&test_global.channels_protector); - if (zrtp_status_ok != s) { - ZRTP_LOG(1, (_ZTU_,"ERROR! Can't create channels protector %d\n", s)); - break; - } - - s = zrtp_test_queue_create(&test_global.queue); - if (zrtp_status_ok != s) { - ZRTP_LOG(1, (_ZTU_,"ERROR! Can't create global queue: %s\n", s)); - break; - } - - /* Start several threads to process test zrtp channels */ - test_global.is_running = 1; - result = start_processors(ZRTP_TEST_STREAMS_COUNT); - if (0 != result) { - break; - } - - ZRTP_LOG(1, (_ZTU_,"Configuring and Initalizing ZRTP engine...\n")); - /* Reset global values to defaults */ - test_global.is_log_enabled = 1; - test_global.packets_rate = 500; - test_global.channels_count = 0; - - /* Initalize ZRTP Engine */ - zrtp_config_defaults(&zrtp_config); - zrtp_config.lic_mode = ZRTP_LICENSE_MODE_ACTIVE; - zrtp_memcpy(zrtp_config.client_id, "ZRTP Test Unite!", 16); - - zrtp_config.cb.event_cb.on_zrtp_secure = on_zrtp_secure; - zrtp_config.cb.event_cb.on_zrtp_security_event = on_zrtp_security_event; - zrtp_config.cb.event_cb.on_zrtp_protocol_event = on_zrtp_protocol_event; - zrtp_config.cb.misc_cb.on_send_packet = on_send_packet; - - s = zrtp_init(&zrtp_config, &zrtp_global); - if (zrtp_status_ok != s) { - ZRTP_LOG(1, (_ZTU_,"ERROR! zrtp_init() failed with status=%d.\n", s)); - break; - } - - result = 0; - } while (0); - - if (0 != result) { - if (!test_global.channels_protector) { - zrtp_mutex_destroy(test_global.channels_protector); - } - if (!test_global.queue) { - zrtp_test_queue_destroy(test_global.queue); - } - } - - return result; -} - -/*----------------------------------------------------------------------------*/ -int zrtp_test_zrtp_down() -{ - mlist_t* node = NULL,* tmp = NULL; - - ZRTP_LOG(1, (_ZTU_,"=====> Destroying ZRTP Test Application:\n")); - ZRTP_LOG(1, (_ZTU_,"Stop all running threads.\n")); - - /* Stop Main Processing Loop */ - test_global.is_running = 0; - - ZRTP_LOG(1, (_ZTU_,"Destroy all active connections.\n")); - /* Stop and destroy all active sessions */ - zrtp_mutex_lock(test_global.channels_protector); - mlist_for_each_safe(node, tmp, &test_global.channels_head) { - zrtp_test_channel_t* result = (zrtp_test_channel_t*) mlist_get_struct(zrtp_test_channel_t, _mlist, node); - zrtp_test_channel_delete(result->id); - } - zrtp_mutex_unlock(test_global.channels_protector); - - ZRTP_LOG(1, (_ZTU_,"Destroy ZRTP Engine.\n")); - /* Destroy libzrtp and all utility components */ - zrtp_down(zrtp_global); - - if (!test_global.channels_protector) { - zrtp_mutex_destroy(test_global.channels_protector); - } - if (!test_global.queue) { - zrtp_test_queue_destroy(test_global.queue); - } - - return 0; -} - -/*----------------------------------------------------------------------------*/ -zrtp_test_channel_t* find_channel_by_index(zrtp_test_channel_id_t chan_id) -{ - unsigned char is_found = 0; - mlist_t* node = NULL,* tmp = NULL; - zrtp_test_channel_t* result = NULL; - - zrtp_mutex_lock(test_global.channels_protector); - mlist_for_each_safe(node, tmp, &test_global.channels_head) { - result = (zrtp_test_channel_t*) mlist_get_struct(zrtp_test_channel_t, _mlist, node); - if (result->id == chan_id) { - is_found = 1; - break; - } - } - zrtp_mutex_unlock(test_global.channels_protector); - - return (is_found) ? result : NULL; -} - -zrtp_test_channel_t* find_channel_with_closest_index(zrtp_test_channel_id_t chan_id) -{ - unsigned char is_found = 0; - mlist_t* node = NULL,* tmp = NULL; - zrtp_test_channel_t* result = NULL; - zrtp_test_channel_t* left = NULL; - - zrtp_mutex_lock(test_global.channels_protector); - mlist_for_each_safe(node, tmp, &test_global.channels_head) { - result = (zrtp_test_channel_t*) mlist_get_struct(zrtp_test_channel_t, _mlist, node); - if (result->id > chan_id) { - is_found = 1; - break; - } else { - left = result; - } - } - zrtp_mutex_unlock(test_global.channels_protector); - - return (is_found) ? result : left; -} - -zrtp_test_stream_t* find_peer_stream_by_ssrc(uint32_t ssrc) -{ - unsigned char is_found = 0; - mlist_t *node = NULL, *tmp = NULL; - zrtp_test_stream_t *result = NULL; - - zrtp_mutex_lock(test_global.channels_protector); - mlist_for_each_safe(node, tmp, &test_global.channels_head) - { - zrtp_test_channel_t *channel = (zrtp_test_channel_t*) mlist_get_struct(zrtp_test_channel_t, _mlist, node); - unsigned i = 0; - - for (i=0; ises_left.streams_count; i++) { - zrtp_test_stream_t *stream = &channel->ses_left.streams[i]; - if (stream->ssrc == ssrc) { - is_found = 1; - result = &channel->ses_right.streams[i]; - break; - } - } - - for (i=0; ises_right.streams_count; i++) { - zrtp_test_stream_t *stream = &channel->ses_right.streams[i]; - if (stream->ssrc == ssrc) { - is_found = 1; - result = &channel->ses_left.streams[i]; - break; - } - } - - if (is_found) { - break; - } - } - zrtp_mutex_unlock(test_global.channels_protector); - - return (is_found) ? result : NULL; -} diff --git a/libs/libzrtp/test/pc/zrtp_test_core.h b/libs/libzrtp/test/pc/zrtp_test_core.h deleted file mode 100644 index 4a99fac328..0000000000 --- a/libs/libzrtp/test/pc/zrtp_test_core.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#ifndef __ZRTP_TEST_CORE_H__ -#define __ZRTP_TEST_CORE_H__ - -#include "zrtp.h" - -extern zrtp_global_t* zrtp_global; - -typedef uint32_t zrtp_test_channel_id_t; - -typedef struct zrtp_test_channel_config -{ - unsigned streams_count; - unsigned char is_autosecure; - unsigned char is_preshared; -} zrtp_test_channel_config_t; - -void zrtp_test_crypto(zrtp_global_t* zrtp); - -int zrtp_test_zrtp_init(); -int zrtp_test_zrtp_down(); - -int zrtp_test_channel_create( const zrtp_test_channel_config_t* config, - zrtp_test_channel_id_t* chan_id); -int zrtp_test_channel_delete(zrtp_test_channel_id_t chan_id); -int zrtp_test_channel_start(zrtp_test_channel_id_t chan_id); -int zrtp_test_channel_secure(zrtp_test_channel_id_t chan_id); -int zrtp_test_channel_clear(zrtp_test_channel_id_t chan_id); - -#endif /*__ZRTP_TEST_CORE_H__*/ diff --git a/libs/libzrtp/test/pc/zrtp_test_ui.c b/libs/libzrtp/test/pc/zrtp_test_ui.c deleted file mode 100644 index bc1d6e2a08..0000000000 --- a/libs/libzrtp/test/pc/zrtp_test_ui.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * libZRTP SDK library, implements the ZRTP secure VoIP protocol. - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * Contact: http://philzimmermann.com - * For licensing and other legal details, see the file zrtp_legal.c. - * - * Viktor Krykun - */ - -#include "zrtp_test_core.h" - -#ifndef ZRTP_TEST_ENABLE_CRYPTO_SELFTESTS -#define ZRTP_TEST_ENABLE_CRYPTO_SELFTESTS 0 -#endif - -static zrtp_test_channel_id_t tmp_id; - -void do_create() -{ - zrtp_test_channel_config_t config; - int status = 0; - - config.is_autosecure = 1; - config.is_preshared = 0; - config.streams_count = 1; - - status = zrtp_test_channel_create(&config, &tmp_id); -} - -void do_delete() -{ - zrtp_test_channel_delete(tmp_id); -} - -void do_quit() -{ - zrtp_test_zrtp_down(); -} - -int main() -{ - int status; - - status = zrtp_test_zrtp_init(); - if (0 != status) { - return status; - } -#if (ZRTP_TEST_ENABLE_CRYPTO_SELFTESTS == 1) - zrtp_test_crypto(zrtp_global); -#endif - - { - zrtp_test_channel_id_t id; - zrtp_test_channel_config_t sconfig; - - sconfig.is_autosecure = 0; - sconfig.is_preshared = 0; - sconfig.streams_count = 1; - - status = zrtp_test_channel_create(&sconfig, &id); - - if (0 == status) { - zrtp_test_channel_start(id); - } - } - - while (1) { - zrtp_sleep(1000); - } - - - do_quit(); - - return 0; -} diff --git a/libs/libzrtp/test/pc/zrtp_test_queue.c b/libs/libzrtp/test/queue.c similarity index 85% rename from libs/libzrtp/test/pc/zrtp_test_queue.c rename to libs/libzrtp/test/queue.c index 488f36f3c3..4b0d9b8194 100644 --- a/libs/libzrtp/test/pc/zrtp_test_queue.c +++ b/libs/libzrtp/test/queue.c @@ -8,10 +8,9 @@ */ #include "zrtp.h" -#include "zrtp_test_queue.h" +#include "queue.h" -struct zrtp_queue -{ +struct zrtp_queue { zrtp_sem_t* size_sem; zrtp_sem_t* main_sem; zrtp_mutex_t* mutex; @@ -19,9 +18,9 @@ struct zrtp_queue uint32_t size; }; -/*----------------------------------------------------------------------------*/ -zrtp_status_t zrtp_test_queue_create(zrtp_queue_t** queue) -{ + +zrtp_status_t zrtp_test_queue_create(zrtp_queue_t** queue) { + zrtp_status_t s = zrtp_status_fail; zrtp_queue_t* new_queue = (zrtp_queue_t*) zrtp_sys_alloc(sizeof(zrtp_queue_t)); if (! new_queue) { @@ -67,8 +66,7 @@ zrtp_status_t zrtp_test_queue_create(zrtp_queue_t** queue) return s; } -void zrtp_test_queue_destroy(zrtp_queue_t* queue) -{ +void zrtp_test_queue_destroy(zrtp_queue_t* queue) { if (queue->size_sem) { zrtp_sem_destroy(queue->size_sem); } @@ -80,9 +78,8 @@ void zrtp_test_queue_destroy(zrtp_queue_t* queue) } } -/*----------------------------------------------------------------------------*/ -void zrtp_test_queue_push(zrtp_queue_t* queue, zrtp_queue_elem_t* elem) -{ + +void zrtp_test_queue_push(zrtp_queue_t* queue, zrtp_queue_elem_t* elem) { zrtp_sem_wait(queue->size_sem); zrtp_mutex_lock(queue->mutex); @@ -93,8 +90,7 @@ void zrtp_test_queue_push(zrtp_queue_t* queue, zrtp_queue_elem_t* elem) zrtp_sem_post(queue->main_sem); } -zrtp_queue_elem_t* zrtp_test_queue_pop(zrtp_queue_t* queue) -{ +zrtp_queue_elem_t* zrtp_test_queue_pop(zrtp_queue_t* queue) { zrtp_queue_elem_t* res = NULL; zrtp_sem_wait(queue->main_sem); diff --git a/libs/libzrtp/test/pc/zrtp_test_queue.h b/libs/libzrtp/test/queue.h similarity index 96% rename from libs/libzrtp/test/pc/zrtp_test_queue.h rename to libs/libzrtp/test/queue.h index 17ecec80af..6a0cbe2bfe 100644 --- a/libs/libzrtp/test/pc/zrtp_test_queue.h +++ b/libs/libzrtp/test/queue.h @@ -14,8 +14,7 @@ #define ZRTP_QUEUE_SIZE 2000 -typedef struct zrtp_queue_elem -{ +typedef struct zrtp_queue_elem { char data[1500]; uint32_t size; mlist_t _mlist; diff --git a/libs/libzrtp/test/sasrelay_test.c b/libs/libzrtp/test/sasrelay_test.c new file mode 100644 index 0000000000..5148c6a724 --- /dev/null +++ b/libs/libzrtp/test/sasrelay_test.c @@ -0,0 +1,123 @@ +/* + * libZRTP SDK library, implements the ZRTP secure VoIP protocol. + * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. + * Contact: http://philzimmermann.com + * For licensing and other legal details, see the file zrtp_legal.c. + * + * Viktor Krykun + */ + +#include /*chmockery dependency*/ +#include /*chmockery dependency*/ +#include /*for usleep*/ + +#include "cmockery/cmockery.h" +#include "test_engine.h" + +#include "enroll_test_helpers.c" + +static void enrollment_test() { + zrtp_status_t s; + + zrtp_test_channel_info_t a2pbx_channel_info, b2pbx_channel_info; + zrtp_test_session_cfg_t session_config, session_config_enroll; + zrtp_test_session_config_defaults(&session_config); + zrtp_test_session_config_defaults(&session_config_enroll); + + session_config_enroll.is_enrollment = 1; + + /************************************************************************** + * Enroll both Alice and Bob to PBX + */ + prepare_alice_pbx_bob_setup(&session_config, &session_config, &session_config_enroll, &session_config_enroll); + + /* Everything is ready. Let's start the stream and give it few seconds to switch secure. */ + s = zrtp_test_channel_start(g_alice2pbx_channel); + assert_int_equal(zrtp_status_ok, s); + s = zrtp_test_channel_start(g_bob2pbx_channel); + assert_int_equal(zrtp_status_ok, s); + + int i = 30; + for (; i>0; i--) { + usleep(100*1000); + } + + s = zrtp_test_channel_get(g_alice2pbx_channel, &a2pbx_channel_info); + assert_int_equal(zrtp_status_ok, s); + s = zrtp_test_channel_get(g_bob2pbx_channel, &b2pbx_channel_info); + assert_int_equal(zrtp_status_ok, s); + + /* Both, Alice and Bob should switch secure and ready for enrollment */ + assert_true(a2pbx_channel_info.is_secure); + assert_true(b2pbx_channel_info.is_secure); + + /* Confirm enrollment for both, Alice and Bob */ + zrtp_test_id_t alice2pbx_stream = zrtp_test_session_get_stream_by_idx(g_alice_sid, 0); + zrtp_test_id_t bob2pbx_stream = zrtp_test_session_get_stream_by_idx(g_bob_sid, 0); + + s = zrtp_register_with_trusted_mitm(zrtp_stream_for_test_stream(alice2pbx_stream)); + assert_int_equal(zrtp_status_ok, s); + s = zrtp_register_with_trusted_mitm(zrtp_stream_for_test_stream(bob2pbx_stream)); + assert_int_equal(zrtp_status_ok, s); + + /* Clean-up */ + cleanup_alice_pbx_bob_setup(); + + /************************************************************************** + * Now, when we have two enrolled parties, make one more call and initiate + * SAS Relay at the PBX side. Both endpoints should received SASRelay, but + * just one should get ZRTP_EVENT_LOCAL_SAS_UPDATED event. + */ + + prepare_alice_pbx_bob_setup(&session_config, &session_config, &session_config, &session_config); + + /* Everything is ready. Let's start the stream and give it few seconds to switch secure. */ + s = zrtp_test_channel_start(g_alice2pbx_channel); + assert_int_equal(zrtp_status_ok, s); + s = zrtp_test_channel_start(g_bob2pbx_channel); + assert_int_equal(zrtp_status_ok, s); + + i = 30; + for (; i>0; i--) { + usleep(100*1000); + } + + s = zrtp_test_channel_get(g_alice2pbx_channel, &a2pbx_channel_info); + assert_int_equal(zrtp_status_ok, s); + s = zrtp_test_channel_get(g_bob2pbx_channel, &b2pbx_channel_info); + assert_int_equal(zrtp_status_ok, s); + + /* Both, Alice and Bob should switch secure */ + assert_true(a2pbx_channel_info.is_secure); + assert_true(b2pbx_channel_info.is_secure); + + zrtp_test_id_t pbx2alice_stream = zrtp_test_session_get_stream_by_idx(g_pbxa_sid, 0); + zrtp_test_id_t pbx2bob_stream = zrtp_test_session_get_stream_by_idx(g_pbxb_sid, 0); + alice2pbx_stream = zrtp_test_session_get_stream_by_idx(g_alice_sid, 0); + bob2pbx_stream = zrtp_test_session_get_stream_by_idx(g_bob_sid, 0); + + /* Resolve MiTM call! */ + s = zrtp_resolve_mitm_call(zrtp_stream_for_test_stream(pbx2alice_stream), + zrtp_stream_for_test_stream(pbx2bob_stream)); + + i = 20; + for (; i>0; i--) { + usleep(100*1000); + } + + /* Alice and Bob should receive Enrollment notification */ + unsigned sas_update1 = zrtp_stream_did_event_receive(alice2pbx_stream, ZRTP_EVENT_LOCAL_SAS_UPDATED); + unsigned sas_update2 = zrtp_stream_did_event_receive(bob2pbx_stream, ZRTP_EVENT_LOCAL_SAS_UPDATED); + assert_true(sas_update1 ^ sas_update2); + + /* Clean-up */ + cleanup_alice_pbx_bob_setup(); +} + +int main(void) { + const UnitTest tests[] = { + unit_test_setup_teardown(enrollment_test, pbx_setup, pbx_teardown), + }; + + return run_tests(tests); +} diff --git a/libs/libzrtp/test/test_engine.c b/libs/libzrtp/test/test_engine.c new file mode 100644 index 0000000000..3b40985f57 --- /dev/null +++ b/libs/libzrtp/test/test_engine.c @@ -0,0 +1,871 @@ +/* + * libZRTP SDK library, implements the ZRTP secure VoIP protocol. + * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. + * Contact: http://philzimmermann.com + * For licensing and other legal details, see the file zrtp_legal.c. + * + * Viktor Krykun + */ + +#include /* for sprintf(), remove() */ +#include /* for string operations */ + +#include "test_engine.h" +#include "queue.h" + +#define _ZTU_ "test engine" + +#define K_ZRTP_TEST_MAX_ENDPOINTS 10 +#define K_ZRTP_TEST_MAX_SESSIONS_PER_ENDPOINT 100 +#define K_ZRTP_TEST_MAX_CHANNELS (K_ZRTP_TEST_MAX_ENDPOINTS * K_ZRTP_TEST_MAX_ENDPOINTS * ZRTP_MAX_STREAMS_PER_SESSION) + +#define K_ZRTP_TEST_PROCESSORS_COUNT 2 +#define K_ZRTP_TEST_RTP_RATE 200 + +extern uint8_t hash_word_list_odd[256][12]; +extern uint8_t hash_word_list_even[256][10]; + +typedef struct { + zrtp_test_id_t id; + zrtp_test_id_t session_id; + zrtp_test_id_t channel_id; + zrtp_test_id_t endpoint_id; + zrtp_stream_t *zrtp; + uint16_t seq; + zrtp_queue_t *input; + zrtp_queue_t *output; + unsigned zrtp_events_queueu[128]; + unsigned zrtp_events_count; +} zrtp_test_stream_t; + +typedef struct { + zrtp_test_id_t id; + zrtp_test_id_t endpoint_id; + zrtp_test_session_cfg_t cfg; + zrtp_session_t *zrtp; + zrtp_test_stream_t streams[ZRTP_MAX_STREAMS_PER_SESSION]; + unsigned streams_count; +} zrtp_test_session_t; + +typedef struct { + zrtp_test_id_t id; + char name[ZRTP_TEST_STR_LEN]; + zrtp_zid_t zid; + zrtp_test_endpoint_cfg_t cfg; + zrtp_test_session_t sessions[K_ZRTP_TEST_MAX_SESSIONS_PER_ENDPOINT]; + unsigned sessions_count; + zrtp_global_t *zrtp; + unsigned is_running; + zrtp_queue_t *input_queue; +} zrtp_endpoint_t; + + +typedef struct { + zrtp_test_id_t id; + zrtp_test_stream_t *left; + zrtp_test_stream_t *right; + unsigned is_attached; + unsigned is_secure; +} zrtp_test_channel_t; + +typedef struct zrtp_test_packet { + uint32_t is_rtp; /*! Defines is packet RTP or RTCP */ + uint32_t length; /*! Packet Length in bytes */ + char body[1024]; /*! Packet body */ +} zrtp_test_packet_t; + + +static zrtp_endpoint_t g_test_endpoints[K_ZRTP_TEST_MAX_ENDPOINTS]; +static unsigned g_test_endpoints_count = 0; + +static zrtp_test_channel_t g_test_channels[K_ZRTP_TEST_MAX_CHANNELS]; +static unsigned g_test_channels_count = 0; + +static int g_endpoints_counter = 7; +static int g_channels_counter = 7; +static int g_sessions_counter = 7; +static int g_streams_counter = 7; + + +zrtp_endpoint_t *zrtp_test_endpoint_by_id(zrtp_test_id_t id); +zrtp_test_stream_t *zrtp_test_stream_by_id(zrtp_test_id_t id); +zrtp_test_stream_t *zrtp_test_stream_by_peerid(zrtp_test_id_t id); +zrtp_test_session_t *zrtp_test_session_by_id(zrtp_test_id_t id); +zrtp_test_channel_t *zrtp_test_channel_by_id(zrtp_test_id_t id); + + +/****************************************************************************** + * libzrtp interface implementation + */ + +static void on_zrtp_event(zrtp_stream_t *ctx, zrtp_protocol_event_t event) { + zrtp_test_id_t *stream_id = zrtp_stream_get_userdata(ctx); + zrtp_test_stream_t *stream = zrtp_test_stream_by_id(*stream_id); + + stream->zrtp_events_queueu[stream->zrtp_events_count++] = event; +} + + +static void on_zrtp_secure(zrtp_stream_t *ctx) { + zrtp_test_id_t *stream_id = zrtp_stream_get_userdata(ctx); + zrtp_test_stream_t *stream = zrtp_test_stream_by_id(*stream_id); + zrtp_test_channel_t *channel = zrtp_test_channel_by_id(stream->channel_id); + zrtp_test_stream_t *remote_stream = (channel->left == stream) ? channel->right : channel->left; + + if (stream->zrtp->state == ZRTP_STATE_SECURE && + remote_stream->zrtp->state == ZRTP_STATE_SECURE) { + channel->is_secure = 1; + } + +} + +static int on_send_packet(const zrtp_stream_t* ctx, char* message, unsigned int length) { + zrtp_queue_elem_t* elem = zrtp_sys_alloc(sizeof(zrtp_queue_elem_t)); + if (elem) { + zrtp_test_packet_t* packet = (zrtp_test_packet_t*) elem->data; + elem->size = length; + + packet->is_rtp = 1; + packet->length = length; + zrtp_memcpy(packet->body, message, length); + + zrtp_test_id_t *stream_id = zrtp_stream_get_userdata(ctx); + zrtp_test_stream_t *stream = zrtp_test_stream_by_id(*stream_id); + if (stream) { + printf("trace>>> PUSH from stream ID=%u\n", stream->id); + zrtp_test_queue_push(stream->output, elem); + return zrtp_status_ok; + } else { + return zrtp_status_fail; + } + } else { + return zrtp_status_alloc_fail; + } +} + + +/****************************************************************************** + * Processing Loop + */ + +static zrtp_test_stream_t *get_stream_to_process_(zrtp_endpoint_t *endpoint) { + zrtp_test_id_t all_streams[K_ZRTP_TEST_MAX_SESSIONS_PER_ENDPOINT*ZRTP_MAX_STREAMS_PER_SESSION]; + unsigned streams_count = 0; + unsigned i, j; + + for (i=0; isessions_count; i++) { + for (j=0; jsessions[i].streams_count; j++) { + zrtp_test_stream_t *stream = &endpoint->sessions[i].streams[j]; + if (stream->input && stream->output) + all_streams[streams_count++] = stream->id; + } + } + + if (0 == streams_count) + return NULL; + + zrtp_randstr(endpoint->zrtp, (unsigned char*)&i, sizeof(i)); + j = (unsigned)i; + j = j % streams_count; + + printf("trace>>> CHOOSE stream Endpoint=%u IDX=%u ID=%u\n", endpoint->id, j, all_streams[j]); + return zrtp_test_stream_by_id(all_streams[j]); + + +// unsigned is_found = 0; +// zrtp_test_id_t result, left; +// for (i=0; i stream_id) { +// is_found = 1; +// break; +// } else { +// left = result; +// } +// } +// +// printf("TRACE>>> choose stream ID=%u\n", is_found ? result : left); +// return zrtp_test_stream_by_id(is_found ? result : left); +} + + +#if (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WINCE) +DWORD WINAPI process_incoming(void *param) +#else +void *process_incoming(void *param) +#endif +{ + zrtp_endpoint_t *the_endpoint = (zrtp_endpoint_t *)param; + + while (the_endpoint->is_running) { + zrtp_test_packet_t* packet = NULL; + zrtp_queue_elem_t* elem = NULL; + zrtp_status_t s = zrtp_status_fail; + zrtp_test_stream_t *stream; + int is_protocol = 0; + + // TODO: use peak to not to block processing if queue for this stream is empty + elem = zrtp_test_queue_pop(the_endpoint->input_queue); + if (!elem || elem->size <= 0) { + if (elem) zrtp_sys_free(elem); + break; + } + + packet = (zrtp_test_packet_t*) elem->data; + zrtp_test_id_t stream_id; + { + if (packet->is_rtp) { + ZRTP_UNALIGNED(zrtp_rtp_hdr_t) *rtp_hdr = (zrtp_rtp_hdr_t*)packet->body; + stream_id = zrtp_ntoh32(rtp_hdr->ssrc); /* remember, we use stream Id as it's RTP SSRC */ + } else { + ZRTP_UNALIGNED(zrtp_rtcp_hdr_t) *rtcp_hdr = (zrtp_rtcp_hdr_t*)packet->body; + stream_id = zrtp_ntoh32(rtcp_hdr->ssrc); /* remember, we use stream Id as it's RTP SSRC */ + } + stream = zrtp_test_stream_by_peerid(stream_id); + } + + /* + * Process incoming packet by libzrtp. Is this a RTP media packet - copy it to the buffer + * to print out later. + */ + if (packet->is_rtp) { + s = zrtp_process_srtp(stream->zrtp, packet->body, &packet->length); + } else { + s = zrtp_process_srtcp(stream->zrtp, packet->body, &packet->length); + } + + if (!is_protocol) { + char *body; + if (packet->is_rtp) { + body = packet->body + sizeof(zrtp_rtp_hdr_t); + body[packet->length - sizeof(zrtp_rtp_hdr_t)] = 0; + } else { + body = packet->body + sizeof(zrtp_rtcp_hdr_t); + body[packet->length - sizeof(zrtp_rtcp_hdr_t)] = 0; + } + + switch (s) + { + case zrtp_status_ok: { + ZRTP_LOG(1, (_ZTU_,"Incoming: (%s) [%p:ssrc=%u] OK. <%s> decrypted %d bytes.\n", + zrtp_log_state2str(stream->zrtp->state), stream->zrtp, stream->id, body, packet->length)); + } break; + + case zrtp_status_drop: { + ZRTP_LOG(1, (_ZTU_,"Incoming: (%s) [%p:ssrc=%u] DROPPED. <%s>\n", + zrtp_log_state2str(stream->zrtp->state), stream->zrtp, stream->id, body)); + } break; + + case zrtp_status_fail: { + ZRTP_LOG(1, (_ZTU_,"Incoming: (%s) [%p:ssrc=%u] DECRYPT FAILED. <%s>\n", + zrtp_log_state2str(stream->zrtp->state), stream->zrtp, stream->id, body)); + } break; + + default: + break; + } + } + + zrtp_sys_free(elem); + + /* + * When zrtp_stream is in the pending clear state and other side wants to send plain + * traffic. We have to call zrtp_clear_stream(). + */ + if (stream->zrtp->state == ZRTP_STATE_PENDINGCLEAR) { + zrtp_stream_clear(stream->zrtp); + } + } +#if (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WINCE) + return 0; +#else + return NULL; +#endif +} + +#if (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WINCE) +DWORD WINAPI process_outgoing(void *param) +#else +void *process_outgoing(void *param) +#endif +{ + unsigned packets_counter = 0; + zrtp_endpoint_t *the_endpoint = (zrtp_endpoint_t *)param; + + while (the_endpoint->is_running) { + zrtp_test_stream_t* stream = NULL; + unsigned i; + + zrtp_status_t s = zrtp_status_fail; + zrtp_test_packet_t* packet; + zrtp_queue_elem_t* elem; + char* word = NULL; + + zrtp_sleep(K_ZRTP_TEST_RTP_RATE); + + /* Get random channel to operate with and select random peer */ + stream = get_stream_to_process_(the_endpoint); + if (!stream) { + continue; + } + + elem = zrtp_sys_alloc(sizeof(zrtp_queue_elem_t)); + if (!elem) { + break; + } + packet = (zrtp_test_packet_t*) elem->data; + packet->is_rtp = (packets_counter++ % 20); /* Every 20-th packet is RTCP */ + + /* + * Construct RTP/RTCP Packet + */ + if (packet->is_rtp) + { + ZRTP_UNALIGNED(zrtp_rtp_hdr_t) *rtp_hdr = (zrtp_rtp_hdr_t*)packet->body; + + /* Fill RTP Header according to the specification */ + zrtp_memset(rtp_hdr, 0, sizeof(zrtp_rtp_hdr_t)); + rtp_hdr->version = 2; /* Current RTP version 2 */ + rtp_hdr->pt = 0; /* PCMU padding type */ + rtp_hdr->ssrc = zrtp_hton32(stream->id); /* Use stream Identifier as it's SSRC */ + if (stream->seq >= 0xFFFF) { + stream->seq = 0; + } + rtp_hdr->seq = zrtp_hton16(stream->seq++); + rtp_hdr->ts = zrtp_hton32((uint32_t)(zrtp_time_now()/1000)); + + /* Get RTP body from PGP words lists */ + word = (char*)(i ? hash_word_list_odd[packets_counter % 256] : hash_word_list_even[packets_counter % 256]); + + zrtp_memcpy(packet->body + sizeof(zrtp_rtp_hdr_t), word, (uint32_t)strlen(word)); + packet->length = sizeof(zrtp_rtp_hdr_t) + (uint32_t)strlen(word); + + /* Process RTP media with libzrtp */ + s = zrtp_process_rtp(stream->zrtp, packet->body, &packet->length); + } + else { + ZRTP_UNALIGNED(zrtp_rtcp_hdr_t) *rtcp_hdr = (zrtp_rtcp_hdr_t*)packet->body; + + /* Fill RTCP Header according to the specification */ + rtcp_hdr->rc = 0; + rtcp_hdr->version = 2; + rtcp_hdr->ssrc = stream->id; + + /* Get RTP body from PGP words lists. Put RTCP marker at the beginning */ + zrtp_memcpy(packet->body + sizeof(zrtp_rtcp_hdr_t), "RTCP", 4); + word = (char*)( i ? hash_word_list_odd[packets_counter % 256] : hash_word_list_even[packets_counter % 256]); + + zrtp_memcpy(packet->body + sizeof(zrtp_rtcp_hdr_t) + 4, word, (uint32_t)strlen(word)); + packet->length = sizeof(zrtp_rtcp_hdr_t) + (uint32_t)strlen(word) + 4; + /* RTCP packets sould be 32 byes aligned */ + packet->length += (packet->length % 4) ? (4 - packet->length % 4) : 0; + + /* Process RTCP control with libzrtp */ + s = zrtp_process_rtcp(stream->zrtp, packet->body, &packet->length); + } + + elem->size = packet->length; + + /* Handle zrtp_process_xxx() instructions */ + switch (s) { + /* Put the packet to the queue ==> send packet to the other side pear */ + case zrtp_status_ok: { + ZRTP_LOG(3, (_ZTU_,"Outgoing: (%s) [%p:ssrc=%u] OK. <%s%s> encrypted %d bytes.\n", + zrtp_log_state2str(stream->zrtp->state), stream->zrtp, stream->id, packet->is_rtp ? "" : "RTCP", word, packet->length)); + zrtp_test_queue_push(stream->output, elem); + } break; + + case zrtp_status_drop: { + ZRTP_LOG(1, (_ZTU_,"Outgoing: (%s) [%p:ssrc=%u] DROPPED.\n", + zrtp_log_state2str(stream->zrtp->state), stream->zrtp, stream->id)); + } break; + + case zrtp_status_fail: { + ZRTP_LOG(1, (_ZTU_,"Outgoing: (%s) [%p:ssrc=%u] ENCRYPT FAILED.\n", + zrtp_log_state2str(stream->zrtp->state), stream->zrtp, stream->id)); + } break; + + default: + break; + } + + if (zrtp_status_ok != s) { + zrtp_sys_free(packet); + } + } +#if (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WINCE) + return 0; +#else + return NULL; +#endif +} + + +/****************************************************************************** + * Test Engine Public API + */ + +void zrtp_test_endpoint_config_defaults(zrtp_test_endpoint_cfg_t* cfg) { + + zrtp_memset(cfg, 0, sizeof(zrtp_test_endpoint_cfg_t)); + + cfg->generate_traffic = 0; + + /* It's always a good idea to start with default values */ + zrtp_config_defaults(&cfg->zrtp); + + /* Set ZRTP client id */ + strcpy(cfg->zrtp.client_id, "zrtp-test-engine"); + + cfg->zrtp.is_mitm = 0; + cfg->zrtp.lic_mode = ZRTP_LICENSE_MODE_ACTIVE; + + cfg->zrtp.cb.event_cb.on_zrtp_secure = &on_zrtp_secure; + cfg->zrtp.cb.event_cb.on_zrtp_security_event = &on_zrtp_event; + cfg->zrtp.cb.event_cb.on_zrtp_protocol_event = &on_zrtp_event; + cfg->zrtp.cb.misc_cb.on_send_packet = &on_send_packet; +} + +zrtp_status_t zrtp_test_endpoint_create(zrtp_test_endpoint_cfg_t* cfg, + const char *name, + zrtp_test_id_t* id) { + zrtp_status_t s; + unsigned i; + char cache_file_path[ZRTP_TEST_STR_LEN]; + zrtp_endpoint_t *new_endpoint; + + if (g_test_endpoints_count >= K_ZRTP_TEST_MAX_ENDPOINTS) + return zrtp_status_alloc_fail; + + new_endpoint = &g_test_endpoints[g_test_endpoints_count++]; + zrtp_memset(new_endpoint, 0, sizeof(zrtp_endpoint_t)); + + /* Copy configuration, we will use it later to clean up after ourselves */ + zrtp_memcpy(&new_endpoint->cfg, cfg, sizeof(zrtp_test_endpoint_cfg_t)); + + /* Remember endpoint name */ + strcpy(new_endpoint->name, name); + + new_endpoint->id = g_endpoints_counter++; + + /* Adjust cache file path so each endpoint will use it's own file. */ + sprintf(cache_file_path, "./%s_cache.dat", name); + zrtp_zstrcpyc(ZSTR_GV(new_endpoint->cfg.zrtp.def_cache_path), cache_file_path); + + /* Initialize libzrtp engine for this endpoint */ + s = zrtp_init(&new_endpoint->cfg.zrtp, &new_endpoint->zrtp); + if (zrtp_status_ok == s) { + *id = new_endpoint->id; + + /* Generate random ZID */ + zrtp_randstr(new_endpoint->zrtp, new_endpoint->zid, sizeof(new_endpoint->zid)); + } + + /* Create Input queue*/ + s = zrtp_test_queue_create(&new_endpoint->input_queue); + if (zrtp_status_ok != s) { + return s; + } + + /* Start processing loop */ + new_endpoint->is_running = 1; + + for (i = 0; igenerate_traffic) { + if (0 != zrtp_thread_create(process_outgoing, new_endpoint)) { + return zrtp_status_fail; + } + } + } + + return s; +} + +zrtp_status_t zrtp_test_endpoint_destroy(zrtp_test_id_t id) { + unsigned i; + zrtp_status_t s = zrtp_status_ok; + zrtp_endpoint_t *endpoint = zrtp_test_endpoint_by_id(id); + + endpoint->is_running = 0; + + if (endpoint->input_queue) { + /* Push faked element to the queue to unlock incoming threads */ + for (i=0; isize = 0; + zrtp_test_queue_push(endpoint->input_queue, elem); + } + zrtp_sleep(0.5*1000); + + zrtp_test_queue_destroy(endpoint->input_queue); + } + + for (i=0; i<20; i++) zrtp_sleep(100); + + if (endpoint) { + /* Shut down libzrtp */ + if (endpoint->zrtp) + s = zrtp_down(endpoint->zrtp); + + /* Clean-up ZRTP cache after ourselves */ + remove(endpoint->cfg.zrtp.def_cache_path.buffer); + } else { + s = zrtp_status_fail; + } + + return s; +} + +zrtp_status_t zrtp_test_stream_get(zrtp_test_id_t id, + zrtp_test_stream_info_t* info) { + + zrtp_test_stream_t *stream = zrtp_test_stream_by_id(id); + if (stream) { + zrtp_status_t s; + zrtp_memset(info, 0, sizeof(zrtp_test_stream_info_t)); + + zrtp_memcpy(info->zrtp_events_queueu, stream->zrtp_events_queueu, sizeof(info->zrtp_events_queueu)); + info->zrtp_events_count = stream->zrtp_events_count; + + s = zrtp_stream_get(stream->zrtp, &info->zrtp); + return s; + } else { + return zrtp_status_bad_param; + } +} + +void zrtp_test_session_config_defaults(zrtp_test_session_cfg_t* cfg) { + cfg->streams_count = 1; + cfg->role = ZRTP_SIGNALING_ROLE_UNKNOWN; + cfg->is_enrollment = 0; + + zrtp_profile_defaults(&cfg->zrtp, NULL); +} + +zrtp_status_t zrtp_test_session_create(zrtp_test_id_t endpoint_id, + zrtp_test_session_cfg_t* cfg, + zrtp_test_id_t* id) { + zrtp_status_t s; + unsigned i; + zrtp_test_session_t *the_session; + zrtp_endpoint_t *the_endpoint = zrtp_test_endpoint_by_id(endpoint_id); + + if (!the_endpoint) + return zrtp_status_fail; + + if (the_endpoint->sessions_count >= K_ZRTP_TEST_MAX_SESSIONS_PER_ENDPOINT) + return zrtp_status_fail; + + the_session = &the_endpoint->sessions[the_endpoint->sessions_count++]; + + zrtp_memset(the_session, 0, sizeof(zrtp_test_session_t)); + + zrtp_memcpy(&the_session->cfg, cfg, sizeof(zrtp_test_session_cfg_t)); + + the_session->id = g_sessions_counter++; + the_session->endpoint_id = endpoint_id; + + s = zrtp_session_init(the_endpoint->zrtp, + &cfg->zrtp, + the_endpoint->zid, + cfg->role, + &the_session->zrtp); + + if (zrtp_status_ok == s) { + + zrtp_session_set_userdata(the_session->zrtp, &the_session->id); + + for (i=0; istreams_count; i++) { + zrtp_test_stream_t *the_stream = &the_session->streams[i]; + zrtp_memset(the_stream, 0, sizeof(zrtp_test_stream_t)); + + the_stream->id = g_streams_counter++; + the_stream->session_id = the_session->id; + the_stream->endpoint_id = endpoint_id; + + s = zrtp_stream_attach(the_session->zrtp, &the_stream->zrtp); + if (zrtp_status_ok == s) { + zrtp_stream_set_userdata(the_stream->zrtp, &the_stream->id); + the_session->streams_count++; + } else { + break; + } + } + } + + if (zrtp_status_ok == s) { + *id = the_session->id; + } + + return s; +} + +zrtp_status_t zrtp_test_session_destroy(zrtp_test_id_t id) { + zrtp_test_session_t *session = zrtp_test_session_by_id(id); + if (session) { + /* NOTE: we don't release session slots here due to nature of testing + * engine: test configuration constructed from scratch for every single test. + */ + zrtp_session_down(session->zrtp); + } + return zrtp_status_ok; +} + +zrtp_status_t zrtp_test_session_get(zrtp_test_id_t id, zrtp_test_session_info_t* info) { + zrtp_status_t s; + zrtp_test_session_t *session = zrtp_test_session_by_id(id); + if (session) { + s = zrtp_session_get(session->zrtp, &info->zrtp); + if (zrtp_status_ok == s) { + unsigned i; + for (i=0; istreams_count; i++) { + s = zrtp_test_stream_get(session->streams[i].id, &info->streams[i]); + if (zrtp_status_ok != s) + break; + } + } + + return s; + } else { + return zrtp_status_bad_param; + } +} + +zrtp_status_t zrtp_test_channel_create(zrtp_test_id_t left_id, zrtp_test_id_t right_id, zrtp_test_id_t* id) { + zrtp_test_channel_t *the_channel; + zrtp_test_stream_t *left = zrtp_test_stream_by_id(left_id); + zrtp_test_stream_t *right = zrtp_test_stream_by_id(right_id); + + if (!left || !right) + return zrtp_status_bad_param; + + if (g_test_channels_count >= K_ZRTP_TEST_MAX_CHANNELS) + return zrtp_status_bad_param; + + zrtp_endpoint_t *left_endpoint = zrtp_test_endpoint_by_id(left->endpoint_id); + zrtp_endpoint_t *right_endpoint = zrtp_test_endpoint_by_id(right->endpoint_id); + + the_channel = &g_test_channels[g_test_channels_count++]; + zrtp_memset(the_channel, 0, sizeof(zrtp_test_channel_t)); + + the_channel->id = g_channels_counter++; + the_channel->left = left; + the_channel->right = right; + + left->output = right_endpoint->input_queue; + left->input = left_endpoint->input_queue; + right->output = left_endpoint->input_queue; + right->input = right_endpoint->input_queue; + + right->channel_id = the_channel->id; + left->channel_id = the_channel->id; + + the_channel->is_attached = 1; + + *id = the_channel->id; + + return zrtp_status_ok; +} + +zrtp_status_t zrtp_test_channel_create2(zrtp_test_id_t left_session, + zrtp_test_id_t right_session, + unsigned stream_idx, + zrtp_test_id_t *id) { + zrtp_test_session_t *left = zrtp_test_session_by_id(left_session); + zrtp_test_session_t *right = zrtp_test_session_by_id(right_session); + + if (!left || !right) + return zrtp_status_bad_param; + + if (left->streams_count <= stream_idx || right->streams_count <= stream_idx) + return zrtp_status_bad_param; + + return zrtp_test_channel_create(left->streams[stream_idx].id, right->streams[stream_idx].id, id); +} + +zrtp_status_t zrtp_test_channel_destroy(zrtp_test_id_t id) { + zrtp_test_channel_t *channel = zrtp_test_channel_by_id(id); + if (!channel) + return zrtp_status_bad_param; + + return zrtp_status_ok; +} + +zrtp_status_t zrtp_test_channel_start(zrtp_test_id_t id) { + zrtp_status_t s1, s2; + zrtp_test_channel_t *the_channel = zrtp_test_channel_by_id(id); + zrtp_test_session_t *the_session; + + the_session = zrtp_test_session_by_id(the_channel->left->session_id); + if (the_session->cfg.is_enrollment) + s1 = zrtp_stream_registration_start(the_channel->left->zrtp, the_channel->left->id); /* use stream Id as ssrc */ + else + s1 = zrtp_stream_start(the_channel->left->zrtp, the_channel->left->id); /* use stream Id as ssrc */ + if (s1 == zrtp_status_ok) { + the_session = zrtp_test_session_by_id(the_channel->right->session_id); + if (the_session->cfg.is_enrollment) + s2 = zrtp_stream_registration_start(the_channel->right->zrtp, the_channel->right->id); + else + s2 = zrtp_stream_start(the_channel->right->zrtp, the_channel->right->id); + } else { + return s1; + } + + return s2; +} + +zrtp_status_t zrtp_test_channel_get(zrtp_test_id_t id, + zrtp_test_channel_info_t* info) { + + zrtp_test_channel_t *channel = zrtp_test_channel_by_id(id); + if (channel) { + zrtp_status_t s; + + zrtp_memset(info, 0, sizeof(zrtp_test_channel_info_t)); + + s = zrtp_test_stream_get(channel->left->id, &info->left); + if (zrtp_status_ok == s) { + s = zrtp_test_stream_get(channel->right->id, &info->right); + if (zrtp_status_ok == s) { + info->is_secure = channel->is_secure; + } + } + + return s; + } else { + return zrtp_status_bad_param; + } +} + + +/****************************************************************************** + * Helpers + */ + +zrtp_endpoint_t *zrtp_test_endpoint_by_id(zrtp_test_id_t id) { + int i; + + if (ZRTP_TEST_UNKNOWN_ID == id) return NULL; + + for (i=0; iid == ZRTP_TEST_UNKNOWN_ID) + continue; + + for (j=0; jsessions_count; j++) { + if (endpoint->sessions[j].id == id) { + return &endpoint->sessions[j]; + } + } + } + + return NULL; +} + +zrtp_test_stream_t *zrtp_test_stream_by_id(zrtp_test_id_t id) { + int i, j, k; + + if (ZRTP_TEST_UNKNOWN_ID == id) return NULL; + + for (i=0; iid == ZRTP_TEST_UNKNOWN_ID) + continue; + + for (j=0; jsessions_count; j++) { + zrtp_test_session_t *session = &endpoint->sessions[j]; + if (session->id == ZRTP_TEST_UNKNOWN_ID) + continue; + + for (k=0; kstreams_count; k++) { + if (session->streams[k].id == id) { + return &session->streams[k]; + } + } + } + } + + return NULL; +} + +zrtp_test_channel_t *zrtp_test_channel_by_id(zrtp_test_id_t id) { + int i; + zrtp_test_channel_t *channel = NULL; + + if (ZRTP_TEST_UNKNOWN_ID == id) return NULL; + + for (i=0; iid == id) + return g_test_channels[i].right; + else if (g_test_channels[i].right->id == id) + return g_test_channels[i].left; + } + } + + return NULL; +} + +zrtp_test_id_t zrtp_test_session_get_stream_by_idx(zrtp_test_id_t session_id, unsigned idx) { + zrtp_test_session_t *session = zrtp_test_session_by_id(session_id); + if (session && session->streams_count > idx) { + return session->streams[idx].id; + } else { + return ZRTP_TEST_UNKNOWN_ID; + } +} + +zrtp_stream_t *zrtp_stream_for_test_stream(zrtp_test_id_t stream_id) { + zrtp_test_stream_t *stream = zrtp_test_stream_by_id(stream_id); + if (stream) { + return stream->zrtp; + } else { + return NULL; + } +} + +unsigned zrtp_stream_did_event_receive(zrtp_test_id_t stream_id, unsigned event) { + unsigned i; + zrtp_test_stream_info_t stream_info; + + zrtp_test_stream_get(stream_id, &stream_info); + for (i=0; i + */ + +#include "zrtp.h" + +/** libzrtp test elements identifier */ +typedef uint32_t zrtp_test_id_t; + +/** Defines constant for unknown test element identifier */ +#define ZRTP_TEST_UNKNOWN_ID 0 + +/** Default lengths for libzrtp test string buffers */ +#define ZRTP_TEST_STR_LEN 128 + +/** libzrtp test endpoint configuration */ +typedef struct { + zrtp_config_t zrtp; /** libzrtp global configuration parameters */ + unsigned generate_traffic; /** switch On to emulate RTP/RTCP traffic generation. Off by default. */ +} zrtp_test_endpoint_cfg_t; + +/** ZRTP test session parameters*/ +typedef struct { + zrtp_profile_t zrtp; /** libzrtp session parameters */ + unsigned streams_count; /** number of zrtp streams to be attached to the session */ + zrtp_signaling_role_t role; /** signaling role, default is ZRTP_SIGNALING_ROLE_UNKNOWN */ + unsigned is_enrollment; /** true if enrollment session should be created */ +} zrtp_test_session_cfg_t; + +/** ZRTP test stream info */ +typedef struct { + zrtp_stream_info_t zrtp; /** libzrtp stream info */ + unsigned zrtp_events_queueu[128]; /** list of received zrtp events*/ + unsigned zrtp_events_count; /** number of received events */ +} zrtp_test_stream_info_t; + +/** ZRTP test session state snapshot */ +typedef struct { + zrtp_session_info_t zrtp; /** libzrtp session info*/ + zrtp_test_stream_info_t streams[ZRTP_MAX_STREAMS_PER_SESSION]; /** array of attached streams info */ + unsigned streams_count; /** number streams attached to the session */ +} zrtp_test_session_info_t; + +/** *ZRTP test channel state */ +typedef struct { + zrtp_test_stream_info_t left; /** one-leg zrtp stream */ + zrtp_test_stream_info_t right; /** second-leg zrtp stream */ + unsigned char is_secure; /** enabled when both streams in the channel are secure */ +} zrtp_test_channel_info_t; + + +/** + * Initialize zrtp test endpoint configuration with default values + * @param cfg - endpoint config to initialize + */ +void zrtp_test_endpoint_config_defaults(zrtp_test_endpoint_cfg_t *cfg); + +/** + * ZRTP test endpoint constructor + * One endpoint is created, it starts processing threads and ready to emulate ZRTP exchange. + * + * @param cfg - endpoint configuration + * @param name - endpoint name for debug purposes and cache naming, e.h "Alice", "Bob". + * @param id - just created endpoint identifier will be placed here + * + * @return zrtp_status_ok on success or some of zrtp_status_t error codes on failure + */ +zrtp_status_t zrtp_test_endpoint_create(zrtp_test_endpoint_cfg_t *cfg, + const char *name, + zrtp_test_id_t *id); + +/** + * ZRTP test endpoint destructor + * zrtp_test_endpoint_destroy() stops processing threads and release all + * recurses allocated in zrtp_test_endpoint_create(). + * + * @param id - endpoint identifier + * @return zrtp_status_ok on success or some of zrtp_status_t error codes on failure + */ +zrtp_status_t zrtp_test_endpoint_destroy(zrtp_test_id_t id); + +/** + * Enables test session config with default values + * @param cfg - session config for initialization + */ +void zrtp_test_session_config_defaults(zrtp_test_session_cfg_t *cfg); + +/** + * Create zrtp test session + * + * @param endpoint - test endpoint creating endpoint should belong to + * @param cfg - session parameters + * @param id - created session identifier will be placed here + * @return zrtp_status_ok on success or some of zrtp_status_t error codes on failure + */ +zrtp_status_t zrtp_test_session_create(zrtp_test_id_t endpoint, + zrtp_test_session_cfg_t *cfg, + zrtp_test_id_t *id); + +zrtp_status_t zrtp_test_session_destroy(zrtp_test_id_t id); + +zrtp_status_t zrtp_test_session_get(zrtp_test_id_t id, zrtp_test_session_info_t *info); + +/** + * Get stream Id by it's index in zrtp session + * + * @param session_id - zrtp test session id where needed stream should be taken + * @param idx - stream index + * @return found stream id, or ZRTP_TEST_UNKNOWN_ID if idex is out of stream array range + */ +zrtp_test_id_t zrtp_test_session_get_stream_by_idx(zrtp_test_id_t session_id, unsigned idx); + +zrtp_status_t zrtp_test_stream_get(zrtp_test_id_t id, zrtp_test_stream_info_t *info); + +zrtp_status_t zrtp_test_channel_create(zrtp_test_id_t left_stream, zrtp_test_id_t right_stream, zrtp_test_id_t *id); +zrtp_status_t zrtp_test_channel_create2(zrtp_test_id_t left_session, zrtp_test_id_t right_session, unsigned stream_idx, zrtp_test_id_t *id); +zrtp_status_t zrtp_test_channel_destroy(zrtp_test_id_t id); +zrtp_status_t zrtp_test_channel_start(zrtp_test_id_t id); +zrtp_status_t zrtp_test_channel_get(zrtp_test_id_t id, zrtp_test_channel_info_t *info); + +zrtp_stream_t *zrtp_stream_for_test_stream(zrtp_test_id_t stream_id); + +unsigned zrtp_stream_did_event_receive(zrtp_test_id_t stream_id, unsigned event); + + From 326370ba48a10f8f6f005200d597a2724c44b7c2 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Wed, 13 Jun 2012 15:23:30 +0300 Subject: [PATCH 08/49] Pass through void* arg in zrtp_thread_create Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/src/zrtp_iface_scheduler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/libzrtp/src/zrtp_iface_scheduler.c b/libs/libzrtp/src/zrtp_iface_scheduler.c index ee7bb3d763..715c584b53 100644 --- a/libs/libzrtp/src/zrtp_iface_scheduler.c +++ b/libs/libzrtp/src/zrtp_iface_scheduler.c @@ -100,7 +100,7 @@ int zrtp_sleep(unsigned int msec) int zrtp_thread_create(zrtp_thread_routine_t start_routine, void *arg) { pthread_t thread; - return pthread_create(&thread, NULL, start_routine, NULL); + return pthread_create(&thread, NULL, start_routine, arg); } #endif From 2bfb3e7408f8821257399c7a5d156538554cc8c9 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Wed, 13 Jun 2012 15:23:30 +0300 Subject: [PATCH 09/49] Update libzrtp version Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/include/zrtp_version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/libzrtp/include/zrtp_version.h b/libs/libzrtp/include/zrtp_version.h index e666e42cb9..f5701e22b3 100644 --- a/libs/libzrtp/include/zrtp_version.h +++ b/libs/libzrtp/include/zrtp_version.h @@ -13,7 +13,7 @@ #define LIBZRTP_VERSION_MAJOR 1 #define LIBZRTP_VERSION_MINOR 15 -#define LIBZRTP_VERSION_BUILD 607 -#define LIBZRTP_VERSION_STR "v1.15 607" +#define LIBZRTP_VERSION_BUILD 609 +#define LIBZRTP_VERSION_STR "v1.15 609" #endif /*__ZRTP_VERSION_H__*/ From 656669d241fd7f9bd9fe8686248686b8ac6a7c16 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Wed, 13 Jun 2012 15:29:29 +0300 Subject: [PATCH 10/49] Fix bug with sasrelay libzrtp was forcing a new SAS rendering even when SasRelay sashash was zero. Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/src/zrtp_pbx.c | 105 ++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 51 deletions(-) diff --git a/libs/libzrtp/src/zrtp_pbx.c b/libs/libzrtp/src/zrtp_pbx.c index cc25c46b3e..dbc2aa7cbb 100644 --- a/libs/libzrtp/src/zrtp_pbx.c +++ b/libs/libzrtp/src/zrtp_pbx.c @@ -25,7 +25,8 @@ static void _send_and_resend_sasrelay(zrtp_stream_t *stream, zrtp_retry_task_t* ZRTP_LOG(1,(_ZTU_,"WARNING! SASRELAY Max retransmissions count reached. ID=%u\n", stream->id)); _zrtp_machine_enter_initiatingerror(stream, zrtp_error_timeout, 0); } else if (task->_is_enabled) { - zrtp_status_t s = _zrtp_packet_send_message(stream, ZRTP_SASRELAY, &stream->messages.sasrelay); + + zrtp_status_t s = _zrtp_packet_send_message(stream, ZRTP_SASRELAY, &stream->messages.sasrelay); task->timeout = _zrtp_get_timeout((uint32_t)task->timeout, ZRTP_SASRELAY); if (zrtp_status_ok == s) { task->_retrys++; @@ -87,13 +88,15 @@ static zrtp_status_t _create_sasrelay( zrtp_stream_t *stream, s = session->blockcipher->encrypt( session->blockcipher, cipher_ctx, - (uint8_t*)&sasrelay->pad, + (uint8_t*)sasrelay->pad, encrypted_body_size ); } while(0); if (cipher_ctx) { session->blockcipher->stop(session->blockcipher, cipher_ctx); } - + + + if (zrtp_status_ok != s) { ZRTP_LOG(1,(_ZTU_,"\tERROR! Failed to encrypt SASRELAY Message status=%d. ID=%u\n", s, stream->id)); return s; @@ -130,10 +133,10 @@ zrtp_status_t _zrtp_machine_process_sasrelay(zrtp_stream_t *stream, zrtp_rtp_inf char zerosashash[32]; unsigned sas_scheme_did_change = 0; unsigned sas_hash_did_change = 0; - + /* (padding + sig_len + flags) + SAS scheme and SAS hash */ const uint8_t encrypted_body_size = (2 + 1 + 1) + 4 + 32; - + zrtp_memset(zerosashash, 0, sizeof(zerosashash)); /* Check if the remote endpoint is assigned to relay the SAS values */ @@ -141,7 +144,7 @@ zrtp_status_t _zrtp_machine_process_sasrelay(zrtp_stream_t *stream, zrtp_rtp_inf ZRTP_LOG(2,(_ZTU_, ZRTP_RELAYED_SAS_FROM_NONMITM_STR)); return zrtp_status_fail; } - + /* Check the HMAC */ s = session->hash->hmac_c( session->hash, stream->cc.peer_hmackey.buffer, @@ -177,15 +180,15 @@ zrtp_status_t _zrtp_machine_process_sasrelay(zrtp_stream_t *stream, zrtp_rtp_inf break; } - s = session->blockcipher->encrypt( session->blockcipher, + s = session->blockcipher->decrypt( session->blockcipher, cipher_ctx, - (uint8_t*)&sasrelay->pad, + (uint8_t*)sasrelay->pad, encrypted_body_size); } while(0); if (cipher_ctx) { session->blockcipher->stop(session->blockcipher, cipher_ctx); } - + if (zrtp_status_ok != s) { ZRTP_LOG(1,(_ZTU_,"\tERROR! Failed to decrypt Confirm. status=%d ID=%u\n", s, stream->id)); return s; @@ -215,7 +218,7 @@ zrtp_status_t _zrtp_machine_process_sasrelay(zrtp_stream_t *stream, zrtp_rtp_inf if (-1 == zrtp_profile_find(&session->profile, ZRTP_CC_SAS, rendering_id)) { ZRTP_LOG(1,(_ZTU_,"\tERROR! PBX Confirm packet with transferred SAS have unknown or" " unsupported rendering scheme %.4s.ID=%u\n", sasrelay->sas_scheme, stream->id)); - + _zrtp_machine_enter_initiatingerror(stream, zrtp_error_invalid_packet, 1); return zrtp_status_fail; } @@ -229,7 +232,7 @@ zrtp_status_t _zrtp_machine_process_sasrelay(zrtp_stream_t *stream, zrtp_rtp_inf } if (session->secrets.matches & ZRTP_BIT_PBX) { - if ( ( ((uint32_t) *sasrelay->sas_scheme) != (uint32_t)0x0L ) && + if ( (((uint32_t) *sasrelay->sas_scheme) != (uint32_t)0x0L) && (0 != zrtp_memcmp(sasrelay->sashash, zerosashash, sizeof(sasrelay->sashash))) ) { char buff[256]; @@ -237,10 +240,10 @@ zrtp_status_t _zrtp_machine_process_sasrelay(zrtp_stream_t *stream, zrtp_rtp_inf /* First 32 bits if sashash includes sasvalue */ zrtp_memcpy(session->sasbin.buffer, sasrelay->sashash, session->sasbin.length); stream->mitm_mode = ZRTP_MITM_MODE_RECONFIRM_CLIENT; - + sas_hash_did_change = 1; ZRTP_LOG(3,(_ZTU_,"\tSasRelay: SAS value was updated to bin=%s.\n", - hex2str(buff, sizeof(buff), session->sasbin.buffer, session->sasbin.length))); + hex2str(session->sasbin.buffer, session->sasbin.length, buff, sizeof(buff)))); } } else if (0 != zrtp_memcmp(sasrelay->sashash, zerosashash, sizeof(sasrelay->sashash))) { ZRTP_LOG(1,(_ZTU_,"\tWARNING! SAS Value was received from NOT Trusted MiTM. ID=%u\n", stream->id)); @@ -318,15 +321,15 @@ zrtp_status_t zrtp_stream_registration_start(zrtp_stream_t* stream, uint32_t ssr if (!stream) { return zrtp_status_bad_param; } - + ZRTP_LOG(3,(_ZTU_,"START REGISTRATION STREAM ID=%u mode=%s state=%s.\n", stream->id, zrtp_log_mode2str(stream->mode), zrtp_log_state2str(stream->state))); - + if (NULL == stream->zrtp->cb.cache_cb.on_get_mitm) { ZRTP_LOG(2,(_ZTU_,"WARNING: Can't use MiTM Functions with no ZRTP Cache.\n")); return zrtp_status_notavailable; } - + stream->mitm_mode = ZRTP_MITM_MODE_REG_SERVER; return zrtp_stream_start(stream, ssrc); } @@ -336,15 +339,15 @@ zrtp_status_t zrtp_stream_registration_secure(zrtp_stream_t* stream) if (!stream) { return zrtp_status_bad_param; } - + ZRTP_LOG(3,(_ZTU_,"SECURE REGISTRATION STREAM ID=%u mode=%s state=%s.\n", stream->id, zrtp_log_mode2str(stream->mode), zrtp_log_state2str(stream->state))); - + if (NULL == stream->zrtp->cb.cache_cb.on_get_mitm) { ZRTP_LOG(2,(_ZTU_,"WARNING: Can't use MiTM Functions with no ZRTP Cache.\n")); return zrtp_status_notavailable; } - + stream->mitm_mode = ZRTP_MITM_MODE_REG_SERVER; return zrtp_stream_secure(stream); } @@ -354,22 +357,22 @@ zrtp_status_t zrtp_register_with_trusted_mitm(zrtp_stream_t* stream) { zrtp_session_t *session = stream->session; zrtp_status_t s = zrtp_status_bad_param; - + if (!stream) { return zrtp_status_bad_param; } - + ZRTP_LOG(3,(_ZTU_,"MARKING this call as REGISTRATION ID=%u\n", stream->id)); - + if (NULL == stream->zrtp->cb.cache_cb.on_get_mitm) { ZRTP_LOG(2,(_ZTU_,"WARNING: Can't use MiTM Functions with no ZRTP Cache.\n")); return zrtp_status_notavailable; } - + if (!stream->protocol) { return zrtp_status_bad_param; } - + /* Passive Client endpoint should NOT generate PBX Secret. */ if ((stream->mitm_mode == ZRTP_MITM_MODE_REG_CLIENT) && (ZRTP_LICENSE_MODE_PASSIVE == stream->zrtp->lic_mode)) { @@ -387,7 +390,7 @@ zrtp_status_t zrtp_register_with_trusted_mitm(zrtp_stream_t* stream) zrtp_string32_t kdf_context = ZSTR_INIT_EMPTY(kdf_context); static const zrtp_string32_t trusted_mitm_key_label = ZSTR_INIT_WITH_CONST_CSTRING(ZRTP_TRUSTMITMKEY_STR); zrtp_string16_t *zidi, *zidr; - + if (stream->protocol->type == ZRTP_STATEMACHINE_INITIATOR) { zidi = &session->zid; zidr = &session->peer_zid; @@ -395,29 +398,29 @@ zrtp_status_t zrtp_register_with_trusted_mitm(zrtp_stream_t* stream) zidi = &session->peer_zid; zidr = &session->zid; } - + zrtp_zstrcat(ZSTR_GV(kdf_context), ZSTR_GVP(zidi)); zrtp_zstrcat(ZSTR_GV(kdf_context), ZSTR_GVP(zidr)); - + _zrtp_kdf( stream, ZSTR_GV(session->zrtpsess), ZSTR_GV(trusted_mitm_key_label), ZSTR_GV(kdf_context), ZRTP_HASH_SIZE, ZSTR_GV(session->secrets.pbxs->value)); - + session->secrets.pbxs->_cachedflag = 1; session->secrets.pbxs->lastused_at = (uint32_t)(zrtp_time_now()/1000); session->secrets.cached |= ZRTP_BIT_PBX; session->secrets.matches |= ZRTP_BIT_PBX; s = zrtp_status_ok; - if (session->zrtp->cb.cache_cb.on_put_mitm) { - s = session->zrtp->cb.cache_cb.on_put_mitm( ZSTR_GV(session->zid), + if (session->zrtp->cb.cache_cb.on_put_mitm) { + s = session->zrtp->cb.cache_cb.on_put_mitm( ZSTR_GV(session->zid), ZSTR_GV(session->peer_zid), session->secrets.pbxs); } - + ZRTP_LOG(3,(_ZTU_,"Makring this call as REGISTRATION - DONE\n")); } @@ -430,46 +433,46 @@ zrtp_status_t zrtp_link_mitm_calls(zrtp_stream_t *stream1, zrtp_stream_t *stream if (!stream1 || !stream2) { return zrtp_status_bad_param; } - - ZRTP_LOG(3,(_ZTU_,"Link to MiTM call together stream1=%u stream2=%u.\n", stream1->id, stream2->id)); - + + ZRTP_LOG(3,(_ZTU_,"Link to MiTM call together stream1=%u stream2=%u.\n", stream1->id, stream2->id)); + /* This APi is for MiTM endpoints only. */ if (stream1->zrtp->is_mitm) { return zrtp_status_bad_param; } - + stream1->linked_mitm = stream2; stream2->linked_mitm = stream1; - + { zrtp_stream_t *passive = NULL; zrtp_stream_t *unlimited = NULL; - + /* Check if we have at least one Unlimited endpoint. */ if (stream1->peer_super_flag) unlimited = stream1; else if (stream2->peer_super_flag) unlimited = stream2; - + /* Check if the peer stream is Passive */ if (unlimited) { passive = (stream1 == unlimited) ? stream2 : stream1; if (!passive->peer_passive) passive = NULL; } - + /* Ok, we haver Unlimited and Passive at two ends, let's make an exception and switch Passive to Secure. */ if (unlimited && passive) { if (passive->state == ZRTP_STATE_CLEAR) { ZRTP_LOG(2,(_ZTU_,"INFO: zrtp_link_mitm_calls() stream with id=%u is Unlimited and" " Peer stream with id=%u is Passive in CLEAR state, switch the passive one to SECURE.\n")); - - /* @note: don't use zrtp_secure_stream() wrapper as it checks for Active/Passive stuff. */ + + /* @note: don't use zrtp_secure_stream() wrapper as it checks for Active/Passive stuff. */ _zrtp_machine_start_initiating_secure(passive); } - } + } } - + return zrtp_status_ok; } @@ -483,16 +486,16 @@ zrtp_status_t zrtp_update_remote_options( zrtp_stream_t* stream, zrtp_retry_task_t* task = &stream->messages.sasrelay_task; zrtp_status_t s = zrtp_status_ok; char buff[256]; - + if (!stream) { return zrtp_status_bad_param; } - + ZRTP_LOG(3,(_ZTU_,"UPDATE REMOTE SAS OPTIONS mode. ID=%u\n", stream->id)); ZRTP_LOG(3,(_ZTU_,"transf_sas=%s scheme=%d.\n", transf_sas_value ? hex2str((const char*)transf_sas_value->buffer, transf_sas_value->length, (char*)buff, sizeof(buff)) : "NULL", transf_sas_scheme)); - + if (NULL == stream->zrtp->cb.cache_cb.on_get_mitm) { ZRTP_LOG(2,(_ZTU_,"WARNING: Can't use MiTM Functions with no ZRTP Cache.\n")); return zrtp_status_notavailable; @@ -507,7 +510,7 @@ zrtp_status_t zrtp_update_remote_options( zrtp_stream_t* stream, if (transf_sas_value && !(stream->session->secrets.matches & ZRTP_BIT_PBX)) { return zrtp_status_bad_param; } - + /* Don't allow to transfer the SAS if the library wasn't initialized as MiTM endpoint */ if (!stream->zrtp->is_mitm) { ZRTP_LOG(3,(_ZTU_,"\tERROR! The endpoint can't transfer SAS values to other endpoints" @@ -551,7 +554,7 @@ zrtp_status_t zrtp_resolve_mitm_call( zrtp_stream_t* stream1, zrtp_stream_t* non_enrolled = NULL; zrtp_sas_id_t mitm_sas_scheme = ZRTP_COMP_UNKN; zrtp_status_t s = zrtp_status_ok; - + if (!stream1 || !stream2) { return zrtp_status_bad_param; } @@ -562,7 +565,7 @@ zrtp_status_t zrtp_resolve_mitm_call( zrtp_stream_t* stream1, ZRTP_LOG(2,(_ZTU_,"WARNING: Can't use MiTM Functions with no ZRTP Cache.\n")); return zrtp_status_notavailable; } - + /* * Both sides must be in the Secure state and at least one should be * enrolled. @@ -667,7 +670,7 @@ uint8_t zrtp_is_user_enrolled(zrtp_stream_t* stream) if (!stream) { return zrtp_status_bad_param; } - + return ( (stream->session->secrets.cached & ZRTP_BIT_PBX) && (stream->session->secrets.matches & ZRTP_BIT_PBX) ); } @@ -677,7 +680,7 @@ zrtp_stream_t* zrtp_choose_one_enrolled(zrtp_stream_t* stream1, zrtp_stream_t* s if (!stream1 || !stream2) { return NULL; } - + if (zrtp_memcmp( stream1->session->zid.buffer, stream2->session->zid.buffer, stream1->session->zid.length) > 0) { From 1b15973f02b1fd324b68a31c5beae0109fc31e83 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Wed, 13 Jun 2012 15:29:29 +0300 Subject: [PATCH 11/49] Bump libzrtp version Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/include/zrtp_version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/libzrtp/include/zrtp_version.h b/libs/libzrtp/include/zrtp_version.h index f5701e22b3..be8fe0dc6d 100644 --- a/libs/libzrtp/include/zrtp_version.h +++ b/libs/libzrtp/include/zrtp_version.h @@ -13,7 +13,7 @@ #define LIBZRTP_VERSION_MAJOR 1 #define LIBZRTP_VERSION_MINOR 15 -#define LIBZRTP_VERSION_BUILD 609 -#define LIBZRTP_VERSION_STR "v1.15 609" +#define LIBZRTP_VERSION_BUILD 610 +#define LIBZRTP_VERSION_STR "v1.15 610" #endif /*__ZRTP_VERSION_H__*/ From a7d0c274abea240cfb9dc6378626e61f8c6dfd76 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Fri, 15 Jun 2012 10:23:13 +0300 Subject: [PATCH 12/49] Fix spelling Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/include/zrtp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/libzrtp/include/zrtp.h b/libs/libzrtp/include/zrtp.h index 37595ab735..44bd194843 100644 --- a/libs/libzrtp/include/zrtp.h +++ b/libs/libzrtp/include/zrtp.h @@ -167,7 +167,7 @@ typedef struct zrtp_config_t * \brief zrtp stream information structure * \ingroup zrtp_main_management * - * libzrtp, since v0.80 takes data incapsulating approach and hides all private date inside + * libzrtp, since v0.80 takes data encapsulating approach and hides all private data inside * zrtp_stream_t structure. Developers shouldn't access them directly. \ref zrtp_stream_get() should * be used instead to fill zrtp_stream_info_t structure. zrtp_stream_info_t contains all needed * information in safe and easy to use form. From fc98238dd6e7d893f92a195be4ae2b368113aa75 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Fri, 15 Jun 2012 10:23:13 +0300 Subject: [PATCH 13/49] Condense formatting of struct Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/include/zrtp_types.h | 76 ++++++++----------------------- 1 file changed, 20 insertions(+), 56 deletions(-) diff --git a/libs/libzrtp/include/zrtp_types.h b/libs/libzrtp/include/zrtp_types.h index c5c7654d68..b1282cc3e6 100644 --- a/libs/libzrtp/include/zrtp_types.h +++ b/libs/libzrtp/include/zrtp_types.h @@ -344,29 +344,15 @@ typedef enum zrtp_statemachine_type_t */ struct zrtp_global_t { - /** ZRTP license mode. */ - uint32_t lic_mode; - - /** Local ZRTP client ID. */ - zrtp_string16_t client_id; - - /** Flags defines that the local endpoint acts as ZRTP MiTM. */ - uint8_t is_mitm; - - /** Hash context for entropy accumulation for the RNG unit. */ - MD_CTX rand_ctx; - - /** RNG unit initialization flag. */ - uint8_t rand_initialized; - - /** Full path to ZRTP cache file. */ - zrtp_string256_t def_cache_path; - - /** This object is used to protect the shared RNG hash zrtp#rand_ctx */ - zrtp_mutex_t* rng_protector; - - /** This section provides static data for DH3K and DH4K components */ - struct BigNum one; + uint32_t lic_mode; /** ZRTP license mode. */ + zrtp_string16_t client_id; /** Local ZRTP client ID. */ + uint8_t is_mitm; /** Flags defines that the local endpoint acts as ZRTP MiTM. */ + MD_CTX rand_ctx; /** Hash context for entropy accumulation for the RNG unit. */ + uint8_t rand_initialized; /** RNG unit initialization flag. */ + zrtp_string256_t def_cache_path; /** Full path to ZRTP cache file. */ + unsigned cache_auto_store; /** Set when user wants libzrtp to flush the cache once it changed */ + zrtp_mutex_t* rng_protector; /** This object is used to protect the shared RNG hash zrtp#rand_ctx */ + struct BigNum one; /** This section provides static data for DH3K and DH4K components */ struct BigNum G; struct BigNum P_2048; struct BigNum P_2048_1; @@ -374,39 +360,17 @@ struct zrtp_global_t struct BigNum P_3072_1; uint8_t P_2048_data[256]; uint8_t P_3072_data[384]; - - /** Head of hash components list */ - mlist_t hash_head; - - /** Head of ciphers list */ - mlist_t cipher_head; - - /** Head of ATL components list */ - mlist_t atl_head; - - /** Head of public key exchange schemes list */ - mlist_t pktype_head; - - /** SAS schemes list */ - mlist_t sas_head; - - /** Storage for some SRTP global data */ - void* srtp_global; - - /** Head of ZRTP sessions list */ - mlist_t sessions_head; - - /** Global sessions count used to create ZRTP session IDs. For debug purposes mostly. */ - uint32_t sessions_count; - - /** Global streams count used to create ZRTP session IDs. For debug purposes mostly. */ - uint32_t streams_count; - - /** This object is used to synchronize sessions list operations */ - zrtp_mutex_t* sessions_protector; - - /** Set of feedback callbacks used by libzrtp to interact with the user-space.*/ - zrtp_callback_t cb; + mlist_t hash_head; /** Head of hash components list */ + mlist_t cipher_head; /** Head of ciphers list */ + mlist_t atl_head; /** Head of ATL components list */ + mlist_t pktype_head; /** Head of public key exchange schemes list */ + mlist_t sas_head; /** SAS schemes list */ + void* srtp_global; /** Storage for some SRTP global data */ + mlist_t sessions_head; /** Head of ZRTP sessions list */ + uint32_t sessions_count; /** Global sessions count used to create ZRTP session IDs. For debug purposes mostly. */ + uint32_t streams_count; /** Global streams count used to create ZRTP session IDs. For debug purposes mostly. */ + zrtp_mutex_t* sessions_protector; /** This object is used to synchronize sessions list operations */ + zrtp_callback_t cb; /** Set of feedback callbacks used by libzrtp to interact with the user-space.*/ }; From 272b36d04bfcbf77609a9e892ace9143fd726564 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Fri, 15 Jun 2012 10:23:13 +0300 Subject: [PATCH 14/49] Improve whitespace and formatting Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/src/zrtp.c | 2 +- libs/libzrtp/src/zrtp_iface_cache.c | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/libs/libzrtp/src/zrtp.c b/libs/libzrtp/src/zrtp.c index c69b5e9692..3e53b2a2ef 100644 --- a/libs/libzrtp/src/zrtp.c +++ b/libs/libzrtp/src/zrtp.c @@ -1129,7 +1129,7 @@ char* zrtp_comp_id2type(zrtp_crypto_comp_t type, uint8_t id) case ZRTP_ATL_HS32: return ZRTP_HS32; case ZRTP_ATL_HS80: return ZRTP_HS80; default: return "Unkn"; - } + } default: return "Unkn"; diff --git a/libs/libzrtp/src/zrtp_iface_cache.c b/libs/libzrtp/src/zrtp_iface_cache.c index 970d97e869..204546b079 100644 --- a/libs/libzrtp/src/zrtp_iface_cache.c +++ b/libs/libzrtp/src/zrtp_iface_cache.c @@ -56,7 +56,6 @@ static zrtp_status_t zrtp_cache_user_down(); return zrtp_status_bad_param; \ } -/*----------------------------------------------------------------------------*/ zrtp_status_t zrtp_def_cache_init(zrtp_global_t* a_zrtp) { zrtp_status_t s = zrtp_status_ok; @@ -102,7 +101,7 @@ void zrtp_def_cache_down() } } -/*----------------------------------------------------------------------------*/ + zrtp_status_t zrtp_def_cache_set_verified( const zrtp_stringn_t* one_ZID, const zrtp_stringn_t* another_ZID, uint32_t verified) @@ -117,7 +116,7 @@ zrtp_status_t zrtp_def_cache_set_verified( const zrtp_stringn_t* one_ZID, new_elem = get_elem(id, 0); if (new_elem) { new_elem->verified = verified; - } + } zrtp_mutex_unlock(def_cache_protector); return (new_elem) ? zrtp_status_ok : zrtp_status_fail; @@ -145,7 +144,6 @@ zrtp_status_t zrtp_def_cache_get_verified( const zrtp_stringn_t* one_ZID, } -/*----------------------------------------------------------------------------*/ static zrtp_status_t cache_put( const zrtp_stringn_t* one_ZID, const zrtp_stringn_t* another_ZID, zrtp_shared_secret_t *rss, @@ -229,7 +227,6 @@ zrtp_status_t zrtp_def_cache_put_mitm( const zrtp_stringn_t* one_ZID, } -/*----------------------------------------------------------------------------*/ static zrtp_status_t cache_get( const zrtp_stringn_t* one_ZID, const zrtp_stringn_t* another_ZID, zrtp_shared_secret_t *rss, @@ -288,7 +285,6 @@ zrtp_status_t zrtp_def_cache_get_mitm( const zrtp_stringn_t* one_ZID, return cache_get(one_ZID, another_ZID, rss, 0, 1); } -/*-----------------------------------------------------------------------------*/ zrtp_status_t zrtp_def_cache_set_presh_counter( const zrtp_stringn_t* one_zid, const zrtp_stringn_t* another_zid, uint32_t counter) @@ -331,7 +327,6 @@ zrtp_status_t zrtp_def_cache_get_presh_counter( const zrtp_stringn_t* one_zid, return (new_elem) ? zrtp_status_ok : zrtp_status_fail; } -/*-----------------------------------------------------------------------------*/ void zrtp_cache_create_id( const zrtp_stringn_t* first_ZID, const zrtp_stringn_t* second_ZID, zrtp_cache_id_t id ) @@ -346,13 +341,12 @@ zrtp_status_t zrtp_def_cache_get_presh_counter( const zrtp_stringn_t* one_zid, zrtp_memcpy((char*)id+sizeof(zrtp_zid_t), second_ZID->buffer, sizeof(zrtp_zid_t)); } -/*-----------------------------------------------------------------------------*/ zrtp_cache_elem_t* zrtp_def_cache_get2(const zrtp_cache_id_t id, int is_mitm) { return get_elem(id, is_mitm); } -/*-----------------------------------------------------------------------------*/ + static zrtp_cache_elem_t* get_elem(const zrtp_cache_id_t id, uint8_t is_mitm) { mlist_t* node = NULL; @@ -367,7 +361,6 @@ static zrtp_cache_elem_t* get_elem(const zrtp_cache_id_t id, uint8_t is_mitm) return NULL; } -/*----------------------------------------------------------------------------*/ static void cache_make_cross(zrtp_cache_elem_t* from, zrtp_cache_elem_t* to, uint8_t is_upload) { if (!to) { @@ -576,7 +569,7 @@ zrtp_status_t zrtp_cache_user_init() return s; } -/*---------------------------------------------------------------------------*/ + #define ZRTP_DOWN_CACHE_RETURN(s, f) \ {\ if (zrtp_status_ok != s) { \ From 551938b89b01b6e682ef463036f60efc7e573e5f Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Fri, 15 Jun 2012 10:23:13 +0300 Subject: [PATCH 15/49] Add preventative breaks to case statement Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/src/zrtp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/libzrtp/src/zrtp.c b/libs/libzrtp/src/zrtp.c index 3e53b2a2ef..139d0b733d 100644 --- a/libs/libzrtp/src/zrtp.c +++ b/libs/libzrtp/src/zrtp.c @@ -1093,6 +1093,7 @@ char* zrtp_comp_id2type(zrtp_crypto_comp_t type, uint8_t id) case ZRTP_HASH_SHA384: return ZRTP_S384; default: return "Unkn"; } + break; case ZRTP_CC_SAS: switch (id) @@ -1101,6 +1102,7 @@ char* zrtp_comp_id2type(zrtp_crypto_comp_t type, uint8_t id) case ZRTP_SAS_BASE256: return ZRTP_B256; default: return "Unkn"; } + break; case ZRTP_CC_CIPHER: switch (id) @@ -1109,6 +1111,7 @@ char* zrtp_comp_id2type(zrtp_crypto_comp_t type, uint8_t id) case ZRTP_CIPHER_AES256: return ZRTP_AES3; default: return "Unkn"; } + break; case ZRTP_CC_PKT: switch (id) @@ -1122,6 +1125,7 @@ char* zrtp_comp_id2type(zrtp_crypto_comp_t type, uint8_t id) case ZRTP_PKTYPE_EC521P: return ZRTP_EC521P; default: return "Unkn"; } + break; case ZRTP_CC_ATL: switch (id) @@ -1130,6 +1134,7 @@ char* zrtp_comp_id2type(zrtp_crypto_comp_t type, uint8_t id) case ZRTP_ATL_HS80: return ZRTP_HS80; default: return "Unkn"; } + break; default: return "Unkn"; From e4daefbadc9c518cf897338424c6b1c09df7e39e Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Fri, 15 Jun 2012 10:23:13 +0300 Subject: [PATCH 16/49] Flush zrtp cache automatically Add option to flush zrtp cache to persistent storage automatically immediately after the cache is modified. See zrtp_config_t#cache_auto_store. Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/include/zrtp.h | 11 +++++++++++ libs/libzrtp/src/zrtp.c | 3 +++ libs/libzrtp/src/zrtp_iface_cache.c | 14 +++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/libs/libzrtp/include/zrtp.h b/libs/libzrtp/include/zrtp.h index 44bd194843..88f549e025 100644 --- a/libs/libzrtp/include/zrtp.h +++ b/libs/libzrtp/include/zrtp.h @@ -161,6 +161,17 @@ typedef struct zrtp_config_t /** @brief Path to zrtp cache file (set if you use built-in realization) */ zrtp_string256_t def_cache_path; + + /** + * @brief Flush the cache automatically + * Set to 1 if you want libzrtp to flush the cache to the persistent storage + * right after it is modified. If cache_auto_store is 0, libzrtp will flush + * the cache on going down only and the app is responsible for storing the + * cache in unexpected situations. Enabled by default. + * + * @sa zrtp_def_cache_store() + */ + unsigned cache_auto_store; } zrtp_config_t; /** diff --git a/libs/libzrtp/src/zrtp.c b/libs/libzrtp/src/zrtp.c index 139d0b733d..9ee078082b 100644 --- a/libs/libzrtp/src/zrtp.c +++ b/libs/libzrtp/src/zrtp.c @@ -34,6 +34,8 @@ void zrtp_config_defaults(zrtp_config_t* config) ZSTR_SET_EMPTY(config->def_cache_path); zrtp_zstrncpyc(ZSTR_GV(config->def_cache_path), "./zrtp_def_cache_path.dat", 25); + config->cache_auto_store = 1; /* cache auto flushing should be enabled by default */ + #if (defined(ZRTP_USE_BUILTIN_CACHE) && (ZRTP_USE_BUILTIN_CACHE == 1)) config->cb.cache_cb.on_init = zrtp_def_cache_init; config->cb.cache_cb.on_down = zrtp_def_cache_down; @@ -81,6 +83,7 @@ zrtp_status_t zrtp_init(zrtp_config_t* config, zrtp_global_t** zrtp) ZSTR_SET_EMPTY(new_zrtp->def_cache_path); zrtp_zstrcpy(ZSTR_GV(new_zrtp->def_cache_path), ZSTR_GV(config->def_cache_path)); zrtp_memcpy(&new_zrtp->cb, &config->cb, sizeof(zrtp_callback_t)); + new_zrtp->cache_auto_store = config->cache_auto_store; ZSTR_SET_EMPTY(new_zrtp->client_id); zrtp_memset(new_zrtp->client_id.buffer, ' ', sizeof(zrtp_client_id_t)); diff --git a/libs/libzrtp/src/zrtp_iface_cache.c b/libs/libzrtp/src/zrtp_iface_cache.c index 204546b079..c7f187b9ab 100644 --- a/libs/libzrtp/src/zrtp_iface_cache.c +++ b/libs/libzrtp/src/zrtp_iface_cache.c @@ -82,7 +82,9 @@ void zrtp_def_cache_down() if (inited) { mlist_t *node = NULL, *tmp = NULL; - zrtp_cache_user_down(); + /* If automatic cache flushing enabled we don't need to store it in a disk as it should be already in sync. */ + if (!zrtp->cache_auto_store) + zrtp_cache_user_down(); mlist_for_each_safe(node, tmp, &cache_head) { zrtp_sys_free(mlist_get_struct(zrtp_cache_elem_t, _mlist, node)); @@ -119,6 +121,8 @@ zrtp_status_t zrtp_def_cache_set_verified( const zrtp_stringn_t* one_ZID, } zrtp_mutex_unlock(def_cache_protector); + if (zrtp->cache_auto_store) zrtp_def_cache_store(zrtp); + return (new_elem) ? zrtp_status_ok : zrtp_status_fail; } @@ -211,6 +215,8 @@ static zrtp_status_t cache_put( const zrtp_stringn_t* one_ZID, } while (0); zrtp_mutex_unlock(def_cache_protector); + if (zrtp->cache_auto_store) zrtp_def_cache_store(zrtp); + return (new_elem) ? zrtp_status_ok : zrtp_status_fail; } @@ -304,6 +310,8 @@ zrtp_status_t zrtp_def_cache_set_presh_counter( const zrtp_stringn_t* one_zid, } zrtp_mutex_unlock(def_cache_protector); + if (zrtp->cache_auto_store) zrtp_def_cache_store(zrtp); + return (new_elem) ? zrtp_status_ok : zrtp_status_fail; } @@ -783,6 +791,8 @@ static zrtp_status_t put_name( const zrtp_stringn_t* one_ZID, } while (0); zrtp_mutex_unlock(def_cache_protector); + if (zrtp->cache_auto_store) zrtp_def_cache_store(zrtp); + return s; } @@ -872,6 +882,8 @@ zrtp_status_t zrtp_def_cache_reset_since( const zrtp_stringn_t* one_zid, } zrtp_mutex_unlock(def_cache_protector); + if (zrtp->cache_auto_store) zrtp_def_cache_store(zrtp); + return (new_elem) ? zrtp_status_ok : zrtp_status_fail; } From be9e71a5e2951de3e422946d83030cbcf7a77434 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Fri, 15 Jun 2012 10:23:13 +0300 Subject: [PATCH 17/49] Log number of dirty cache entries flushed Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/src/zrtp_iface_cache.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/libs/libzrtp/src/zrtp_iface_cache.c b/libs/libzrtp/src/zrtp_iface_cache.c index c7f187b9ab..27191f80f3 100644 --- a/libs/libzrtp/src/zrtp_iface_cache.c +++ b/libs/libzrtp/src/zrtp_iface_cache.c @@ -645,7 +645,7 @@ zrtp_status_t zrtp_cache_user_down() { FILE* cache_file = 0; mlist_t *node = 0; - uint32_t count = 0; + uint32_t count = 0, dirty_count=0; uint32_t pos = 0; ZRTP_LOG(3,(_ZTU_,"\tStoring ZRTP cache to <%s>...\n", zrtp->def_cache_path.buffer)); @@ -687,7 +687,7 @@ zrtp_status_t zrtp_cache_user_down() */ pos = ftell(cache_file); - count = 0; + count = 0; dirty_count = 0; fwrite(&count, sizeof(count), 1, cache_file); mlist_for_each(node, &mitmcache_head) { @@ -695,6 +695,7 @@ zrtp_status_t zrtp_cache_user_down() /* Store dirty values only. */ if (g_needs_rewriting || elem->_is_dirty) { // printf("zrtp_cache_user_down: Store MiTM elem index=%u, not modified.\n", elem->_index); + dirty_count++; if (zrtp_status_ok != flush_elem_(elem, cache_file, 1)) { ZRTP_DOWN_CACHE_RETURN(zrtp_status_write_fail, cache_file); } @@ -710,7 +711,8 @@ zrtp_status_t zrtp_cache_user_down() ZRTP_DOWN_CACHE_RETURN(zrtp_status_write_fail, cache_file); } - ZRTP_LOG(3,(_ZTU_,"\t%u MiTM cache entries have been stored successfully.\n",zrtp_ntoh32(count))); + if (dirty_count > 0) + ZRTP_LOG(3,(_ZTU_,"\t%u out of %u MiTM cache entries have been flushed successfully.\n", dirty_count, zrtp_ntoh32(count))); /* * Store regular secrets. Format: , @@ -723,7 +725,7 @@ zrtp_status_t zrtp_cache_user_down() fseek(cache_file, pos, SEEK_SET); - count = 0; + count = 0; dirty_count=0; fwrite(&count, sizeof(count), 1, cache_file); mlist_for_each(node, &cache_head) { @@ -732,6 +734,7 @@ zrtp_status_t zrtp_cache_user_down() /* Store dirty values only. */ if (g_needs_rewriting || elem->_is_dirty) { // printf("zrtp_cache_user_down: Store RS elem index=%u, not modified.\n", elem->_index); + dirty_count++; if (zrtp_status_ok != flush_elem_(elem, cache_file, 0)) { ZRTP_DOWN_CACHE_RETURN(zrtp_status_write_fail, cache_file); } @@ -747,7 +750,9 @@ zrtp_status_t zrtp_cache_user_down() if (fwrite(&count, sizeof(count), 1, cache_file) != 1) { ZRTP_DOWN_CACHE_RETURN(zrtp_status_write_fail, cache_file); } - ZRTP_LOG(3,(_ZTU_,"\t%u regular cache entries have been stored successfully.\n", zrtp_ntoh32(count))); + + if (dirty_count > 0) + ZRTP_LOG(3,(_ZTU_,"\t%u out of %u regular cache entries have been flushed successfully.\n", dirty_count, zrtp_ntoh32(count))); g_needs_rewriting = 0; @@ -946,13 +951,10 @@ void zrtp_def_cache_foreach( zrtp_global_t *global, /*----------------------------------------------------------------------------*/ zrtp_status_t zrtp_def_cache_store(zrtp_global_t *zrtp) { - ZRTP_LOG(3,(_ZTU_,"Storing ZRTP Cache...\n")); - zrtp_mutex_lock(def_cache_protector); zrtp_cache_user_down(); zrtp_mutex_unlock(def_cache_protector); - ZRTP_LOG(3,(_ZTU_,"Storing ZRTP Cache - DONE.\n")); return zrtp_status_ok; } From e5caa9e1961a12ad20068798f6405fafbade1978 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Fri, 15 Jun 2012 10:23:13 +0300 Subject: [PATCH 18/49] Bump libzrp version Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/include/zrtp_version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/libzrtp/include/zrtp_version.h b/libs/libzrtp/include/zrtp_version.h index be8fe0dc6d..3b4dfcb97f 100644 --- a/libs/libzrtp/include/zrtp_version.h +++ b/libs/libzrtp/include/zrtp_version.h @@ -13,7 +13,7 @@ #define LIBZRTP_VERSION_MAJOR 1 #define LIBZRTP_VERSION_MINOR 15 -#define LIBZRTP_VERSION_BUILD 610 -#define LIBZRTP_VERSION_STR "v1.15 610" +#define LIBZRTP_VERSION_BUILD 611 +#define LIBZRTP_VERSION_STR "v1.15 611" #endif /*__ZRTP_VERSION_H__*/ From cc134b8cbe912c474caf9f93cf6a0d8d3bea3b8e Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Fri, 15 Jun 2012 10:23:46 +0300 Subject: [PATCH 19/49] Update pointer to changelog Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/libzrtp/ChangeLog b/libs/libzrtp/ChangeLog index e86032d299..6fdf46638c 100644 --- a/libs/libzrtp/ChangeLog +++ b/libs/libzrtp/ChangeLog @@ -5,7 +5,7 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SINCE LIBZRTP v0.80 CHANGELOG IS A PART OF HTML DOCUMENTATION. -https://developers.zfoneproject.com/libzrtp/wiki/LibzrtpChangeLog +Check generated html or doc/manuals/changelog.dox doxygen sources !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! From 95519659b9eb129ecd876dfa27bc380d9c2e76db Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Fri, 15 Jun 2012 10:23:46 +0300 Subject: [PATCH 20/49] Clean up in libzrtp tests Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/test/cache_test.c | 8 ++--- libs/libzrtp/test/cipher_test.c | 57 --------------------------------- libs/libzrtp/test/test_engine.c | 19 +---------- 3 files changed, 5 insertions(+), 79 deletions(-) diff --git a/libs/libzrtp/test/cache_test.c b/libs/libzrtp/test/cache_test.c index 8ba699ee3f..5713249b7e 100644 --- a/libs/libzrtp/test/cache_test.c +++ b/libs/libzrtp/test/cache_test.c @@ -11,7 +11,7 @@ #include #include #include - #include +#include #include "zrtp.h" #include "cmockery/cmockery.h" @@ -109,7 +109,7 @@ void cache_init_store_empty_test() { * Add few entries to the empty cache, flush it and then load again. Check if * all the entries were restored successfully. */ -void cache_add2empty_test() { +void cache_add2empty_test() { zrtp_status_t status; int intres; @@ -146,8 +146,8 @@ void cache_save_unchanged_test() { /* * TEST: now let's store the cache making no changes to it. - * After opening it should include all the secrets untouched. - */ + * After opening it should include all the secrets untouched. + */ printf("==> And the cache again, it should contain all the stored values.\n"); diff --git a/libs/libzrtp/test/cipher_test.c b/libs/libzrtp/test/cipher_test.c index 4098d8b16e..8ef7ec15d2 100644 --- a/libs/libzrtp/test/cipher_test.c +++ b/libs/libzrtp/test/cipher_test.c @@ -52,64 +52,7 @@ static void aes256_cfb_test() { assert_non_null(cipher); cipher->self_test(cipher, ZRTP_CIPHER_MODE_CFB); } -/* -static void aes256_cfb_test2() { - rtp_aes_cfb_ctx_t *ctx = (zrtp_aes_cfb_ctx_t*)self->start( self, - aes_cfb_test_key, - NULL, - ZRTP_CIPHER_MODE_CFB); - if (NULL == ctx) { - return zrtp_status_fail; - } - ZRTP_LOG(3, (_ZTU_,"256 bit AES CFB\n")); - ZRTP_LOG(3, (_ZTU_, "1st test...\n")); - - zrtp_memcpy(aes_cfb_test_buf2b, aes_cfb_test_buf2a, sizeof(aes_cfb_test_buf2a)); - zrtp_memcpy(&tmp_iv, aes_cfb_test_iv, sizeof(tmp_iv)); - - ZRTP_LOG(3, (_ZTU_, "\tencryption... ")); - - self->set_iv(self, ctx, &tmp_iv); - err = self->encrypt(self, ctx, aes_cfb_test_buf2b, sizeof(aes_cfb_test_buf2b)); - if (zrtp_status_ok != err) { - ZRTP_LOGC(1, ("ERROR! 256-bit AES CFB encrypt returns error %d\n", err)); - self->stop(self, ctx); - return err; - } - - for (i=0; i<16; i++) { - if (aes_cfb_test_buf2b[i] != 0x00) { - ZRTP_LOGC(1, ("ERROR! 256-bit AES CFB failed on encrypt test\n")); - self->stop(self, ctx); - return zrtp_status_fail; - } - } - ZRTP_LOGC(3, ("OK\n")); - - ZRTP_LOG(3, (_ZTU_, "\tdecryption... ")); - - zrtp_memcpy(&tmp_iv, aes_cfb_test_iv, sizeof(tmp_iv)); - self->set_iv(self, ctx, &tmp_iv); - - err = self->decrypt(self, ctx, aes_cfb_test_buf2b, sizeof(aes_cfb_test_buf2b)); - if (zrtp_status_ok != err) { - ZRTP_LOGC(1, ("ERROR! 256-bit AES CFB decrypt returns error %d\n", err)); - self->stop(self, ctx); - return err; - } - for (i=0; istop(self, ctx); - return zrtp_status_fail; - } - } - self->stop(self, ctx); - ZRTP_LOGC(3, ("OK\n")); - -} -*/ int main(void) { const UnitTest tests[] = { unit_test_setup_teardown(aes128_ctr_test, setup, teardown), diff --git a/libs/libzrtp/test/test_engine.c b/libs/libzrtp/test/test_engine.c index 3b40985f57..8ec6fc2381 100644 --- a/libs/libzrtp/test/test_engine.c +++ b/libs/libzrtp/test/test_engine.c @@ -132,7 +132,6 @@ static int on_send_packet(const zrtp_stream_t* ctx, char* message, unsigned int zrtp_test_id_t *stream_id = zrtp_stream_get_userdata(ctx); zrtp_test_stream_t *stream = zrtp_test_stream_by_id(*stream_id); if (stream) { - printf("trace>>> PUSH from stream ID=%u\n", stream->id); zrtp_test_queue_push(stream->output, elem); return zrtp_status_ok; } else { @@ -168,24 +167,8 @@ static zrtp_test_stream_t *get_stream_to_process_(zrtp_endpoint_t *endpoint) { j = (unsigned)i; j = j % streams_count; - printf("trace>>> CHOOSE stream Endpoint=%u IDX=%u ID=%u\n", endpoint->id, j, all_streams[j]); + //printf("trace>>> CHOOSE stream Endpoint=%u IDX=%u ID=%u\n", endpoint->id, j, all_streams[j]); return zrtp_test_stream_by_id(all_streams[j]); - - -// unsigned is_found = 0; -// zrtp_test_id_t result, left; -// for (i=0; i stream_id) { -// is_found = 1; -// break; -// } else { -// left = result; -// } -// } -// -// printf("TRACE>>> choose stream ID=%u\n", is_found ? result : left); -// return zrtp_test_stream_by_id(is_found ? result : left); } From d938a6da6d5db9a47fd3b1cb3445150c80810513 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Fri, 15 Jun 2012 10:23:46 +0300 Subject: [PATCH 21/49] Add test for some minor bugs Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/test/minor_bugs_test.c | 92 +++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 libs/libzrtp/test/minor_bugs_test.c diff --git a/libs/libzrtp/test/minor_bugs_test.c b/libs/libzrtp/test/minor_bugs_test.c new file mode 100644 index 0000000000..2bf46b220b --- /dev/null +++ b/libs/libzrtp/test/minor_bugs_test.c @@ -0,0 +1,92 @@ +/* + * libZRTP SDK library, implements the ZRTP secure VoIP protocol. + * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. + * Contact: http://philzimmermann.com + * For licensing and other legal details, see the file zrtp_legal.c. + * + * Viktor Krykun + */ + +#include +#include + +#include "zrtp.h" +#include "cmockery/cmockery.h" + +zrtp_global_t *zrtp; + +void setup() { + zrtp_status_t s; + zrtp_config_t zrtp_config; + + zrtp_config_defaults(&zrtp_config); + + s = zrtp_init(&zrtp_config, &zrtp); + assert_int_equal(s, zrtp_status_ok); +} + +void teardown() { + zrtp_down(zrtp); +} + + +static void session_init_fails_with_no_dh2k() { + zrtp_profile_t profile; + zrtp_status_t s; + + zrtp_session_t *new_session; + + /* Let's initialize ZRTP session with default profile first */ + zrtp_profile_defaults(&profile, zrtp); + + new_session = NULL; + s = zrtp_session_init(zrtp, + &profile, + ZRTP_SIGNALING_ROLE_INITIATOR, + &new_session); + + assert_int_equal(zrtp_status_ok, s); + assert_non_null(new_session); + + /* Then disable DH2K and leave just mandatory parameters */ + profile.pk_schemes[0] = ZRTP_PKTYPE_DH3072; + profile.pk_schemes[1] = ZRTP_PKTYPE_MULT; + profile.pk_schemes[2] = 0; + + new_session = NULL; + s = zrtp_session_init(zrtp, + &profile, + ZRTP_SIGNALING_ROLE_INITIATOR, + &new_session); + + assert_int_equal(zrtp_status_ok, s); + assert_non_null(new_session); + + /* Let's try to disable Multi key exchange, it should produce an error. */ + profile.pk_schemes[0] = ZRTP_PKTYPE_DH3072; + profile.pk_schemes[1] = 0; + + new_session = NULL; + s = zrtp_session_init(zrtp, + &profile, + ZRTP_SIGNALING_ROLE_INITIATOR, + &new_session); + + assert_int_not_equal(zrtp_status_ok, s); + assert_null(new_session); + + /* Profile checking with one of mandatory components missing should return error too. */ + s = zrtp_profile_check(&profile, zrtp); + assert_int_not_equal(zrtp_status_ok, s); + + /* NOTE: we ignore memory leaks and don't destroy ZRTP sessions to make test sources cleaner */ +} + + +int main(void) { + const UnitTest tests[] = { + unit_test_setup_teardown(session_init_fails_with_no_dh2k, setup, teardown), + }; + + return run_tests(tests); +} From b7fd94a53e8b20266b4fcf89fee5be8e81a5ff4d Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Tue, 26 Jun 2012 19:59:23 +0000 Subject: [PATCH 22/49] Fix build of cmockery cmockery.h was trying to redefine uintptr_t, but this is already defined in stdint.h. --- libs/libzrtp/test/cmockery/cmockery.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/libs/libzrtp/test/cmockery/cmockery.h b/libs/libzrtp/test/cmockery/cmockery.h index dd156c8692..6810f5b8ff 100644 --- a/libs/libzrtp/test/cmockery/cmockery.h +++ b/libs/libzrtp/test/cmockery/cmockery.h @@ -114,9 +114,6 @@ typedef unsigned long uintptr_t; * what's the right preprocessor symbol? typedef unsigned long long uintptr_t */ -/* ILP32 and LP64 platforms */ -typedef unsigned long uintptr_t; - #endif /* _WIN32 */ #endif /* _UINTPTR_T */ From b544076505fb69b5afb35de660c35f5e34c823dc Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Fri, 15 Jun 2012 10:23:46 +0300 Subject: [PATCH 23/49] Rename changelog page Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/doc/manuals/changelog.dox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/libzrtp/doc/manuals/changelog.dox b/libs/libzrtp/doc/manuals/changelog.dox index eb13ef2b5a..854278bc0e 100644 --- a/libs/libzrtp/doc/manuals/changelog.dox +++ b/libs/libzrtp/doc/manuals/changelog.dox @@ -11,7 +11,7 @@ */ /*! -\page changelog libzrtp ChangeLog +\page changelog ChangeLog **************************************************************************************************** \section v091 DEVELOPERS BUILD Release Notes - libzrtp - Version 0.91 build XXX (ZRTP ID v16x, protocol 1.X) From 5f19e3f1f7b02328ea37eb0a2a9cbe148fcf8fa3 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Fri, 15 Jun 2012 10:23:46 +0300 Subject: [PATCH 24/49] Add test for zrtp_register_with_trusted_mitm Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/test/enrollment_test.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/libzrtp/test/enrollment_test.c b/libs/libzrtp/test/enrollment_test.c index 5d54c55478..aaedfd1785 100644 --- a/libs/libzrtp/test/enrollment_test.c +++ b/libs/libzrtp/test/enrollment_test.c @@ -54,10 +54,13 @@ static void enrollment_test() { zrtp_test_id_t pbx2alice_stream = zrtp_test_session_get_stream_by_idx(g_pbxa_sid, 0); assert_true(zrtp_stream_did_event_receive(pbx2alice_stream, ZRTP_EVENT_NEW_USER_ENROLLED)); + /* Confirm enrollment at the PBX side */ + s = zrtp_register_with_trusted_mitm(zrtp_stream_for_test_stream(alice2pbx_stream)); + assert_int_equal(zrtp_status_ok, s); + /* Clean-up */ cleanup_alice_pbx_bob_setup(); - /************************************************************************** * Try to make one more enrollment call. This time it should say "Already enrolled" */ @@ -87,8 +90,6 @@ static void enrollment_test() { // TODO: check if we have PBX secret cached // TODO: test zrtp_is_user_enrolled() - - // TODO: use zrtp_register_with_trusted_mitm() } int main(void) { From 2cfadc6d8e3c2dd275ba6713f1538c31858a9949 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Fri, 15 Jun 2012 10:23:46 +0300 Subject: [PATCH 25/49] Remove unused variable Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/src/zrtp_log.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libs/libzrtp/src/zrtp_log.c b/libs/libzrtp/src/zrtp_log.c index 6de359f134..b2576e5cf7 100644 --- a/libs/libzrtp/src/zrtp_log.c +++ b/libs/libzrtp/src/zrtp_log.c @@ -51,8 +51,6 @@ void zrtp_log_set_log_engine(zrtp_log_engine *engine) { log_writer = engine; } -static const uint32_t zrtp_log_header_allign = 16; - /*----------------------------------------------------------------------------*/ static void zrtp_log(uint8_t is_clean, const char *sender, uint32_t level, const char *format, va_list marker) { From c78a4dc221d0788f6f04ba76d864512fed618d51 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Fri, 15 Jun 2012 10:23:46 +0300 Subject: [PATCH 26/49] Remove superfluous include Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/include/zrtp_string.h | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/libzrtp/include/zrtp_string.h b/libs/libzrtp/include/zrtp_string.h index 2c48ca694b..a132130cfe 100644 --- a/libs/libzrtp/include/zrtp_string.h +++ b/libs/libzrtp/include/zrtp_string.h @@ -11,7 +11,6 @@ #define __ZRTP_STRING_H__ #include "zrtp_config.h" -#include "zrtp_types.h" /** * \file zrtp_strings.h From 5f0b30cd7c97b31267b7c1862bb7a487dc598247 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Fri, 15 Jun 2012 10:23:46 +0300 Subject: [PATCH 27/49] Fix typo in comment Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/src/zrtp_protocol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/libzrtp/src/zrtp_protocol.c b/libs/libzrtp/src/zrtp_protocol.c index a98e53aa37..ae46a9e5d9 100644 --- a/libs/libzrtp/src/zrtp_protocol.c +++ b/libs/libzrtp/src/zrtp_protocol.c @@ -1086,7 +1086,7 @@ zrtp_status_t _zrtp_machine_enter_secure(zrtp_stream_t* stream) session->zrtp->cb.event_cb.on_zrtp_protocol_event(stream, ZRTP_EVENT_IS_SECURE_DONE); } - /* We have computed all subkeys from S0 and don't need it anylonger. */ + /* We have computed all subkeys from S0 and don't need it any longer. */ zrtp_wipe_zstring(ZSTR_GV(cc->s0)); /* Clear DH crypto context */ From 4ba74ad38ac7eed6e5f3030f7cab7c5111bb5768 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Fri, 15 Jun 2012 10:23:46 +0300 Subject: [PATCH 28/49] Cleanup the go secure test Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/test/go_secure_test.c | 81 +++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 7 deletions(-) diff --git a/libs/libzrtp/test/go_secure_test.c b/libs/libzrtp/test/go_secure_test.c index ab6740d3cc..be0f28583d 100644 --- a/libs/libzrtp/test/go_secure_test.c +++ b/libs/libzrtp/test/go_secure_test.c @@ -38,10 +38,10 @@ static void teardown() { zrtp_test_endpoint_destroy(g_bob); } -static void go_secure_test() { +static void prepare_alice_bob() { zrtp_status_t s; - zrtp_test_channel_info_t channel_info; + //zrtp_test_channel_info_t channel_info; zrtp_test_session_cfg_t session_config; zrtp_test_session_config_defaults(&session_config); @@ -60,12 +60,24 @@ static void go_secure_test() { s = zrtp_test_channel_create2(g_alice_sid, g_bob_sid, 0, &g_secure_audio_channel); assert_int_equal(zrtp_status_ok, s); assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_secure_audio_channel); +} + +static void release_alice_bob() { + zrtp_test_session_destroy(g_alice_sid); + zrtp_test_session_destroy(g_bob_sid); + + zrtp_test_channel_destroy(g_secure_audio_channel); +} + +static void start_alice_bob_and_wait4secure() { + zrtp_status_t s; + zrtp_test_channel_info_t channel_info; /* Everything is ready. Let's start the stream and give it few seconds to switch secure. */ s = zrtp_test_channel_start(g_secure_audio_channel); assert_int_equal(zrtp_status_ok, s); - int i = 30; + unsigned i = 30; for (; i>0; i--) { usleep(100*1000); } @@ -73,18 +85,73 @@ static void go_secure_test() { s = zrtp_test_channel_get(g_secure_audio_channel, &channel_info); assert_int_equal(zrtp_status_ok, s); - /* Both, Alice and Bob should switch secure */ assert_true(channel_info.is_secure); +} - zrtp_test_session_destroy(g_alice_sid); - zrtp_test_session_destroy(g_bob_sid); - zrtp_test_channel_destroy(g_secure_audio_channel); +static void go_secure_test() { + /* + * Create two test sessions, one for Alice and one for Bob and link them + * into test secure channel + */ + prepare_alice_bob(); + start_alice_bob_and_wait4secure(); + release_alice_bob(); +} + +static void go_secure_flags_test() { + zrtp_status_t s; + zrtp_test_session_info_t alice_ses_info; + + prepare_alice_bob(); + + start_alice_bob_and_wait4secure(); + + /* All flags should be clear */ + s = zrtp_test_session_get(g_alice_sid, &alice_ses_info); + assert_int_equal(zrtp_status_ok, s); + + assert_int_equal(0, alice_ses_info.zrtp.matches_flags); + assert_int_equal(0, alice_ses_info.zrtp.cached_flags); + assert_int_equal(0, alice_ses_info.zrtp.wrongs_flags); + + /* + * Now let's make one more call, RS1 should match and cached + */ + release_alice_bob(); + + prepare_alice_bob(); + + start_alice_bob_and_wait4secure(); + + s = zrtp_test_session_get(g_alice_sid, &alice_ses_info); + assert_int_equal(zrtp_status_ok, s); + + assert_int_equal((int)ZRTP_BIT_RS1, alice_ses_info.zrtp.matches_flags); + assert_int_equal((int)ZRTP_BIT_RS1, alice_ses_info.zrtp.cached_flags); + assert_int_equal(0, alice_ses_info.zrtp.wrongs_flags); + + /* + * And one more time.. both RS1 and RS2 should be cached and should match. + */ + release_alice_bob(); + + prepare_alice_bob(); + + start_alice_bob_and_wait4secure(); + + s = zrtp_test_session_get(g_alice_sid, &alice_ses_info); + assert_int_equal(zrtp_status_ok, s); + + assert_int_equal((int)(ZRTP_BIT_RS1 | ZRTP_BIT_RS2) , alice_ses_info.zrtp.matches_flags); + assert_int_equal((int)(ZRTP_BIT_RS1 | ZRTP_BIT_RS2), alice_ses_info.zrtp.cached_flags); + assert_int_equal(0, alice_ses_info.zrtp.wrongs_flags); } int main(void) { const UnitTest tests[] = { unit_test_setup_teardown(go_secure_test, setup, teardown), + unit_test_setup_teardown(go_secure_flags_test, setup, teardown), }; return run_tests(tests); From 5af0af90ed8cfa690de052fad175508c40284dec Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Fri, 15 Jun 2012 10:23:46 +0300 Subject: [PATCH 29/49] Add zrtp_randstr2 Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/include/zrtp.h | 2 ++ libs/libzrtp/src/zrtp_rng.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/libs/libzrtp/include/zrtp.h b/libs/libzrtp/include/zrtp.h index 88f549e025..67c64a8eeb 100644 --- a/libs/libzrtp/include/zrtp.h +++ b/libs/libzrtp/include/zrtp.h @@ -956,6 +956,8 @@ int zrtp_entropy_add(zrtp_global_t* zrtp, const unsigned char *buffer, uint32_t */ int zrtp_randstr(zrtp_global_t* zrtp, unsigned char *buffer, uint32_t length); +int zrtp_randstr2(unsigned char *buffer, uint32_t length); + /* \} */ #if defined(__cplusplus) diff --git a/libs/libzrtp/src/zrtp_rng.c b/libs/libzrtp/src/zrtp_rng.c index db394a7a9e..c32fbe3a30 100644 --- a/libs/libzrtp/src/zrtp_rng.c +++ b/libs/libzrtp/src/zrtp_rng.c @@ -343,3 +343,9 @@ int zrtp_randstr(zrtp_global_t* zrtp, unsigned char *buffer, uint32_t length) return generated; } + +int zrtp_randstr2(unsigned char *buffer, uint32_t length) { + zrtp_global_t zrtp; + zrtp.rand_initialized = 0; + return zrtp_randstr(&zrtp, buffer, length); +} From 46ecb6f90bcb820cd2e916071bf046dc267a0ec5 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Fri, 15 Jun 2012 10:23:46 +0300 Subject: [PATCH 30/49] Update libzrtp version Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/configure.in | 2 +- libs/libzrtp/doc/manuals/changelog.dox | 24 ++++++++++++++++++++++++ libs/libzrtp/include/zrtp_version.h | 6 +++--- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/libs/libzrtp/configure.in b/libs/libzrtp/configure.in index 34feb59a91..f95cf8d4f5 100644 --- a/libs/libzrtp/configure.in +++ b/libs/libzrtp/configure.in @@ -32,7 +32,7 @@ case $target_os in esac -AM_INIT_AUTOMAKE([libzrtp], [1.15]) +AM_INIT_AUTOMAKE([libzrtp], [1.20]) AX_PREFIX_CONFIG_H(include/zrtp_config_unix.h,ZRTP,config/config.h) CFLAGS="$CFLAGS -Wno-unused-parameter -fno-strict-aliasing -fPIC -DZRTP_AUTOMAKE=1" diff --git a/libs/libzrtp/doc/manuals/changelog.dox b/libs/libzrtp/doc/manuals/changelog.dox index 854278bc0e..6686515851 100644 --- a/libs/libzrtp/doc/manuals/changelog.dox +++ b/libs/libzrtp/doc/manuals/changelog.dox @@ -13,6 +13,29 @@ /*! \page changelog ChangeLog +**************************************************************************************************** +\section v120 libzrtp v1.20 build XXX (ZRTP RFC 6189, protocol 1.1) +**************************************************************************************************** + +This release is focused on better ZRTP cache management. + +***\subsection v120_changes API changes and Upgrade Instructions: + *- Starting from v120 libzrtp uses global ZID for all outgoing connections. Local ZID should be + specified in zrtp_global_t#zid and provided to zrtp_init(). App doesn't need to pass local ZID + each time it creates new session via zrtp_session_init(). + *- Added zrtp_randstr2() which allow to generate random string before libzrtp being initialized. + Can be handy to generate initial ZID. In normal circumstances, use zrtp_randstr() whenever possible. + *- ZRTP cache API was completely redesigned. Look at zrtp_cache.h for more details. + + +***\subsection v120_feature New features and improvements. + *- new better cache management API. + +***\subsection v120_bugs Bug fixes + *- fixed bug when ZRTP forces enrolled endpoints to re-render SAS when sashash is empty. + *- other minor bug fixes and improvements + + **************************************************************************************************** \section v091 DEVELOPERS BUILD Release Notes - libzrtp - Version 0.91 build XXX (ZRTP ID v16x, protocol 1.X) **************************************************************************************************** @@ -194,4 +217,5 @@ Minor improvements. Zfone and libZRTP projects moved to public bug-tracking and *- [LZRTP-132] Replace HMAC with KDF function call.\n Since ZRTP draft 12b defines ZRTP KDF to be in compliance with the recommendations in NIST SP 800-108. KDF function implemented as _zrtp_kdf() in zrtp_utils_proto.c. All KDF operations were replaced with from hmac to kdf function. + */ diff --git a/libs/libzrtp/include/zrtp_version.h b/libs/libzrtp/include/zrtp_version.h index 3b4dfcb97f..fc0a349442 100644 --- a/libs/libzrtp/include/zrtp_version.h +++ b/libs/libzrtp/include/zrtp_version.h @@ -12,8 +12,8 @@ #define LIBZRTP_VERSION_MAJOR 1 -#define LIBZRTP_VERSION_MINOR 15 -#define LIBZRTP_VERSION_BUILD 611 -#define LIBZRTP_VERSION_STR "v1.15 611" +#define LIBZRTP_VERSION_MINOR 20 +#define LIBZRTP_VERSION_BUILD 616 +#define LIBZRTP_VERSION_STR "v1.20 616" #endif /*__ZRTP_VERSION_H__*/ From 1b642cae3956ec43672613882c90d9adf6bb61dd Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Sat, 23 Jun 2012 03:03:09 +0000 Subject: [PATCH 31/49] Build ZRTP docs with automake Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/.gitignore | 3 + libs/libzrtp/Makefile.am | 7 + libs/libzrtp/configure.in | 12 + libs/libzrtp/doc/{Doxyfile => Doxyfile.in} | 1784 +++++++++++--------- libs/libzrtp/doc/doxygen.css | 451 ----- libs/libzrtp/doc/footer.html | 4 - libs/libzrtp/doc/header.html | 6 - libs/libzrtp/doc/out/html/zfone.jpg | Bin 8517 -> 0 bytes 8 files changed, 1044 insertions(+), 1223 deletions(-) rename libs/libzrtp/doc/{Doxyfile => Doxyfile.in} (59%) delete mode 100644 libs/libzrtp/doc/doxygen.css delete mode 100644 libs/libzrtp/doc/footer.html delete mode 100644 libs/libzrtp/doc/header.html delete mode 100644 libs/libzrtp/doc/out/html/zfone.jpg diff --git a/libs/libzrtp/.gitignore b/libs/libzrtp/.gitignore index f45d0ca054..7510e5e64c 100644 --- a/libs/libzrtp/.gitignore +++ b/libs/libzrtp/.gitignore @@ -1,6 +1,7 @@ # -*- mode:conf -*- /.cproject /.project +/.stamp-doc /Makefile /Makefile.in /_configs.sed @@ -10,6 +11,8 @@ /config.* /config/* /configure +/doc/Doxyfile +/doc/out /include/zrtp_config_unix.h !/build/Makefile.am !/build/test/Makefile.am diff --git a/libs/libzrtp/Makefile.am b/libs/libzrtp/Makefile.am index d4916e3cf8..d0bd6c32c9 100644 --- a/libs/libzrtp/Makefile.am +++ b/libs/libzrtp/Makefile.am @@ -52,6 +52,13 @@ endif SUBDIRS = third_party/bnlib SUBDIRS += build +if HAVE_DOXYGEN +doc: .stamp-doc +.stamp-doc: + (cd doc && $(DOXYGEN) Doxyfile) + touch $@ +endif + uninstall: rm -rf $(prefix)/include/libzrtp rm -f $(prefix)/lib/libzrtp.a diff --git a/libs/libzrtp/configure.in b/libs/libzrtp/configure.in index f95cf8d4f5..8124fda9fc 100644 --- a/libs/libzrtp/configure.in +++ b/libs/libzrtp/configure.in @@ -92,5 +92,17 @@ fi AC_SUBST(ENABLE_EC) +# +# Documentation +# +AC_CHECK_PROGS([DOXYGEN], [doxygen]) +if test -z "$DOXYGEN"; + then AC_MSG_WARN([Doxygen not found - continuing without Doxygen support]) +fi + +AM_CONDITIONAL([HAVE_DOXYGEN], +[test -n "$DOXYGEN"])AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile])]) + +# # Genearte Makefiles AC_OUTPUT([Makefile build/Makefile build/test/Makefile]) diff --git a/libs/libzrtp/doc/Doxyfile b/libs/libzrtp/doc/Doxyfile.in similarity index 59% rename from libs/libzrtp/doc/Doxyfile rename to libs/libzrtp/doc/Doxyfile.in index b01900e4d5..ae1f390756 100644 --- a/libs/libzrtp/doc/Doxyfile +++ b/libs/libzrtp/doc/Doxyfile.in @@ -1,775 +1,849 @@ -# Doxyfile 1.5.8 +# Doxyfile 1.8.0 # This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project +# doxygen (www.doxygen.org) for a project. # -# All text after a hash (#) is considered a comment and will be ignored +# All text after a hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") +# Values that contain spaces should be placed between quotes (" "). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. +# The PROJECT_NAME tag is a single word (or sequence of words) that should +# identify the project. Note that if you do not use Doxywizard you need +# to put quotes around the project name if it contains spaces. -PROJECT_NAME = libzrtp +PROJECT_NAME = @PACKAGE_NAME@ -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = v0.91 +PROJECT_NUMBER = @PACKAGE_VERSION@ -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = "ZRTP VoIP security" + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = ./out +OUTPUT_DIRECTORY = @top_srcdir@/doc/out -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, -# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), -# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, -# Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, Slovene, -# Spanish, Swedish, and Ukrainian. +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the +ABBREVIATE_BRIEF = -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the # path to strip. -STRIP_FROM_PATH = /Users/dimitri/doxygen/mail/1.5.7/doxywizard/ +STRIP_FROM_PATH = -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. -STRIP_FROM_INC_PATH = +STRIP_FROM_INC_PATH = -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = NO -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO -# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 4 -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. -ALIASES = +ALIASES = -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding +# "class=itcl::class" will allow you to use the command class in the +# itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = YES -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO -# Doxygen selects the parser to use depending on the extension of the files it parses. -# With this tag you can assign which parser to use for a given extension. -# Doxygen has a built-in mapping, but you can override or extend it using this tag. -# The format is ext=language, where ext is a file extension, and language is one of -# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, -# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat -# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), -# use: inc=Fortran f=C +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. -EXTENSION_MAPPING = +EXTENSION_MAPPING = -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration +# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all +# comments according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you +# can mix doxygen, HTML, and XML commands with Markdown formatting. +# Disable only in case of backward compatibilities issues. + +MARKDOWN_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO -# If you use Microsoft's C++/CLI language, you should set this option to YES to +# If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO -# For Microsoft's IDL there are propget and propput attributes to indicate getter -# and setter methods for a property. Setting this option to YES (the default) -# will make doxygen to replace the get and set methods by a property in the -# documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and +# unions with only public data fields will be shown inline in the documentation +# of the scope in which they are defined (i.e. file, namespace, or group +# documentation), provided this scope is documented. If set to NO (the default), +# structs, classes, and unions are shown on a separate page (for HTML and Man +# pages) or section (for LaTeX and RTF). + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penality. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will rougly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. SYMBOL_CACHE_SIZE = 0 +# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be +# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given +# their name and scope. Since this can be an expensive process and often the +# same symbol appear multiple times in the code, doxygen keeps a cache of +# pre-resolved symbols. If the cache is too small doxygen will become slower. +# If the cache is too large, memory is wasted. The cache size is given by this +# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +LOOKUP_CACHE_SIZE = 0 + #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = NO -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO -# If the EXTRACT_STATIC tag is set to YES all static members of a file +# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal scope will be included in the documentation. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespace are hidden. +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. EXTRACT_ANON_NSPACES = NO -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = NO -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. -HIDE_SCOPE_NAMES = YES +HIDE_SCOPE_NAMES = NO -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES -# The ENABLED_SECTIONS tag can be used to enable conditional +# The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. -ENABLED_SECTIONS = +ENABLED_SECTIONS = -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = NO -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. This will remove the Namespaces entry from the Quick Index +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. -FILE_VERSION_FILTER = +FILE_VERSION_FILTER = -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by -# doxygen. The layout file controls the global structure of the generated output files -# in an output format independent way. The create the layout file that represents -# doxygen's defaults, run doxygen with the -l option. You can optionally specify a -# file name after the option, if omitted DoxygenLayout.xml will be used as the name -# of the layout file. +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. The create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. -LAYOUT_FILE = +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files +# containing the references data. This must be a list of .bib files. The +# .bib extension is automatically appended if omitted. Using this command +# requires the bibtex tool to be installed. See also +# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style +# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this +# feature you need bibtex and perl available in the search path. + +CITE_BIB_FILES = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- -# The QUIET tag can be used to turn on/off the messages that are generated +# The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written # to stderr. -WARN_LOGFILE = +WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = ./manuals/main.dox \ - ./manuals/howto.dox \ - ./manuals/changelog.dox \ - ./manuals/rng.dox \ - ./../include/zrtp_config_user.h \ - ./../include/zrtp.h \ - ./../include/zrtp_iface_system.h \ - ./../include/zrtp_iface.h \ - ./../include/zrtp_error.h \ - ./../include/zrtp_types.h \ - ./../include/zrtp_string.h \ - ./../include/zrtp_pbx.h - +INPUT = @top_srcdir@ +INPUT = @top_srcdir@/doc/manuals/main.dox \ + @top_srcdir@/doc/manuals/howto.dox \ + @top_srcdir@/doc/manuals/changelog.dox \ + @top_srcdir@/doc/manuals/rng.dox \ + @top_srcdir@/include/zrtp_config_user.h \ + @top_srcdir@/include/zrtp.h \ + @top_srcdir@/include/zrtp_iface_system.h \ + @top_srcdir@/include/zrtp_iface.h \ + @top_srcdir@/include/zrtp_error.h \ + @top_srcdir@/include/zrtp_types.h \ + @top_srcdir@/include/zrtp_string.h \ + @top_srcdir@/include/zrtp_pbx.h -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl -FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cpp \ - *.c++ \ - *.d \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.idl \ - *.odl \ - *.cs \ - *.php \ - *.php3 \ - *.inc \ - *.m \ - *.mm \ - *.dox \ - *.py \ - *.f90 \ - *.f \ - *.vhd \ - *.vhdl +FILE_PATTERNS = -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = NO -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. +# Note that relative paths are relative to the directory from which doxygen is +# run. -EXCLUDE = +EXCLUDE = -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test -EXCLUDE_SYMBOLS = +EXCLUDE_SYMBOLS = -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see # the \include command). -EXAMPLE_PATH = +EXAMPLE_PATH = -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left # blank all files are included. -EXAMPLE_PATTERNS = * +EXAMPLE_PATTERNS = -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see # the \image command). -IMAGE_PATH = +IMAGE_PATH = -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be # ignored. -INPUT_FILTER = +INPUT_FILTER = -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. -FILTER_PATTERNS = +FILTER_PATTERNS = -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = + #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = NO -# Setting the INLINE_SOURCES tag to YES will include the body +# Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = NO -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentation. +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES @@ -778,384 +852,549 @@ VERBATIM_HEADERS = YES # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. -ALPHABETICAL_INDEX = NO +ALPHABETICAL_INDEX = YES -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. -IGNORE_PREFIX = +IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is advised to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when +# changing the value of configuration settings such as GENERATE_TREEVIEW! -HTML_HEADER = header.html +HTML_HEADER = -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a # standard footer. -HTML_FOOTER = footer.html +HTML_FOOTER = -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# style sheet in the HTML output directory as well, or it will be erased! -HTML_STYLESHEET = doxygen.css +HTML_STYLESHEET = -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the style sheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = NO -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. -GENERATE_DOCSET = YES +GENERATE_DOCSET = NO -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be # written to the html output directory. -CHM_FILE = +CHM_FILE = -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. -HHC_LOCATION = +HHC_LOCATION = -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. -CHM_INDEX_ENCODING = +CHM_INDEX_ENCODING = -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO -# The TOC_EXPAND flag can be set to YES to add extra items for group members +# The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER -# are set, an additional index file will be generated that can be used as input for -# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated -# HTML documentation. +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. GENERATE_QHP = NO -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. -QCH_FILE = +QCH_FILE = -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace -QHP_NAMESPACE = +QHP_NAMESPACE = org.doxygen.Project -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. -# For more information please see +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters -QHP_CUST_FILTER_NAME = +QHP_CUST_FILTER_NAME = -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see -# Qt Help Project / Custom Filters. +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. -QHP_CUST_FILTER_ATTRS = +QHP_CUST_FILTER_ATTRS = -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's -# filter section matches. -# Qt Help Project / Filter Attributes. +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. -QHP_SECT_FILTER_ATTRS = +QHP_SECT_FILTER_ATTRS = -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. -QHG_LOCATION = +QHG_LOCATION = -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) +# at top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. Since the tabs have the same information as the +# navigation tree you can set this option to NO if you already set +# GENERATE_TREEVIEW to YES. DISABLE_INDEX = NO -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. +# Since the tree basically has the same information as the tab index you +# could consider to set DISABLE_INDEX to NO when enabling this option. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. ENUM_VALUES_PER_LINE = 4 -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to FRAME, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. Other possible values -# for this tag are: HIERARCHIES, which will generate the Groups, Directories, -# and Class Hierarchy pages using a tree view instead of an ordered list; -# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which -# disables this behavior completely. For backwards compatibility with previous -# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE -# respectively. +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list. -GENERATE_TREEVIEW = YES +USE_INLINE_TREES = NO -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you may also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to +# the MathJax Content Delivery Network so you can quickly see the result without +# installing MathJax. +# However, it is strongly recommended to install a local +# copy of MathJax from http://www.mathjax.org before deployment. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension +# names that should be enabled during MathJax rendering. + +MATHJAX_EXTENSIONS = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvantages are that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. LATEX_CMD_NAME = latex -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and # executive. If left blank a4wide will be used. -PAPER_TYPE = a4wide +PAPER_TYPE = a4 -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. -EXTRA_PACKAGES = +EXTRA_PACKAGES = -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! -LATEX_HEADER = +LATEX_HEADER = -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = YES -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the +# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See +# http://en.wikipedia.org/wiki/BibTeX for more info. + +LATEX_BIB_STYLE = plain + #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide +# Load style sheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. -RTF_STYLESHEET_FILE = +RTF_STYLESHEET_FILE = -# Set optional variables used in the generation of an rtf document. +# Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. -RTF_EXTENSIONS_FILE = +RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages -GENERATE_MAN = NO +GENERATE_MAN = YES -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man -# The MAN_EXTENSION tag determines the extension that is added to +# The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO @@ -1164,33 +1403,33 @@ MAN_LINKS = NO # configuration options related to the XML output #--------------------------------------------------------------------------- -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the # syntax of the XML files. -XML_SCHEMA = +XML_SCHEMA = -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the # syntax of the XML files. -XML_DTD = +XML_DTD = -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES @@ -1199,10 +1438,10 @@ XML_PROGRAMLISTING = YES # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO @@ -1211,343 +1450,364 @@ GENERATE_AUTOGEN_DEF = NO # configuration options related to the Perl module output #--------------------------------------------------------------------------- -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. -PERLMOD_MAKEVAR_PREFIX = +PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- -# Configuration options related to the preprocessor +# Configuration options related to the preprocessor #--------------------------------------------------------------------------- -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. SEARCH_INCLUDES = YES -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by # the preprocessor. -INCLUDE_PATH = +INCLUDE_PATH = -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. -INCLUDE_FILE_PATTERNS = +INCLUDE_FILE_PATTERNS = -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator # instead of the = operator. -PREDEFINED = +PREDEFINED = -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. -EXPAND_AS_DEFINED = +EXPAND_AS_DEFINED = -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- -# Configuration::additions related to external references +# Configuration::additions related to external references #--------------------------------------------------------------------------- -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. +# The TAGFILES option can be used to specify one or more tagfiles. For each +# tag file the location of the external documentation should be added. The +# format of a tag file without this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths +# or URLs. Note that each tag file must have a unique name (where the name does +# NOT include the path). If a tag file is not located in the directory in which +# doxygen is run, you must also specify the path to the tagfile here. -TAGFILES = +TAGFILES = -# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. -GENERATE_TAGFILE = +GENERATE_TAGFILE = -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES -# The PERL_PATH should be the absolute path and name of the perl script +# The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- -# Configuration options related to the dot tool +# Configuration options related to the dot tool #--------------------------------------------------------------------------- -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. -CLASS_DIAGRAMS = NO +CLASS_DIAGRAMS = YES -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. -MSCGEN_PATH = +MSCGEN_PATH = -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) -HAVE_DOT = YES +HAVE_DOT = NO -# By default doxygen will write a font called FreeSans.ttf to the output -# directory and reference it in all dot files that doxygen generates. This -# font does not include all possible unicode characters however, so when you need -# these (or just want a differently looking font) you can specify the font name -# using DOT_FONTNAME. You need need to make sure dot is able to find the font, -# which can be done by putting it in a standard location or by setting the -# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory -# containing the font. +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. -DOT_FONTNAME = FreeSans +DOT_NUM_THREADS = 0 -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# By default doxygen will use the Helvetica font for all dot files that +# doxygen generates. When you want a differently looking font you can specify +# the font name using DOT_FONTNAME. You need to make sure dot is able to find +# the font, which can be done by putting it in a standard location or by setting +# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# directory containing the font. + +DOT_FONTNAME = Helvetica + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 -# By default doxygen will tell dot to use the output directory to look for the -# FreeSans.ttf font (which doxygen will put there itself). If you specify a -# different font using DOT_FONTNAME you can set the path where dot -# can find it using this tag. +# By default doxygen will tell dot to use the Helvetica font. +# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to +# set the path where dot can find it. -DOT_FONTPATH = +DOT_FONTPATH = -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO -# If set to YES, the inheritance and collaboration graphs will show the +# If the UML_LOOK tag is enabled, the fields and methods are shown inside +# the class node. If there are many fields or methods and many nodes the +# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS +# threshold limits the number of items for each type to make the size more +# managable. Set this to 0 for no limit. Note that the threshold may be +# exceeded by 50% before the limit is enforced. + +UML_LIMIT_NUM_FIELDS = 10 + +# If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. If you choose svg you need to set +# HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible in IE 9+ (other browsers do not have this requirement). DOT_IMAGE_FORMAT = png -# The tag DOT_PATH can be used to specify the path where the dot tool can be +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to +# enable generation of interactive SVG images that allow zooming and panning. +# Note that this requires a modern browser other than Internet Explorer. +# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you +# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible. Older versions of IE do not have SVG support. + +INTERACTIVE_SVG = NO + +# The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. -DOT_PATH = +DOT_PATH = -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the # \dotfile command). -DOTFILE_DIRS = +DOTFILE_DIRS = -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = NO -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Options related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO diff --git a/libs/libzrtp/doc/doxygen.css b/libs/libzrtp/doc/doxygen.css deleted file mode 100644 index 1d38770349..0000000000 --- a/libs/libzrtp/doc/doxygen.css +++ /dev/null @@ -1,451 +0,0 @@ -BODY,H1,H2,H3,H4,H5,H6,P,CENTER,TD,TH,UL,DL,DIV { - font-family: Geneva, Arial, Helvetica, sans-serif; -} - -BODY,TD { - font-size: 100%; -} - -CODE { - font-size: 120%; - font-family: monospace; -} - -.fragment, pre { - font-size: 110%; - font-family: monospace; -} -H1 { - text-align: center; - font-size: 240%; -} -H2 { - font-size: 180%; - margin-top: 60px; -} -H3 { - font-size: 140%; -} -H4 { - font-size: 120%; -} - -caption { - font-weight: bold; -} - -div.qindex, div.navtab{ - background-color: #e8eef2; - border: 1px solid #84b0c7; - text-align: center; - margin: 2px; - padding: 2px; -} - -div.qindex, div.navpath { - width: 100%; - line-height: 140%; -} - -div.navtab { - margin-right: 15px; -} - -/* @group Link Styling */ - -a { - color: #153788; - font-weight: normal; - text-decoration: none; -} - -.contents a:visited { - color: #1b77c5; -} - -a:hover { - text-decoration: underline; -} - -a.qindex { - font-weight: bold; -} - -a.qindexHL { - font-weight: bold; - background-color: #6666cc; - color: #ffffff; - border: 1px double #9295C2; -} - -.contents a.qindexHL:visited { - color: #ffffff; -} - -a.el { - font-weight: bold; -} - -a.elRef { -} - -a.code { -} - -a.codeRef { -} - -/* @end */ - -dl.el { - margin-left: -1cm; -} - -.fragment { - font-family: monospace, fixed; - font-size: 105%; -} - -pre.fragment { - border: 1px solid #CCCCCC; - background-color: #f5f5f5; - padding: 4px 6px; - margin: 4px 8px 4px 2px; -} - -div.ah { - background-color: black; - font-weight: bold; - color: #ffffff; - margin-bottom: 3px; - margin-top: 3px -} - -div.groupHeader { - margin-left: 16px; - margin-top: 12px; - margin-bottom: 6px; - font-weight: bold; -} - -div.groupText { - margin-left: 16px; - font-style: italic; -} - -body { - background: white; - color: black; - margin-right: 20px; - margin-left: 20px; -} - -td.indexkey { - background-color: #e8eef2; - font-weight: bold; - border: 1px solid #CCCCCC; - margin: 2px 0px 2px 0; - padding: 2px 10px; -} - -td.indexvalue { - background-color: #e8eef2; - border: 1px solid #CCCCCC; - padding: 2px 10px; - margin: 2px 0px; -} - -tr.memlist { - background-color: #f0f0f0; -} - -p.formulaDsp { - text-align: center; -} - -img.formulaDsp { - -} - -img.formulaInl { - vertical-align: middle; -} - -/* @group Code Colorization */ - -span.keyword { - color: #008000 -} - -span.keywordtype { - color: #604020 -} - -span.keywordflow { - color: #e08000 -} - -span.comment { - color: #800000 -} - -span.preprocessor { - color: #806020 -} - -span.stringliteral { - color: #002080 -} - -span.charliteral { - color: #008080 -} - -span.vhdldigit { - color: #ff00ff -} - -span.vhdlchar { - color: #000000 -} - -span.vhdlkeyword { - color: #700070 -} - -span.vhdllogic { - color: #ff0000 -} - -/* @end */ - -.search { - color: #003399; - font-weight: bold; -} - -form.search { - margin-bottom: 0px; - margin-top: 0px; -} - -input.search { - font-size: 75%; - color: #000080; - font-weight: normal; - background-color: #e8eef2; -} - -td.tiny { - font-size: 75%; -} - -.dirtab { - padding: 4px; - border-collapse: collapse; - border: 1px solid #84b0c7; -} - -th.dirtab { - background: #e8eef2; - font-weight: bold; -} - -hr { - height: 0; - border: none; - border-top: 1px solid #666; -} - -/* @group Member Descriptions */ - -.mdescLeft, .mdescRight, -.memItemLeft, .memItemRight, -.memTemplItemLeft, .memTemplItemRight, .memTemplParams { - background-color: #FAFAFA; - border: none; - margin: 4px; - padding: 1px 0 0 8px; -} - -.mdescLeft, .mdescRight { - padding: 0px 8px 4px 8px; - color: #555; -} - -.memItemLeft, .memItemRight, .memTemplParams { - border-top: 1px solid #ccc; -} - -.memTemplParams { - color: #606060; -} - -/* @end */ - -/* @group Member Details */ - -/* Styles for detailed member documentation */ - -.memtemplate { - font-size: 80%; - color: #606060; - font-weight: normal; - margin-left: 3px; -} - -.memnav { - background-color: #e8eef2; - border: 1px solid #84b0c7; - text-align: center; - margin: 2px; - margin-right: 15px; - padding: 2px; -} - -.memitem { - padding: 0; -} - -.memname { - white-space: nowrap; - font-weight: bold; -} - -.memproto, .memdoc { - border: 1px solid #84b0c7; -} - -.memproto { - padding: 0; - background-color: #d5e1e8; - font-weight: bold; - -webkit-border-top-left-radius: 8px; - -webkit-border-top-right-radius: 8px; - -moz-border-radius-topleft: 8px; - -moz-border-radius-topright: 8px; -} - -.memdoc { - padding: 2px 5px; - background-color: #eef3f5; - border-top-width: 0; - -webkit-border-bottom-left-radius: 8px; - -webkit-border-bottom-right-radius: 8px; - -moz-border-radius-bottomleft: 8px; - -moz-border-radius-bottomright: 8px; -} - -.paramkey { - text-align: right; -} - -.paramtype { - white-space: nowrap; -} - -.paramname { - color: #602020; - white-space: nowrap; -} -.paramname em { - font-style: normal; -} - -/* @end */ - -/* @group Directory (tree) */ - -/* for the tree view */ - -.ftvtree { - font-family: sans-serif; - margin: 0.5em; -} - -/* these are for tree view when used as main index */ - -.directory { - font-size: 9pt; - font-weight: bold; -} - -.directory h3 { - margin: 0px; - margin-top: 1em; - font-size: 11pt; -} - -/* -The following two styles can be used to replace the root node title -with an image of your choice. Simply uncomment the next two styles, -specify the name of your image and be sure to set 'height' to the -proper pixel height of your image. -*/ - -/* -.directory h3.swap { - height: 61px; - background-repeat: no-repeat; - background-image: url("yourimage.gif"); -} -.directory h3.swap span { - display: none; -} -*/ - -.directory > h3 { - margin-top: 0; -} - -.directory p { - margin: 0px; - white-space: nowrap; -} - -.directory div { - display: none; - margin: 0px; -} - -.directory img { - vertical-align: -30%; -} - -/* these are for tree view when not used as main index */ - -.directory-alt { - font-size: 100%; - font-weight: bold; -} - -.directory-alt h3 { - margin: 0px; - margin-top: 1em; - font-size: 11pt; -} - -.directory-alt > h3 { - margin-top: 0; -} - -.directory-alt p { - margin: 0px; - white-space: nowrap; -} - -.directory-alt div { - display: none; - margin: 0px; -} - -.directory-alt img { - vertical-align: -30%; -} - -/* @end */ - -address { - font-style: normal; - color: #333; -} diff --git a/libs/libzrtp/doc/footer.html b/libs/libzrtp/doc/footer.html deleted file mode 100644 index 292249e9d9..0000000000 --- a/libs/libzrtp/doc/footer.html +++ /dev/null @@ -1,4 +0,0 @@ -
-Generated on $datetime for $projectname  zfone
- - diff --git a/libs/libzrtp/doc/header.html b/libs/libzrtp/doc/header.html deleted file mode 100644 index 41c1d88fd7..0000000000 --- a/libs/libzrtp/doc/header.html +++ /dev/null @@ -1,6 +0,0 @@ - - -$title - - - diff --git a/libs/libzrtp/doc/out/html/zfone.jpg b/libs/libzrtp/doc/out/html/zfone.jpg deleted file mode 100644 index 739e3a45454ccfb8706a2bd80db6d04c448f1c42..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8517 zcmb_=2UJwc(r!;C=Oj@iOOhy2M6!S&DkvaBkR*~pP{Jr8NpcVc1d)tHNs1hDP!Lg~ zfRZIhaF8^}F!OKDIrrYT{{P+e?tAOi%&h%Q@9OUQs=9Y|ZSoiL3}85~YoH5YFc{E> zK7c$&&tagYg*7!Z(KRsAfo=dmPhscfbqfvvaQE=@G1EJD{OUE!{t#KDYnWg(ijd1Mq+P{}<=Kdmy0T90iyGC;>mv4wHpVz-tlB z$ZfPY1q0WI($k555<@Xi8 zD%GllsA;QjYvgF^og3D^tW%}vIz+*+J+|Yr zv%ed=$G2Ba&?b!Ud;UiKes-XAFhcY_WIk*lS&;!5MIFuKVw!4zW{_@$5ygCrRhXUo7@Bj5dx*F0c;1N=!Ej*@QQMOS5(-kx(yKB}a$yQ; zipxrgDq^bj>RM;&&T?v6pL?$LP3M^IWxa>`bp~^WG)A($dCDHv6^=cEa{b4*EB)INCeibPjaExyIZ~b<4R`;$G*`eI#2x;-Y(X@^s1Oix5W0^$xOaG;`~ZZ*9)gFY2vQV?M#s=T zVu|IA6N{HmIFqQ8WSnfCVwq}_X8RbMZvDjkscD93rg4_xGyQC>9JS|ixneK4^Jw#k z`Ktxvg>6N}#R(<1OD$fil<|}!%eO0*DkrNxR=2#WtjVg4s`IVC-k|sT)EkaBCn&&o$0_FNiM8 zd{17~S=?JHST*-%#xB@x z+6y3@A}sA^{5Jf3a8N=tKZG5YlPpN&zvE8}q<}5R1)DGrI12tAQH|_I9bjxICaBzK zC}~UR&oeAA`7`gchOuKf9&xg974WF=b{@aLKOx{CxFl>ZGA?FtvQmOl(q5`mdR^v} z>~*;i`6z`%#njX3O6kfeDzU2f)o!c1oUzc*J}afks!2RItJR}jsuQQ{t#?V^z(C`? ztf8>cF=I+&!iDc9gQm?FOU=?Q;V$30VqvarA$OJk8vQl0<%(6Ob=vhCHZoX%9k9)@ z^RQQUpmmtKQQ>&c>9Vt^Gtp(pwfttJ8}^ohJHox+BgNC&OW146yUi!T7waeONAmBx z{W!ojP%LocPW4^iAgQ3`;Jgs0(2F?Ld&2h_?(c?;KWGfkcz8R)G*T=IM2$tij0t^Y z7Aq9H7xz9sJHao}GU;5hSPFg0cIub3w~w>ZgP&Y~dM1NE6PdZ3)&HzE`&mxpbH7~s z7w7YY@^+oeG$0$k zysmwd)adortm*V0yv>;A&6dg5uD0^_#~mS^_FcN&B0cDyrFY}+dwbjaYCe?oKl_+C z5cVnH^UXo)p$o$rBQm4>V@zL=U$)2RCx$0`zRpacr%%mT&nC?EEiiv~S?pcbTNz#r zU03_bzDd8uy`#Msx&M`@K}tE=|9|DaqnvBZ#0$V)J_P^BA2PrUcz`Hq1vP+=U;*sI=wJdcC73bH0Tu{LfEB=+V8gIA zI2z6eSAmYFyp;Bo#gv;=+EnROtJGT58PwY} zrZknbbhO^IqjYL?`SkSk!St&P*BL%D>M}MlDKJ$sOE8zRh_bw7J<0l#O^U6KU7fv$ z;|j;pvAdj%oG-cbxt6$Nc%*oSc|-X``38^U_@(*3oro7O5Tp_OEc6sw^Wq|VqFrLC zC+)>$CEyanlKE1;(mJPDPc6vQ$UcxWmlu=YSNNd#;&gzLiL!t)QDsE6O6`&Q%`-+C zGH1CpF`B>5t!PbYkLyh6e$!jj-!a%Xq%dMO7P_EhVrJ@dG1;u?(()B9b5n~)R|hOv zt*ospY+%?+wz+om4kvGTJGMA8xVX4>xry9*47$T>lD;@>LX(rGl4kSNKwSLT zUa{3$*Vn&!*|gp&)?wEj`M%^s=fK3^$_Qzk`78Z2#T?Cd+GW;Nwhg9D%+~7e`~4K6 z&7b*00a$_{@C3X9yylJ8TlR4X1;P!FAyd@Gy8Tyd6G| zKq7<@=b_jqA?gql2r^O#X@vAcW+6L~8z>Hx7Rm#aiF%JBpheNw(2vk9=xvNR<_0Dk zGfu%qVNUUcVgic0GvzBPIF%Ju4K+QrJM{+|Nt$GueOi0kk5JUh>G|o?85kJi7^xW_ zG0`!lFmo~&ut>4IWj)K_>i=tv;2(hV?Z^Y9id?hbRNlDX4ubz4*Qy?2I=Ok~SAgy@p zG~)Dz(wK6KN~vn9TBy3~8FLN2v#OfX=LEF)wRv=Sb%pe#^wkZF&YK&$7zG%|UdS_P zHJvd-UXr|QbtTrk#e#TE-SVDQ_jPs~M{I-bK9masZ@h7WIiGjQaNTgzxs~Hi^tAG7 z^AYw<^xMDf6!7_u=H0i!Mj>ms$orCEgW(|&B9Vj9_a8~ePRA!Eo=e(JDNZv_r+PAy zQI-{xZS`F41$Ew!g3h9%lK7YR%7ZF{t7B@i>pB~LHVQPEH$Q7#>^Rp|@Q%GVy$WfM9_$wqZU2nFDsTkRpcK3Vi!eBh z7mB?(%ommjtAO>x)}gq|z^}lA;Cb*q_%?zMVTcGoC>`_lq zgJ@c`0Xh=hgQ3J+z&yrGQHWCnQS?(Dr@Tw~g-VmEoSKI^kp@MBqao6U(!uFs=-KEC z8B`bs8QqzvnaY^Wmv&W11 zy-z3$&rvgwJ7ShK=Q_$!*`sTM!4nOIg@ zvs@3g`EF}ymu|mwL)kIG>4%HHYndDKt-J2?o`zoaK778>e)!v01Dc>SOlt7SkP%$K z{o`R>;Ws0wBJ-owV?M>&#;qp=C6be4Qt8tY(m9^AXFSN#dv=ghk!zDjnO|LKUUX3M z{H1=`PDOr|#VdxIfx0IRH{Q@RzHYkKOxaS^X4ApY+0pIy?&SOVzUTed2Y5cs4!#(6 z8I>O+j(1ENeC?Q0p01h|n2VeL`Q2bKV`+AU?}yQ<*INAgvyGykrTE;<)L%hccH5de zd^oyYdeVT!AsL0}g-HX;3RbGXRj~c7$4nl88sw|5f}P1ECrY04-0i zJ3g+?E`G-~p(@o;;<$l_gOtQ^*;A*K0eKe0>IAwv0bpzlpvn%K6%9iJC_h5g8e|QO z>2C~`QZP=aGCpbtz#PW)PizAd{g-~ED?t9O1C9Bo=>PryuPgjH{GS@p&k_H`l1IAa zNuUMbFldv(;Be>*2?B*U5;PKtKw;1r3(3_5ZbyTLB{lkOa{P*a-kpk{4Fpz z0*Qhwg6x14>KGvN5ePVBED8xZ0u}<@2S`Q~6Tgfmn)#v~=7cwk?ER!%3W0OgZLDUW z@q%*pK4FwpZ0sDzIE92oM8!_ZD=3~;QdZH@*3s3|H#mRk@)dInsEl^F;ppV-;(F89 z&;NEn;GMeU7!|0MP=UK4-@I>Esi5sW|sOp`%aFRsl|!&Q1*k3^-nDbT6`NCISF8)$fz)UT*0 za&~Z|DM>Ni*<1RjbKM;-zZ(5%Ic|^ERzRO!-ZInJ(tzp|6RPYCIj_F}8|isaYtO-} z$x*#mmOxMn(7+Qs9}zUR(L^$+mM2=o5(0MPKW+a3@16*9H~3!P5HCE=l&Eh?zd1JS z)ot;3G3}(*sm>sA%PHq~n;xDSjx4!qmGtXY-)^6|PX>|8phO?Nbi0)9A>X7L6Y z%)G_bAI8=62W<+NMu-mAs0OO)!p?4(d~u5%s*EqNW0@1n-AYu7H$@by-SaZJx!E$o zH;3IV-~3c7W~k{gy>cOc&SIWQJw0A^X`*>3ia>qxofkd3gi+>!xXGQGnb+7(qv@zE z*06ZClj3uCn=dyz4{6Zjj%f3BwXj*bXi%Tw|3MNO{TV+Q#3R>csovk&bNFPwN64_VB;m4y<>07QSnACNV1kTb(V2O2(41_x~FJyPS7FQQOL04ulcwU*0;vk|~VfB>4K=OIAUyNfU%ip9{s0GoN4_lW)xjTvo=RrdA%gCOG3h^9p3 zr;R4N0_%{NONW`WWI*RqmG3DUt=D@$N~5(o1tDmJ<+7u>_@{-FA(DIg%zBlvrt#!2;(r z!51RZbJ$3d35=Fc2ya#$3pOcjIWc5_S4_F1sD8f3R-bn%W(P}<7$Y*7T)4P`6r)03@({!P1L|({D1JXN-8khRf zP!@bZ_$~7#i(z7p?3P&~XueT~-d{?3N7bB<0`~Vbjt7T8wopS|vWZgotsm12vxKz# zl_aTssUm`VAx9q8!g1)G=7zV85^iR8dXiqmvx|7od*GoT#Haqs0qX%XuI)}JCFv`U z`_k-Q$1>4kc7S2Jth}J2!HwnAk4cudf+j4L^~TSublZ+AD$fv;$N(dbYm+64%~nQu z2Zs=(^Cny@%j@%46JpBCW*Ia?Q<$o!?zpu+F{tAp1BN7n{nTXG*7TYIWa#)|DM>nX ze43(3WRrO=XE);hTmt9v?+Zn4WI!>Mz&=s#+#Dh1FwK+E=%MHMwT#30_=A3&jw)uK zl^74LF~!#q(`X`s+k2C%at16$hI8R4t zb>2((@bI1S|j&%moq!q{gl-fMK45Ukhr^Ar>1XWs{5db>gqUO}AuTl$9u z7UzbJ*9>k`2hP-=je6vB7K(>&%cTwDkO1_+$&Pt*5&7a&yVAJKMV#R78S(hMEPL6# zi1#Z~zMtO~^fqpcE|n5i>YVTkn*=G*g_b8QdI1zCFfW}Crn2`dDaJx+S4nJjDiLp4 z;8V(%-$ti>d2B1IXH%pwg6p_qk}ZD~hle)frb7BWc7hJe8R+A#Vk{+!EQ__aX6qhB zde?eq9BfE^RPu}xYaCz}F_YOlk#e3CFS5kVoU~~{YaWMs7*nJyqO6!zP6qe=G+wqm zoJebqKF}c8Z(Z@`DKCnYSbSRl_{$@ghw?%hc8y6%#Z!_m)$IE6 ztKN0kX~@CLbT!Q=E87zyTNwSP!>1I7f_3l%=FOjW)=xOTu4%4G?NMlYkc$je3s`pB z?wi39d9G|?TbqwH43U%w)a}`-Z|*CSfoq4qaGI}1-ucp3x>m!bmGZFPLS%r1_IlVY zLJEnp|3J-+Goah}T>H0|LGH8kNWB*W-pn3)uMK=pJeYQEC5mq~>_QA5q=zb!K20(H@hOyLMTNfoP|h?i z_x0-`r{t|mf$#X!JRGS6-p#x^(U4o2ft$&};xBr#L4Hv^BfZM2Kyc1q4iy;je<@u3 z`ueSp@7i*F&)EChcPS!`&74{O&#i(`-OsTW%8(P*Atyu< z@<^0#H?7P!1KLBFJ0^BWs34hQ4eNAxGP-8 zu=ZfylT)QDZ`nq?C1~X;od5pdlt^NNHj~Gh4)wE@MbN3_Ma!!kq8eiN#HK|Dw5V1U z8$-sT%4hx<^oJWg?w7w%qitPi5Vt#joEuF8>lWYNf~-k~p5R1pXrj}DO=8ZQxQvqN+{j0hHTp1qoRe)DJ88ZcBB zw~=04S=I=f`XS51a$9dIPlQSoQHUQPa?Kt%1WRrHQBjSb*7;o9kJZcSb0~Gqma1=f zj9H+x3z;2D$X&|5nXo>4AViv+M&X=kO)L-ViB@wVhO_h6tt_V|uM@uBOzIPVe^5R; zXZ|hH)JL!PtipCa7JqxO=6gbIFy-K*`DC>#qL}3~eLaIs(j=;i4&FGofkY*Or@0%fi{B$D>4bO>&1x-gy(Nj}4KMMJt=)Pse(_CH9!OT)xMfwX45#dUh?}{^1pG>?hClI5I#J zf;kS~;9SUnk$8zvGv^uo8yBT^ao4lXYK1c{R?+(~dz9<)uR$v@Zb!*aS#S2EyU}1v znh?IX>rV!`1M?;%+U)_7#l$xTO4CXyO?^Xjm1hQttIOx>tAPSza1%@ z(p^gNx^a?4jP)QINdo_lL$D^Yr)_DN-X&gK&CCWBL)tHo&%FXoukj!-d?2WUhBkZSa2aeC1k-;1$%=s|g zeOp{f!X)O!5aZMAZdSB!vHr(C*;Wy`D77-DON_Bq-7_qtAu{L`X{o6^q{DII@ScUZ zUyTX>!xN^MIj6cgKDz#clgo{`$PGXJy5$>B>qKMDHY6iXrgpp2l>bTzYoG$$C5ufp zI>Q$d$|kO_g?ZMTf5ovFYshu)u53sayOvnhc^$aL(A@+$4EulT90u!FPYY zP0F8Zt7M>+)15=)TFD_+Jg4upN?;|(?(L?;EVd6ARpUc)PmRBveEJ;wjVJknqDKnT zDZwHTpUi-WhgD9t z{10{)|94RUM6HoJY0QcS2azh#Fdw`8TWh?q&et8GQ2v?uXKGsD{Y2!xfv9goZfQ$x zWo(nee4K-B6TywP>D1x9^6>+C^F7{xC;Log3|)+Xm8$otD6_X@#$oq=O1=X-KH163 zFsPtzE*)FHJK)IL_~W*u84=p-Bym=~ z&NO?Ktvj;)*_Y+FPi^5Yg+*_oU>S`P;6HAAs;zPo`=2_1YtWyEN*Ya=Pz{gv^vE7w zp1b-;zqF=0RltEN_|==GoV!1E$RNgsrS|ZdpET`?r8av8@wZ>t@71-@_q*Z=>&Nn$ z?zA{>OhFkU}KuhmI2=q)&8^-GF1srPC{O)?{>5Rgx-N6Aj i6%)?h65BG<+M68WVggFGUV6)g-8&@Q{8>Ko_ Date: Sat, 23 Jun 2012 03:04:31 +0000 Subject: [PATCH 32/49] Improve some autoconf minutia Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/libzrtp/configure.in b/libs/libzrtp/configure.in index 8124fda9fc..eeb1e5d224 100644 --- a/libs/libzrtp/configure.in +++ b/libs/libzrtp/configure.in @@ -6,7 +6,7 @@ # Viktor Krikun # -AC_INIT() +AC_INIT([libzrtp], [1.2.0]) AC_CONFIG_AUX_DIR(config) AC_CONFIG_HEADER(config/config.h) @@ -32,7 +32,7 @@ case $target_os in esac -AM_INIT_AUTOMAKE([libzrtp], [1.20]) +AM_INIT_AUTOMAKE AX_PREFIX_CONFIG_H(include/zrtp_config_unix.h,ZRTP,config/config.h) CFLAGS="$CFLAGS -Wno-unused-parameter -fno-strict-aliasing -fPIC -DZRTP_AUTOMAKE=1" From f311f81b8d37b0a103c058de8620420160b2f6a3 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Wed, 20 Jun 2012 18:52:56 +0300 Subject: [PATCH 33/49] Cleanup whitespace and comments Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/doc/manuals/changelog.dox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/libzrtp/doc/manuals/changelog.dox b/libs/libzrtp/doc/manuals/changelog.dox index 6686515851..36f8117b62 100644 --- a/libs/libzrtp/doc/manuals/changelog.dox +++ b/libs/libzrtp/doc/manuals/changelog.dox @@ -25,7 +25,7 @@ each time it creates new session via zrtp_session_init(). *- Added zrtp_randstr2() which allow to generate random string before libzrtp being initialized. Can be handy to generate initial ZID. In normal circumstances, use zrtp_randstr() whenever possible. - *- ZRTP cache API was completely redesigned. Look at zrtp_cache.h for more details. + *- ZRTP cache API was completely redesigned. Look at zrtp_cache.h for more details. ***\subsection v120_feature New features and improvements. From 7503d8aafa7e8fdd14d5460b6182f1a497069a86 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Thu, 21 Jun 2012 11:36:33 +0300 Subject: [PATCH 34/49] Fix bug with libzrtp zrtp_signaling_hash_set() The function would silently not accept the imported zrtp-hash-value with "buffer too small" in the debug output. Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/doc/manuals/changelog.dox | 2 ++ libs/libzrtp/include/zrtp.h | 9 ++++++--- libs/libzrtp/src/zrtp.c | 26 +++++++++++--------------- libs/libzrtp/src/zrtp_string.c | 5 +++-- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/libs/libzrtp/doc/manuals/changelog.dox b/libs/libzrtp/doc/manuals/changelog.dox index 36f8117b62..42fdae34d0 100644 --- a/libs/libzrtp/doc/manuals/changelog.dox +++ b/libs/libzrtp/doc/manuals/changelog.dox @@ -34,6 +34,8 @@ ***\subsection v120_bugs Bug fixes *- fixed bug when ZRTP forces enrolled endpoints to re-render SAS when sashash is empty. *- other minor bug fixes and improvements + *- fixed bug when zrtp_signaling_hash_set() silently not accepted imported zrtp-hash-value with + "buffer too small" debug output. **************************************************************************************************** diff --git a/libs/libzrtp/include/zrtp.h b/libs/libzrtp/include/zrtp.h index 67c64a8eeb..3b5e5f67af 100644 --- a/libs/libzrtp/include/zrtp.h +++ b/libs/libzrtp/include/zrtp.h @@ -82,6 +82,9 @@ * \ingroup zrtp_main_init */ +/** Length of "zrtp-hash-value", RFC 6189 sec 8. @sa zrtp_signaling_hash_get(); */ +#define ZRTP_SIGN_ZRTP_HASH_LENGTH (ZRTP_MESSAGE_HASH_SIZE*2) + /** * \brief Enumeration for ZRTP Licensing modes * \ingroup zrtp_main_init @@ -798,7 +801,7 @@ zrtp_status_t zrtp_process_srtcp( zrtp_stream_t *stream, * * \param stream - stream for operating with; * \param hash_buff - signaling hash buffer. Function accepts string, not a binary value!; - * \param hash_buff_length - signaling hash length in bytes (must be 64 bytes); + * \param hash_buff_length - signaling hash length in bytes, must be ZRTP_SIGN_ZRTP_HASH_LENGTH bytes; * \return: * - zrtp_status_ok if the operation finished successfully * - one of the errors otherwise @@ -819,8 +822,8 @@ zrtp_status_t zrtp_signaling_hash_set( zrtp_stream_t* stream, * * \param stream - stream for operating with * \param hash_buff - buffer for storing signaling hash. Function returns already parsed hex string. - * String is null-terminated. - * \param hash_buff_length - buffer length in bytes (not shorter than 65 bytes) + * String is null-terminated. Buffer must be at least ZRTP_SIGN_ZRTP_HASH_LENGTH bytes length. + * \param hash_buff_length - buffer length in bytes, non less than ZRTP_SIGN_ZRTP_HASH_LENGTH bytes. * \return: * - zrtp_status_ok if the operation finished successfully * - one of the errors otherwise diff --git a/libs/libzrtp/src/zrtp.c b/libs/libzrtp/src/zrtp.c index 9ee078082b..05be53dfaf 100644 --- a/libs/libzrtp/src/zrtp.c +++ b/libs/libzrtp/src/zrtp.c @@ -437,8 +437,6 @@ zrtp_status_t zrtp_stream_attach(zrtp_session_t *session, zrtp_stream_t** stream ZSTR_SET_EMPTY(new_stream->cc.peer_hmackey); ZSTR_SET_EMPTY(new_stream->cc.zrtp_key); ZSTR_SET_EMPTY(new_stream->cc.peer_zrtp_key); - - ZSTR_SET_EMPTY(new_stream->messages.signaling_hash); new_stream->dh_cc.initialized_with = ZRTP_COMP_UNKN; bnBegin(&new_stream->dh_cc.peer_pv); @@ -466,6 +464,7 @@ zrtp_status_t zrtp_stream_attach(zrtp_session_t *session, zrtp_stream_t** stream zrtp_memset(&new_stream->messages, 0, sizeof(new_stream->messages)); ZSTR_SET_EMPTY(new_stream->messages.h0); + ZSTR_SET_EMPTY(new_stream->messages.signaling_hash); /* Generate Random nonce, compute H1 and store in the DH packet */ new_stream->messages.h0.length = (uint16_t)zrtp_randstr( new_stream->zrtp, @@ -595,11 +594,11 @@ zrtp_status_t zrtp_signaling_hash_get( zrtp_stream_t* stream, zrtp_string32_t hash_str = ZSTR_INIT_EMPTY(hash_str); zrtp_hash_t *hash = NULL; - if (!stream) { + if (!stream || !hash_buff) { return zrtp_status_bad_param; } - if (ZRTP_MESSAGE_HASH_SIZE*2+1 > hash_buff_length) { + if (ZRTP_SIGN_ZRTP_HASH_LENGTH > hash_buff_length) { return zrtp_status_buffer_size; } @@ -622,11 +621,11 @@ zrtp_status_t zrtp_signaling_hash_set( zrtp_stream_t* ctx, const char *hash_buff, uint32_t hash_buff_length) { - if (!ctx) { + if (!ctx || !hash_buff) { return zrtp_status_bad_param; } - if (ZRTP_MESSAGE_HASH_SIZE*2 < hash_buff_length) { + if (ZRTP_SIGN_ZRTP_HASH_LENGTH > hash_buff_length) { return zrtp_status_buffer_size; } @@ -634,17 +633,14 @@ zrtp_status_t zrtp_signaling_hash_set( zrtp_stream_t* ctx, return zrtp_status_wrong_state; } - str2hex( hash_buff, - hash_buff_length, - ctx->messages.signaling_hash.buffer, - ctx->messages.signaling_hash.max_length); + str2hex(hash_buff, + ZRTP_SIGN_ZRTP_HASH_LENGTH, + ctx->messages.signaling_hash.buffer, + ctx->messages.signaling_hash.max_length); ctx->messages.signaling_hash.length = ZRTP_MESSAGE_HASH_SIZE; - { - char buff[64]; - ZRTP_LOG(3, (_ZTU_,"SIGNALLING HAS was ADDED for the comparision. ID=%u\n", ctx->id)); - ZRTP_LOG(3, (_ZTU_,"Hash=%s.\n", hex2str(hash_buff, hash_buff_length, buff, sizeof(buff)))); - } + ZRTP_LOG(3, (_ZTU_,"SIGNALLING HAS was ADDED for the comparison. ID=%u\n", ctx->id)); + ZRTP_LOG(3, (_ZTU_,"Hash=%.*s.\n", ZRTP_SIGN_ZRTP_HASH_LENGTH, hash_buff)); return zrtp_status_ok; } diff --git a/libs/libzrtp/src/zrtp_string.c b/libs/libzrtp/src/zrtp_string.c index 2c78140051..162dbca2f9 100644 --- a/libs/libzrtp/src/zrtp_string.c +++ b/libs/libzrtp/src/zrtp_string.c @@ -113,7 +113,7 @@ const char* hex2str(const char* bin, int bin_size, char* buff, int buff_size) if (NULL == buff) { return "buffer is NULL"; } - if (buff_size < bin_size*2+1) { + if (buff_size < bin_size*2) { return "buffer too small"; } @@ -121,7 +121,8 @@ const char* hex2str(const char* bin, int bin_size, char* buff, int buff_size) nptr = hex2char(nptr, *bin++); } - *nptr = 0; + if (buff_size >= bin_size*2+1) + *nptr = 0; return buff; } From 521e673b5f30e1d2507d4b2f84ac0536427b5372 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Thu, 21 Jun 2012 11:36:33 +0300 Subject: [PATCH 35/49] Cleanup whitespace Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/include/zrtp.h | 6 +++--- libs/libzrtp/src/zrtp.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/libzrtp/include/zrtp.h b/libs/libzrtp/include/zrtp.h index 3b5e5f67af..185ffdfe30 100644 --- a/libs/libzrtp/include/zrtp.h +++ b/libs/libzrtp/include/zrtp.h @@ -831,9 +831,9 @@ zrtp_status_t zrtp_signaling_hash_set( zrtp_stream_t* stream, * - ZRTP RFC. sec 8; * - zrtp_signaling_hash_set() */ -zrtp_status_t zrtp_signaling_hash_get( zrtp_stream_t* stream, - char* hash_buff, - uint32_t hash_buff_length); +zrtp_status_t zrtp_signaling_hash_get(zrtp_stream_t* stream, + char* hash_buff, + uint32_t hash_buff_length); /** * \brief Changing the value of the secret's verification flag diff --git a/libs/libzrtp/src/zrtp.c b/libs/libzrtp/src/zrtp.c index 05be53dfaf..3842da10d4 100644 --- a/libs/libzrtp/src/zrtp.c +++ b/libs/libzrtp/src/zrtp.c @@ -462,7 +462,7 @@ zrtp_status_t zrtp_stream_attach(zrtp_session_t *session, zrtp_stream_t** stream * Then insert these directly into the message structures. */ - zrtp_memset(&new_stream->messages, 0, sizeof(new_stream->messages)); + zrtp_memset(&new_stream->messages, 0, sizeof(new_stream->messages)); ZSTR_SET_EMPTY(new_stream->messages.h0); ZSTR_SET_EMPTY(new_stream->messages.signaling_hash); From 02b3b8060a456cdedf81cc068b4b0ece37149d88 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Thu, 21 Jun 2012 11:36:33 +0300 Subject: [PATCH 36/49] Refactor test cases Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/test/engine_helpers.c | 69 ++++++++++++++++++ libs/libzrtp/test/go_secure_test.c | 61 +--------------- libs/libzrtp/test/zrtphash_test.c | 113 +++++++++++++++++++++++++++++ 3 files changed, 183 insertions(+), 60 deletions(-) create mode 100644 libs/libzrtp/test/engine_helpers.c create mode 100644 libs/libzrtp/test/zrtphash_test.c diff --git a/libs/libzrtp/test/engine_helpers.c b/libs/libzrtp/test/engine_helpers.c new file mode 100644 index 0000000000..3a3c2cb80a --- /dev/null +++ b/libs/libzrtp/test/engine_helpers.c @@ -0,0 +1,69 @@ +/* + * libZRTP SDK library, implements the ZRTP secure VoIP protocol. + * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. + * Contact: http://philzimmermann.com + * For licensing and other legal details, see the file zrtp_legal.c. + * + * Viktor Krykun + */ + +#include /*chmockery dependency*/ +#include /*chmockery dependency*/ +#include /*for usleep*/ + +#include "cmockery/cmockery.h" +#include "test_engine.h" + +static zrtp_test_id_t g_alice, g_bob; +static zrtp_test_id_t g_alice_sid, g_bob_sid; +static zrtp_test_id_t g_secure_audio_channel; + + +static void prepare_alice_bob() { + zrtp_status_t s; + + zrtp_test_session_cfg_t session_config; + zrtp_test_session_config_defaults(&session_config); + + /* + * Create two test sessions, one for Alice and one for Bob and link them + * into test secure channel + */ + s = zrtp_test_session_create(g_alice, &session_config, &g_alice_sid); + assert_int_equal(zrtp_status_ok, s); + assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_alice_sid); + + s = zrtp_test_session_create(g_bob, &session_config, &g_bob_sid); + assert_int_equal(zrtp_status_ok, s); + assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_bob_sid); + + s = zrtp_test_channel_create2(g_alice_sid, g_bob_sid, 0, &g_secure_audio_channel); + assert_int_equal(zrtp_status_ok, s); + assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_secure_audio_channel); +} + +static void release_alice_bob() { + zrtp_test_session_destroy(g_alice_sid); + zrtp_test_session_destroy(g_bob_sid); + + zrtp_test_channel_destroy(g_secure_audio_channel); +} + +static void start_alice_bob_and_wait4secure() { + zrtp_status_t s; + zrtp_test_channel_info_t channel_info; + + /* Everything is ready. Let's start the stream and give it few seconds to switch secure. */ + s = zrtp_test_channel_start(g_secure_audio_channel); + assert_int_equal(zrtp_status_ok, s); + + unsigned i = 30; + for (; i>0; i--) { + usleep(100*1000); + } + + s = zrtp_test_channel_get(g_secure_audio_channel, &channel_info); + assert_int_equal(zrtp_status_ok, s); + + assert_true(channel_info.is_secure); +} diff --git a/libs/libzrtp/test/go_secure_test.c b/libs/libzrtp/test/go_secure_test.c index be0f28583d..d75af8d91e 100644 --- a/libs/libzrtp/test/go_secure_test.c +++ b/libs/libzrtp/test/go_secure_test.c @@ -7,16 +7,7 @@ * Viktor Krykun */ -#include /*chmockery dependency*/ -#include /*chmockery dependency*/ -#include /*for usleep*/ - -#include "cmockery/cmockery.h" -#include "test_engine.h" - -static zrtp_test_id_t g_alice, g_bob; -static zrtp_test_id_t g_alice_sid, g_bob_sid; -static zrtp_test_id_t g_secure_audio_channel; +#include "engine_helpers.c" static void setup() { zrtp_status_t s; @@ -38,56 +29,6 @@ static void teardown() { zrtp_test_endpoint_destroy(g_bob); } -static void prepare_alice_bob() { - zrtp_status_t s; - - //zrtp_test_channel_info_t channel_info; - zrtp_test_session_cfg_t session_config; - zrtp_test_session_config_defaults(&session_config); - - /* - * Create two test sessions, one for Alice and one for Bob and link them - * into test secure channel - */ - s = zrtp_test_session_create(g_alice, &session_config, &g_alice_sid); - assert_int_equal(zrtp_status_ok, s); - assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_alice_sid); - - s = zrtp_test_session_create(g_bob, &session_config, &g_bob_sid); - assert_int_equal(zrtp_status_ok, s); - assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_bob_sid); - - s = zrtp_test_channel_create2(g_alice_sid, g_bob_sid, 0, &g_secure_audio_channel); - assert_int_equal(zrtp_status_ok, s); - assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_secure_audio_channel); -} - -static void release_alice_bob() { - zrtp_test_session_destroy(g_alice_sid); - zrtp_test_session_destroy(g_bob_sid); - - zrtp_test_channel_destroy(g_secure_audio_channel); -} - -static void start_alice_bob_and_wait4secure() { - zrtp_status_t s; - zrtp_test_channel_info_t channel_info; - - /* Everything is ready. Let's start the stream and give it few seconds to switch secure. */ - s = zrtp_test_channel_start(g_secure_audio_channel); - assert_int_equal(zrtp_status_ok, s); - - unsigned i = 30; - for (; i>0; i--) { - usleep(100*1000); - } - - s = zrtp_test_channel_get(g_secure_audio_channel, &channel_info); - assert_int_equal(zrtp_status_ok, s); - - assert_true(channel_info.is_secure); -} - static void go_secure_test() { /* diff --git a/libs/libzrtp/test/zrtphash_test.c b/libs/libzrtp/test/zrtphash_test.c new file mode 100644 index 0000000000..0566148914 --- /dev/null +++ b/libs/libzrtp/test/zrtphash_test.c @@ -0,0 +1,113 @@ +/* + * libZRTP SDK library, implements the ZRTP secure VoIP protocol. + * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. + * Contact: http://philzimmermann.com + * For licensing and other legal details, see the file zrtp_legal.c. + * + * Viktor Krykun + */ + +#include "engine_helpers.c" + +static void setup() { + zrtp_status_t s; + + zrtp_test_endpoint_cfg_t endpoint_cfg; + zrtp_test_endpoint_config_defaults(&endpoint_cfg); + + s = zrtp_test_endpoint_create(&endpoint_cfg, "Alice", &g_alice); + assert_int_equal(zrtp_status_ok, s); + assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_alice); + + s = zrtp_test_endpoint_create(&endpoint_cfg, "Bob", &g_bob); + assert_int_equal(zrtp_status_ok, s); + assert_int_not_equal(ZRTP_TEST_UNKNOWN_ID, g_bob); +} + +static void teardown() { + zrtp_test_endpoint_destroy(g_alice); + zrtp_test_endpoint_destroy(g_bob); +} + + +static void zrtp_hash_export_import_sunny_test() { + zrtp_status_t s; + char alice_zrtp_hash[ZRTP_SIGN_ZRTP_HASH_LENGTH]; + char bob_zrtp_hash[ZRTP_SIGN_ZRTP_HASH_LENGTH]; + zrtp_stream_t *alice_zrtp_stream, *bob_zrtp_stream; + + /* Create two test sessions, one for Alice and one for Bob and link them into test secure channel */ + prepare_alice_bob(); + + alice_zrtp_stream = zrtp_stream_for_test_stream(zrtp_test_session_get_stream_by_idx(g_alice_sid, 0)); + bob_zrtp_stream = zrtp_stream_for_test_stream(zrtp_test_session_get_stream_by_idx(g_bob_sid, 0)); + assert_non_null(alice_zrtp_stream); assert_non_null(bob_zrtp_stream); + + /* Take Alice's hash and give it to Bob */ + s = zrtp_signaling_hash_get(alice_zrtp_stream, alice_zrtp_hash, sizeof(alice_zrtp_hash)); + assert_int_equal(zrtp_status_ok, s); + + s = zrtp_signaling_hash_set(bob_zrtp_stream, alice_zrtp_hash, ZRTP_SIGN_ZRTP_HASH_LENGTH); + assert_int_equal(zrtp_status_ok, s); + + /* Take Bob's hash and give it to Alice */ + s = zrtp_signaling_hash_get(bob_zrtp_stream, bob_zrtp_hash, sizeof(bob_zrtp_hash)); + assert_int_equal(zrtp_status_ok, s); + + s = zrtp_signaling_hash_set(alice_zrtp_stream, bob_zrtp_hash, ZRTP_SIGN_ZRTP_HASH_LENGTH); + assert_int_equal(zrtp_status_ok, s); + + /* Start and wait for Secure */ + start_alice_bob_and_wait4secure(); + + /* Check if ZRTP_EVENT_WRONG_SIGNALING_HASH was not triggered for any of test endpoints */ + assert_false(zrtp_stream_did_event_receive(zrtp_test_session_get_stream_by_idx(g_alice_sid, 0), + ZRTP_EVENT_WRONG_SIGNALING_HASH)); + + assert_false(zrtp_stream_did_event_receive(zrtp_test_session_get_stream_by_idx(g_bob_sid, 0), + ZRTP_EVENT_WRONG_SIGNALING_HASH)); + + /* Release test setup */ + release_alice_bob(); +} + +static void zrtp_hash_import_wrong_test() { + zrtp_status_t s; + char wrong_alice_zrtp_hash[ZRTP_SIGN_ZRTP_HASH_LENGTH]; + zrtp_stream_t *bob_zrtp_stream; + + /* Create two test sessions, one for Alice and one for Bob and link them into test secure channel */ + prepare_alice_bob(); + + bob_zrtp_stream = zrtp_stream_for_test_stream(zrtp_test_session_get_stream_by_idx(g_bob_sid, 0)); + assert_non_null(bob_zrtp_stream); + + /* Let's provide wrong hash to bob */ + zrtp_memset(wrong_alice_zrtp_hash, 6, ZRTP_SIGN_ZRTP_HASH_LENGTH); + + s = zrtp_signaling_hash_set(bob_zrtp_stream, wrong_alice_zrtp_hash, ZRTP_SIGN_ZRTP_HASH_LENGTH); + assert_int_equal(zrtp_status_ok, s); + + /* Start and wait for Secure */ + start_alice_bob_and_wait4secure(); + + /* Check if Alice don't receive ZRTP_EVENT_WRONG_SIGNALING_HASH, but Bob should get one */ + assert_false(zrtp_stream_did_event_receive(zrtp_test_session_get_stream_by_idx(g_alice_sid, 0), + ZRTP_EVENT_WRONG_SIGNALING_HASH)); + + assert_true(zrtp_stream_did_event_receive(zrtp_test_session_get_stream_by_idx(g_bob_sid, 0), + ZRTP_EVENT_WRONG_SIGNALING_HASH)); + + /* Release test setup */ + release_alice_bob(); +} + + +int main(void) { + const UnitTest tests[] = { + unit_test_setup_teardown(zrtp_hash_export_import_sunny_test, setup, teardown), + unit_test_setup_teardown(zrtp_hash_import_wrong_test, setup, teardown), + }; + + return run_tests(tests); +} From 91c855a2ed62e0c1685acb83eea4d1068b3213de Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Thu, 21 Jun 2012 11:36:33 +0300 Subject: [PATCH 37/49] Remove outdated credit Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/AUTHORS | 2 -- 1 file changed, 2 deletions(-) diff --git a/libs/libzrtp/AUTHORS b/libs/libzrtp/AUTHORS index 6a435669c0..bc17ed718e 100644 --- a/libs/libzrtp/AUTHORS +++ b/libs/libzrtp/AUTHORS @@ -28,7 +28,5 @@ Thanks to: Ariel Boston Donovan Preston -Software development services provided by Soft_industry http://www.soft-industry.com/en. - Portions of this software are available under open source licenses from other authors. Notably, Brian Gladman's AES implementation, and David McGrew's libSRTP package. From 63cd37a2c4f936ec21d5f5482827236f47d2ae94 Mon Sep 17 00:00:00 2001 From: Viktor Krykun Date: Thu, 21 Jun 2012 11:36:33 +0300 Subject: [PATCH 38/49] Remove beta label Modified-by: Travis Cross Signed-off-by: Travis Cross --- libs/libzrtp/AUTHORS | 2 -- 1 file changed, 2 deletions(-) diff --git a/libs/libzrtp/AUTHORS b/libs/libzrtp/AUTHORS index bc17ed718e..f948f2f08e 100644 --- a/libs/libzrtp/AUTHORS +++ b/libs/libzrtp/AUTHORS @@ -5,8 +5,6 @@ # # Viktor Krikun -libzrtp BETA - Created by Phil Zimmermann. Developers: From 49346a57f4195cc69fc7d9a7240c615a3be7c9e3 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Fri, 6 Jul 2012 15:34:27 +0000 Subject: [PATCH 39/49] Reduce indirection in makefiles --- libs/libzrtp/Makefile.am | 68 ++++++++++++------------- libs/libzrtp/build/Makefile.am | 77 ++++++++++++++--------------- libs/libzrtp/build/test/Makefile.am | 21 ++++---- 3 files changed, 80 insertions(+), 86 deletions(-) diff --git a/libs/libzrtp/Makefile.am b/libs/libzrtp/Makefile.am index d0bd6c32c9..22596c1e35 100644 --- a/libs/libzrtp/Makefile.am +++ b/libs/libzrtp/Makefile.am @@ -5,48 +5,43 @@ # Viktor Krikun # -TEST_DIR=$(top_srcdir)/test -TOP_SRCDIR=$(top_srcdir)/include -THIRD_DIR=$(top_srcdir)/third_party - libzrtp_includedir=$(includedir)/libzrtp - libzrtp_include_HEADERS = \ - $(TOP_SRCDIR)/zrtp.h \ - $(TOP_SRCDIR)/zrtp_base.h \ - $(TOP_SRCDIR)/zrtp_config.h \ - $(TOP_SRCDIR)/zrtp_config_user.h \ - $(TOP_SRCDIR)/zrtp_config_unix.h \ - $(TOP_SRCDIR)/zrtp_crypto.h \ - $(TOP_SRCDIR)/zrtp_engine.h \ - $(TOP_SRCDIR)/zrtp_error.h \ - $(TOP_SRCDIR)/zrtp_iface.h \ - $(TOP_SRCDIR)/zrtp_iface_scheduler.h \ - $(TOP_SRCDIR)/zrtp_iface_cache.h \ - $(TOP_SRCDIR)/zrtp_iface_system.h \ - $(TOP_SRCDIR)/zrtp_legal.h \ - $(TOP_SRCDIR)/zrtp_list.h \ - $(TOP_SRCDIR)/zrtp_log.h \ - $(TOP_SRCDIR)/zrtp_pbx.h \ - $(TOP_SRCDIR)/zrtp_protocol.h \ - $(TOP_SRCDIR)/zrtp_srtp.h \ - $(TOP_SRCDIR)/zrtp_srtp_builtin.h \ - $(TOP_SRCDIR)/zrtp_string.h \ - $(TOP_SRCDIR)/zrtp_types.h \ - $(TOP_SRCDIR)/zrtp_version.h \ + $(top_srcdir)/include/zrtp.h \ + $(top_srcdir)/include/zrtp_base.h \ + $(top_srcdir)/include/zrtp_config.h \ + $(top_srcdir)/include/zrtp_config_user.h \ + $(top_srcdir)/include/zrtp_config_unix.h \ + $(top_srcdir)/include/zrtp_crypto.h \ + $(top_srcdir)/include/zrtp_engine.h \ + $(top_srcdir)/include/zrtp_error.h \ + $(top_srcdir)/include/zrtp_iface.h \ + $(top_srcdir)/include/zrtp_iface_scheduler.h \ + $(top_srcdir)/include/zrtp_iface_cache.h \ + $(top_srcdir)/include/zrtp_iface_system.h \ + $(top_srcdir)/include/zrtp_legal.h \ + $(top_srcdir)/include/zrtp_list.h \ + $(top_srcdir)/include/zrtp_log.h \ + $(top_srcdir)/include/zrtp_pbx.h \ + $(top_srcdir)/include/zrtp_protocol.h \ + $(top_srcdir)/include/zrtp_srtp.h \ + $(top_srcdir)/include/zrtp_srtp_builtin.h \ + $(top_srcdir)/include/zrtp_string.h \ + $(top_srcdir)/include/zrtp_types.h \ + $(top_srcdir)/include/zrtp_version.h \ \ - $(THIRD_DIR)/bnlib/bn.h \ + $(top_srcdir)/third_party/bnlib/bn.h \ \ - $(THIRD_DIR)/bgaes/aes.h \ - $(THIRD_DIR)/bgaes/aesopt.h \ - $(THIRD_DIR)/bgaes/aestab.h \ - $(THIRD_DIR)/bgaes/bg2zrtp.h \ - $(THIRD_DIR)/bgaes/brg_types.h \ - $(THIRD_DIR)/bgaes/sha1.h \ - $(THIRD_DIR)/bgaes/sha2.h + $(top_srcdir)/third_party/bgaes/aes.h \ + $(top_srcdir)/third_party/bgaes/aesopt.h \ + $(top_srcdir)/third_party/bgaes/aestab.h \ + $(top_srcdir)/third_party/bgaes/bg2zrtp.h \ + $(top_srcdir)/third_party/bgaes/brg_types.h \ + $(top_srcdir)/third_party/bgaes/sha1.h \ + $(top_srcdir)/third_party/bgaes/sha2.h if ZRTP_BUILD_ENTERPRISE -libzrtp_include_HEADERS += $(TOP_SRCDIR)/zrtp_ec.h +libzrtp_include_HEADERS += $(top_srcdir)/include/zrtp_ec.h endif SUBDIRS = third_party/bnlib @@ -62,3 +57,4 @@ endif uninstall: rm -rf $(prefix)/include/libzrtp rm -f $(prefix)/lib/libzrtp.a + diff --git a/libs/libzrtp/build/Makefile.am b/libs/libzrtp/build/Makefile.am index 4252e672ec..26a8e9ae41 100644 --- a/libs/libzrtp/build/Makefile.am +++ b/libs/libzrtp/build/Makefile.am @@ -5,52 +5,51 @@ # Viktor Krikun # -TOP_SRCDIR=$(top_srcdir) -INCLUDES = -I$(TOP_SRCDIR)/include \ - -I$(TOP_SRCDIR)/. \ - -I$(TOP_SRCDIR)/third_party/bgaes \ - -I$(TOP_SRCDIR)/third_party/bnlib +INCLUDES = -I$(top_srcdir)/include \ + -I$(top_srcdir)/. \ + -I$(top_srcdir)/third_party/bgaes \ + -I$(top_srcdir)/third_party/bnlib lib_LIBRARIES = libzrtp.a -libzrtp_a_LIBADD = $(TOP_SRCDIR)/third_party/bnlib/libbn.a +libzrtp_a_LIBADD = $(top_srcdir)/third_party/bnlib/libbn.a -libzrtp_a_SOURCES = $(TOP_SRCDIR)/src/zrtp.c \ - $(TOP_SRCDIR)/src/zrtp_crc.c \ - $(TOP_SRCDIR)/src/zrtp_crypto_aes.c \ - $(TOP_SRCDIR)/src/zrtp_crypto_atl.c \ - $(TOP_SRCDIR)/src/zrtp_crypto_hash.c \ - $(TOP_SRCDIR)/src/zrtp_crypto_pk.c \ - $(TOP_SRCDIR)/src/zrtp_crypto_sas.c \ - $(TOP_SRCDIR)/src/zrtp_datatypes.c \ - $(TOP_SRCDIR)/src/zrtp_engine.c \ - $(TOP_SRCDIR)/src/zrtp_iface_scheduler.c \ - $(TOP_SRCDIR)/src/zrtp_iface_sys.c \ - $(TOP_SRCDIR)/src/zrtp_initiator.c \ - $(TOP_SRCDIR)/src/zrtp_legal.c \ - $(TOP_SRCDIR)/src/zrtp_list.c \ - $(TOP_SRCDIR)/src/zrtp_log.c \ - $(TOP_SRCDIR)/src/zrtp_pbx.c \ - $(TOP_SRCDIR)/src/zrtp_protocol.c \ - $(TOP_SRCDIR)/src/zrtp_responder.c \ - $(TOP_SRCDIR)/src/zrtp_rng.c \ - $(TOP_SRCDIR)/src/zrtp_srtp_builtin.c \ - $(TOP_SRCDIR)/src/zrtp_string.c \ - $(TOP_SRCDIR)/src/zrtp_utils.c \ - $(TOP_SRCDIR)/src/zrtp_utils_proto.c \ +libzrtp_a_SOURCES = $(top_srcdir)/src/zrtp.c \ + $(top_srcdir)/src/zrtp_crc.c \ + $(top_srcdir)/src/zrtp_crypto_aes.c \ + $(top_srcdir)/src/zrtp_crypto_atl.c \ + $(top_srcdir)/src/zrtp_crypto_hash.c \ + $(top_srcdir)/src/zrtp_crypto_pk.c \ + $(top_srcdir)/src/zrtp_crypto_sas.c \ + $(top_srcdir)/src/zrtp_datatypes.c \ + $(top_srcdir)/src/zrtp_engine.c \ + $(top_srcdir)/src/zrtp_iface_scheduler.c \ + $(top_srcdir)/src/zrtp_iface_sys.c \ + $(top_srcdir)/src/zrtp_initiator.c \ + $(top_srcdir)/src/zrtp_legal.c \ + $(top_srcdir)/src/zrtp_list.c \ + $(top_srcdir)/src/zrtp_log.c \ + $(top_srcdir)/src/zrtp_pbx.c \ + $(top_srcdir)/src/zrtp_protocol.c \ + $(top_srcdir)/src/zrtp_responder.c \ + $(top_srcdir)/src/zrtp_rng.c \ + $(top_srcdir)/src/zrtp_srtp_builtin.c \ + $(top_srcdir)/src/zrtp_string.c \ + $(top_srcdir)/src/zrtp_utils.c \ + $(top_srcdir)/src/zrtp_utils_proto.c \ \ - $(TOP_SRCDIR)/third_party/bgaes/aes_modes.c \ - $(TOP_SRCDIR)/third_party/bgaes/aescrypt.c \ - $(TOP_SRCDIR)/third_party/bgaes/aeskey.c \ - $(TOP_SRCDIR)/third_party/bgaes/aestab.c \ - $(TOP_SRCDIR)/third_party/bgaes/sha1.c \ - $(TOP_SRCDIR)/third_party/bgaes/sha2.c\ + $(top_srcdir)/third_party/bgaes/aes_modes.c \ + $(top_srcdir)/third_party/bgaes/aescrypt.c \ + $(top_srcdir)/third_party/bgaes/aeskey.c \ + $(top_srcdir)/third_party/bgaes/aestab.c \ + $(top_srcdir)/third_party/bgaes/sha1.c \ + $(top_srcdir)/third_party/bgaes/sha2.c\ \ - $(TOP_SRCDIR)/src/zrtp_iface_cache.c \ - $(TOP_SRCDIR)/src/zrtp_engine_driven.c + $(top_srcdir)/src/zrtp_iface_cache.c + $(top_srcdir)/src/zrtp_engine_driven.c if ZRTP_BUILD_ENTERPRISE -libzrtp_a_SOURCES +=$(TOP_SRCDIR)/src/zrtp_crypto_ec.c \ - $(TOP_SRCDIR)/src/zrtp_crypto_ecdh.c +libzrtp_a_SOURCES +=$(top_srcdir)/src/zrtp_crypto_ec.c \ + $(top_srcdir)/src/zrtp_crypto_ecdh.c endif SUBDIRS = test diff --git a/libs/libzrtp/build/test/Makefile.am b/libs/libzrtp/build/test/Makefile.am index 4a9321c69f..7b4b148114 100644 --- a/libs/libzrtp/build/test/Makefile.am +++ b/libs/libzrtp/build/test/Makefile.am @@ -7,23 +7,22 @@ -TOP_SRCDIR=$(top_srcdir) -INCLUDES = -I$(TOP_SRCDIR)/include \ - -I$(TOP_SRCDIR)/include/enterprise \ - -I$(TOP_SRCDIR)/. \ - -I$(TOP_SRCDIR)/test \ - -I$(TOP_SRCDIR)/test/cmockery \ - -I$(TOP_SRCDIR)/third_party/bgaes \ - -I$(TOP_SRCDIR)/third_party/bnlib +INCLUDES = -I$(top_srcdir)/include \ + -I$(top_srcdir)/include/enterprise \ + -I$(top_srcdir)/. \ + -I$(top_srcdir)/test \ + -I$(top_srcdir)/test/cmockery \ + -I$(top_srcdir)/third_party/bgaes \ + -I$(top_srcdir)/third_party/bnlib check_PROGRAMS = cache_test ### ZRTP Cache testing -cache_test_SOURCES = $(TOP_SRCDIR)/test/cmockery/cmockery.c \ - $(TOP_SRCDIR)/test/cache_test.c -cache_test_LDADD = ../libzrtp.a $(TOP_SRCDIR)/third_party/bnlib/libbn.a -lpthread +cache_test_SOURCES = $(top_srcdir)/test/cmockery/cmockery.c \ + $(top_srcdir)/test/cache_test.c +cache_test_LDADD = ../libzrtp.a $(top_srcdir)/third_party/bnlib/libbn.a -lpthread SUBDIRS = . From e09a6a35797379a5d7be830741ab48ab1a22e45e Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Fri, 6 Jul 2012 23:18:59 +0000 Subject: [PATCH 40/49] Make libzrtp build non-recursive This eliminates the recursive makefiles for libzrtp (we still recurse to build bnlib). Object files, library files, and executables (including tests) are now produced in the root directory. --- libs/libzrtp/.gitignore | 6 ++- libs/libzrtp/Makefile.am | 62 ++++++++++++++++++++++++++++- libs/libzrtp/build/Makefile.am | 55 ------------------------- libs/libzrtp/build/test/Makefile.am | 46 --------------------- libs/libzrtp/configure.in | 2 +- 5 files changed, 67 insertions(+), 104 deletions(-) delete mode 100644 libs/libzrtp/build/Makefile.am delete mode 100644 libs/libzrtp/build/test/Makefile.am diff --git a/libs/libzrtp/.gitignore b/libs/libzrtp/.gitignore index 7510e5e64c..9f4002095f 100644 --- a/libs/libzrtp/.gitignore +++ b/libs/libzrtp/.gitignore @@ -1,5 +1,9 @@ # -*- mode:conf -*- +/*.a +/*.dat +/*.o /.cproject +/.deps /.project /.stamp-doc /Makefile @@ -7,7 +11,7 @@ /_configs.sed /aclocal.m4 /autom4te.cache/* -/build/ +/cache_test /config.* /config/* /configure diff --git a/libs/libzrtp/Makefile.am b/libs/libzrtp/Makefile.am index 22596c1e35..f42a72dbe9 100644 --- a/libs/libzrtp/Makefile.am +++ b/libs/libzrtp/Makefile.am @@ -44,8 +44,68 @@ if ZRTP_BUILD_ENTERPRISE libzrtp_include_HEADERS += $(top_srcdir)/include/zrtp_ec.h endif +lib_LIBRARIES = libzrtp.a + +libzrtp_a_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/. \ + -I$(top_srcdir)/third_party/bgaes \ + -I$(top_srcdir)/third_party/bnlib + +libzrtp_a_LIBADD = $(top_srcdir)/third_party/bnlib/libbn.a + +libzrtp_a_SOURCES = $(top_srcdir)/src/zrtp.c \ + $(top_srcdir)/src/zrtp_crc.c \ + $(top_srcdir)/src/zrtp_crypto_aes.c \ + $(top_srcdir)/src/zrtp_crypto_atl.c \ + $(top_srcdir)/src/zrtp_crypto_hash.c \ + $(top_srcdir)/src/zrtp_crypto_pk.c \ + $(top_srcdir)/src/zrtp_crypto_sas.c \ + $(top_srcdir)/src/zrtp_datatypes.c \ + $(top_srcdir)/src/zrtp_engine.c \ + $(top_srcdir)/src/zrtp_iface_scheduler.c \ + $(top_srcdir)/src/zrtp_iface_sys.c \ + $(top_srcdir)/src/zrtp_initiator.c \ + $(top_srcdir)/src/zrtp_legal.c \ + $(top_srcdir)/src/zrtp_list.c \ + $(top_srcdir)/src/zrtp_log.c \ + $(top_srcdir)/src/zrtp_pbx.c \ + $(top_srcdir)/src/zrtp_protocol.c \ + $(top_srcdir)/src/zrtp_responder.c \ + $(top_srcdir)/src/zrtp_rng.c \ + $(top_srcdir)/src/zrtp_srtp_builtin.c \ + $(top_srcdir)/src/zrtp_string.c \ + $(top_srcdir)/src/zrtp_utils.c \ + $(top_srcdir)/src/zrtp_utils_proto.c \ + \ + $(top_srcdir)/third_party/bgaes/aes_modes.c \ + $(top_srcdir)/third_party/bgaes/aescrypt.c \ + $(top_srcdir)/third_party/bgaes/aeskey.c \ + $(top_srcdir)/third_party/bgaes/aestab.c \ + $(top_srcdir)/third_party/bgaes/sha1.c \ + $(top_srcdir)/third_party/bgaes/sha2.c\ + \ + $(top_srcdir)/src/zrtp_iface_cache.c + $(top_srcdir)/src/zrtp_engine_driven.c +if ZRTP_BUILD_ENTERPRISE +libzrtp_a_SOURCES +=$(top_srcdir)/src/zrtp_crypto_ec.c \ + $(top_srcdir)/src/zrtp_crypto_ecdh.c +endif + +check_PROGRAMS = cache_test + +cache_test_CPPFLAGS = -I$(top_srcdir)/include \ + -I$(top_srcdir)/. \ + -I$(top_srcdir)/test \ + -I$(top_srcdir)/test/cmockery \ + -I$(top_srcdir)/third_party/bgaes \ + -I$(top_srcdir)/third_party/bnlib + +cache_test_SOURCES = $(top_srcdir)/test/cmockery/cmockery.c \ + $(top_srcdir)/test/cache_test.c +cache_test_LDADD = libzrtp.a $(top_srcdir)/third_party/bnlib/libbn.a -lpthread + SUBDIRS = third_party/bnlib -SUBDIRS += build if HAVE_DOXYGEN doc: .stamp-doc diff --git a/libs/libzrtp/build/Makefile.am b/libs/libzrtp/build/Makefile.am deleted file mode 100644 index 26a8e9ae41..0000000000 --- a/libs/libzrtp/build/Makefile.am +++ /dev/null @@ -1,55 +0,0 @@ -# -# Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. -# Contact: http://philzimmermann.com -# -# Viktor Krikun -# - -INCLUDES = -I$(top_srcdir)/include \ - -I$(top_srcdir)/. \ - -I$(top_srcdir)/third_party/bgaes \ - -I$(top_srcdir)/third_party/bnlib - -lib_LIBRARIES = libzrtp.a - -libzrtp_a_LIBADD = $(top_srcdir)/third_party/bnlib/libbn.a - -libzrtp_a_SOURCES = $(top_srcdir)/src/zrtp.c \ - $(top_srcdir)/src/zrtp_crc.c \ - $(top_srcdir)/src/zrtp_crypto_aes.c \ - $(top_srcdir)/src/zrtp_crypto_atl.c \ - $(top_srcdir)/src/zrtp_crypto_hash.c \ - $(top_srcdir)/src/zrtp_crypto_pk.c \ - $(top_srcdir)/src/zrtp_crypto_sas.c \ - $(top_srcdir)/src/zrtp_datatypes.c \ - $(top_srcdir)/src/zrtp_engine.c \ - $(top_srcdir)/src/zrtp_iface_scheduler.c \ - $(top_srcdir)/src/zrtp_iface_sys.c \ - $(top_srcdir)/src/zrtp_initiator.c \ - $(top_srcdir)/src/zrtp_legal.c \ - $(top_srcdir)/src/zrtp_list.c \ - $(top_srcdir)/src/zrtp_log.c \ - $(top_srcdir)/src/zrtp_pbx.c \ - $(top_srcdir)/src/zrtp_protocol.c \ - $(top_srcdir)/src/zrtp_responder.c \ - $(top_srcdir)/src/zrtp_rng.c \ - $(top_srcdir)/src/zrtp_srtp_builtin.c \ - $(top_srcdir)/src/zrtp_string.c \ - $(top_srcdir)/src/zrtp_utils.c \ - $(top_srcdir)/src/zrtp_utils_proto.c \ - \ - $(top_srcdir)/third_party/bgaes/aes_modes.c \ - $(top_srcdir)/third_party/bgaes/aescrypt.c \ - $(top_srcdir)/third_party/bgaes/aeskey.c \ - $(top_srcdir)/third_party/bgaes/aestab.c \ - $(top_srcdir)/third_party/bgaes/sha1.c \ - $(top_srcdir)/third_party/bgaes/sha2.c\ - \ - $(top_srcdir)/src/zrtp_iface_cache.c - $(top_srcdir)/src/zrtp_engine_driven.c -if ZRTP_BUILD_ENTERPRISE -libzrtp_a_SOURCES +=$(top_srcdir)/src/zrtp_crypto_ec.c \ - $(top_srcdir)/src/zrtp_crypto_ecdh.c -endif - -SUBDIRS = test diff --git a/libs/libzrtp/build/test/Makefile.am b/libs/libzrtp/build/test/Makefile.am deleted file mode 100644 index 7b4b148114..0000000000 --- a/libs/libzrtp/build/test/Makefile.am +++ /dev/null @@ -1,46 +0,0 @@ - -# Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. -# Contact: http://philzimmermann.com -# -# Viktor Krikun -# - - - -INCLUDES = -I$(top_srcdir)/include \ - -I$(top_srcdir)/include/enterprise \ - -I$(top_srcdir)/. \ - -I$(top_srcdir)/test \ - -I$(top_srcdir)/test/cmockery \ - -I$(top_srcdir)/third_party/bgaes \ - -I$(top_srcdir)/third_party/bnlib - - -check_PROGRAMS = cache_test - -### ZRTP Cache testing - -cache_test_SOURCES = $(top_srcdir)/test/cmockery/cmockery.c \ - $(top_srcdir)/test/cache_test.c -cache_test_LDADD = ../libzrtp.a $(top_srcdir)/third_party/bnlib/libbn.a -lpthread - - -SUBDIRS = . - -check: -# @ ./cache_test - -# check: -# @echo "" -# @echo "*========================================================================*" -# @echo "* starting libZRTP tests *" -# @echo "*========================================================================*" -# @echo "" -# @./libzrtp_test -# -# @echo "" -# @echo "*========================================================================*" -# @echo "* In case you have a test FAILED send the generated log file *" -# @echo "* with your comment to . *" -# @echo "*========================================================================*" -# @echo "" diff --git a/libs/libzrtp/configure.in b/libs/libzrtp/configure.in index eeb1e5d224..bbb2d5d751 100644 --- a/libs/libzrtp/configure.in +++ b/libs/libzrtp/configure.in @@ -105,4 +105,4 @@ AM_CONDITIONAL([HAVE_DOXYGEN], # # Genearte Makefiles -AC_OUTPUT([Makefile build/Makefile build/test/Makefile]) +AC_OUTPUT([Makefile]) From 85a35d67b19cc4e1ebbb5fbb31f48060e7cb71da Mon Sep 17 00:00:00 2001 From: Werner Dittmann Date: Mon, 25 Jun 2012 19:09:37 +0200 Subject: [PATCH 41/49] Prepend to LIBS rather than replacing Modified-by: Travis Cross --- libs/libzrtp/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/libzrtp/configure.in b/libs/libzrtp/configure.in index bbb2d5d751..d0a5a05661 100644 --- a/libs/libzrtp/configure.in +++ b/libs/libzrtp/configure.in @@ -78,7 +78,7 @@ AC_CHECK_FUNCS([pthread_mutex_lock pthread_mutex_unlock pthread_mutex_init pthre AC_CHECK_FUNCS([pthread_attr_init pthread_attr_setdetachstate pthread_create]) AC_CHECK_FUNCS([sem_wait sem_trywait sem_post sem_unlink sem_destroy sem_open sem_init]) -AC_CHECK_LIB([pthread], [main], [LIB_PTHREAD="-lpthread"], [echo " Couldn't find library pthread";]) +AC_CHECK_LIB([pthread], [main], [LIBS="-lpthread $LIBS"], [echo " Couldn't find library pthread";]) # Other AC_DEFINE(PRAGMA_PACK_PUSH,[#pragma pack(push, 1)],[Define pragma pack(push) for your platform]) From dcf7fff0f47f8f90fea03e0fe5c681099f41f13a Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Sat, 7 Jul 2012 18:57:24 +0000 Subject: [PATCH 42/49] Set default CFLAGS to catch more issues --- libs/libzrtp/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/libzrtp/configure.in b/libs/libzrtp/configure.in index d0a5a05661..c15ae7cd1c 100644 --- a/libs/libzrtp/configure.in +++ b/libs/libzrtp/configure.in @@ -35,7 +35,7 @@ esac AM_INIT_AUTOMAKE AX_PREFIX_CONFIG_H(include/zrtp_config_unix.h,ZRTP,config/config.h) -CFLAGS="$CFLAGS -Wno-unused-parameter -fno-strict-aliasing -fPIC -DZRTP_AUTOMAKE=1" +CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-parameter -fno-strict-aliasing -fPIC -DZRTP_AUTOMAKE=1" # Configuring external libraries echo "========================= configuring bnlib ==============================" From 25ca19218b1390019a6607da1c7c2b07c97ecefe Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Sat, 7 Jul 2012 18:57:55 +0000 Subject: [PATCH 43/49] Target C99 --- libs/libzrtp/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/libzrtp/configure.in b/libs/libzrtp/configure.in index c15ae7cd1c..b29c5c3211 100644 --- a/libs/libzrtp/configure.in +++ b/libs/libzrtp/configure.in @@ -35,7 +35,7 @@ esac AM_INIT_AUTOMAKE AX_PREFIX_CONFIG_H(include/zrtp_config_unix.h,ZRTP,config/config.h) -CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-parameter -fno-strict-aliasing -fPIC -DZRTP_AUTOMAKE=1" +CFLAGS="$CFLAGS -std=c99 -Wall -Wextra -Wno-unused-parameter -fno-strict-aliasing -fPIC -DZRTP_AUTOMAKE=1" # Configuring external libraries echo "========================= configuring bnlib ==============================" From b3cfc73e139497a9ceb38d372fe7f80b1ea1d888 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Sat, 7 Jul 2012 18:58:42 +0000 Subject: [PATCH 44/49] Include debugging symbols --- libs/libzrtp/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/libzrtp/configure.in b/libs/libzrtp/configure.in index b29c5c3211..10fe77ca5a 100644 --- a/libs/libzrtp/configure.in +++ b/libs/libzrtp/configure.in @@ -35,7 +35,7 @@ esac AM_INIT_AUTOMAKE AX_PREFIX_CONFIG_H(include/zrtp_config_unix.h,ZRTP,config/config.h) -CFLAGS="$CFLAGS -std=c99 -Wall -Wextra -Wno-unused-parameter -fno-strict-aliasing -fPIC -DZRTP_AUTOMAKE=1" +CFLAGS="$CFLAGS -std=c99 -g3 -Wall -Wextra -Wno-unused-parameter -fno-strict-aliasing -fPIC -DZRTP_AUTOMAKE=1" # Configuring external libraries echo "========================= configuring bnlib ==============================" From fafd8f337cf479b2eb1827ed61cdb087dfc4e1fc Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Sat, 7 Jul 2012 18:59:23 +0000 Subject: [PATCH 45/49] Optimize -O2 --- libs/libzrtp/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/libzrtp/configure.in b/libs/libzrtp/configure.in index 10fe77ca5a..1e637031c1 100644 --- a/libs/libzrtp/configure.in +++ b/libs/libzrtp/configure.in @@ -35,7 +35,7 @@ esac AM_INIT_AUTOMAKE AX_PREFIX_CONFIG_H(include/zrtp_config_unix.h,ZRTP,config/config.h) -CFLAGS="$CFLAGS -std=c99 -g3 -Wall -Wextra -Wno-unused-parameter -fno-strict-aliasing -fPIC -DZRTP_AUTOMAKE=1" +CFLAGS="$CFLAGS -std=c99 -O2 -g3 -Wall -Wextra -Wno-unused-parameter -fno-strict-aliasing -fPIC -DZRTP_AUTOMAKE=1" # Configuring external libraries echo "========================= configuring bnlib ==============================" From 8843819ce5179d9a03488e4d865b6b5c61858263 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Sun, 10 Feb 2013 21:54:15 +0000 Subject: [PATCH 46/49] Add back the elliptic curve (ECC) files Signed-off-by: Travis Cross Signed-off-by: Philip Zimmermann --- libs/libzrtp/include/zrtp_config_user.h | 2 +- libs/libzrtp/include/zrtp_ec.h | 89 +++ libs/libzrtp/projects/win/libzrtp.vcproj | 20 +- .../projects/win_ce/libzrtp_wince.vcproj | 28 +- .../projects/win_kernel/MAKEFILE.WIN32 | 11 +- .../projects/win_kernel/MAKEFILE.WIN64 | 11 +- libs/libzrtp/src/zrtp_crypto_ec.c | 469 +++++++++++++ libs/libzrtp/src/zrtp_crypto_ecdh.c | 567 +++++++++++++++ libs/libzrtp/src/zrtp_crypto_ecdsa.c | 646 ++++++++++++++++++ 9 files changed, 1828 insertions(+), 15 deletions(-) create mode 100644 libs/libzrtp/include/zrtp_ec.h create mode 100644 libs/libzrtp/src/zrtp_crypto_ec.c create mode 100644 libs/libzrtp/src/zrtp_crypto_ecdh.c create mode 100644 libs/libzrtp/src/zrtp_crypto_ecdsa.c diff --git a/libs/libzrtp/include/zrtp_config_user.h b/libs/libzrtp/include/zrtp_config_user.h index 352770eaa4..c87a6c790e 100644 --- a/libs/libzrtp/include/zrtp_config_user.h +++ b/libs/libzrtp/include/zrtp_config_user.h @@ -123,7 +123,7 @@ #endif #ifndef ZRTP_ENABLE_EC -#define ZRTP_ENABLE_EC 0 +#define ZRTP_ENABLE_EC 1 #endif #ifndef ZRTP_DEBUG_WITH_PJSIP diff --git a/libs/libzrtp/include/zrtp_ec.h b/libs/libzrtp/include/zrtp_ec.h new file mode 100644 index 0000000000..c4d2f712c6 --- /dev/null +++ b/libs/libzrtp/include/zrtp_ec.h @@ -0,0 +1,89 @@ +/* + * zrtp_crypto_ec.c - Elliptic Curve Low Level Crypto functions for ZRTP. + * NSA Suite B Elliptic Curves from NIST SP 800-56A and FIPS 186-3. + * + * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. + * This is NOT licensed under the GPL or any other open source license. + * For licensing terms or other information, + * contact: Philip Zimmermann . + * For more contact information, see http://philzimmermann.com + */ + +#ifndef __ZRTP_CRYPTO_EC_H__ +#define __ZRTP_CRYPTO_EC_H__ + +#include "bn.h" + +#include "zrtp_config.h" +#include "zrtp_types.h" +#include "zrtp_error.h" + +#if (defined(ZRTP_ENABLE_EC) && (ZRTP_ENABLE_EC == 1)) + +#define ZRTP_MAXECBITS 521 +#define ZRTP_MAXECWORDS ((ZRTP_MAXECBITS+7)/8) + +typedef struct zrtp_ec_params +{ + unsigned ec_bits; /* # EC bits: 256, 384, 521 */ + uint8_t P_data[ZRTP_MAXECWORDS]; /* curve field prime */ + uint8_t n_data[ZRTP_MAXECWORDS]; /* curve order (# points) */ + uint8_t b_data[ZRTP_MAXECWORDS]; /* curve param, y^3 = x^2 -3x + b */ + uint8_t Gx_data[ZRTP_MAXECWORDS]; /* curve point, x coordinate */ + uint8_t Gy_data[ZRTP_MAXECWORDS]; /* curve point, y coordinate */ +} zrtp_ec_params_t; + +#if defined(__cplusplus) +extern "C" +{ +#endif + +/*============================================================================*/ +/* Elliptic Curve library */ +/*============================================================================*/ + +int zrtp_ecAdd ( struct BigNum *rsltx, + struct BigNum *rslty, + struct BigNum *p1x, + struct BigNum *p1y, + struct BigNum *p2x, + struct BigNum *p2y, + struct BigNum *mod); + +int zrtp_ecMul ( struct BigNum *rsltx, + struct BigNum *rslty, + struct BigNum *mult, + struct BigNum *basex, + struct BigNum *basey, + struct BigNum *mod); + +zrtp_status_t zrtp_ec_random_point( zrtp_global_t *zrtp, + struct BigNum *P, + struct BigNum *n, + struct BigNum *Gx, + struct BigNum *Gy, + struct BigNum *pkx, + struct BigNum *pky, + struct BigNum *sv, + uint8_t *test_sv_data, + size_t test_sv_data_len); + +extern zrtp_status_t zrtp_ec_init_params(struct zrtp_ec_params *params, uint32_t bits ); + + +/* Useful bignum utility functions not defined in bignum library */ +int bnAddMod_ (struct BigNum *rslt, struct BigNum *n1, struct BigNum *mod); +int bnAddQMod_ (struct BigNum *rslt, unsigned n1, struct BigNum *mod); +int bnSubMod_ (struct BigNum *rslt, struct BigNum *n1, struct BigNum *mod); +int bnSubQMod_ (struct BigNum *rslt, unsigned n1, struct BigNum *mod); +int bnMulMod_ (struct BigNum *rslt, struct BigNum *n1, struct BigNum *n2, struct BigNum *mod); +int bnMulQMod_ (struct BigNum *rslt, struct BigNum *n1, unsigned n2, struct BigNum *mod); +int bnSquareMod_ (struct BigNum *rslt, struct BigNum *n1, struct BigNum *mod); + +#if defined(__cplusplus) +} +#endif + +#endif /*ZRTP_ENABLE_EC*/ + +#endif /* __ZRTP_CRYPTO_EC_H__ */ diff --git a/libs/libzrtp/projects/win/libzrtp.vcproj b/libs/libzrtp/projects/win/libzrtp.vcproj index 38fd62fbb4..485bd2f02d 100644 --- a/libs/libzrtp/projects/win/libzrtp.vcproj +++ b/libs/libzrtp/projects/win/libzrtp.vcproj @@ -43,7 +43,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="../../include;../../third_party/bnlib;../../third_party/bgaes;../../test/include" - PreprocessorDefinitions="WIN32;_DEBUG;_LIB;HAVE_CONFIG_H=1;ZRTP_ENABLE_EC=0" + PreprocessorDefinitions="WIN32;_DEBUG;_LIB;HAVE_CONFIG_H=1;ZRTP_ENABLE_EC=1" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -109,7 +109,7 @@ + + @@ -244,6 +248,10 @@ RelativePath="..\..\include\zrtp_utils.h" > + +
+ + + + diff --git a/libs/libzrtp/projects/win_ce/libzrtp_wince.vcproj b/libs/libzrtp/projects/win_ce/libzrtp_wince.vcproj index d16b5559d6..cbe4fb4389 100644 --- a/libs/libzrtp/projects/win_ce/libzrtp_wince.vcproj +++ b/libs/libzrtp/projects/win_ce/libzrtp_wince.vcproj @@ -52,7 +52,7 @@ ExecutionBucket="7" Optimization="0" AdditionalIncludeDirectories="../../third_party/bnlib;../../include;../../include/enterprise;../../third_party/bgaes;../../test/include" - PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;DEBUG;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE;ZRTP_ENABLE_EC=0" + PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;DEBUG;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE;ZRTP_ENABLE_EC=1" MinimalRebuild="true" RuntimeLibrary="1" StructMemberAlignment="0" @@ -136,7 +136,7 @@ ExecutionBucket="7" Optimization="0" AdditionalIncludeDirectories="../../third_party/bnlib;../../include;../../include/enterprise;../../third_party/bgaes;../../test/include" - PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;DEBUG;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;ZRTP_ENABLE_EC=0" + PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;DEBUG;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;ZRTP_ENABLE_EC=1" MinimalRebuild="true" RuntimeLibrary="1" BufferSecurityCheck="false" @@ -219,7 +219,7 @@ ExecutionBucket="7" Optimization="2" AdditionalIncludeDirectories="../../third_party/bnlib;../../include;../../include/enterprise;../../third_party/bgaes;../../test/include" - PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;ZRTP_ENABLE_EC=0" + PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;ZRTP_ENABLE_EC=1" RuntimeLibrary="0" BufferSecurityCheck="false" UsePrecompiledHeader="0" @@ -300,7 +300,7 @@ ExecutionBucket="7" Optimization="2" AdditionalIncludeDirectories="../../third_party/bnlib;../../include;../../include/enterprise;../../third_party/bgaes;../../test/include" - PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE;ZRTP_ENABLE_EC=0" + PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE;ZRTP_ENABLE_EC=1" RuntimeLibrary="0" BufferSecurityCheck="false" UsePrecompiledHeader="0" @@ -382,6 +382,10 @@ RelativePath="..\..\include\zrtp_crypto.h" > + + @@ -462,6 +466,18 @@ RelativePath="..\..\src\zrtp_crypto_atl.c" > + + + + + + @@ -482,6 +498,10 @@ RelativePath="..\..\src\zrtp_engine.c" > + + diff --git a/libs/libzrtp/projects/win_kernel/MAKEFILE.WIN32 b/libs/libzrtp/projects/win_kernel/MAKEFILE.WIN32 index e44b955933..2b15ded64a 100644 --- a/libs/libzrtp/projects/win_kernel/MAKEFILE.WIN32 +++ b/libs/libzrtp/projects/win_kernel/MAKEFILE.WIN32 @@ -43,6 +43,9 @@ protocol = \ ../../src/zrtp_crypto_sas.obj \ ../../src/zrtp_datatypes.obj \ ../../src/zrtp_engine.obj \ + ../../src/enterprise/zrtp_engine_driven.obj \ + ../../src/enterprise/zrtp_crypto_ec.obj \ + ../../src/enterprise/zrtp_crypto_ecdh.obj \ ../../src/zrtp_iface_sys.obj \ ../../src/zrtp_initiator.obj \ ../../src/zrtp_legal.obj \ @@ -71,13 +74,13 @@ OBJECTS = $(bnlib) $(protocol) $(bgaes) # Debug -OUT_DIR = debug.km +OUT_DIR = debug_ec.km DEFINES_D = -D_X86_=1 -Di386=1 -DSTD_CALL -DCONDITION_HANDLING=1 \ -DNT_UP=1 -DNT_INST=0 -DWIN32=100 -D_NT1X_=100 \ -DWINNT=1 -D_WIN32_WINNT=0x0500 -DWIN32_LEAN_AND_MEAN=1 -DDBG=1 -D_DEBUG -DDEBUG -DDEVL=1 \ -DFPO=0 -D_DLL=1 -D_IDWBUILD -DRDRDBG -DSRVDBG -DDBG_MESSAGES=1 \ --D_UNICODE -DLITTLE_ENDIAN -DZRTP_USE_ENTERPRISE=0 +-D_UNICODE -DLITTLE_ENDIAN -DZRTP_USE_ENTERPRISE=1 CFLAGS_D = $(DEFINES_D) -Zel -Zp8 -Gy -cbstring -Gz -QIfdiv- -QIf -Gi- -Gm- -GX- \ -GR- -GF -FI$(DDK)\inc\$(OS)\warning.h -Z7 -Od -Oi -Oy- -W3 @@ -86,13 +89,13 @@ CFLAGS_D = $(DEFINES_D) -Zel -Zp8 -Gy -cbstring -Gz -QIfdiv- -QIf -Gi- -Gm- -GX- # Release -OUT_DIR = release.km +OUT_DIR = release_ec.km DEFINES_D = -D_X86_=1 -Di386=1 -DSTD_CALL -DCONDITION_HANDLING=1 \ -DNT_UP=1 -DNO_DISK_ACCESS -DNT_INST=0 -DWIN32=100 -D_NT1X_=100 \ -DWINNT=1 -D_WIN32_WINNT=0x0500 -DWIN32_LEAN_AND_MEAN=1 -DDEVL=1 \ -DFPO=1 -DNDEBUG -D_DLL=1 -D_IDWBUILD -D_UNICODE \ --DLITTLE_ENDIAN -DZRTP_USE_ENTERPRISE=0 +-DLITTLE_ENDIAN -DZRTP_USE_ENTERPRISE=1 CFLAGS_D = $(DEFINES_D) -Zel -Zp8 -Gy -cbstring -Gz -QIfdiv- -QIf -Gi- -Gm- -GX- \ -GR- -GF -Oxs -Oy -FI$(DDK)\inc\$(OS)\warning.h -W3 -FAcs -Z7 diff --git a/libs/libzrtp/projects/win_kernel/MAKEFILE.WIN64 b/libs/libzrtp/projects/win_kernel/MAKEFILE.WIN64 index 52a1cb7e4d..ccc2a73a17 100644 --- a/libs/libzrtp/projects/win_kernel/MAKEFILE.WIN64 +++ b/libs/libzrtp/projects/win_kernel/MAKEFILE.WIN64 @@ -44,6 +44,9 @@ protocol = \ ../../src/zrtp_crypto_sas.obj \ ../../src/zrtp_datatypes.obj \ ../../src/zrtp_engine.obj \ + ../../src/enterprise/zrtp_engine_driven.obj \ + ../../src/enterprise/zrtp_crypto_ec.obj \ + ../../src/enterprise/zrtp_crypto_ecdh.obj \ ../../src/zrtp_iface_sys.obj \ ../../src/zrtp_initiator.obj \ ../../src/zrtp_legal.obj \ @@ -72,14 +75,14 @@ OBJECTS = $(bnlib) $(protocol) $(bgaes) # Debug -OUT_DIR = debug64.km +OUT_DIR = debug64_ec.km DEFINES_D = -DWIN64=1 -D_WIN64=1 -D_AMD64_=1 -D_M_AMD64 -D_WINDOWS \ -DSTD_CALL -DCONDITION_HANDLING=1 \ -DNT_UP=1 -DNT_INST=0 -D_NT1X_=100 \ -DWINNT=1 -D_WIN32_WINNT=0x0500 -DWIN32_LEAN_AND_MEAN=1 -DDBG=1 -D_DEBUG -DDEBUG -DDEVL=1 \ -DFPO=0 -D_DLL=1 -D_IDWBUILD -DRDRDBG -DSRVDBG -DDBG_MESSAGES=1 \ --D_UNICODE -DLITTLE_ENDIAN -DZRTP_USE_ENTERPRISE=0 +-D_UNICODE -DLITTLE_ENDIAN -DZRTP_USE_ENTERPRISE=1 CFLAGS_D = $(DEFINES_D) -Zp8 -Gy -cbstring -Gz -Gm- -EHs-c- \ -GR- -GF -FI$(DDK)\inc\$(OS)\warning.h -Z7 -Od -Oi -Oy- -W3 @@ -88,14 +91,14 @@ CFLAGS_D = $(DEFINES_D) -Zp8 -Gy -cbstring -Gz -Gm- -EHs-c- \ # Release -OUT_DIR = release64.km +OUT_DIR = release64_ec.km DEFINES_D = -DWIN64=1 -D_WIN64=1 -D_AMD64_=1 -D_M_AMD64 -D_WINDOWS \ -DSTD_CALL -DCONDITION_HANDLING=1 \ -DNT_UP=1 -DNO_DISK_ACCESS -DNT_INST=0 -DWIN32=100 -D_NT1X_=100 \ -DWINNT=1 -D_WIN32_WINNT=0x0500 -DWIN32_LEAN_AND_MEAN=1 -DDEVL=1 \ -DFPO=1 -DNDEBUG -D_DLL=1 -D_IDWBUILD -D_UNICODE \ --DLITTLE_ENDIAN -DZRTP_USE_ENTERPRISE=0 +-DLITTLE_ENDIAN -DZRTP_USE_ENTERPRISE=1 CFLAGS_D = $(DEFINES_D) -Zel -Zp8 -Gy -cbstring -Gz -QIfdiv- -QIf -Gi- -Gm- -GX- \ -GR- -GF -Oxs -Oy -FI$(DDK)\inc\$(OS)\warning.h -W3 -FAcs -Z7 diff --git a/libs/libzrtp/src/zrtp_crypto_ec.c b/libs/libzrtp/src/zrtp_crypto_ec.c new file mode 100644 index 0000000000..818081c74d --- /dev/null +++ b/libs/libzrtp/src/zrtp_crypto_ec.c @@ -0,0 +1,469 @@ +/* + * zrtp_crypto_ec.c - Elliptic Curve Low Level Crypto functions for ZRTP. + * NSA Suite B Elliptic Curves from NIST SP 800-56A and FIPS 186-3. + * + * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. + * This is NOT licensed under the GPL or any other open source license. + * For licensing terms or other information, + * contact: Philip Zimmermann . + * For more contact information, see http://philzimmermann.com + */ + +#include "zrtp.h" + +#if (defined(ZRTP_ENABLE_EC) && (ZRTP_ENABLE_EC == 1)) + +/* Size of extra random data to approximate a uniform distribution mod n */ +#define UNIFORMBYTES 8 + + +/*============================================================================*/ +/* Bignum Shorthand Functions */ +/*============================================================================*/ + +int bnAddMod_ (struct BigNum *rslt, struct BigNum *n1, struct BigNum *mod) +{ + bnAdd (rslt, n1); + if (bnCmp (rslt, mod) >= 0) { + bnSub (rslt, mod); + } + return 0; +} + +int bnAddQMod_ (struct BigNum *rslt, unsigned n1, struct BigNum *mod) +{ + bnAddQ (rslt, n1); + if (bnCmp (rslt, mod) >= 0) { + bnSub (rslt, mod); + } + return 0; +} + +int bnSubMod_ (struct BigNum *rslt, struct BigNum *n1, struct BigNum *mod) +{ + if (bnCmp (rslt, n1) < 0) { + bnAdd (rslt, mod); + } + bnSub (rslt, n1); + return 0; +} + +int bnSubQMod_ (struct BigNum *rslt, unsigned n1, struct BigNum *mod) +{ + if (bnCmpQ (rslt, n1) < 0) { + bnAdd (rslt, mod); + } + bnSubQ (rslt, n1); + return 0; +} + +int bnMulMod_ (struct BigNum *rslt, struct BigNum *n1, struct BigNum *n2, struct BigNum *mod) +{ + bnMul (rslt, n1, n2); + bnMod (rslt, rslt, mod); + return 0; +} + +int bnMulQMod_ (struct BigNum *rslt, struct BigNum *n1, unsigned n2, struct BigNum *mod) +{ + bnMulQ (rslt, n1, n2); + bnMod (rslt, rslt, mod); + return 0; +} + +int bnSquareMod_ (struct BigNum *rslt, struct BigNum *n1, struct BigNum *mod) +{ + bnSquare (rslt, n1); + bnMod (rslt, rslt, mod); + return 0; +} + + +/*============================================================================*/ +/* Elliptic Curve arithmetic */ +/*============================================================================*/ + +/* Add two elliptic curve points. Any of them may be the same object. */ +int zrtp_ecAdd ( struct BigNum *rsltx, struct BigNum *rslty, + struct BigNum *p1x, struct BigNum *p1y, + struct BigNum *p2x, struct BigNum *p2y, struct BigNum *mod) +{ + struct BigNum trsltx, trslty; + struct BigNum t1, gam; + struct BigNum bnzero; + + bnBegin (&bnzero); + + /* Check for an operand being zero */ + if (bnCmp (p1x, &bnzero) == 0 && bnCmp (p1y, &bnzero) == 0) { + bnCopy (rsltx, p2x); bnCopy (rslty, p2y); + bnEnd (&bnzero); + return 0; + } + if (bnCmp (p2x, &bnzero) == 0 && bnCmp (p2y, &bnzero) == 0) { + bnCopy (rsltx, p1x); bnCopy (rslty, p1y); + bnEnd (&bnzero); + return 0; + } + + /* Check if p1 == -p2 and return 0 if so */ + if (bnCmp (p1x, p2x) == 0) { + struct BigNum tsum; + bnBegin (&tsum); + bnCopy (&tsum, p1x); + bnAddMod_ (&tsum, p2x, mod); + if (bnCmp (&tsum, &bnzero) == 0) { + bnSetQ (rsltx, 0); bnSetQ (rslty, 0); + bnEnd (&tsum); + bnEnd (&bnzero); + return 0; + } + bnEnd (&tsum); + } + + bnBegin (&t1); + bnBegin (&gam); + bnBegin (&trsltx); + bnBegin (&trslty); + + /* Check for doubling, different formula for gamma */ + if (bnCmp (p1x, p2x) == 0 && bnCmp (p1y, p2y) == 0) { + bnCopy (&t1, p1y); + bnAddMod_ (&t1, p1y, mod); + bnInv (&t1, &t1, mod); + bnSquareMod_ (&gam, p1x, mod); + bnMulQMod_ (&gam, &gam, 3, mod); + bnSubQMod_ (&gam, 3, mod); + bnMulMod_ (&gam, &gam, &t1, mod); + } else { + bnCopy (&t1, p2x); + bnSubMod_ (&t1, p1x, mod); + bnInv (&t1, &t1, mod); + bnCopy (&gam, p2y); + bnSubMod_ (&gam, p1y, mod); + bnMulMod_ (&gam, &gam, &t1, mod); + } + + bnSquareMod_ (&trsltx, &gam, mod); + bnSubMod_ (&trsltx, p1x, mod); + bnSubMod_ (&trsltx, p2x, mod); + + bnCopy (&trslty, p1x); + bnSubMod_ (&trslty, &trsltx, mod); + bnMulMod_ (&trslty, &trslty, &gam, mod); + bnSubMod_ (&trslty, p1y, mod); + + bnCopy (rsltx, &trsltx); + bnCopy (rslty, &trslty); + + bnEnd (&t1); + bnEnd (&gam); + bnEnd (&trsltx); + bnEnd (&trslty); + bnEnd (&bnzero); + + return 0; +} + +int zrtp_ecMul ( struct BigNum *rsltx, struct BigNum *rslty, struct BigNum *mult, + struct BigNum *basex, struct BigNum *basey, struct BigNum *mod) +{ + struct BigNum bnzero; + struct BigNum tbasex, tbasey; + struct BigNum trsltx, trslty; + struct BigNum tmult; + + bnBegin (&bnzero); + bnBegin (&tbasex); + bnBegin (&tbasey); + bnBegin (&trsltx); + bnBegin (&trslty); + bnBegin (&tmult); + + /* Initialize result to 0 before additions */ + bnSetQ (&trsltx, 0); + bnSetQ (&trslty, 0); + /* Make copies of base and multiplier */ + bnCopy (&tbasex, basex); + bnCopy (&tbasey, basey); + bnCopy (&tmult, mult); + while (bnCmp (&tmult, &bnzero) > 0) { + /* Test lsb of mult */ + unsigned lsw = bnLSWord (&tmult); + if (lsw & 1) { + /* Add base to result */ + zrtp_ecAdd (&trsltx, &trslty, &trsltx, &trslty, &tbasex, &tbasey, mod); + } + /* Double the base */ + zrtp_ecAdd (&tbasex, &tbasey, &tbasex, &tbasey, &tbasex, &tbasey, mod); + /* Shift multiplier right */ + bnRShift (&tmult, 1); + } + + bnCopy (rsltx, &trsltx); + bnCopy (rslty, &trslty); + + bnEnd (&bnzero); + bnEnd (&tbasex); + bnEnd (&tbasey); + bnEnd (&trsltx); + bnEnd (&trslty); + bnEnd (&tmult); + return 0; +} + + + +/*----------------------------------------------------------------------------*/ +/* Choose a random point on the elliptic curve. */ +/* Provision is made to use a given point from test vectors. */ +/* pkx and pky are the output point, sv is output discrete log */ +/* Input base is Gx, Gy; curve field modulus is P; curve order is n. */ +/*----------------------------------------------------------------------------*/ +zrtp_status_t zrtp_ec_random_point( zrtp_global_t *zrtp, + struct BigNum *P, + struct BigNum *n, + struct BigNum *Gx, + struct BigNum *Gy, + struct BigNum *pkx, + struct BigNum *pky, + struct BigNum *sv, + uint8_t *test_sv_data, + size_t test_sv_data_len) +{ + zrtp_status_t s = zrtp_status_fail; + unsigned char* buffer = zrtp_sys_alloc(sizeof(zrtp_uchar1024_t)); + + if (!buffer) { + return zrtp_status_alloc_fail; + } + zrtp_memset(buffer, 0, sizeof(zrtp_uchar1024_t)); + + do + { + if (test_sv_data_len != 0) { + /* Force certain secret value */ + if (bnBytes(P) != test_sv_data_len) { + break; + } + zrtp_memcpy(buffer+UNIFORMBYTES, test_sv_data, test_sv_data_len); + } else { + /* Choose random value, larger than needed so it will be uniform */ + if (bnBytes(P)+UNIFORMBYTES != (uint32_t)zrtp_randstr(zrtp, buffer, bnBytes(P)+UNIFORMBYTES)) { + break; /* if we can't generate random string - fail initialization */ + } + } + + bnInsertBigBytes(sv, (const unsigned char *)buffer, 0, bnBytes(P)+UNIFORMBYTES); + bnMod(sv, sv, n); + zrtp_ecMul(pkx, pky, sv, Gx, Gy, P); + + s = zrtp_status_ok; + } while (0); + + if (buffer) { + zrtp_sys_free(buffer); + } + + return s; +} + + +/*============================================================================*/ +/* Curve parameters */ +/*============================================================================*/ + +uint8_t P_256_data[] = +{ + 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +uint8_t n_256_data[] = +{ + 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xBC, 0xE6, 0xFA, 0xAD, 0xA7, 0x17, 0x9E, 0x84, + 0xF3, 0xB9, 0xCA, 0xC2, 0xFC, 0x63, 0x25, 0x51 +}; + +uint8_t b_256_data[] = +{ + 0x5a, 0xc6, 0x35, 0xd8, 0xaa, 0x3a, 0x93, 0xe7, + 0xb3, 0xeb, 0xbd, 0x55, 0x76, 0x98, 0x86, 0xbc, + 0x65, 0x1d, 0x06, 0xb0, 0xcc, 0x53, 0xb0, 0xf6, + 0x3b, 0xce, 0x3c, 0x3e, 0x27, 0xd2, 0x60, 0x4b +}; + +uint8_t Gx_256_data[] = +{ + 0x6b, 0x17, 0xd1, 0xf2, 0xe1, 0x2c, 0x42, 0x47, + 0xf8, 0xbc, 0xe6, 0xe5, 0x63, 0xa4, 0x40, 0xf2, + 0x77, 0x03, 0x7d, 0x81, 0x2d, 0xeb, 0x33, 0xa0, + 0xf4, 0xa1, 0x39, 0x45, 0xd8, 0x98, 0xc2, 0x96 +}; + +uint8_t Gy_256_data[] = +{ + 0x4f, 0xe3, 0x42, 0xe2, 0xfe, 0x1a, 0x7f, 0x9b, + 0x8e, 0xe7, 0xeb, 0x4a, 0x7c, 0x0f, 0x9e, 0x16, + 0x2b, 0xce, 0x33, 0x57, 0x6b, 0x31, 0x5e, 0xce, + 0xcb, 0xb6, 0x40, 0x68, 0x37, 0xbf, 0x51, 0xf5 +}; + + + +uint8_t P_384_data[] = +{ + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, + 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF +}; + +uint8_t n_384_data[] = +{ + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xC7, 0x63, 0x4D, 0x81, 0xF4, 0x37, 0x2D, 0xDF, + 0x58, 0x1A, 0x0D, 0xB2, 0x48, 0xB0, 0xA7, 0x7A, + 0xEC, 0xEC, 0x19, 0x6A, 0xCC, 0xC5, 0x29, 0x73 +}; + +uint8_t b_384_data[] = +{ + 0xb3, 0x31, 0x2f, 0xa7, 0xe2, 0x3e, 0xe7, 0xe4, + 0x98, 0x8e, 0x05, 0x6b, 0xe3, 0xf8, 0x2d, 0x19, + 0x18, 0x1d, 0x9c, 0x6e, 0xfe, 0x81, 0x41, 0x12, + 0x03, 0x14, 0x08, 0x8f, 0x50, 0x13, 0x87, 0x5a, + 0xc6, 0x56, 0x39, 0x8d, 0x8a, 0x2e, 0xd1, 0x9d, + 0x2a, 0x85, 0xc8, 0xed, 0xd3, 0xec, 0x2a, 0xef +}; + +uint8_t Gx_384_data[] = +{ + 0xaa, 0x87, 0xca, 0x22, 0xbe, 0x8b, 0x05, 0x37, + 0x8e, 0xb1, 0xc7, 0x1e, 0xf3, 0x20, 0xad, 0x74, + 0x6e, 0x1d, 0x3b, 0x62, 0x8b, 0xa7, 0x9b, 0x98, + 0x59, 0xf7, 0x41, 0xe0, 0x82, 0x54, 0x2a, 0x38, + 0x55, 0x02, 0xf2, 0x5d, 0xbf, 0x55, 0x29, 0x6c, + 0x3a, 0x54, 0x5e, 0x38, 0x72, 0x76, 0x0a, 0xb7 +}; + +uint8_t Gy_384_data[] = +{ + 0x36, 0x17, 0xde, 0x4a, 0x96, 0x26, 0x2c, 0x6f, + 0x5d, 0x9e, 0x98, 0xbf, 0x92, 0x92, 0xdc, 0x29, + 0xf8, 0xf4, 0x1d, 0xbd, 0x28, 0x9a, 0x14, 0x7c, + 0xe9, 0xda, 0x31, 0x13, 0xb5, 0xf0, 0xb8, 0xc0, + 0x0a, 0x60, 0xb1, 0xce, 0x1d, 0x7e, 0x81, 0x9d, + 0x7a, 0x43, 0x1d, 0x7c, 0x90, 0xea, 0x0e, 0x5f +}; + + +uint8_t P_521_data[] = +{ + 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF +}; + +uint8_t n_521_data[] = +{ + 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFA, 0x51, 0x86, 0x87, 0x83, 0xBF, 0x2F, + 0x96, 0x6B, 0x7F, 0xCC, 0x01, 0x48, 0xF7, 0x09, + 0xA5, 0xD0, 0x3B, 0xB5, 0xC9, 0xB8, 0x89, 0x9C, + 0x47, 0xAE, 0xBB, 0x6F, 0xB7, 0x1E, 0x91, 0x38, + 0x64, 0x09 +}; + +uint8_t b_521_data[] = +{ + 0x00, 0x51, 0x95, 0x3e, 0xb9, 0x61, 0x8e, 0x1c, + 0x9a, 0x1f, 0x92, 0x9a, 0x21, 0xa0, 0xb6, 0x85, + 0x40, 0xee, 0xa2, 0xda, 0x72, 0x5b, 0x99, 0xb3, + 0x15, 0xf3, 0xb8, 0xb4, 0x89, 0x91, 0x8e, 0xf1, + 0x09, 0xe1, 0x56, 0x19, 0x39, 0x51, 0xec, 0x7e, + 0x93, 0x7b, 0x16, 0x52, 0xc0, 0xbd, 0x3b, 0xb1, + 0xbf, 0x07, 0x35, 0x73, 0xdf, 0x88, 0x3d, 0x2c, + 0x34, 0xf1, 0xef, 0x45, 0x1f, 0xd4, 0x6b, 0x50, + 0x3f, 0x00 +}; + +uint8_t Gx_521_data[] = +{ + 0x00, 0xc6, 0x85, 0x8e, 0x06, 0xb7, 0x04, 0x04, + 0xe9, 0xcd, 0x9e, 0x3e, 0xcb, 0x66, 0x23, 0x95, + 0xb4, 0x42, 0x9c, 0x64, 0x81, 0x39, 0x05, 0x3f, + 0xb5, 0x21, 0xf8, 0x28, 0xaf, 0x60, 0x6b, 0x4d, + 0x3d, 0xba, 0xa1, 0x4b, 0x5e, 0x77, 0xef, 0xe7, + 0x59, 0x28, 0xfe, 0x1d, 0xc1, 0x27, 0xa2, 0xff, + 0xa8, 0xde, 0x33, 0x48, 0xb3, 0xc1, 0x85, 0x6a, + 0x42, 0x9b, 0xf9, 0x7e, 0x7e, 0x31, 0xc2, 0xe5, + 0xbd, 0x66 +}; + +uint8_t Gy_521_data[] = +{ + 0x01, 0x18, 0x39, 0x29, 0x6a, 0x78, 0x9a, 0x3b, + 0xc0, 0x04, 0x5c, 0x8a, 0x5f, 0xb4, 0x2c, 0x7d, + 0x1b, 0xd9, 0x98, 0xf5, 0x44, 0x49, 0x57, 0x9b, + 0x44, 0x68, 0x17, 0xaf, 0xbd, 0x17, 0x27, 0x3e, + 0x66, 0x2c, 0x97, 0xee, 0x72, 0x99, 0x5e, 0xf4, + 0x26, 0x40, 0xc5, 0x50, 0xb9, 0x01, 0x3f, 0xad, + 0x07, 0x61, 0x35, 0x3c, 0x70, 0x86, 0xa2, 0x72, + 0xc2, 0x40, 0x88, 0xbe, 0x94, 0x76, 0x9f, 0xd1, + 0x66, 0x50 +}; + +/*----------------------------------------------------------------------------*/ +/* Initialize the curve parameters struct */ +zrtp_status_t zrtp_ec_init_params( struct zrtp_ec_params *params, uint32_t bits ) +{ + unsigned ec_bytes = (bits+7) / 8; + params->ec_bits = bits; + switch (bits) { + case 256: + zrtp_memcpy (params->P_data, P_256_data, ec_bytes); + zrtp_memcpy (params->n_data, n_256_data, ec_bytes); + zrtp_memcpy (params->b_data, b_256_data, ec_bytes); + zrtp_memcpy (params->Gx_data, Gx_256_data, ec_bytes); + zrtp_memcpy (params->Gy_data, Gy_256_data, ec_bytes); + break; + case 384: + zrtp_memcpy (params->P_data, P_384_data, ec_bytes); + zrtp_memcpy (params->n_data, n_384_data, ec_bytes); + zrtp_memcpy (params->b_data, b_384_data, ec_bytes); + zrtp_memcpy (params->Gx_data, Gx_384_data, ec_bytes); + zrtp_memcpy (params->Gy_data, Gy_384_data, ec_bytes); + break; + case 521: + zrtp_memcpy (params->P_data, P_521_data, ec_bytes); + zrtp_memcpy (params->n_data, n_521_data, ec_bytes); + zrtp_memcpy (params->b_data, b_521_data, ec_bytes); + zrtp_memcpy (params->Gx_data, Gx_521_data, ec_bytes); + zrtp_memcpy (params->Gy_data, Gy_521_data, ec_bytes); + break; + default: + return zrtp_status_bad_param; + } + + return zrtp_status_ok; +} + +#endif /*ZRTP_ENABLE_EC*/ diff --git a/libs/libzrtp/src/zrtp_crypto_ecdh.c b/libs/libzrtp/src/zrtp_crypto_ecdh.c new file mode 100644 index 0000000000..b78ecb1439 --- /dev/null +++ b/libs/libzrtp/src/zrtp_crypto_ecdh.c @@ -0,0 +1,567 @@ +/* + * zrtp_crypto_ecdh.c - Elliptic Curve Diffie Hellman functions for ZRTP. + * NSA Suite B Elliptic Curves from NIST SP 800-56A and FIPS 186-3. + * + * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. + * This is NOT licensed under the GPL or any other open source license. + * For licensing terms or other information, + * contact: Philip Zimmermann . + * For more contact information, see http://philzimmermann.com + */ + +#include "zrtp.h" + + +#if (defined(ZRTP_ENABLE_EC) && (ZRTP_ENABLE_EC == 1)) + +#define _ZTU_ "zrtp ecdh" + +static unsigned get_pbits(zrtp_pk_scheme_t *self) +{ + switch (self->base.id) { + case ZRTP_PKTYPE_EC256P: + return 256; + break; + case ZRTP_PKTYPE_EC384P: + return 384; + break; + case ZRTP_PKTYPE_EC521P: + return 521; + break; + default: + return 0; + } +} + +/*============================================================================*/ +/* Shared Elliptic Curve functions */ +/* */ +/* The Elliptic Curve DH algorithm and key generation is from */ +/* NIST SP 800-56A. The curves used are from NSA Suite B, which */ +/* uses the same curves as ECDSA defined by FIPS 186-3, and are */ +/* also defined in RFC 4753, sections 3.1 through 3.3. */ +/* The validation procedures are from NIST SP 800-56A section 5.6.2.6, */ +/* method 3, ECC Partial Validation. */ +/*============================================================================*/ + + +/*----------------------------------------------------------------------------*/ +static zrtp_status_t zrtp_ecdh_init(void *s) { + return zrtp_status_ok; +} + +static zrtp_status_t zrtp_ecdh_free(void *s) { + return zrtp_status_ok; +} + + +/*----------------------------------------------------------------------------*/ +/* Return dh_cc->pv holding public value and dh_cc->sv holding secret value */ +/* The public value is an elliptic curve point encoded as the x part shifted */ +/* left Pbits bits and or'd with the y part. */ +/*----------------------------------------------------------------------------*/ +static zrtp_status_t zrtp_ecdh_initialize( zrtp_pk_scheme_t *self, + zrtp_dh_crypto_context_t *dh_cc) +{ + zrtp_status_t s = zrtp_status_fail; + struct BigNum P, Gx, Gy, n; + struct BigNum pkx, pky; + unsigned ec_bytes = 0; + unsigned pbits = 0; + struct zrtp_ec_params ec_params; + zrtp_time_t start_ts = zrtp_time_now(); + + if (!self || !dh_cc) { + return zrtp_status_bad_param; + } + + pbits = get_pbits(self); + if (!pbits) { + return zrtp_status_bad_param; + } + + zrtp_ec_init_params(&ec_params, pbits); + + ec_bytes = (ec_params.ec_bits+7) / 8; + + bnBegin(&P); + bnInsertBigBytes(&P, ec_params.P_data, 0, ec_bytes ); + bnBegin(&Gx); + bnInsertBigBytes(&Gx, ec_params.Gx_data, 0, ec_bytes ); + bnBegin(&Gy); + bnInsertBigBytes(&Gy, ec_params.Gy_data, 0, ec_bytes ); + bnBegin(&n); + bnInsertBigBytes(&n, ec_params.n_data, 0, ec_bytes ); + + bnBegin(&pkx); + bnBegin(&pky); + bnBegin(&dh_cc->sv); + s = zrtp_ec_random_point( self->base.zrtp, &P, &n, &Gx, &Gy, + &pkx, &pky, &dh_cc->sv, + NULL, 0); + + if (zrtp_status_ok == s) + { + bnBegin(&dh_cc->pv); + bnCopy (&dh_cc->pv, &pkx); + bnLShift (&dh_cc->pv, pbits); + bnAdd (&dh_cc->pv, &pky); + } + + bnEnd (&pkx); + bnEnd (&pky); + bnEnd (&P); + bnEnd (&Gx); + bnEnd (&Gy); + bnEnd (&n); + + ZRTP_LOG(1,(_ZTU_,"\tDH TEST: zrtp_ecdh_initialize() for %.4s was executed by %llums.\n", self->base.type, zrtp_time_now()-start_ts)); + return s; +} + + +/*----------------------------------------------------------------------------*/ +/* Compute the shared dhresult as the X coordinate of the EC point. */ +/*----------------------------------------------------------------------------*/ +static zrtp_status_t zrtp_ecdh_compute( zrtp_pk_scheme_t *self, + zrtp_dh_crypto_context_t *dh_cc, + struct BigNum *dhresult, + struct BigNum *pv) +{ + struct BigNum P; + struct BigNum pkx, pky, rsltx, rslty; + unsigned ec_bytes = 0; + unsigned pbits = 0; + struct zrtp_ec_params ec_params; + zrtp_time_t start_ts = zrtp_time_now(); + + if (!self || !dh_cc || !dhresult || !pv) { + return zrtp_status_bad_param; + } + + pbits = get_pbits(self); + if (!pbits) { + return zrtp_status_bad_param; + } + + zrtp_ec_init_params(&ec_params, pbits); + + ec_bytes = (ec_params.ec_bits+7) / 8; + + bnBegin(&P); + bnInsertBigBytes( &P, ec_params.P_data, 0, ec_bytes ); + + bnBegin (&pkx); + bnBegin (&pky); + bnBegin (&rsltx); + bnBegin (&rslty); + + bnSetQ (&pkx, 1); + bnLShift (&pkx, pbits); + bnMod (&pky, pv, &pkx); + bnCopy (&pkx, pv); + bnRShift (&pkx, pbits); + + zrtp_ecMul (&rsltx, &rslty, &dh_cc->sv, &pkx, &pky, &P); + bnCopy (dhresult, &rsltx); + + bnEnd (&pkx); + bnEnd (&pky); + bnEnd (&rsltx); + bnEnd (&rslty); + bnEnd (&P); + + ZRTP_LOG(1,(_ZTU_,"\tDH TEST: zrtp_ecdh_compute() for %.4s was executed by %llums.\n", self->base.type, zrtp_time_now()-start_ts)); + return zrtp_status_ok; +} + +/*----------------------------------------------------------------------------*/ +/* ECC Partial Validation per NIST SP800-56A section 5.6.2.6 */ +/*----------------------------------------------------------------------------*/ +static zrtp_status_t zrtp_ecdh_validate( zrtp_pk_scheme_t *self, + struct BigNum *pv) +{ + zrtp_status_t s = zrtp_status_fail; + struct BigNum P, b; + struct BigNum t1, t2; + struct BigNum pkx, pky, bnzero; + unsigned ec_bytes = 0; + unsigned pbits = 0; + struct zrtp_ec_params ec_params; + zrtp_time_t start_ts = zrtp_time_now(); + + if (!self || !pv) { + return zrtp_status_bad_param; + } + + pbits = get_pbits(self); + if (!pbits) { + return zrtp_status_bad_param; + } + + zrtp_ec_init_params(&ec_params, pbits); + + ec_bytes = (ec_params.ec_bits+7) / 8; + + bnBegin(&P); + bnInsertBigBytes( &P, ec_params.P_data, 0, ec_bytes ); + bnBegin(&b); + bnInsertBigBytes( &b, ec_params.b_data, 0, ec_bytes ); + + bnBegin (&t1); + bnBegin (&t2); + bnBegin (&pkx); + bnBegin (&pky); + bnBegin (&bnzero); + + bnSetQ (&pkx, 1); + bnLShift (&pkx, pbits); + bnMod (&pky, pv, &pkx); + bnCopy (&pkx, pv); + bnRShift (&pkx, pbits); + + do{ + /* Represent point at infinity by (0, 0), make sure it's not that */ + if (bnCmp (&pkx, &bnzero) == 0 && bnCmp (&pky, &bnzero) == 0) { + break; + } + /* Check coordinates within range */ + if (bnCmp (&pkx, &bnzero) < 0 || bnCmp (&pkx, &P) >= 0) { + break; + } + if (bnCmp (&pky, &bnzero) < 0 || bnCmp (&pky, &P) >= 0) { + break; + } + + /* Check that point satisfies EC equation y^2 = x^3 - 3x + b, mod P */ + bnSquareMod_ (&t1, &pky, &P); + bnSquareMod_ (&t2, &pkx, &P); + bnSubQMod_ (&t2, 3, &P); + bnMulMod_ (&t2, &t2, &pkx, &P); + bnAddMod_ (&t2, &b, &P); + if (bnCmp (&t1, &t2) != 0) { + break; + } + + s = zrtp_status_ok; + } while (0); + + bnEnd (&t1); + bnEnd (&t2); + bnEnd (&pkx); + bnEnd (&pky); + bnEnd (&bnzero); + bnEnd (&P); + bnEnd (&b); + + ZRTP_LOG(1,(_ZTU_,"\tDH TEST: zrtp_ecdh_validate() for %.4s was executed by %llums.\n", self->base.type, zrtp_time_now()-start_ts)); + return s; +} + + +/*============================================================================*/ +/* P-256, 384, 521 (FIPS 186-3) support. See RFC 4753 3.1, 3.2, 3.3 */ +/*============================================================================*/ + +static uint8_t sv256_data[] = { + 0x81, 0x42, 0x64, 0x14, 0x5F, 0x2F, 0x56, 0xF2, + 0xE9, 0x6A, 0x8E, 0x33, 0x7A, 0x12, 0x84, 0x99, + 0x3F, 0xAF, 0x43, 0x2A, 0x5A, 0xBC, 0xE5, 0x9E, + 0x86, 0x7B, 0x72, 0x91, 0xD5, 0x07, 0xA3, 0xAF +}; +static uint8_t pvx256_data[] = { + 0x2A, 0xF5, 0x02, 0xF3, 0xBE, 0x89, 0x52, 0xF2, + 0xC9, 0xB5, 0xA8, 0xD4, 0x16, 0x0D, 0x09, 0xE9, + 0x71, 0x65, 0xBE, 0x50, 0xBC, 0x42, 0xAE, 0x4A, + 0x5E, 0x8D, 0x3B, 0x4B, 0xA8, 0x3A, 0xEB, 0x15 +}; +static uint8_t pvy256_data[] = { + 0xEB, 0x0F, 0xAF, 0x4C, 0xA9, 0x86, 0xC4, 0xD3, + 0x86, 0x81, 0xA0, 0xF9, 0x87, 0x2D, 0x79, 0xD5, + 0x67, 0x95, 0xBD, 0x4B, 0xFF, 0x6E, 0x6D, 0xE3, + 0xC0, 0xF5, 0x01, 0x5E, 0xCE, 0x5E, 0xFD, 0x85 +}; + +static uint8_t sv384_data[] = { + 0xD2, 0x73, 0x35, 0xEA, 0x71, 0x66, 0x4A, 0xF2, + 0x44, 0xDD, 0x14, 0xE9, 0xFD, 0x12, 0x60, 0x71, + 0x5D, 0xFD, 0x8A, 0x79, 0x65, 0x57, 0x1C, 0x48, + 0xD7, 0x09, 0xEE, 0x7A, 0x79, 0x62, 0xA1, 0x56, + 0xD7, 0x06, 0xA9, 0x0C, 0xBC, 0xB5, 0xDF, 0x29, + 0x86, 0xF0, 0x5F, 0xEA, 0xDB, 0x93, 0x76, 0xF1 +}; +static uint8_t pvx384_data[] = { + 0x79, 0x31, 0x48, 0xF1, 0x78, 0x76, 0x34, 0xD5, + 0xDA, 0x4C, 0x6D, 0x90, 0x74, 0x41, 0x7D, 0x05, + 0xE0, 0x57, 0xAB, 0x62, 0xF8, 0x20, 0x54, 0xD1, + 0x0E, 0xE6, 0xB0, 0x40, 0x3D, 0x62, 0x79, 0x54, + 0x7E, 0x6A, 0x8E, 0xA9, 0xD1, 0xFD, 0x77, 0x42, + 0x7D, 0x01, 0x6F, 0xE2, 0x7A, 0x8B, 0x8C, 0x66 +}; +static uint8_t pvy384_data[] = { + 0xC6, 0xC4, 0x12, 0x94, 0x33, 0x1D, 0x23, 0xE6, + 0xF4, 0x80, 0xF4, 0xFB, 0x4C, 0xD4, 0x05, 0x04, + 0xC9, 0x47, 0x39, 0x2E, 0x94, 0xF4, 0xC3, 0xF0, + 0x6B, 0x8F, 0x39, 0x8B, 0xB2, 0x9E, 0x42, 0x36, + 0x8F, 0x7A, 0x68, 0x59, 0x23, 0xDE, 0x3B, 0x67, + 0xBA, 0xCE, 0xD2, 0x14, 0xA1, 0xA1, 0xD1, 0x28 +}; + +static uint8_t sv521_data[] = { + 0x01, 0x13, 0xF8, 0x2D, 0xA8, 0x25, 0x73, 0x5E, + 0x3D, 0x97, 0x27, 0x66, 0x83, 0xB2, 0xB7, 0x42, + 0x77, 0xBA, 0xD2, 0x73, 0x35, 0xEA, 0x71, 0x66, + 0x4A, 0xF2, 0x43, 0x0C, 0xC4, 0xF3, 0x34, 0x59, + 0xB9, 0x66, 0x9E, 0xE7, 0x8B, 0x3F, 0xFB, 0x9B, + 0x86, 0x83, 0x01, 0x5D, 0x34, 0x4D, 0xCB, 0xFE, + 0xF6, 0xFB, 0x9A, 0xF4, 0xC6, 0xC4, 0x70, 0xBE, + 0x25, 0x45, 0x16, 0xCD, 0x3C, 0x1A, 0x1F, 0xB4, + 0x73, 0x62 +}; +static uint8_t pvx521_data[] = { + 0x01, 0xEB, 0xB3, 0x4D, 0xD7, 0x57, 0x21, 0xAB, + 0xF8, 0xAD, 0xC9, 0xDB, 0xED, 0x17, 0x88, 0x9C, + 0xBB, 0x97, 0x65, 0xD9, 0x0A, 0x7C, 0x60, 0xF2, + 0xCE, 0xF0, 0x07, 0xBB, 0x0F, 0x2B, 0x26, 0xE1, + 0x48, 0x81, 0xFD, 0x44, 0x42, 0xE6, 0x89, 0xD6, + 0x1C, 0xB2, 0xDD, 0x04, 0x6E, 0xE3, 0x0E, 0x3F, + 0xFD, 0x20, 0xF9, 0xA4, 0x5B, 0xBD, 0xF6, 0x41, + 0x3D, 0x58, 0x3A, 0x2D, 0xBF, 0x59, 0x92, 0x4F, + 0xD3, 0x5C +}; +static uint8_t pvy521_data[] = { + 0x00, 0xF6, 0xB6, 0x32, 0xD1, 0x94, 0xC0, 0x38, + 0x8E, 0x22, 0xD8, 0x43, 0x7E, 0x55, 0x8C, 0x55, + 0x2A, 0xE1, 0x95, 0xAD, 0xFD, 0x15, 0x3F, 0x92, + 0xD7, 0x49, 0x08, 0x35, 0x1B, 0x2F, 0x8C, 0x4E, + 0xDA, 0x94, 0xED, 0xB0, 0x91, 0x6D, 0x1B, 0x53, + 0xC0, 0x20, 0xB5, 0xEE, 0xCA, 0xED, 0x1A, 0x5F, + 0xC3, 0x8A, 0x23, 0x3E, 0x48, 0x30, 0x58, 0x7B, + 0xB2, 0xEE, 0x34, 0x89, 0xB3, 0xB4, 0x2A, 0x5A, + 0x86, 0xA4 +}; + +zrtp_status_t zrtp_ecdh_selftest(zrtp_pk_scheme_t *self) +{ + zrtp_status_t s = zrtp_status_fail; + struct BigNum P, Gx, Gy, n, sv; + struct BigNum pkx, pky; + unsigned ec_bytes = 0; + unsigned pbits = 0; + struct zrtp_ec_params ec_params; + + zrtp_time_t start_ts = 0; + + uint8_t *sv_data = NULL; + size_t sv_data_len = 0; + uint8_t *pvx_data = NULL; + size_t pvx_data_len = 0; + uint8_t *pvy_data = NULL; + size_t pvy_data_len = 0; + + if (!self) { + return zrtp_status_bad_param; + } + + ZRTP_LOG(3, (_ZTU_, "PKS %.4s testing... ", self->base.type)); + + switch (self->base.id) { + case ZRTP_PKTYPE_EC256P: + sv_data = sv256_data; + sv_data_len = sizeof(sv256_data); + pvx_data = pvx256_data; + pvx_data_len = sizeof(pvx256_data); + pvy_data = pvy256_data; + pvy_data_len = sizeof(pvy256_data); + break; + case ZRTP_PKTYPE_EC384P: + sv_data = sv384_data; + sv_data_len = sizeof(sv384_data); + pvx_data = pvx384_data; + pvx_data_len = sizeof(pvx384_data); + pvy_data = pvy384_data; + pvy_data_len = sizeof(pvy384_data); + break; + case ZRTP_PKTYPE_EC521P: + sv_data = sv521_data; + sv_data_len = sizeof(sv521_data); + pvx_data = pvx521_data; + pvx_data_len = sizeof(pvx521_data); + pvy_data = pvy521_data; + pvy_data_len = sizeof(pvy521_data); + break; + default: + return 0; + } + + pbits = get_pbits(self); + if (!pbits) { + return zrtp_status_bad_param; + } + + zrtp_ec_init_params(&ec_params, pbits); + + ec_bytes = (ec_params.ec_bits+7) / 8; + + bnBegin(&P); + bnInsertBigBytes(&P, ec_params.P_data, 0, ec_bytes ); + bnBegin(&Gx); + bnInsertBigBytes(&Gx, ec_params.Gx_data, 0, ec_bytes ); + bnBegin(&Gy); + bnInsertBigBytes(&Gy, ec_params.Gy_data, 0, ec_bytes ); + bnBegin(&n); + bnInsertBigBytes(&n, ec_params.n_data, 0, ec_bytes ); + + bnBegin(&pkx); + bnBegin(&pky); + bnBegin(&sv); + s = zrtp_ec_random_point( self->base.zrtp, &P, &n, &Gx, &Gy, + &pkx, &pky, &sv, + sv_data, sv_data_len); + if (zrtp_status_ok == s) + { + struct BigNum pkx1, pky1; + + bnBegin(&pkx1); bnBegin(&pky1); + bnInsertBigBytes(&pkx1, pvx_data, 0, pvx_data_len); + bnInsertBigBytes(&pky1, pvy_data, 0, pvy_data_len); + s = (bnCmp (&pkx1, &pkx) == 0 && bnCmp (&pky1, &pky) == 0) ? zrtp_status_ok : zrtp_status_fail; + bnEnd(&pkx1); + bnEnd(&pky1); + } + + bnEnd (&pkx); + bnEnd (&pky); + bnEnd (&P); + bnEnd (&Gx); + bnEnd (&Gy); + bnEnd (&n); + bnEnd (&sv); + + if (zrtp_status_ok == s) { + zrtp_status_t s = zrtp_status_ok; + zrtp_dh_crypto_context_t alice_cc; + zrtp_dh_crypto_context_t bob_cc; + struct BigNum alice_k; + struct BigNum bob_k; + + start_ts = zrtp_time_now(); + + bnBegin(&alice_k); + bnBegin(&bob_k); + + do { + /* Both sides initalise DH schemes and compute secret and public values. */ + s = self->initialize(self, &alice_cc); + if (zrtp_status_ok != s) { + break; + } + s = self->initialize(self, &bob_cc); + if (zrtp_status_ok != s) { + break; + } + + /* Both sides validate public values. (to provide exact performance estimation) */ + s = self->validate(self, &bob_cc.pv); + if (zrtp_status_ok != s) { + break; + } + s = self->validate(self, &alice_cc.pv); + if (zrtp_status_ok != s) { + break; + } + + /* Compute secret keys and compare them. */ + s = self->compute(self, &alice_cc, &alice_k, &bob_cc.pv); + if (zrtp_status_ok != s) { + break; + } + s= self->compute(self, &bob_cc, &bob_k, &alice_cc.pv); + if (zrtp_status_ok != s) { + break; + } + + s = (0 == bnCmp(&alice_k, &bob_k)) ? zrtp_status_ok : zrtp_status_algo_fail; + } while (0); + + bnEnd(&alice_k); + bnEnd(&bob_k); + } + ZRTP_LOGC(3, ("%s (%llu ms)\n", zrtp_log_status2str(s), (zrtp_time_now()-start_ts)/2)); + + return s; +} + + +/*============================================================================*/ +/* Public Key support */ +/*============================================================================*/ + +/*----------------------------------------------------------------------------*/ +zrtp_status_t zrtp_defaults_ec_pkt(zrtp_global_t* zrtp) +{ + zrtp_pk_scheme_t* ec256p = zrtp_sys_alloc(sizeof(zrtp_pk_scheme_t)); + zrtp_pk_scheme_t* ec384p = zrtp_sys_alloc(sizeof(zrtp_pk_scheme_t)); + zrtp_pk_scheme_t* ec521p = zrtp_sys_alloc(sizeof(zrtp_pk_scheme_t)); + + if (!ec256p || !ec384p || !ec521p) { + if(ec256p) { + zrtp_sys_free(ec256p); + } + if(ec384p) { + zrtp_sys_free(ec384p); + } + if(ec521p) { + zrtp_sys_free(ec521p); + } + return zrtp_status_alloc_fail; + } + + zrtp_memset(ec256p, 0, sizeof(zrtp_pk_scheme_t)); + zrtp_memcpy(ec256p->base.type, ZRTP_EC256P, ZRTP_COMP_TYPE_SIZE); + ec256p->base.id = ZRTP_PKTYPE_EC256P; + ec256p->base.zrtp = zrtp; + ec256p->sv_length = 256/8; + ec256p->pv_length = 2*256/8; + ec256p->base.init = zrtp_ecdh_init; + ec256p->base.free = zrtp_ecdh_free; + ec256p->initialize = zrtp_ecdh_initialize; + ec256p->compute = zrtp_ecdh_compute; + ec256p->validate = zrtp_ecdh_validate; + ec256p->self_test = zrtp_ecdh_selftest; + + zrtp_memset(ec384p, 0, sizeof(zrtp_pk_scheme_t)); + zrtp_memcpy(ec384p->base.type, ZRTP_EC384P, ZRTP_COMP_TYPE_SIZE); + ec384p->base.id = ZRTP_PKTYPE_EC384P; + ec384p->base.zrtp = zrtp; + ec384p->sv_length = 384/8; + ec384p->pv_length = 2*384/8; + ec384p->base.init = zrtp_ecdh_init; + ec384p->base.free = zrtp_ecdh_free; + ec384p->initialize = zrtp_ecdh_initialize; + ec384p->compute = zrtp_ecdh_compute; + ec384p->validate = zrtp_ecdh_validate; + ec384p->self_test = zrtp_ecdh_selftest; + + + zrtp_memset(ec521p, 0, sizeof(zrtp_pk_scheme_t)); + zrtp_memcpy(ec521p->base.type, ZRTP_EC521P, ZRTP_COMP_TYPE_SIZE); + ec521p->base.id = ZRTP_PKTYPE_EC521P; + ec521p->base.zrtp = zrtp; + ec521p->sv_length = 528/8; + ec521p->pv_length = 2*528/8; + ec521p->base.init = zrtp_ecdh_init; + ec521p->base.free = zrtp_ecdh_free; + ec521p->initialize = zrtp_ecdh_initialize; + ec521p->compute = zrtp_ecdh_compute; + ec521p->validate = zrtp_ecdh_validate; + ec521p->self_test = zrtp_ecdh_selftest; + + zrtp_comp_register(ZRTP_CC_PKT, ec256p, zrtp); + zrtp_comp_register(ZRTP_CC_PKT, ec384p, zrtp); + zrtp_comp_register(ZRTP_CC_PKT, ec521p, zrtp); + + return zrtp_status_ok; +} + +#endif /*ZRTP_ENABLE_EC*/ diff --git a/libs/libzrtp/src/zrtp_crypto_ecdsa.c b/libs/libzrtp/src/zrtp_crypto_ecdsa.c new file mode 100644 index 0000000000..679f1259c1 --- /dev/null +++ b/libs/libzrtp/src/zrtp_crypto_ecdsa.c @@ -0,0 +1,646 @@ +/* + * zrtp_crypto_ecdsa.c - Elliptic Curve Digital Signature functions for ZRTP. + * NSA Suite B Elliptic Curves from NIST SP 800-56A and FIPS 186-3. + * + * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. + * This is NOT licensed under the GPL or any other open source license. + * For licensing terms or other information, + * contact: Philip Zimmermann . + * For more contact information, see http://philzimmermann.com + */ + +#include "zrtp.h" + +/* We don't have digital signatures ready yet. */ +#if 0 + +/* Size of extra random data to approximate a uniform distribution mod n */ +#define UNIFORMBYTES 8 + +/*============================================================================*/ +/* Shared Elliptic Curve functions */ +/* */ +/* The Elliptic Curve DSA algorithm, key generation, and curves are */ +/* from FIPS 186-3. The curves used are */ +/* also defined in RFC 4753, sections 3.1 through 3.3. */ +/*============================================================================*/ + +/*----------------------------------------------------------------------------*/ +/* Return dsa_cc->pv holding public value and dsa_cc->sv holding secret value */ +/* The public value is an elliptic curve point encoded as the x part shifted */ +/* left Pbits bits and or'd with the y part. */ +/*----------------------------------------------------------------------------*/ +static zrtp_status_t ECDSA_keygen( struct zrtp_sig_scheme *self, + zrtp_dsa_crypto_context_t *dsa_cc, + zrtp_ec_params_t *ec_params, +#ifdef ZRTP_TEST_VECTORS + uint8_t *sv_data, size_t sv_data_len, + uint8_t *pvx_data, size_t pvx_data_len, + uint8_t *pvy_data, size_t pvy_data_len, +#endif + unsigned Pbits ) +{ + zrtp_status_t s = zrtp_status_fail; + struct BigNum P, Gx, Gy, n; + struct BigNum pkx, pky; + unsigned ec_bytes; + + if (!ec_params) + return zrtp_status_bad_param; + + ec_bytes = (ec_params->ec_bits+7) / 8; + + do + { + if (!self || !dsa_cc) + { + s = zrtp_status_bad_param; + break; + } + + bnBegin(&P); + bnInsertBigBytes( &P, ec_params->P_data, 0, ec_bytes ); + bnBegin(&Gx); + bnInsertBigBytes( &Gx, ec_params->Gx_data, 0, ec_bytes ); + bnBegin(&Gy); + bnInsertBigBytes( &Gy, ec_params->Gy_data, 0, ec_bytes ); + bnBegin(&n); + bnInsertBigBytes( &n, ec_params->n_data, 0, ec_bytes ); + + bnBegin(&pkx); + bnBegin(&pky); + bnBegin(&dsa_cc->sv); + s = zrtp_ec_random_point( self->base.zrtp_global, &P, &n, &Gx, &Gy, +#ifdef ZRTP_TEST_VECTORS + sv_data, sv_data_len, + pvx_data, pvx_data_len, + pvy_data, pvy_data_len, +#endif + &pkx, &pky, &dsa_cc->sv ); + if ( s != zrtp_status_ok ) + break; + s = zrtp_status_fail; + + bnBegin(&dsa_cc->pv); + bnCopy (&dsa_cc->pv, &pkx); + bnLShift (&dsa_cc->pv, Pbits); + bnAdd (&dsa_cc->pv, &pky); + bnEnd (&pkx); + bnEnd (&pky); + bnEnd (&P); + bnEnd (&Gx); + bnEnd (&Gy); + bnEnd (&n); + + s = zrtp_status_ok; + } while (0); + + return s; +} + + +/*----------------------------------------------------------------------------*/ +/* Sign the specified hash value - must be size matching the curve */ +/*----------------------------------------------------------------------------*/ +static zrtp_status_t ECDSA_sign( struct zrtp_sig_scheme *self, + zrtp_dsa_crypto_context_t *dsa_cc, + zrtp_ec_params_t *ec_params, +#ifdef ZRTP_TEST_VECTORS + uint8_t *k_data, size_t k_data_len, + uint8_t *rx_data, size_t rx_data_len, + uint8_t *ry_data, size_t ry_data_len, + uint8_t *s_data, size_t s_data_len, +#endif + uint8_t *hash, uint32_t hash_len, + struct BigNum *dsasig ) +{ + zrtp_status_t s = zrtp_status_fail; + struct BigNum P, Gx, Gy, n; + struct BigNum h, s1, k, rx, ry, kinv, pkx, pky; + unsigned ec_bytes; + + if (!ec_params) + return zrtp_status_bad_param; + + ec_bytes = (ec_params->ec_bits+7) / 8; + + do + { + if (!self || !dsa_cc) + { + s = zrtp_status_bad_param; + break; + } + + bnBegin(&P); + bnInsertBigBytes( &P, ec_params->P_data, 0, ec_bytes ); + bnBegin(&Gx); + bnInsertBigBytes( &Gx, ec_params->Gx_data, 0, ec_bytes ); + bnBegin(&Gy); + bnInsertBigBytes( &Gy, ec_params->Gy_data, 0, ec_bytes ); + bnBegin(&n); + bnInsertBigBytes( &n, ec_params->n_data, 0, ec_bytes ); + + /* Hash to bignum */ + bnBegin(&h); + bnInsertBigBytes( &h, hash, 0, hash_len ); + bnMod (&h, &h, &P); + + /* Unpack signing key */ + bnBegin(&pkx); + bnBegin(&pky); + bnSetQ (&pkx, 1); + bnLShift (&pkx, ec_bytes*8); + bnMod (&pky, &dsa_cc->pv, &pkx); + bnCopy (&pkx, &dsa_cc->pv); + bnRShift (&pkx, ec_bytes*8); + + /* Choose signature secret k value */ + bnBegin(&rx); + bnBegin(&ry); + bnBegin(&k); + s = zrtp_ec_random_point( self->base.zrtp_global, &P, &n, &Gx, &Gy, +#ifdef ZRTP_TEST_VECTORS + k_data, k_data_len, + rx_data, rx_data_len, + ry_data, ry_data_len, +#endif + &rx, &ry, &k ); + if ( s != zrtp_status_ok ) + break; + s = zrtp_status_fail; + +#ifndef ZRTP_TEST_VECTORS + /* For further randomness we are going to add the secret key to k */ + bnAddMod_ (&k, &dsa_cc->sv, &n); + zrtp_ecAdd (&rx, &ry, &rx, &ry, &pkx, &pky, &P); +#endif + + /* Perform the signature */ + bnBegin (&s1); + bnMulMod_ (&s1, &rx, &dsa_cc->sv, &n); + bnAddMod_ (&s1, &h, &n); + bnBegin (&kinv); + bnInv (&kinv, &k, &n); + bnMulMod_ (&s1, &s1, &kinv, &n); + +#ifdef ZRTP_TEST_VECTORS + if (k_data_len != 0) + { + /* rx is checked in ec_random_point */ + struct BigNum s2; + int ok; + bnBegin(&s2); + bnInsertBigBytes(&s2, s_data, 0, s_data_len); + ok = (bnCmp (&s1, &s2) == 0); + bnEnd(&s2); + if (!ok) + break; + } +#endif + + /* Combine r, s into dsasig */ + bnBegin(dsasig); + bnCopy (dsasig, &rx); + bnLShift (dsasig, ec_bytes*8); + bnAdd (dsasig, &s1); + bnEnd (&rx); + bnEnd (&ry); + bnEnd (&k); + bnEnd (&kinv); + bnEnd (&s1); + bnEnd (&h); + bnEnd (&pkx); + bnEnd (&pky); + bnEnd (&P); + bnEnd (&Gx); + bnEnd (&Gy); + bnEnd (&n); + + s = zrtp_status_ok; + } while (0); + + return s; +} + + +/*----------------------------------------------------------------------------*/ +/* Verify a signature value - hash must be size matching the curve */ +/* Signing key should be in peer_pv entry of dsa_cc */ +/*----------------------------------------------------------------------------*/ +static zrtp_status_t ECDSA_verify( struct zrtp_sig_scheme *self, + zrtp_dsa_crypto_context_t *dsa_cc, + zrtp_ec_params_t *ec_params, + uint8_t *hash, uint32_t hash_len, + struct BigNum *dsasig ) +{ + zrtp_status_t s = zrtp_status_fail; + struct BigNum P, Gx, Gy, n; + struct BigNum rx, ry, pkx, pky, r, s1, sinv, u1, u2, u1x, u2x, u1y, u2y, h; + unsigned ec_bytes; + + if (!ec_params) + return zrtp_status_bad_param; + + ec_bytes = (ec_params->ec_bits+7) / 8; + + do + { + if (!self || !dsa_cc) + { + s = zrtp_status_bad_param; + break; + } + + bnBegin(&P); + bnInsertBigBytes( &P, ec_params->P_data, 0, ec_bytes ); + bnBegin(&Gx); + bnInsertBigBytes( &Gx, ec_params->Gx_data, 0, ec_bytes ); + bnBegin(&Gy); + bnInsertBigBytes( &Gy, ec_params->Gy_data, 0, ec_bytes ); + bnBegin(&n); + bnInsertBigBytes( &n, ec_params->n_data, 0, ec_bytes ); + + /* hash */ + bnBegin(&h); + bnInsertBigBytes( &h, hash, 0, hash_len ); + bnMod (&h, &h, &P); + + /* Unpack sig */ + bnBegin(&r); + bnBegin(&s1); + bnSetQ (&r, 1); + bnLShift (&r, ec_bytes*8); + bnMod (&s1, dsasig, &r); + bnCopy (&r, dsasig); + bnRShift (&r, ec_bytes*8); + + /* Unpack signing key */ + bnBegin(&pkx); + bnBegin(&pky); + bnSetQ (&pkx, 1); + bnLShift (&pkx, ec_bytes*8); + bnMod (&pky, &dsa_cc->peer_pv, &pkx); + bnCopy (&pkx, &dsa_cc->peer_pv); + bnRShift (&pkx, ec_bytes*8); + + /* Verify signature */ + bnBegin (&sinv); + bnInv (&sinv, &s1, &n); + bnBegin (&u1); + bnBegin (&u2); + bnMulMod_ (&u1, &sinv, &h, &n); + bnMulMod_ (&u2, &sinv, &r, &n); + + bnBegin (&u1x); + bnBegin (&u1y); + bnBegin (&u2x); + bnBegin (&u2y); + bnBegin (&rx); + bnBegin (&ry); + zrtp_ecMul (&u1x, &u1y, &u1, &Gx, &Gy, &P); + zrtp_ecMul (&u2x, &u2y, &u2, &pkx, &pky, &P); + zrtp_ecAdd (&rx, &ry, &u1x, &u1y, &u2x, &u2y, &P); + + if (bnCmp (&rx, &r) == 0) { + s = zrtp_status_ok; + } else { + s = zrtp_status_fail; + } + + /* Clean up */ + bnEnd (&rx); + bnEnd (&ry); + bnEnd (&r); + bnEnd (&s1); + bnEnd (&sinv); + bnEnd (&u1); + bnEnd (&u1x); + bnEnd (&u1y); + bnEnd (&u2); + bnEnd (&u2x); + bnEnd (&u2y); + bnEnd (&h); + bnEnd (&pkx); + bnEnd (&pky); + bnEnd (&P); + bnEnd (&Gx); + bnEnd (&Gy); + bnEnd (&n); + + } while (0); + + return s; +} + + + +/*----------------------------------------------------------------------------*/ +static zrtp_status_t EC_dummy(void *s) +{ + return zrtp_status_ok; +} + + +/*============================================================================*/ +/* P-256 (FIPS 186-3) support. See RFC 4753, section 3.1. */ +/*============================================================================*/ + +/* Test vectors from RFC4754 */ +#ifdef ZRTP_TEST_VECTORS +static uint8_t sv256_data[] = { + 0xDC, 0x51, 0xD3, 0x86, 0x6A, 0x15, 0xBA, 0xCD, + 0xE3, 0x3D, 0x96, 0xF9, 0x92, 0xFC, 0xA9, 0x9D, + 0xA7, 0xE6, 0xEF, 0x09, 0x34, 0xE7, 0x09, 0x75, + 0x59, 0xC2, 0x7F, 0x16, 0x14, 0xC8, 0x8A, 0x7F, +}; +static uint8_t pvx256_data[] = { + 0x24, 0x42, 0xA5, 0xCC, 0x0E, 0xCD, 0x01, 0x5F, + 0xA3, 0xCA, 0x31, 0xDC, 0x8E, 0x2B, 0xBC, 0x70, + 0xBF, 0x42, 0xD6, 0x0C, 0xBC, 0xA2, 0x00, 0x85, + 0xE0, 0x82, 0x2C, 0xB0, 0x42, 0x35, 0xE9, 0x70, +}; +static uint8_t pvy256_data[] = { + 0x6F, 0xC9, 0x8B, 0xD7, 0xE5, 0x02, 0x11, 0xA4, + 0xA2, 0x71, 0x02, 0xFA, 0x35, 0x49, 0xDF, 0x79, + 0xEB, 0xCB, 0x4B, 0xF2, 0x46, 0xB8, 0x09, 0x45, + 0xCD, 0xDF, 0xE7, 0xD5, 0x09, 0xBB, 0xFD, 0x7D, +}; + +static uint8_t k256_data[] = { + 0x9E, 0x56, 0xF5, 0x09, 0x19, 0x67, 0x84, 0xD9, + 0x63, 0xD1, 0xC0, 0xA4, 0x01, 0x51, 0x0E, 0xE7, + 0xAD, 0xA3, 0xDC, 0xC5, 0xDE, 0xE0, 0x4B, 0x15, + 0x4B, 0xF6, 0x1A, 0xF1, 0xD5, 0xA6, 0xDE, 0xCE, +}; +static uint8_t rx256_data[] = { + 0xCB, 0x28, 0xE0, 0x99, 0x9B, 0x9C, 0x77, 0x15, + 0xFD, 0x0A, 0x80, 0xD8, 0xE4, 0x7A, 0x77, 0x07, + 0x97, 0x16, 0xCB, 0xBF, 0x91, 0x7D, 0xD7, 0x2E, + 0x97, 0x56, 0x6E, 0xA1, 0xC0, 0x66, 0x95, 0x7C, +}; +static uint8_t ry256_data[] = { + 0x2B, 0x57, 0xC0, 0x23, 0x5F, 0xB7, 0x48, 0x97, + 0x68, 0xD0, 0x58, 0xFF, 0x49, 0x11, 0xC2, 0x0F, + 0xDB, 0xE7, 0x1E, 0x36, 0x99, 0xD9, 0x13, 0x39, + 0xAF, 0xBB, 0x90, 0x3E, 0xE1, 0x72, 0x55, 0xDC, +}; + +static uint8_t h256_data[] = { + 0xBA, 0x78, 0x16, 0xBF, 0x8F, 0x01, 0xCF, 0xEA, + 0x41, 0x41, 0x40, 0xDE, 0x5D, 0xAE, 0x22, 0x23, + 0xB0, 0x03, 0x61, 0xA3, 0x96, 0x17, 0x7A, 0x9C, + 0xB4, 0x10, 0xFF, 0x61, 0xF2, 0x00, 0x15, 0xAD, +}; +static uint8_t s256_data[] = { + 0x86, 0xFA, 0x3B, 0xB4, 0xE2, 0x6C, 0xAD, 0x5B, + 0xF9, 0x0B, 0x7F, 0x81, 0x89, 0x92, 0x56, 0xCE, + 0x75, 0x94, 0xBB, 0x1E, 0xA0, 0xC8, 0x92, 0x12, + 0x74, 0x8B, 0xFF, 0x3B, 0x3D, 0x5B, 0x03, 0x15, +}; + + +#endif + +/*----------------------------------------------------------------------------*/ +/* Return dsa_cc->pv holding public value and dsa_cc->sv holding secret value */ +/* The public value is an elliptic curve point encoded as the x part shifted */ +/* left 256 bits and or'd with the y part. */ +/*----------------------------------------------------------------------------*/ +static zrtp_status_t EC256P_keygen( struct zrtp_sig_scheme *self, + zrtp_dsa_crypto_context_t *dsa_cc ) +{ + struct zrtp_ec_params params; + zrtp_ec_init_params(¶ms, 256); + return ECDSA_keygen(self, dsa_cc, ¶ms, +#ifdef ZRTP_TEST_VECTORS + sv256_data, sizeof(sv256_data), + pvx256_data, sizeof(pvx256_data), + pvy256_data, sizeof(pvy256_data), +#endif + 256); +} + + +/*----------------------------------------------------------------------------*/ +/* Sign the specified hash value */ +/*----------------------------------------------------------------------------*/ +static zrtp_status_t EC256P_sign( struct zrtp_sig_scheme *self, + zrtp_dsa_crypto_context_t *dsa_cc, + uint8_t *hash, uint32_t hash_len, + struct BigNum *dsasig ) +{ + struct zrtp_ec_params params; + zrtp_ec_init_params(¶ms, 256); + return ECDSA_sign(self, dsa_cc, ¶ms, +#ifdef ZRTP_TEST_VECTORS + k256_data, sizeof(k256_data), + rx256_data, sizeof(rx256_data), + ry256_data, sizeof(ry256_data), + s256_data, sizeof(s256_data), + h256_data, sizeof(h256_data), +#else + hash, hash_len, +#endif + dsasig); +} + + +/*----------------------------------------------------------------------------*/ +/* Verify the signature on the hash value */ +/*----------------------------------------------------------------------------*/ +static zrtp_status_t EC256P_verify(struct zrtp_sig_scheme *self, + zrtp_dsa_crypto_context_t *dsa_cc, + uint8_t *hash, uint32_t hash_len, + struct BigNum *dsasig ) +{ + struct zrtp_ec_params params; + zrtp_ec_init_params(¶ms, 256); + return ECDSA_verify(self, dsa_cc, ¶ms, +#ifdef ZRTP_TEST_VECTORS + h256_data, sizeof(h256_data), +#else + hash, hash_len, +#endif + dsasig); +} + + + +/*============================================================================*/ +/* P-384 (FIPS 186-3) support. See RFC 4753, section 3.2. */ +/*============================================================================*/ + + + +/*----------------------------------------------------------------------------*/ +/* Return dsa_cc->pv holding public value and dsa_cc->sv holding secret value */ +/* The public value is an elliptic curve point encoded as the x part shifted */ +/* left 384 bits and or'd with the y part. */ +/*----------------------------------------------------------------------------*/ +static zrtp_status_t EC384P_keygen( struct zrtp_sig_scheme *self, + zrtp_dsa_crypto_context_t *dsa_cc ) +{ + struct zrtp_ec_params params; + zrtp_ec_init_params(¶ms, 384); + return ECDSA_keygen(self, dsa_cc, ¶ms, +#ifdef ZRTP_TEST_VECTORS + 0, 0, 0, 0, 0, 0, +#endif + 384); +} + + +/*----------------------------------------------------------------------------*/ +/* Sign the specified hash value */ +/*----------------------------------------------------------------------------*/ +static zrtp_status_t EC384P_sign( struct zrtp_sig_scheme *self, + zrtp_dsa_crypto_context_t *dsa_cc, + uint8_t *hash, uint32_t hash_len, + struct BigNum *dsasig ) +{ + struct zrtp_ec_params params; + zrtp_ec_init_params(¶ms, 384); + return ECDSA_sign(self, dsa_cc, ¶ms, +#ifdef ZRTP_TEST_VECTORS + 0, 0, 0, 0, 0, 0, 0, 0, +#endif + hash, hash_len, dsasig); +} + + +/*----------------------------------------------------------------------------*/ +/* Verify the signature on the hash value */ +/*----------------------------------------------------------------------------*/ +static zrtp_status_t EC384P_verify(struct zrtp_sig_scheme *self, + zrtp_dsa_crypto_context_t *dsa_cc, + uint8_t *hash, uint32_t hash_len, + struct BigNum *dsasig ) +{ + struct zrtp_ec_params params; + zrtp_ec_init_params(¶ms, 384); + return ECDSA_verify(self, dsa_cc, ¶ms, hash, hash_len, dsasig); +} + + + +/*============================================================================*/ +/* P-521 (FIPS 186-3) support. See RFC 4753, section 3.3. */ +/*============================================================================*/ + + +/*----------------------------------------------------------------------------*/ +/* Return dsa_cc->pv holding public value and dsa_cc->sv holding secret value */ +/* The public value is an elliptic curve point encoded as the x part shifted */ +/* left 528 bits (note, not 521) and or'd with the y part. */ +/*----------------------------------------------------------------------------*/ +static zrtp_status_t EC521P_keygen( struct zrtp_sig_scheme *self, + zrtp_dsa_crypto_context_t *dsa_cc ) +{ + struct zrtp_ec_params params; + zrtp_ec_init_params(¶ms, 521); + return ECDSA_keygen(self, dsa_cc, ¶ms, +#ifdef ZRTP_TEST_VECTORS + 0, 0, 0, 0, 0, 0, +#endif + 528); +} + + +/*----------------------------------------------------------------------------*/ +/* Sign the specified hash value */ +/*----------------------------------------------------------------------------*/ +static zrtp_status_t EC521P_sign( struct zrtp_sig_scheme *self, + zrtp_dsa_crypto_context_t *dsa_cc, + uint8_t *hash, uint32_t hash_len, + struct BigNum *dsasig ) +{ + struct zrtp_ec_params params; + zrtp_ec_init_params(¶ms, 521); + return ECDSA_sign(self, dsa_cc, ¶ms, +#ifdef ZRTP_TEST_VECTORS + 0, 0, 0, 0, 0, 0, 0, 0, +#endif + hash, hash_len, dsasig); +} + + +/*----------------------------------------------------------------------------*/ +/* Verify the signature on the hash value */ +/*----------------------------------------------------------------------------*/ +static zrtp_status_t EC521P_verify(struct zrtp_sig_scheme *self, + zrtp_dsa_crypto_context_t *dsa_cc, + uint8_t *hash, uint32_t hash_len, + struct BigNum *dsasig ) +{ + struct zrtp_ec_params params; + zrtp_ec_init_params(¶ms, 521); + return ECDSA_verify(self, dsa_cc, ¶ms, hash, hash_len, dsasig); +} + + + +/*============================================================================*/ +/* Public Key support */ +/*============================================================================*/ + + +/*----------------------------------------------------------------------------*/ +zrtp_status_t zrtp_defaults_sig(zrtp_global_ctx_t* zrtp_global) +{ + zrtp_sig_scheme_t* ec256p = zrtp_sys_alloc(sizeof(zrtp_sig_scheme_t)); + zrtp_sig_scheme_t* ec384p = zrtp_sys_alloc(sizeof(zrtp_sig_scheme_t)); + zrtp_sig_scheme_t* ec521p = zrtp_sys_alloc(sizeof(zrtp_sig_scheme_t)); + + if (!ec256p || !ec384p || !ec521p) + { + if(ec256p) zrtp_sys_free(ec256p); + if(ec384p) zrtp_sys_free(ec384p); + if(ec521p) zrtp_sys_free(ec521p); + return zrtp_status_alloc_fail; + } + + zrtp_memset(ec256p, 0, sizeof(zrtp_sig_scheme_t)); + zrtp_memcpy(ec256p->base.type, ZRTP_EC256P, ZRTP_COMP_TYPE_SIZE); + ec256p->base.id = ZRTP_SIGTYPE_EC256P; + ec256p->base.zrtp_global = zrtp_global; + ec256p->sv_length = 256/8; + ec256p->pv_length = 2*256/8; + ec256p->base.init = EC_dummy; + ec256p->base.free = EC_dummy; + ec256p->generate_key = EC256P_keygen; + ec256p->sign = EC256P_sign; + ec256p->verify = EC256P_verify; + + zrtp_memset(ec384p, 0, sizeof(zrtp_sig_scheme_t)); + zrtp_memcpy(ec384p->base.type, ZRTP_EC384P, ZRTP_COMP_TYPE_SIZE); + ec384p->base.id = ZRTP_SIGTYPE_EC384P; + ec384p->base.zrtp_global = zrtp_global; + ec384p->sv_length = 384/8; + ec384p->pv_length = 2*384/8; + ec384p->base.init = EC_dummy; + ec384p->base.free = EC_dummy; + ec384p->generate_key = EC384P_keygen; + ec384p->sign = EC384P_sign; + ec384p->verify = EC384P_verify; + + zrtp_memset(ec521p, 0, sizeof(zrtp_sig_scheme_t)); + zrtp_memcpy(ec521p->base.type, ZRTP_EC521P, ZRTP_COMP_TYPE_SIZE); + ec521p->base.id = ZRTP_SIGTYPE_EC521P; + ec521p->base.zrtp_global = zrtp_global; + ec521p->sv_length = 528/8; + ec521p->pv_length = 2*528/8; + ec521p->base.init = EC_dummy; + ec521p->base.free = EC_dummy; + ec521p->generate_key = EC521P_keygen; + ec521p->sign = EC521P_sign; + ec521p->verify = EC521P_verify; + + zrtp_register_comp(ZRTP_CC_SIG, ec256p, zrtp_global); + zrtp_register_comp(ZRTP_CC_SIG, ec384p, zrtp_global); + zrtp_register_comp(ZRTP_CC_SIG, ec521p, zrtp_global); + + return zrtp_status_ok; +} + +#endif /* don't have disgital signature ready for the moment*/ From 18273e5f3bf13c2aba63b13743fa1ed78c1077f7 Mon Sep 17 00:00:00 2001 From: Philip Zimmermann Date: Sun, 10 Feb 2013 22:07:19 +0000 Subject: [PATCH 47/49] Relicense ECC code under APGLv3 with exception for FreeSWITCH Thanks to Travis Cross for pushing for this to happen. Signed-off-by: Philip Zimmermann Signed-off-by: Travis Cross --- libs/libzrtp/include/zrtp_ec.h | 12 ++++-------- libs/libzrtp/src/zrtp_crypto_ec.c | 12 ++++-------- libs/libzrtp/src/zrtp_crypto_ecdh.c | 12 ++++-------- libs/libzrtp/src/zrtp_crypto_ecdsa.c | 12 ++++-------- libs/libzrtp/src/zrtp_legal.c | 8 -------- 5 files changed, 16 insertions(+), 40 deletions(-) diff --git a/libs/libzrtp/include/zrtp_ec.h b/libs/libzrtp/include/zrtp_ec.h index c4d2f712c6..42e68c553f 100644 --- a/libs/libzrtp/include/zrtp_ec.h +++ b/libs/libzrtp/include/zrtp_ec.h @@ -1,12 +1,8 @@ /* - * zrtp_crypto_ec.c - Elliptic Curve Low Level Crypto functions for ZRTP. - * NSA Suite B Elliptic Curves from NIST SP 800-56A and FIPS 186-3. - * - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * This is NOT licensed under the GPL or any other open source license. - * For licensing terms or other information, - * contact: Philip Zimmermann . - * For more contact information, see http://philzimmermann.com + * libZRTP SDK library, implements the ZRTP secure VoIP protocol. + * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. + * Contact: http://philzimmermann.com + * For licensing and other legal details, see the file zrtp_legal.c. */ #ifndef __ZRTP_CRYPTO_EC_H__ diff --git a/libs/libzrtp/src/zrtp_crypto_ec.c b/libs/libzrtp/src/zrtp_crypto_ec.c index 818081c74d..a593bc07e5 100644 --- a/libs/libzrtp/src/zrtp_crypto_ec.c +++ b/libs/libzrtp/src/zrtp_crypto_ec.c @@ -1,12 +1,8 @@ /* - * zrtp_crypto_ec.c - Elliptic Curve Low Level Crypto functions for ZRTP. - * NSA Suite B Elliptic Curves from NIST SP 800-56A and FIPS 186-3. - * - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * This is NOT licensed under the GPL or any other open source license. - * For licensing terms or other information, - * contact: Philip Zimmermann . - * For more contact information, see http://philzimmermann.com + * libZRTP SDK library, implements the ZRTP secure VoIP protocol. + * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. + * Contact: http://philzimmermann.com + * For licensing and other legal details, see the file zrtp_legal.c. */ #include "zrtp.h" diff --git a/libs/libzrtp/src/zrtp_crypto_ecdh.c b/libs/libzrtp/src/zrtp_crypto_ecdh.c index b78ecb1439..96840fee29 100644 --- a/libs/libzrtp/src/zrtp_crypto_ecdh.c +++ b/libs/libzrtp/src/zrtp_crypto_ecdh.c @@ -1,12 +1,8 @@ /* - * zrtp_crypto_ecdh.c - Elliptic Curve Diffie Hellman functions for ZRTP. - * NSA Suite B Elliptic Curves from NIST SP 800-56A and FIPS 186-3. - * - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * This is NOT licensed under the GPL or any other open source license. - * For licensing terms or other information, - * contact: Philip Zimmermann . - * For more contact information, see http://philzimmermann.com + * libZRTP SDK library, implements the ZRTP secure VoIP protocol. + * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. + * Contact: http://philzimmermann.com + * For licensing and other legal details, see the file zrtp_legal.c. */ #include "zrtp.h" diff --git a/libs/libzrtp/src/zrtp_crypto_ecdsa.c b/libs/libzrtp/src/zrtp_crypto_ecdsa.c index 679f1259c1..fc86f12d2a 100644 --- a/libs/libzrtp/src/zrtp_crypto_ecdsa.c +++ b/libs/libzrtp/src/zrtp_crypto_ecdsa.c @@ -1,12 +1,8 @@ /* - * zrtp_crypto_ecdsa.c - Elliptic Curve Digital Signature functions for ZRTP. - * NSA Suite B Elliptic Curves from NIST SP 800-56A and FIPS 186-3. - * - * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. - * This is NOT licensed under the GPL or any other open source license. - * For licensing terms or other information, - * contact: Philip Zimmermann . - * For more contact information, see http://philzimmermann.com + * libZRTP SDK library, implements the ZRTP secure VoIP protocol. + * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. + * Contact: http://philzimmermann.com + * For licensing and other legal details, see the file zrtp_legal.c. */ #include "zrtp.h" diff --git a/libs/libzrtp/src/zrtp_legal.c b/libs/libzrtp/src/zrtp_legal.c index 33b5c2dfc4..0261977d0d 100644 --- a/libs/libzrtp/src/zrtp_legal.c +++ b/libs/libzrtp/src/zrtp_legal.c @@ -46,14 +46,6 @@ * derivative work of the FreeSWITCH code in the same work, the terms * of the AGPLv3 apply. * - * You might have received some files with this library that are not - * covered by this license grant. These files have a header - * identifying the copyright holder as Philip R. Zimmermann and a - * clear statement that the file is not freely available, such as, - * "This is NOT licensed under the GPL or any other open source - * license." This document grants you no right to distribute or use - * these files. - * * I, Phil Zimmermann, would like to make the following non-binding * request of any contributors to this library: please make your * changes available for me to sublicense. I support myself in part From b03636f0cf4098a6862e36ccdb42aedbcbb4cd58 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Sun, 10 Feb 2013 22:44:12 +0000 Subject: [PATCH 48/49] Always build with ECC support --- libs/libzrtp/Makefile.am | 11 +++-------- libs/libzrtp/configure.in | 11 ----------- libs/libzrtp/include/zrtp.h | 2 -- libs/libzrtp/include/zrtp_config_android.h | 2 -- libs/libzrtp/include/zrtp_config_user.h | 4 ---- libs/libzrtp/include/zrtp_crypto.h | 3 --- libs/libzrtp/include/zrtp_ec.h | 4 ---- libs/libzrtp/src/zrtp.c | 11 ----------- libs/libzrtp/src/zrtp_crypto_ec.c | 4 ---- libs/libzrtp/src/zrtp_crypto_ecdh.c | 4 ---- libs/libzrtp/src/zrtp_crypto_pk.c | 6 ------ 11 files changed, 3 insertions(+), 59 deletions(-) diff --git a/libs/libzrtp/Makefile.am b/libs/libzrtp/Makefile.am index f42a72dbe9..2d3b82421d 100644 --- a/libs/libzrtp/Makefile.am +++ b/libs/libzrtp/Makefile.am @@ -13,6 +13,7 @@ libzrtp_include_HEADERS = \ $(top_srcdir)/include/zrtp_config_user.h \ $(top_srcdir)/include/zrtp_config_unix.h \ $(top_srcdir)/include/zrtp_crypto.h \ + $(top_srcdir)/include/zrtp_ec.h \ $(top_srcdir)/include/zrtp_engine.h \ $(top_srcdir)/include/zrtp_error.h \ $(top_srcdir)/include/zrtp_iface.h \ @@ -40,10 +41,6 @@ libzrtp_include_HEADERS = \ $(top_srcdir)/third_party/bgaes/sha1.h \ $(top_srcdir)/third_party/bgaes/sha2.h -if ZRTP_BUILD_ENTERPRISE -libzrtp_include_HEADERS += $(top_srcdir)/include/zrtp_ec.h -endif - lib_LIBRARIES = libzrtp.a libzrtp_a_CPPFLAGS = \ @@ -58,6 +55,8 @@ libzrtp_a_SOURCES = $(top_srcdir)/src/zrtp.c \ $(top_srcdir)/src/zrtp_crc.c \ $(top_srcdir)/src/zrtp_crypto_aes.c \ $(top_srcdir)/src/zrtp_crypto_atl.c \ + $(top_srcdir)/src/zrtp_crypto_ec.c \ + $(top_srcdir)/src/zrtp_crypto_ecdh.c \ $(top_srcdir)/src/zrtp_crypto_hash.c \ $(top_srcdir)/src/zrtp_crypto_pk.c \ $(top_srcdir)/src/zrtp_crypto_sas.c \ @@ -87,10 +86,6 @@ libzrtp_a_SOURCES = $(top_srcdir)/src/zrtp.c \ \ $(top_srcdir)/src/zrtp_iface_cache.c $(top_srcdir)/src/zrtp_engine_driven.c -if ZRTP_BUILD_ENTERPRISE -libzrtp_a_SOURCES +=$(top_srcdir)/src/zrtp_crypto_ec.c \ - $(top_srcdir)/src/zrtp_crypto_ecdh.c -endif check_PROGRAMS = cache_test diff --git a/libs/libzrtp/configure.in b/libs/libzrtp/configure.in index 1e637031c1..f6001d7515 100644 --- a/libs/libzrtp/configure.in +++ b/libs/libzrtp/configure.in @@ -49,10 +49,6 @@ AC_PROG_CC AC_PROG_CXX AC_PROG_RANLIB -# Apply configure options -AC_ARG_ENABLE(enterprise, [ --enable-enterprise enable building of enterprise components).], enable_enterprise=$enableval,enable_enterprise="no") -AM_CONDITIONAL(ZRTP_BUILD_ENTERPRISE, [test "x$enable_enterprise" = "xyes"]) - # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([linux/version.h endian.h]) @@ -85,13 +81,6 @@ AC_DEFINE(PRAGMA_PACK_PUSH,[#pragma pack(push, 1)],[Define pragma pack(push) for AC_DEFINE(PRAGMA_PACK_POP,[#pragma pack(pop)],[Define pragma pack(pop) for your platform]) AC_DEFINE(INLINE,[static inline],[Define inline construction for your platform]) -if test "x$enable_enterprise" = "xyes" ; then - AC_DEFINE(ENABLE_EC,1,Enterprise) - CFLAGS="$CFLAGS -DZRTP_ENABLE_EC=1" -fi - -AC_SUBST(ENABLE_EC) - # # Documentation # diff --git a/libs/libzrtp/include/zrtp.h b/libs/libzrtp/include/zrtp.h index 185ffdfe30..c2ff1c2c78 100644 --- a/libs/libzrtp/include/zrtp.h +++ b/libs/libzrtp/include/zrtp.h @@ -35,9 +35,7 @@ #include "zrtp_legal.h" #include "zrtp_version.h" #include "zrtp_iface_cache.h" -#if (defined(ZRTP_ENABLE_EC) && (ZRTP_ENABLE_EC == 1)) #include "zrtp_ec.h" -#endif diff --git a/libs/libzrtp/include/zrtp_config_android.h b/libs/libzrtp/include/zrtp_config_android.h index b13bc3f6b5..06d379939e 100644 --- a/libs/libzrtp/include/zrtp_config_android.h +++ b/libs/libzrtp/include/zrtp_config_android.h @@ -94,8 +94,6 @@ #define ZRTP_USE_BUILTIN_SCEHDULER 1 #undef ZRTP_USE_STACK_MINIM #define ZRTP_USE_STACK_MINIM 1 -#undef ZRTP_ENABLE_EC -#define ZRTP_ENABLE_EC 0 #define ALIGNMENT_32BIT_REQUIRED #endif /* ZRTP_WIN_CONFIG_H__ */ diff --git a/libs/libzrtp/include/zrtp_config_user.h b/libs/libzrtp/include/zrtp_config_user.h index c87a6c790e..2989878d08 100644 --- a/libs/libzrtp/include/zrtp_config_user.h +++ b/libs/libzrtp/include/zrtp_config_user.h @@ -122,10 +122,6 @@ # endif #endif -#ifndef ZRTP_ENABLE_EC -#define ZRTP_ENABLE_EC 1 -#endif - #ifndef ZRTP_DEBUG_WITH_PJSIP #define ZRTP_DEBUG_WITH_PJSIP 0 #endif diff --git a/libs/libzrtp/include/zrtp_crypto.h b/libs/libzrtp/include/zrtp_crypto.h index f4ad639710..bb191bdedd 100644 --- a/libs/libzrtp/include/zrtp_crypto.h +++ b/libs/libzrtp/include/zrtp_crypto.h @@ -15,10 +15,7 @@ #include "zrtp_error.h" #include "zrtp_engine.h" #include "zrtp_config_user.h" - -#if (defined(ZRTP_ENABLE_EC) && (ZRTP_ENABLE_EC == 1)) #include "zrtp_ec.h" -#endif diff --git a/libs/libzrtp/include/zrtp_ec.h b/libs/libzrtp/include/zrtp_ec.h index 42e68c553f..75497979a5 100644 --- a/libs/libzrtp/include/zrtp_ec.h +++ b/libs/libzrtp/include/zrtp_ec.h @@ -14,8 +14,6 @@ #include "zrtp_types.h" #include "zrtp_error.h" -#if (defined(ZRTP_ENABLE_EC) && (ZRTP_ENABLE_EC == 1)) - #define ZRTP_MAXECBITS 521 #define ZRTP_MAXECWORDS ((ZRTP_MAXECBITS+7)/8) @@ -80,6 +78,4 @@ int bnSquareMod_ (struct BigNum *rslt, struct BigNum *n1, struct BigNum *mod); } #endif -#endif /*ZRTP_ENABLE_EC*/ - #endif /* __ZRTP_CRYPTO_EC_H__ */ diff --git a/libs/libzrtp/src/zrtp.c b/libs/libzrtp/src/zrtp.c index 3842da10d4..de630d23ef 100644 --- a/libs/libzrtp/src/zrtp.c +++ b/libs/libzrtp/src/zrtp.c @@ -802,7 +802,6 @@ void zrtp_profile_defaults(zrtp_profile_t* profile, zrtp_global_t* zrtp) profile->auth_tag_lens[0] = ZRTP_ATL_HS32; profile->hash_schemes[0] = ZRTP_HASH_SHA256; -#if (defined(ZRTP_ENABLE_EC) && (ZRTP_ENABLE_EC == 1)) if (zrtp && (ZRTP_LICENSE_MODE_PASSIVE == zrtp->lic_mode)) { profile->pk_schemes[0] = ZRTP_PKTYPE_DH2048; profile->pk_schemes[1] = ZRTP_PKTYPE_EC256P; @@ -813,16 +812,6 @@ void zrtp_profile_defaults(zrtp_profile_t* profile, zrtp_global_t* zrtp) profile->pk_schemes[2] = ZRTP_PKTYPE_DH2048; } profile->pk_schemes[3] = ZRTP_PKTYPE_MULT; -#else - if (zrtp && (ZRTP_LICENSE_MODE_PASSIVE == zrtp->lic_mode)) { - profile->pk_schemes[0] = ZRTP_PKTYPE_DH2048; - profile->pk_schemes[1] = ZRTP_PKTYPE_DH3072; - } else { - profile->pk_schemes[0] = ZRTP_PKTYPE_DH3072; - profile->pk_schemes[1] = ZRTP_PKTYPE_DH2048; - } - profile->pk_schemes[2] = ZRTP_PKTYPE_MULT; -#endif } /*----------------------------------------------------------------------------*/ diff --git a/libs/libzrtp/src/zrtp_crypto_ec.c b/libs/libzrtp/src/zrtp_crypto_ec.c index a593bc07e5..6a7fd2907d 100644 --- a/libs/libzrtp/src/zrtp_crypto_ec.c +++ b/libs/libzrtp/src/zrtp_crypto_ec.c @@ -7,8 +7,6 @@ #include "zrtp.h" -#if (defined(ZRTP_ENABLE_EC) && (ZRTP_ENABLE_EC == 1)) - /* Size of extra random data to approximate a uniform distribution mod n */ #define UNIFORMBYTES 8 @@ -461,5 +459,3 @@ zrtp_status_t zrtp_ec_init_params( struct zrtp_ec_params *params, uint32_t bits return zrtp_status_ok; } - -#endif /*ZRTP_ENABLE_EC*/ diff --git a/libs/libzrtp/src/zrtp_crypto_ecdh.c b/libs/libzrtp/src/zrtp_crypto_ecdh.c index 96840fee29..7a47e6c474 100644 --- a/libs/libzrtp/src/zrtp_crypto_ecdh.c +++ b/libs/libzrtp/src/zrtp_crypto_ecdh.c @@ -8,8 +8,6 @@ #include "zrtp.h" -#if (defined(ZRTP_ENABLE_EC) && (ZRTP_ENABLE_EC == 1)) - #define _ZTU_ "zrtp ecdh" static unsigned get_pbits(zrtp_pk_scheme_t *self) @@ -559,5 +557,3 @@ zrtp_status_t zrtp_defaults_ec_pkt(zrtp_global_t* zrtp) return zrtp_status_ok; } - -#endif /*ZRTP_ENABLE_EC*/ diff --git a/libs/libzrtp/src/zrtp_crypto_pk.c b/libs/libzrtp/src/zrtp_crypto_pk.c index 5961b04794..4130d6cbed 100644 --- a/libs/libzrtp/src/zrtp_crypto_pk.c +++ b/libs/libzrtp/src/zrtp_crypto_pk.c @@ -214,9 +214,7 @@ static zrtp_status_t zrtp_dh_self_test(zrtp_pk_scheme_t *self) } /*----------------------------------------------------------------------------*/ -#if (defined(ZRTP_ENABLE_EC) && (ZRTP_ENABLE_EC == 1)) extern zrtp_status_t zrtp_defaults_ec_pkt(zrtp_global_t* zrtp); -#endif zrtp_status_t zrtp_defaults_pkt(zrtp_global_t* zrtp) { @@ -329,11 +327,7 @@ zrtp_status_t zrtp_defaults_pkt(zrtp_global_t* zrtp) presh->base.id = ZRTP_PKTYPE_PRESH; zrtp_comp_register(ZRTP_CC_PKT, presh, zrtp); -#if (defined(ZRTP_ENABLE_EC) && (ZRTP_ENABLE_EC == 1)) return zrtp_defaults_ec_pkt(zrtp); -#else - return zrtp_status_ok; -#endif } /*----------------------------------------------------------------------------*/ From e5a1b54e9e55284bd81414bfc00d642ad38f1d5d Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Sun, 10 Feb 2013 23:47:38 +0000 Subject: [PATCH 49/49] Adjust build for libzrtp changes libzrtp now builds from its root directory rather from projects/gnu. --- Makefile.am | 8 ++++---- bootstrap.sh | 2 +- configure.in | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index ab668b7082..c792e0caf4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -159,11 +159,11 @@ CORE_CFLAGS += -I$(switch_srcdir)/libs/libzrtp/third_party/bgaes CORE_CFLAGS += -I$(switch_srcdir)/libs/libzrtp/third_party/bnlib CORE_CFLAGS += -isystem $(switch_srcdir)/libs/libzrtp/include ZRTP_LDFLAGS = -L$(switch_srcdir)/libs/libzrtp/third_party/bnlib -ZRTP_LDFLAGS += -L$(switch_srcdir)/libs/libzrtp/projects/gnu/build +ZRTP_LDFLAGS += -L$(switch_srcdir)/libs/libzrtp ZRTP_LIBS = -lbn -lzrtp libfreeswitch_la_LDFLAGS += $(ZRTP_LDFLAGS) libfreeswitch_la_LIBADD += $(ZRTP_LIBS) -CORE_LIBS += libs/libzrtp/projects/gnu/build/libzrtp.a +CORE_LIBS += libs/libzrtp/libzrtp.a LIBS += libs/libzrtp/third_party/bnlib/libbn.a endif @@ -441,8 +441,8 @@ src/include/switch_version.h: src/include/switch_version.h.in Makefile build/pri libs/libedit/src/.libs/libedit.a: cd libs/libedit && $(MAKE) -libs/libzrtp/projects/gnu/build/libzrtp.a: - cd libs/libzrtp/projects/gnu && $(MAKE) +libs/libzrtp/libzrtp.a: + cd libs/libzrtp && $(MAKE) libs/sofia-sip/Makefile: cd libs/sofia-sip && sh ./configure.gnu --prefix=$(prefix) diff --git a/bootstrap.sh b/bootstrap.sh index f6d4cfd05a..cdf0711a7b 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -347,7 +347,7 @@ bootstrap_apr() { } bootstrap_libzrtp() { - (cd ${LIBDIR}/libzrtp/projects/gnu && ./bootstrap.sh) + (cd ${LIBDIR}/libzrtp && ./bootstrap.sh) } # Libs automake automation function diff --git a/configure.in b/configure.in index dadc6aaafb..0c83d77d1d 100644 --- a/configure.in +++ b/configure.in @@ -1181,7 +1181,7 @@ AC_CONFIG_SUBDIRS([libs/libg722_1]) AC_CONFIG_SUBDIRS([libs/silk]) AC_CONFIG_SUBDIRS([libs/libcodec2]) if test "x${enable_zrtp}" = "xyes"; then - AC_CONFIG_SUBDIRS([libs/libzrtp/projects/gnu]) + AC_CONFIG_SUBDIRS([libs/libzrtp]) fi AC_CONFIG_SUBDIRS([libs/libwebsockets])