提交 89980756 authored 作者: Travis Cross's avatar Travis Cross

Merge libzrtp fixes and improvements

This brings FS's libzrtp up to date with upstream with the exception
of the changes to the cache API, the new SQLite cache backend, and
SDES support.

In particular, this merge brings in support for elliptic curve (ECC)
algorithms.
......@@ -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)
......
......@@ -347,7 +347,7 @@ bootstrap_apr() {
}
bootstrap_libzrtp() {
(cd ${LIBDIR}/libzrtp/projects/gnu && ./bootstrap.sh)
(cd ${LIBDIR}/libzrtp && ./bootstrap.sh)
}
# Libs automake automation function
......
......@@ -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])
......
# -*- mode:conf -*-
/*.a
/*.dat
/*.o
/.cproject
/.deps
/.project
/.stamp-doc
/Makefile
/Makefile.in
/_configs.sed
/aclocal.m4
/autom4te.cache/*
/cache_test
/config.*
/config/*
/configure
/doc/Doxyfile
/doc/out
/include/zrtp_config_unix.h
!/build/Makefile.am
!/build/test/Makefile.am
......@@ -5,8 +5,6 @@
#
# Viktor Krikun <v.krikun at zfoneproject.com>
libzrtp BETA
Created by Phil Zimmermann.
Developers:
......@@ -28,7 +26,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.
......@@ -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
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
......
#
# Copyright (c) 2006-2007 Philip R. Zimmermann. All rights reserved.
# Contact: http://philzimmermann.com
#
# Viktor Krikun <v.krikun@soft-industry.com> <v.krikun@gmail.com>
#
libzrtp_includedir=$(includedir)/libzrtp
libzrtp_include_HEADERS = \
$(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_ec.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 \
\
$(top_srcdir)/third_party/bnlib/bn.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
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_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 \
$(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
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
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
......@@ -9,6 +9,6 @@ reconf () {
automake --no-force --add-missing --copy
}
(cd ../../third_party/bnlib && ./bootstrap.sh)
(cd third_party/bnlib && ./bootstrap.sh)
reconf
......@@ -6,7 +6,7 @@
# Viktor Krikun <v.krikun at zfoneproject.com>
#
AC_INIT()
AC_INIT([libzrtp], [1.2.0])
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_HEADER(config/config.h)
......@@ -32,16 +32,16 @@ case $target_os in
esac
AM_INIT_AUTOMAKE([libzrtp], [1.15])
AX_PREFIX_CONFIG_H(../../include/zrtp_config_unix.h,ZRTP,config/config.h)
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 -std=c99 -O2 -g3 -Wall -Wextra -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.
......@@ -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])
......@@ -78,19 +74,24 @@ 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])
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"
#
# Documentation
#
AC_CHECK_PROGS([DOXYGEN], [doxygen])
if test -z "$DOXYGEN";
then AC_MSG_WARN([Doxygen not found - continuing without Doxygen support])
fi
AC_SUBST(ENABLE_EC)
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])
AC_OUTPUT([Makefile])
......@@ -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
This source diff could not be displayed because it is too large. You can view the blob instead.
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;
}
<hr size="1"><address style="text-align: right;"><small>
Generated on $datetime for $projectname &nbsp;<a href="http://www.zfoneproject.com"><img src="zfone.jpg" alt="zfone" align="middle" border="0"></a> </small></address>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>$title</title>
<link href="$relpath$tabs.css" rel="stylesheet" type="text/css">
<link href="$relpath$doxygen.css" rel="stylesheet" type="text/css">
</head><body>
......@@ -11,7 +11,32 @@
*/
/*!
\page changelog libzrtp ChangeLog
\page changelog ChangeLog
****************************************************************************************************
\section v120 libzrtp v1.20 build XXX (ZRTP RFC 6189, protocol 1.1)
****************************************************************************************************
<b>This release is focused</b> 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
*- fixed bug when zrtp_signaling_hash_set() silently not accepted imported zrtp-hash-value with
"buffer too small" debug output.
****************************************************************************************************
\section v091 DEVELOPERS BUILD Release Notes - libzrtp - Version 0.91 build XXX (ZRTP ID v16x, protocol 1.X)
......@@ -194,4 +219,5 @@ Minor improvements. Zfone and libZRTP projects moved to public bug-tracking and
*- [LZRTP-132] <b>Replace HMAC with KDF function call.</b>\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.
*/
This diff was suppressed by a .gitattributes entry.
......@@ -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
......@@ -82,6 +80,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
......@@ -161,13 +162,24 @@ 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;
/**
* \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.
......@@ -787,7 +799,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
......@@ -808,8 +820,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
......@@ -817,9 +829,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
......@@ -945,6 +957,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)
......
......@@ -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__ */
......@@ -122,10 +122,6 @@
# endif
#endif
#ifndef ZRTP_ENABLE_EC
#define ZRTP_ENABLE_EC 0
#endif
#ifndef ZRTP_DEBUG_WITH_PJSIP
#define ZRTP_DEBUG_WITH_PJSIP 0
#endif
......
......@@ -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
......
/*
* 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__
#define __ZRTP_CRYPTO_EC_H__
#include "bn.h"
#include "zrtp_config.h"
#include "zrtp_types.h"
#include "zrtp_error.h"
#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_CRYPTO_EC_H__ */
......@@ -11,7 +11,6 @@
#define __ZRTP_STRING_H__
#include "zrtp_config.h"
#include "zrtp_types.h"
/**
* \file zrtp_strings.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.*/
};
......
......@@ -12,8 +12,8 @@
#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_MINOR 20
#define LIBZRTP_VERSION_BUILD 616
#define LIBZRTP_VERSION_STR "v1.20 616"
#endif /*__ZRTP_VERSION_H__*/
# -*- 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
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 <v.krikun@soft-industry.com> <v.krikun@gmail.com>
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.
Change Log is available at [https://developers.zfoneproject.com/libzrtp/wiki/LibzrtpChangeLog]
\ No newline at end of file
#
# Copyright (c) 2006-2007 Philip R. Zimmermann. All rights reserved.
# Contact: http://philzimmermann.com
#
# Viktor Krikun <v.krikun@soft-industry.com> <v.krikun@gmail.com>
#
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 \
\
$(THIRD_DIR)/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
if ZRTP_BUILD_ENTERPRISE
libzrtp_include_HEADERS += $(TOP_SRCDIR)/zrtp_ec.h
endif
SUBDIRS = ../../third_party/bnlib
SUBDIRS += build
uninstall:
rm -rf $(prefix)/include/libzrtp
rm -f $(prefix)/lib/libzrtp.a
#
# Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved.
# Contact: http://philzimmermann.com
#
# Viktor Krikun <v.krikun@soft-industry.com> <v.krikun@gmail.com>
#
TOP_SRCDIR=$(top_srcdir)/../..
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
# Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved.
# Contact: http://philzimmermann.com
#
# Viktor Krikun <v.krikun@soft-industry.com> <v.krikun@gmail.com>
#
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
#check_PROGRAMS = cache_test libzrtp_test
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
### 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:
# @ ./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 <zrtp_support@zfoneproject.com>. *"
# @echo "*========================================================================*"
# @echo ""
......@@ -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 @@
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../include;../../third_party/bnlib;../../third_party/bgaes"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;HAVE_CONFIG_H=1;ZRTP_ENABLE_EC=0"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;HAVE_CONFIG_H=1;ZRTP_ENABLE_EC=1"
ExceptionHandling="0"
RuntimeLibrary="0"
StructMemberAlignment="0"
......@@ -180,6 +180,10 @@
RelativePath="..\..\include\zrtp_crypto.h"
>
</File>
<File
RelativePath="..\..\include\zrtp_ec.h"
>
</File>
<File
RelativePath="..\..\include\zrtp_engine.h"
>
......@@ -244,6 +248,10 @@
RelativePath="..\..\include\zrtp_utils.h"
>
</File>
<File
RelativePath="..\..\include\zrtp_version.h"
>
</File>
</Filter>
<Filter
Name="src"
......@@ -264,6 +272,14 @@
RelativePath="..\..\src\zrtp_crypto_atl.c"
>
</File>
<File
RelativePath="..\..\src\zrtp_crypto_ec.c"
>
</File>
<File
RelativePath="..\..\src\zrtp_crypto_ecdh.c"
>
</File>
<File
RelativePath="..\..\src\zrtp_crypto_hash.c"
>
......
......@@ -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"
>
</File>
<File
RelativePath="..\..\include\zrtp_ec.h"
>
</File>
<File
RelativePath="..\..\include\zrtp_engine.h"
>
......@@ -462,6 +466,18 @@
RelativePath="..\..\src\zrtp_crypto_atl.c"
>
</File>
<File
RelativePath="..\..\src\zrtp_crypto_ec.c"
>
</File>
<File
RelativePath="..\..\src\zrtp_crypto_ecdh.c"
>
</File>
<File
RelativePath="..\..\src\zrtp_crypto_ecdsa.c"
>
</File>
<File
RelativePath="..\..\src\zrtp_crypto_hash.c"
>
......@@ -482,6 +498,10 @@
RelativePath="..\..\src\zrtp_engine.c"
>
</File>
<File
RelativePath="..\..\src\zrtp_engine_driven.c"
>
</File>
<File
RelativePath="..\..\src\zrtp_iface_cache.c"
>
......
......@@ -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
......
......@@ -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
......
......@@ -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));
......@@ -434,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);
......@@ -461,8 +462,9 @@ 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);
/* Generate Random nonce, compute H1 and store in the DH packet */
new_stream->messages.h0.length = (uint16_t)zrtp_randstr( new_stream->zrtp,
......@@ -592,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;
}
......@@ -619,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;
}
......@@ -631,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;
}
......@@ -803,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;
......@@ -814,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
}
/*----------------------------------------------------------------------------*/
......@@ -1093,6 +1081,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 +1090,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 +1099,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 +1113,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)
......@@ -1129,7 +1121,8 @@ 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";
}
}
break;
default:
return "Unkn";
......
差异被折叠。
差异被折叠。
差异被折叠。
......@@ -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
}
/*----------------------------------------------------------------------------*/
......
......@@ -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;
......@@ -83,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));
......@@ -102,7 +103,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,9 +118,11 @@ 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);
if (zrtp->cache_auto_store) zrtp_def_cache_store(zrtp);
return (new_elem) ? zrtp_status_ok : zrtp_status_fail;
}
......@@ -145,7 +148,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,
......@@ -213,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;
}
......@@ -229,7 +233,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 +291,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)
......@@ -308,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;
}
......@@ -331,7 +335,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 +349,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 +369,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 +577,7 @@ zrtp_status_t zrtp_cache_user_init()
return s;
}
/*---------------------------------------------------------------------------*/
#define ZRTP_DOWN_CACHE_RETURN(s, f) \
{\
if (zrtp_status_ok != s) { \
......@@ -644,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));
......@@ -686,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) {
......@@ -694,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);
}
......@@ -709,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: <secrets count>, <secrets' data>
......@@ -722,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) {
......@@ -731,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);
}
......@@ -746,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;
......@@ -790,6 +796,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;
}
......@@ -879,6 +887,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;
}
......@@ -941,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;
}
......
......@@ -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
......
......@@ -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
......
......@@ -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)
{
......
......@@ -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 */
......
......@@ -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);
}
......@@ -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;
}
......
......@@ -11,7 +11,7 @@
#include <stddef.h>
#include <setjmp.h>
#include <string.h>
#include <stdio.h>
#include <stdio.h>
#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");
......
/*
* 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 <v.krikun at zfoneproject.com>
*/
#include <setjmp.h>
#include <stdio.h>
#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);
}
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);
}
......@@ -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 */
......
/*
* 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 <v.krikun at zfoneproject.com>
*/
#include <setjmp.h>
#include <stdio.h>
#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);
}
/*
* 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 <v.krikun at zfoneproject.com>
*/
#include <setjmp.h>
#include <stdio.h>
#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<len; i++) {
if (a[i] != b[i]) {
res = zrtp_status_fail;
break;
}
}
return res;
}
static void dk_test() {
zrtp_status_t res;
zrtp_string16_t master_key, master_salt, cipher_key, cipher_salt;
zrtp_string128_t auth_key;
zrtp_dk_ctx *ctx;
zrtp_cipher_t *cipher = zrtp_comp_find(ZRTP_CC_CIPHER, ZRTP_CIPHER_AES128, zrtp);
assert_non_null(cipher);
master_key.length = master_key.max_length = 16;
zrtp_memcpy(master_key.buffer, dk_master_key, 16);
master_salt.length = 14;
master_salt.max_length = 16;
zrtp_memcpy(master_salt.buffer, dk_master_salt, 14);
ctx = zrtp_dk_init(cipher, (zrtp_stringn_t*)&master_key, (zrtp_stringn_t*)&master_salt);
assert_non_null(ctx);
cipher_key.length = 16;
cipher_key.max_length = 16;
zrtp_derive_key(ctx, label_rtp_encryption, (zrtp_stringn_t*)&cipher_key);
res = hex_cmp((uint8_t*)cipher_key.buffer, dk_cipher_key, cipher_key.length);
assert_int_equal(res, zrtp_status_ok);
cipher_salt.length = 14;
cipher_salt.max_length = 16;
zrtp_derive_key(ctx, label_rtp_salt, (zrtp_stringn_t*)&cipher_salt);
res = hex_cmp((uint8_t*)cipher_salt.buffer, dk_cipher_salt, cipher_salt.length);
assert_int_equal(res, zrtp_status_ok);
auth_key.length = 94;
auth_key.max_length = 128;
zrtp_derive_key(ctx, label_rtp_msg_auth, (zrtp_stringn_t*)&auth_key);
res = hex_cmp((uint8_t*)auth_key.buffer, dk_auth_key, auth_key.length);
assert_int_equal(res, zrtp_status_ok);
zrtp_dk_deinit(ctx);
}
int main(void) {
const UnitTest tests[] = {
unit_test_setup_teardown(dk_test, setup, teardown),
};
return run_tests(tests);
}
/*
* 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 <v.krikun at zfoneproject.com>
*/
#include <setjmp.h>
#include <stdio.h>
#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);
}
/*
* 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 <v.krikun at zfoneproject.com>
*/
#include <setjmp.h> /*chmockery dependency*/
#include <stdio.h> /*chmockery dependency*/
#include <unistd.h> /*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);
}
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);
}
/*
* 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 <v.krikun at zfoneproject.com>
*/
#include <setjmp.h> /*chmockery dependency*/
#include <stdio.h> /*chmockery dependency*/
#include <unistd.h> /*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));
/* 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"
*/
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()
}
int main(void) {
const UnitTest tests[] = {
unit_test_setup_teardown(enrollment_test, pbx_setup, pbx_teardown),
};
return run_tests(tests);
}
/*
* 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 <v.krikun at zfoneproject.com>
*/
#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 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);
}
/*
* 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 <v.krikun at zfoneproject.com>
*/
#include <setjmp.h>
#include <stdio.h>
#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);
}
/*
* 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 <v.krikun at zfoneproject.com>
*/
#include <setjmp.h>
#include <stdio.h>
#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);
}
差异被折叠。
/*
* 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 <v.krikun at zfoneproject.com>
*/
#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__*/
/*
* 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 <v.krikun at zfoneproject.com>
*/
#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;
}
......@@ -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);
......
......@@ -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;
......
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
/*
* 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: <chaser@soft-industry.com>
*/
#pragma once
#ifdef POCKETPC2003_UI_MODEL
#include "resourceppc.h"
#endif
#ifdef SMARTPHONE2003_UI_MODEL
#include "resourcesp.h"
#endif
//
// libzrtp_test_GUIPPC.RC2 - resources Microsoft Visual C++ does not edit directly
//
#ifdef APSTUDIO_INVOKED
#error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// Add manually edited resources here...
/////////////////////////////////////////////////////////////////////////////
HI_RES_AWARE CEUX {1} // turn off the emulation layer
// Remove this resource to enable pixel-
// doubling on platforms that support it
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//
// SHMENUBAR
//
IDR_MENU SHMENUBAR DISCARDABLE
BEGIN
IDR_MENU,
2,
I_IMAGENONE, IDM_OK, TBSTATE_ENABLED, TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE,
IDS_OK, 0, NOMENU,
I_IMAGENONE, IDM_HELP, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
IDS_HELP, 0, 0,
END
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
# -*- mode:conf -*-
/*.a
/*.o
/Makefile
/autom4te.cache/*
/bnconfig.h
/config.*
/configure
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论