Skip to content
Snippets Groups Projects
Commit e24852d9 authored by Alexandre Lision's avatar Alexandre Lision
Browse files

* #40116: Switch to 2.3.0 libzrtpcpp version

parent c735aa22
Branches
Tags
No related merge requests found
Showing
with 840 additions and 4882 deletions
......@@ -109,6 +109,7 @@ LOCAL_SRC_FILES := \
$(LOCAL_SRC_PATH)/audio/audiortp/audio_rtp_record_handler.cpp \
$(LOCAL_SRC_PATH)/audio/audiortp/audio_rtp_factory.cpp \
$(LOCAL_SRC_PATH)/audio/audiortp/audio_srtp_session.cpp \
$(LOCAL_SRC_PATH)/audio/audiortp/dtmf_event.cpp \
$(LOCAL_SRC_PATH)/config/sfl_config.cpp \
$(LOCAL_SRC_PATH)/config/yamlemitter.cpp \
$(LOCAL_SRC_PATH)/config/yamlparser.cpp \
......@@ -159,8 +160,8 @@ LOCAL_C_INCLUDES += $(LOCAL_SRC_PATH)/.. \
$(MY_SPEEX)/include \
$(MY_LIBYAML)/inc \
$(MY_LIBZRTPCPP) \
$(MY_LIBZRTPCPP)/zrtp \
$(MY_LIBZRTPCPP)/zrtp/libzrtpcpp \
$(MY_LIBZRTPCPP)/src \
$(MY_LIBZRTPCPP)/src/libzrtpcpp \
$(MY_CCRTP)/src \
$(MY_LIBSAMPLE)/src \
$(MY_OPENSSL)/include \
......
......@@ -17,104 +17,62 @@ LOCAL_CPPFLAGS += -fexceptions
MY_COMMONCPP = libucommon/sources
MY_CCRTP = libccrtp/sources
MY_OPENSSL = libopenssl
# include paths for zrtpcpp modules
LOCAL_C_INCLUDES += $(ROOT_SRC_PATH) \
$(ROOT_SRC_PATH)/srtp \
$(ROOT_SRC_PATH)/zrtp \
$(ROOT_SRC_PATH)/zrtp/libzrtpcpp \
$(ROOT_SRC_PATH)/src \
$(ROOT_SRC_PATH)/src/libzrtpcpp \
$(ROOT_SRC_PATH)/src/libzrtpcpp/openssl \
${MY_COMMONCPP}/inc \
$(MY_OPENSSL)/include \
$(MY_CCRTP)/src \
$(ROOT_SRC_PATH)/bnlib \
$(ROOT_SRC_PATH)/bnlib/ec
EC_SRCS = $(ROOT_SRC_PATH)/bnlib/ec/ec.c \
$(ROOT_SRC_PATH)/bnlib/ec/ecdh.c \
$(ROOT_SRC_PATH)/bnlib/ec/curve25519-donna.c
COMMON_SRCS = $(ROOT_SRC_PATH)/common/osSpecifics.c \
$(ROOT_SRC_PATH)/common/Thread.cpp \
$(ROOT_SRC_PATH)/common/MutexClass.cpp \
$(ROOT_SRC_PATH)/common/EventClass.cpp
BNLIB_SRCS = $(ROOT_SRC_PATH)/bnlib/bninit64.c \
$(ROOT_SRC_PATH)/bnlib/legal.c \
$(ROOT_SRC_PATH)/bnlib/sieve.c \
$(ROOT_SRC_PATH)/bnlib/bn16.c \
$(ROOT_SRC_PATH)/bnlib/bn64.c \
$(ROOT_SRC_PATH)/bnlib/bnprint.c \
$(ROOT_SRC_PATH)/bnlib/germain.c \
$(ROOT_SRC_PATH)/bnlib/lbn32.c \
$(ROOT_SRC_PATH)/bnlib/bninit16.c \
$(ROOT_SRC_PATH)/bnlib/lbnmem.c \
$(ROOT_SRC_PATH)/bnlib/prime.c \
$(ROOT_SRC_PATH)/bnlib/bn32.c \
$(ROOT_SRC_PATH)/bnlib/bn.c \
$(ROOT_SRC_PATH)/bnlib/bninit32.c \
$(ROOT_SRC_PATH)/bnlib/jacobi.c
LOCAL_SRC_FILES += $(ROOT_SRC_PATH)/zrtp/ZrtpCallbackWrapper.cpp \
$(ROOT_SRC_PATH)/zrtp/ZRtp.cpp \
$(ROOT_SRC_PATH)/zrtp/ZrtpCrc32.cpp \
$(ROOT_SRC_PATH)/zrtp/ZrtpPacketCommit.cpp \
$(ROOT_SRC_PATH)/zrtp/ZrtpPacketConf2Ack.cpp \
$(ROOT_SRC_PATH)/zrtp/ZrtpPacketConfirm.cpp \
$(ROOT_SRC_PATH)/zrtp/ZrtpPacketDHPart.cpp \
$(ROOT_SRC_PATH)/zrtp/ZrtpPacketGoClear.cpp \
$(ROOT_SRC_PATH)/zrtp/ZrtpPacketClearAck.cpp \
$(ROOT_SRC_PATH)/zrtp/ZrtpPacketHelloAck.cpp \
$(ROOT_SRC_PATH)/zrtp/ZrtpPacketHello.cpp \
$(ROOT_SRC_PATH)/zrtp/ZrtpPacketError.cpp \
$(ROOT_SRC_PATH)/zrtp/ZrtpPacketErrorAck.cpp \
$(ROOT_SRC_PATH)/zrtp/ZrtpPacketPingAck.cpp \
$(ROOT_SRC_PATH)/zrtp/ZrtpPacketPing.cpp \
$(ROOT_SRC_PATH)/zrtp/ZrtpPacketSASrelay.cpp \
$(ROOT_SRC_PATH)/zrtp/ZrtpPacketRelayAck.cpp \
$(ROOT_SRC_PATH)/zrtp/ZrtpStateClass.cpp \
$(ROOT_SRC_PATH)/zrtp/ZrtpTextData.cpp \
$(ROOT_SRC_PATH)/zrtp/ZrtpConfigure.cpp \
$(ROOT_SRC_PATH)/zrtp/ZrtpCWrapper.cpp \
$(ROOT_SRC_PATH)/zrtp/ZrtpQueue.cpp \
$(ROOT_SRC_PATH)/zrtp/Base32.cpp \
$(ROOT_SRC_PATH)/zrtp/zrtpB64Encode.c \
$(ROOT_SRC_PATH)/zrtp/zrtpB64Decode.c \
$(ROOT_SRC_PATH)/zrtp/ZrtpSdesStream.cpp \
$(ROOT_SRC_PATH)/zrtp/ZIDRecordDb.cpp \
$(ROOT_SRC_PATH)/zrtp/crypto/zrtpDH.cpp \
$(ROOT_SRC_PATH)/zrtp/crypto/hmac256.cpp \
$(ROOT_SRC_PATH)/zrtp/crypto/sha256.cpp \
$(ROOT_SRC_PATH)/zrtp/crypto/hmac384.cpp \
$(ROOT_SRC_PATH)/zrtp/crypto/sha384.cpp \
$(ROOT_SRC_PATH)/zrtp/crypto/aesCFB.cpp \
$(ROOT_SRC_PATH)/zrtp/crypto/twoCFB.cpp \
$(ROOT_SRC_PATH)/zrtp/crypto/skein256.cpp \
$(ROOT_SRC_PATH)/zrtp/crypto/skeinMac256.cpp \
$(ROOT_SRC_PATH)/zrtp/crypto/skein384.cpp \
$(ROOT_SRC_PATH)/zrtp/crypto/skeinMac384.cpp \
$(ROOT_SRC_PATH)/zrtp/crypto/sha2.c \
$(ROOT_SRC_PATH)/zrtp/ZIDCacheFile.cpp \
$(ROOT_SRC_PATH)/zrtp/ZIDRecordFile.cpp \
LOCAL_SRC_FILES += $(ROOT_SRC_PATH)/src/ZrtpCallbackWrapper.cpp \
$(ROOT_SRC_PATH)/src/ZRtp.cpp \
$(ROOT_SRC_PATH)/src/ZIDFile.cpp \
$(ROOT_SRC_PATH)/src/ZrtpCrc32.cpp \
$(ROOT_SRC_PATH)/src/ZrtpPacketCommit.cpp \
$(ROOT_SRC_PATH)/src/ZrtpPacketConf2Ack.cpp \
$(ROOT_SRC_PATH)/src/ZrtpPacketConfirm.cpp \
$(ROOT_SRC_PATH)/src/ZrtpPacketDHPart.cpp \
$(ROOT_SRC_PATH)/src/Base32.cpp \
$(ROOT_SRC_PATH)/src/ZIDRecord.cpp \
$(ROOT_SRC_PATH)/src/ZrtpPacketGoClear.cpp \
$(ROOT_SRC_PATH)/src/ZrtpPacketClearAck.cpp \
$(ROOT_SRC_PATH)/src/ZrtpPacketHelloAck.cpp \
$(ROOT_SRC_PATH)/src/ZrtpPacketHello.cpp \
$(ROOT_SRC_PATH)/src/ZrtpPacketError.cpp \
$(ROOT_SRC_PATH)/src/ZrtpPacketErrorAck.cpp \
$(ROOT_SRC_PATH)/src/ZrtpPacketPingAck.cpp \
$(ROOT_SRC_PATH)/src/ZrtpPacketPing.cpp \
$(ROOT_SRC_PATH)/src/ZrtpPacketSASrelay.cpp \
$(ROOT_SRC_PATH)/src/ZrtpPacketRelayAck.cpp \
$(ROOT_SRC_PATH)/src/ZrtpStateClass.cpp \
$(ROOT_SRC_PATH)/src/ZrtpTextData.cpp \
$(ROOT_SRC_PATH)/src/ZrtpConfigure.cpp \
$(ROOT_SRC_PATH)/src/ZrtpCWrapper.cpp \
$(ROOT_SRC_PATH)/src/ZrtpQueue.cpp \
$(ROOT_SRC_PATH)/src/libzrtpcpp/crypto/TwoCFB.cpp \
$(ROOT_SRC_PATH)/src/libzrtpcpp/crypto/twofish_cfb.c \
$(ROOT_SRC_PATH)/src/libzrtpcpp/crypto/twofish.c \
$(ROOT_SRC_PATH)/src/libzrtpcpp/crypto/openssl/sha256.cpp \
$(ROOT_SRC_PATH)/src/libzrtpcpp/crypto/openssl/hmac384.cpp \
$(ROOT_SRC_PATH)/src/libzrtpcpp/crypto/openssl/hmac256.cpp \
$(ROOT_SRC_PATH)/src/libzrtpcpp/crypto/openssl/sha384.cpp \
$(ROOT_SRC_PATH)/src/libzrtpcpp/crypto/openssl/ZrtpDH.cpp \
$(ROOT_SRC_PATH)/src/libzrtpcpp/crypto/openssl/AesCFB.cpp \
$(ROOT_SRC_PATH)/srtp/crypto/skein.c \
$(ROOT_SRC_PATH)/srtp/crypto/skeinApi.c \
$(ROOT_SRC_PATH)/srtp/crypto/skein_block.c \
$(ROOT_SRC_PATH)/srtp/crypto/macSkein.cpp \
$(ROOT_SRC_PATH)/srtp/CryptoContext.cpp \
$(ROOT_SRC_PATH)/srtp/CryptoContextCtrl.cpp \
$(ROOT_SRC_PATH)/srtp/SrtpHandler.cpp \
$(ROOT_SRC_PATH)/srtp/crypto/hmac.cpp \
$(ROOT_SRC_PATH)/srtp/crypto/SrtpSymCrypto.cpp \
$(ROOT_SRC_PATH)/srtp/crypto/sha1.c \
$(ROOT_SRC_PATH)/cryptcommon/twofish.c \
$(ROOT_SRC_PATH)/cryptcommon/twofish_cfb.c \
$(ROOT_SRC_PATH)/cryptcommon/aescrypt.c \
$(ROOT_SRC_PATH)/cryptcommon/aeskey.c \
$(ROOT_SRC_PATH)/cryptcommon/aestab.c \
$(ROOT_SRC_PATH)/cryptcommon/aes_modes.c \
$(ROOT_SRC_PATH)/cryptcommon/macSkein.cpp \
$(ROOT_SRC_PATH)/cryptcommon/skein.c \
$(ROOT_SRC_PATH)/cryptcommon/skein_block.c \
$(ROOT_SRC_PATH)/cryptcommon/skeinApi.c \
$(ROOT_SRC_PATH)/cryptcommon/ZrtpRandom.cpp \
$(EC_SRCS) \
$(COMMON_SRCS) \
$(BNLIB_SRCS)
$(ROOT_SRC_PATH)/srtp/crypto/openssl/hmac.cpp \
$(ROOT_SRC_PATH)/srtp/crypto/openssl/SrtpSymCrypto.cpp \
LOCAL_STATIC_LIBRARY += libccrtp1
......
build*/
build/
autoconf/
doc/html/
configure
......@@ -16,8 +16,4 @@ aclocal.m4
*.pc
*.spec
*~
.DS_Store
._.DS_Store
._buildmac
.directory
......@@ -12,53 +12,13 @@ cmake_minimum_required(VERSION 2.6)
PROJECT(libzrtpcpp)
SET(CPACK_PACKAGE_VERSION_MAJOR 4)
SET(CPACK_PACKAGE_VERSION_MINOR 1)
SET(CPACK_PACKAGE_VERSION_PATCH 1)
SET(CPACK_PACKAGE_VERSION_MAJOR 2)
SET(CPACK_PACKAGE_VERSION_MINOR 3)
SET(CPACK_PACKAGE_VERSION_PATCH 0)
set (VERSION 4.1.1)
set (SOVERSION 4)
# Define supported command line parameters.
#
# Example to build the tivi client: cmake -DTIVI=true ..
# Without any options cmake generates libzrtpcpp for use with GNU ccRTP
#
option(CCRTP "Build library to use with GNU ccRTP." OFF)
option(CORE_LIB "Build core library only, no spcific client support." OFF)
option(CRYPTO_STANDALONE "Use embedded crypto and big number modules." ON)
option(TIVI "Build library for the tivi client, implies '-DCRYPTO_STNDALONE=true'." OFF)
option(SQLITE "Use SQLite DB as backend for ZRTP cache." OFF)
option(SDES "Include SDES when not building for CCRTP." ON)
option(ANDROID "Generate Android makefiles (Android.mk)" ON)
option(JAVA "Generate Java support files (requires JDK and SWIG)" OFF)
# **** Check what and how to build ****
#
if (CCRTP AND TIVI)
MESSAGE(FATAL_ERROR "Cannot build more than one client at once. Use different build directories.")
endif()
if (CCRTP)
set (VERSION 2.3.0)
set (SOVERSION 2)
set (PACKAGE libzrtpcpp)
set(zrtplibName zrtpcpp)
elseif (TIVI)
set (PACKAGE libzrtptivi)
set(zrtplibName zrtptivi)
set(CRYPTO_STANDALONE true)
set(SQLITE true)
elseif (CORE_LIB)
set (PACKAGE libzrtpcore)
set(zrtplibName zrtpcppcore)
else()
MESSAGE(WARNING "No client defined, building for GNU ccRTP.")
set (PACKAGE libzrtpcpp)
set(CCRTP true)
set(zrtplibName zrtpcpp)
endif()
if(MSVC60)
set(BUILD_STATIC ON CACHE BOOL "static linking only" FORCE)
......@@ -68,18 +28,26 @@ else()
endif()
# set to true for debug and trace during CMakeLists development
# set(CMAKE_VERBOSE_MAKEFILE TRUE)
execute_process(COMMAND git rev-parse --short HEAD OUTPUT_VARIABLE GIT_COMMIT)
STRING(REGEX REPLACE "(\r?\n)+$" "" GIT_COMMIT "${GIT_COMMIT}")
set(CMAKE_VERBOSE_MAKEFILE FALSE)
MESSAGE( STATUS "Configuring GNU ${PROJECT_NAME} ${VERSION} for ${PACKAGE}, commit: ${GIT_COMMIT} ...")
MESSAGE( STATUS "Configuring GNU ${PROJECT_NAME} ${VERSION}...")
# include most of the fine stuff we need
include(cmake/Modules/FindGcryptConfig.cmake)
include(FindPkgConfig)
include(CheckLibraryExists)
include(CheckIncludeFiles)
include(CheckFunctionExists)
include(cmake/Modules/AutoArgs.cmake)
if(${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME})
include(cmake/Modules/GeneratePackage.cmake)
GENERATE_PACKAGING(${PACKAGE} ${VERSION})
endif()
# check the -Denable-ccrtp setting, defaults to true
enable_arg(ccrtp true "Enable GNU ccRTP support for GNU ZRTP")
args_help()
if (NOT LIB_SUFFIX)
set(LIBDIRNAME "lib")
......@@ -93,10 +61,38 @@ else()
set(LIBDIRNAME "lib${LIB_SUFFIX}")
endif()
check_include_files(stdlib.h HAVE_STDLIB_H)
check_include_files(string.h HAVE_STRING_H)
# setup the Thread include and lib
find_package(Threads)
if(CMAKE_HAVE_PTHREAD_H)
set(HAVE_PTHREAD_H TRUE)
endif()
set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})
if (NOT CRYPTO_STANDALONE)
# define the name of the lib. zrtpcppcore does not include the ccRTP stuff.
set(zrtplib zrtpcppcore)
if(enable_ccrtp)
if (USES_CCRTP_INCLUDE_DIRS)
message(STATUS " Using local commoncpp dependency")
else()
find_package(PkgConfig)
pkg_check_modules(USES_CCRTP libccrtp>=2.0.0)
endif()
include_directories(${USES_CCRTP_INCLUDE_DIRS})
link_directories(${USES_CRTP_LIBRARY_DIRS})
add_definitions(${USES_CCRTP_CFLAGS})
set (LIBS ${LIBS} ${USES_CCRTP_LDFLAGS} ${USES_CCRTP_LIBRARIES})
set(zrtplib zrtpcpp)
endif()
# now get info about crypto libraries
gcr_check(GCRYPT gcrypt)
#if(GCRYPT_FOUND)
# check_include_files(gcrypt.h HAVE_GCRYPT_H)
# set(LIBS ${LIBS} ${GCRYPT_LIBRARIES})
# set(BUILD_REQ "libgcrypt-devel")
# set(CRYPTOBACKEND="")
# set(PACKAGE_REQ "libgcrypt")
#else()
pkg_check_modules(OPENSSL libcrypto>=0.9.8)
if (OPENSSL_FOUND)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${OPENSSL_INCLUDE_DIRS}) #update include files search directory
......@@ -112,152 +108,60 @@ if (NOT CRYPTO_STANDALONE)
else()
message(FATAL_ERROR "No crypto library found")
endif()
else()
# For crypto standalone mode we need to configure the bnlib. In a first step
# without the tests and demos.
check_include_files(stdint.h HAVE_STDINT_H)
check_include_files(stdint.h HAVE_ASSERT_H)
check_include_files(limits.h HAVE_LIMITS_H)
check_function_exists(memmove HAVE_MEMMOVE)
check_function_exists(memcpy HAVE_MEMCPY)
#endif()
# TODO: check if we compile the tests for bnlib
#
# check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
# check_function_exists(getrusage HAVE_GETRUSAGE)
# check_function_exists(clock HAVE_CLOCK)
# check_function_exists(time HAVE_TIME)
# Check if Solaris-style gethrvtime() is available
# check_function_exists(gethrvtime HAVE_GETHRVTIME)
#
# until here
check_include_files(stdlib.h HAVE_STDLIB_H)
check_include_files(string.h HAVE_STRING_H)
# necessary and required modules checked, ready to generate config.h
configure_file(${CMAKE_SOURCE_DIR}/bnlib/bnconfig.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/bnconfig.h)
endif()
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
if (SQLITE)
pkg_check_modules(SQLITE3 sqlite3>=3.7)
if (SQLITE3_FOUND)
check_include_files(sqlite3.h HAVE_SQLITE_H)
set(LIBS ${LIBS} -lsqlite3)
else()
message(FATAL_ERROR "SQLite3 library not found")
endif()
endif()
# the following set(...) commands are only to have backward
# compatibility with autoconf stuff to generate the pc file
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${prefix}/bin)
set(libdir ${prefix}/${LIBDIRNAME})
set(includedir ${prefix}/include)
set(PACKAGE pkgconfig)
configure_file(libzrtpcpp.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/lib${zrtplib}.pc @ONLY)
# necessary and required modules checked, ready to generate config.h in top-level build directory
configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h)
configure_file(libzrtpcpp.spec.cmake ${CMAKE_CURRENT_BINARY_DIR}/libzrtpcpp.spec @ONLY)
#to make sure includes are first taken from those directory
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src)
add_definitions(-g -O2 -fno-strict-aliasing)
if(CMAKE_COMPILER_IS_GNUCXX)
# add_definitions(-Wno-long-long -Wno-char-subscripts)
# add_definitions(-Wall -ansi -pedantic)
# add_definitions(-Wall -pedantic)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -std=c99")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -std=c++11")
add_definitions(-Wno-long-long -Wno-char-subscripts)
add_definitions(-Wall -ansi -pedantic)
add_definitions(-DNEW_STDCPP)
endif()
include_directories(BEFORE ${CMAKE_BINARY_DIR})
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/zrtp)
add_subdirectory(src)
if(CRYPTO_STANDALONE)
add_definitions(-DSUPPORT_NON_NIST)
include_directories (${CMAKE_SOURCE_DIR}/bnlib)
if (enable_ccrtp)
add_subdirectory(demo)
endif()
if (SDES AND NOT CCRTP)
set (sdes_src ${CMAKE_SOURCE_DIR}/zrtp/ZrtpSdesStream.cpp)
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/package/)
MESSAGE(STATUS "package dir not found")
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/package/)
endif()
# **** The following source files a common for all clients ****
#
set(zrtp_src_no_cache
${CMAKE_SOURCE_DIR}/zrtp/ZrtpCallbackWrapper.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZRtp.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZrtpCrc32.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZrtpPacketCommit.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZrtpPacketConf2Ack.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZrtpPacketConfirm.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZrtpPacketDHPart.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZrtpPacketGoClear.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZrtpPacketClearAck.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZrtpPacketHelloAck.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZrtpPacketHello.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZrtpPacketError.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZrtpPacketErrorAck.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZrtpPacketPingAck.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZrtpPacketPing.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZrtpPacketSASrelay.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZrtpPacketRelayAck.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZrtpStateClass.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZrtpTextData.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZrtpConfigure.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZrtpCWrapper.cpp
${CMAKE_SOURCE_DIR}/zrtp/Base32.cpp
${CMAKE_SOURCE_DIR}/zrtp/zrtpB64Encode.c
${CMAKE_SOURCE_DIR}/zrtp/zrtpB64Decode.c
${CMAKE_SOURCE_DIR}/common/osSpecifics.c ${sdes_src})
set(bnlib_src
${CMAKE_SOURCE_DIR}/bnlib/bn00.c
${CMAKE_SOURCE_DIR}/bnlib/lbn00.c
${CMAKE_SOURCE_DIR}/bnlib/bn.c
${CMAKE_SOURCE_DIR}/bnlib/lbnmem.c
${CMAKE_SOURCE_DIR}/bnlib/sieve.c
${CMAKE_SOURCE_DIR}/bnlib/prime.c
${CMAKE_SOURCE_DIR}/bnlib/bnprint.c
${CMAKE_SOURCE_DIR}/bnlib/jacobi.c
${CMAKE_SOURCE_DIR}/bnlib/germain.c
${CMAKE_SOURCE_DIR}/bnlib/ec/ec.c
${CMAKE_SOURCE_DIR}/bnlib/ec/ecdh.c
${CMAKE_SOURCE_DIR}/bnlib/ec/curve25519-donna.c)
set(zrtp_skein_src
${CMAKE_SOURCE_DIR}/zrtp/crypto/skeinMac256.cpp
${CMAKE_SOURCE_DIR}/zrtp/crypto/skein256.cpp
${CMAKE_SOURCE_DIR}/zrtp/crypto/skeinMac384.cpp
${CMAKE_SOURCE_DIR}/zrtp/crypto/skein384.cpp)
set(zrtp_crypto_src
${CMAKE_SOURCE_DIR}/zrtp/crypto/zrtpDH.cpp
${CMAKE_SOURCE_DIR}/zrtp/crypto/hmac256.cpp
${CMAKE_SOURCE_DIR}/zrtp/crypto/sha256.cpp
${CMAKE_SOURCE_DIR}/zrtp/crypto/hmac384.cpp
${CMAKE_SOURCE_DIR}/zrtp/crypto/sha384.cpp
${CMAKE_SOURCE_DIR}/zrtp/crypto/aesCFB.cpp
${CMAKE_SOURCE_DIR}/zrtp/crypto/twoCFB.cpp
${CMAKE_SOURCE_DIR}/zrtp/crypto/sha2.c)
if (NOT SQLITE)
set(zrtp_src ${zrtp_src_no_cache}
${CMAKE_SOURCE_DIR}/zrtp/ZIDCacheFile.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZIDRecordFile.cpp)
else()
set(zrtp_src ${zrtp_src_no_cache}
${CMAKE_SOURCE_DIR}/zrtp/ZIDCacheDb.cpp
${CMAKE_SOURCE_DIR}/zrtp/ZIDRecordDb.cpp
${CMAKE_SOURCE_DIR}/zrtp/zrtpCacheSqliteBackend.c)
endif()
########### install files ###############
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${zrtplib}.pc DESTINATION ${LIBDIRNAME}/pkgconfig)
if (CCRTP)
add_subdirectory(clients/ccrtp)
add_subdirectory(demo)
endif()
if(${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME})
if (TIVI)
add_subdirectory(clients/tivi)
endif()
########### Add uninstall target ###############
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
if (CORE_LIB)
add_subdirectory(clients/no_client)
endif()
##very usefull for macosx, specially when using gtkosx bundler
if(APPLE)
if (NOT CMAKE_INSTALL_NAME_DIR)
......
This diff is collapsed.
== GNU ZRTP 4.1.1 ==
Is a bug fix release that fixes some problems when building a standalone
version of the library, i.e. with embedded crypto algorithms and not using
on openSSL.
Another fix was necessary for NetBSD thread handling.
== GNU ZRTP 4.1.0 ==
Small enhancements when dealing with non-NIST algorithms. An application may
set a ''algorithm selection policy'' to control the selection behaviour. In
addition the the standrad selection policy (as per RFC6189) this version
provides a _non-NIST_ selection policy: if the selected public key algorithm
is a non-NIST ECC algorithm then the other selection functions prefer non-NIST
HASH algorithms (Skein etc).
== GNU ZRTP 4.0.0 ==
For this version I added some new algorithms for the DH key agreement
and the Skein Hash for ZRTP. Not further functional enhancments.
Added a new (old) build parameter -DCORE_LIB that will build a ZRTP core
library. This was available in V2.3 but I somehow lost this for 3.0
You may add other build parameters, such as SQLITE and CRYPTO_STANDALONE
if you build the core library.
== GNU ZRTP 3.2.0 ==
The main ZRTP modules contain fixes for three vulnerabilities found by Mark
Dowd. Thus we advise application developers to use this version of the
library. The vulnerabilities may lead to application crashes during ZRTP
negotiation if an attacker sends prepared ZRTP packets. The fixes remove these
attack vectors.
Some small other enhancements and cleanup, mainly inside client code.
Some enhancements in cache handling and the handling of retained shared
secrets. This change was proposed by Phil, is a slight security enhacement and
is fully backward comaptible.
Because of some API changes clients must be compiled and linked with the new
library.
For details please refer to the Git logs.
== GNU ZRTP 3.1.0 ==
This version adds some new features and code that supports some other
client and this accounts for the most changes inside this release.
The ZRTP core functionality was not changed as much (bug fixes, cleanup
mainly) and remains fully backward compatible with older library
versions. However, one nice enhancement was done: the addition of a standalone
SDES support module. This module supports basic SDES only without the fancy
stuff like many other SDES implementations. Thus it's pretty interoperable.
Some other features are:
- add some android support for a client, may serve as template for others
- documentation and code cleanup
Because of some API changes clients must be compiled and linked with the new
library.
== GNU ZRTP 3.0.0 ==
This is a major enhancement and restructuring of the overall ZRTP
distribution. This was necessary because more and more other clients use ZRTP
and add their specific glue code. Also some clients are not prepared to use
openSSL or other crypto libraries to their code and distributions.
Here a summary of the changes
- a new directory layout to accomodate various clients
- add standalone crypto modules, for example for AES, to have a real
standalone ZRTP/SRTP library that does not require any other crypto library
(optional via CMake configuration)
- Re-structure ZRTP cache and add SQlite3 as optional storage backend
The default settings for CMake build the normal ZRTP library that use openSSL
as crypto backend, use the normal file based cache and include the GNU ccRTP
modules. This is a librray that is to a large degree compatible with the
earlier builds.
Please refer to the top level CMakeFile.txt for options how to switch on the
standalone crypto mode or the SQlite3 based cache storage.
== GNU ZRTP 2.3.0 ==
Add a "paranoid" mode to ZRTP. If and applications switches to this mode then
the ZRTP stack _always_ asks the user to confirm the SAS thus ZRTP behaves as
if it does not have a cache to store the retained secrets. However, setting
the paranoid mode does not diable the cache, only the GUI behaviour.
Enhance the CMake scripts to build a ZRTP library that does not contain GNU
ccRTP modules and does not require ccRTP dependencies.
== GNU ZRTP 2.2.0 ==
Add stubs, callbacks and other provisions to prepare the full implementation
of the SAS signing feature, see RFC6189, section 7.2. This feature needs
support from applications and is rarely used if at all.
As usual smaller fixes, code clean up etc.
Because of some API changes clients must be compiled and linked with the new
library.
== GNU ZRTP 2.1.2 ==
The main topic of this release was to add SRTCP support and some missing
optional features of ZRTP.
As such I've added some new API and classes that applications may use to add
SRTCP or to use the new ZRTP features. the ZRTP stack now supports PBX
handling, refer to RFC6189 section 7.3ff.
Because of some API changes clients must be compiled and linked with the new
library.
== GNU ZRTP 2.0.0 ==
Modify some files to use the new uCommon/commoncpp libraries instead
......@@ -275,7 +150,7 @@ not support this additional secret anymore.
The method ''setOtherSecret(...)'' was renamed to ''setPbxSecret(...)''
to reflect the modification in the draft.
The method ''setSrtpsSecret(...)'' was renamed to ''setAuxSecret(...)''
The methos ''setSrtpsSecret(...)'' is was renamed to ''setAuxSecret(...)''
to reflect the modification in the draft.
......
## GNU ZRTP C++
This package provides a library that adds ZRTP support to the GNU
ccRTP stack and serves as library for other RTP stacks (PJSIP, GStreamer).
Phil Zimmermann developed ZRTP to allow ad-hoc, easy to
ccRTP stack. Phil Zimmermann developed ZRTP to allow ad-hoc, easy to
use key negotiation to setup Secure RTP (SRTP) sessions. GNU ZRTP works
together with GNU ccRTP (1.5.0 or later) and provides a ZRTP
implementation that can be directly embedded into client and server
applications.
The GNU ZRTP implementation is compliant to [RFC 6189][] and adds some more
algorithms. Currently GNU ZRTP C++ supports the following features:
The GNU ZRTP implementation is compliant to [RFC 6189][]. Currently GNU ZRTP
C++ supports the following features:
* multi-stream mode
* Finite field Diffie-Hellman with 2048 and 3072 bit primes
* Elliptic curve Diffie-Hellman with 256 and 384 bit curves (NIST curves)
* Elliptic curves Curve25519 and Curve3617 (Dan Bernstein, Tanja Lange)
* Skein Hash and MAC for ZRTP
* AES-128 and AES-256 symmetric ciphers
* Finite field Diffie-Helman with 2048 and 3072 bit primes
* Elliptic curve Diffie-Helman with 256 and 384 bit curves
* AES-128 and AES-256 symmetric cipher
* Twofish-128 and Twofish-256 bit symmetric ciphers
* The SRTP authentication methods HMAC-SHA1 with 32 bit and 80 bit length and
the Skein MAC with 32 bit and 64 bit length
* The Short Authentication String (SAS) type with base 32 encoding (4
characters) and the SAS 256 type using words.
Some features like preshared mode are not supported but the GNU
ZRTP C++ implementation defines the necessary external interfaces and
functions for these enhanced features.
**Note:** The Elliptic curves Cure25519 and Curve3617 are available only if you
select the crypto standalone mode during build.
The newer verisons (starting with 4.1) implement an extensible mechanisms to
define algorithm selection policies that control selection of Hash, symmetric
cipher, and the SRTP authentication. Currently two policies exist: _Standard_
and _PreferNonNist_. The Standard policy selects algorihms based on the
preferences (order) in the Hello packet, the PreferNonNist policy prefers
non-NIST algorithms, for example Skein and Twofish, if the selected public key
(Diffie-Hellman) algorithm is also one of the non-NIST algorithms. This is
fully backward compatible and in-line with RFC6189.
### SDES support
This release also provides SDES support. The SDES implementation does not
support all of the fancy stuff but is usable in most cases. This implementation
however supports the new SDES crypto mixing to overcome some security issues
for SIP forking. Please look for `draft-zimmermann-mmusic-sdesc-mix-00`.
characters)
Enhanced features like PBX SAS relay aka *trusted Man-in-the-Middle* or
preshared mode are not supported but the GNU ZRTP C++ implementation defines
the necessary external interfaces and functions for these enhanced features
(stubs only).
### Interoperability
During the development of ZRTP and its sister implementation ZRTP4J (the Java
......@@ -68,7 +48,7 @@ To enable C based code to use ZRTP C++ I did a C wrapper that offers the same
functionality to C based RTP implementations. The first use of the ZRTP C
wrapper was for the [PJSIP][] library, actually the RTP part of this
library. The ZRTP handler for PJSIP is [here][pjzrtp]. This port enables PJSIP
based clients to use ZRTP. One of the first clients that uses this feature is
based clients to use ZRTP. One of the first clients that use this feature is
*[CSipSimple][]*, an very good open source Android SIP client.
[pjsip]: http://www.pjsip.org
......@@ -91,21 +71,13 @@ following versions of Twinkle include GNU ZRTP C++ as well.
### License and further information
I changed the license of the ZRTP core source files from GPL to LGPL. Other
sources files may have own license. Please refer to the copyright notices of
the files.
Thus most of this library is licensed under the GNU LGPL, version 3 or later.
Please note, this library is licensed under the GNU GPL, version 3 or
later, and has been copyright assigned to the Free Software Foundation.
For further information refer to the [ZRTP FAQ][zrtpfaq] and the
[GNU ZRTP howto][zrtphow]. Both are part of the GNU Telephony wiki and are
located in its documentation category.
Source code in the directory `clients/tivi` and below is not licensed under the
GNU LGPL and is for reference and review only. Refer to the copyright statments
of the source code in these directories, in particular the sqlite3 sources which
have their own license.
[zrtphow]: http://www.gnutelephony.org/index.php/GNU_ZRTP_How_To
[zrtpfaq]: http://www.gnutelephony.org/index.php/ZRTP_FAQ
[rfc 6189]: http://tools.ietf.org/html/rfc6189
......@@ -122,18 +94,6 @@ the source archive or pulled the source from [Github][]:
cmake ..
make
The CMakeLists.txt supports several options. If you don't specify any options
then `cmake` generates the build that supports GNU ccRTP library and it uses
the standalone cryptographic modules, thus no it's not necessary to install an
cryptographic library on the system. Optionally you may configure ZRTP to use
_sqlite3_ instead of a simple file to store the ZRTP cache data. For example
cmake -DSQLITE=true ..
creates the build files that use _sqlite3_.
Please have a look at the `CMakeLists.txt` for other options.
Running cmake in a separate `build` directory is the preferred way. Cmake and
the following `make` generate all files in or below the build directory. Thus
the base directory and the source directories are not polluted with `*.o`,
......@@ -143,13 +103,3 @@ build directory and create a new one to start from fresh (this is the ultimate
different settings without mixing the two builds.
[github]: http://github.com/wernerd/ZRTPCPP
### Notes when building ZRTP C++ for Android
The CMake files support creation of an `Android.mk` file for the Tivi client
and may give you an idea how to do it for other clients. The generated
`Android.mk` generates `buildinfo_*.c` files in the root directory. You may
delete these files after the Android static libraries are ready.
Since version 4.1.1 the example Android build files require NDK r9c.
/*
* bn.c - the high-level bignum interface
*
* Copyright (c) 1995 Colin Plumb. All rights reserved.
* For licensing and other legal details, see the file legal.c.
*/
#include <bn.h>
/* Functions */
void
bnBegin(struct BigNum *bn)
{
static int bninit = 0;
if (!bninit) {
bnInit();
bninit = 1;
}
bn->ptr = 0;
bn->size = 0;
bn->allocated = 0;
}
void
bnSwap(struct BigNum *a, struct BigNum *b)
{
void *p;
unsigned t;
p = a->ptr;
a->ptr = b->ptr;
b->ptr = p;
t = a->size;
a->size = b->size;
b->size = t;
t = a->allocated;
a->allocated = b->allocated;
b->allocated = t;
}
int (*bnYield)(void);
void (*bnEnd)(struct BigNum *bn);
int (*bnPrealloc)(struct BigNum *bn, unsigned bits);
int (*bnCopy)(struct BigNum *dest, struct BigNum const *src);
void (*bnNorm)(struct BigNum *bn);
void (*bnExtractBigBytes)(struct BigNum const *bn, unsigned char *dest,
unsigned lsbyte, unsigned len);
int (*bnInsertBigBytes)(struct BigNum *bn, unsigned char const *src,
unsigned lsbyte, unsigned len);
void (*bnExtractLittleBytes)(struct BigNum const *bn, unsigned char *dest,
unsigned lsbyte, unsigned len);
int (*bnInsertLittleBytes)(struct BigNum *bn, unsigned char const *src,
unsigned lsbyte, unsigned len);
unsigned (*bnLSWord)(struct BigNum const *src);
int (*bnReadBit)(struct BigNum const *bn, unsigned bit);
unsigned (*bnBits)(struct BigNum const *src);
int (*bnAdd)(struct BigNum *dest, struct BigNum const *src);
int (*bnSub)(struct BigNum *dest, struct BigNum const *src);
int (*bnCmpQ)(struct BigNum const *a, unsigned b);
int (*bnSetQ)(struct BigNum *dest, unsigned src);
int (*bnAddQ)(struct BigNum *dest, unsigned src);
int (*bnSubQ)(struct BigNum *dest, unsigned src);
int (*bnCmp)(struct BigNum const *a, struct BigNum const *b);
int (*bnSquare)(struct BigNum *dest, struct BigNum const *src);
int (*bnMul)(struct BigNum *dest, struct BigNum const *a,
struct BigNum const *b);
int (*bnMulQ)(struct BigNum *dest, struct BigNum const *a, unsigned b);
int (*bnDivMod)(struct BigNum *q, struct BigNum *r, struct BigNum const *n,
struct BigNum const *d);
int (*bnMod)(struct BigNum *dest, struct BigNum const *src,
struct BigNum const *d);
unsigned (*bnModQ)(struct BigNum const *src, unsigned d);
int (*bnExpMod)(struct BigNum *result, struct BigNum const *n,
struct BigNum const *exp, struct BigNum const *mod);
int (*bnDoubleExpMod)(struct BigNum *dest,
struct BigNum const *n1, struct BigNum const *e1,
struct BigNum const *n2, struct BigNum const *e2,
struct BigNum const *mod);
int (*bnTwoExpMod)(struct BigNum *n, struct BigNum const *exp,
struct BigNum const *mod);
int (*bnGcd)(struct BigNum *dest, struct BigNum const *a,
struct BigNum const *b);
int (*bnInv)(struct BigNum *dest, struct BigNum const *src,
struct BigNum const *mod);
int (*bnLShift)(struct BigNum *dest, unsigned amt);
void (*bnRShift)(struct BigNum *dest, unsigned amt);
unsigned (*bnMakeOdd)(struct BigNum *n);
int (*bnBasePrecompBegin)(struct BnBasePrecomp *pre, struct BigNum const *base,
struct BigNum const *mod, unsigned maxebits);
int (*bnBasePrecompCopy)(struct BnBasePrecomp *dst,
struct BnBasePrecomp const *src);
void (*bnBasePrecompEnd)(struct BnBasePrecomp *pre);
int (*bnBasePrecompExpMod)(struct BigNum *dest,
struct BnBasePrecomp const *pre, struct BigNum const *exp,
struct BigNum const *mod);
int (*bnDoubleBasePrecompExpMod)(struct BigNum *dest,
struct BnBasePrecomp const *pre1, struct BigNum const *exp1,
struct BnBasePrecomp const *pre2, struct BigNum const *exp2,
struct BigNum const *mod);
/*
* bn.h - the interface to the bignum routines.
* All functions which return ints can potentially allocate memory
* and return -1 if they are unable to. All "const" arguments
* are unmodified.
*
* This is not particularly asymmetric, as some operations are of the
* form a = b @ c, while others do a @= b. In general, outputs may not
* point to the same struct BigNums as inputs, except as specified
* below. This relationship is referred to as "being the same as".
* This is not numerical equivalence.
*
* The "Q" operations take "unsigned" inputs. Higher values of the
* extra input may work on some implementations, but 65535 is the
* highest portable value. Just because UNSIGNED_MAX is larger than
* that, or you know that the word size of the library is larger than that,
* that, does *not* mean it's allowed.
*/
#ifndef BN_H
#define BN_H
#ifdef __cplusplus
extern "C"
{
#endif
struct BigNum {
void *ptr;
unsigned size; /* Note: in (variable-sized) words */
unsigned allocated;
};
#ifndef SWIG
/*
* User-supplied function: if non-NULL, this is called during long-running
* computations. You may put Yield() calls in here to give CPU time to
* other processes. You may also force the computation to be aborted,
* by returning a value < 0, which will be the return value of the
* bnXXX call. (You probably want the value to be someting other than
* -1, to distinguish it from a n out-of-memory error.)
*
* The functions that this is called from, and the intervals at which it
* is called, are not well defined, just "reasonably often". (Currently,
* once per exponent bit in nodular exponentiation, and once per two
* divisions in GCD and inverse computation.)
*/
extern int (*bnYield)(void);
/* Functions */
/*
* You usually never have to call this function explicitly, as
* bnBegin() takes care of it. If the program jumps to address 0,
* this function has bot been called.
*/
void bnInit(void);
/*
* This initializes an empty struct BigNum to a zero value.
* Do not use this on a BigNum which has had a value stored in it!
*/
void bnBegin(struct BigNum *bn);
/* Swap two BigNums. Cheap. */
void bnSwap(struct BigNum *a, struct BigNum *b);
/* Reset an initialized bigNum to empty, pending deallocation. */
extern void (*bnEnd)(struct BigNum *bn);
/*
* If you know you'll need space in the number soon, you can use this function
* to ensure that there is room for at least "bits" bits. Optional.
* Returns <0 on out of memory, but the value is unaffected.
*/
extern int (*bnPrealloc)(struct BigNum *bn, unsigned bits);
/* Hopefully obvious. dest = src. dest may be the same as src. */
extern int (*bnCopy)(struct BigNum *dest, struct BigNum const *src);
/*
* Mostly done automatically, but this removes leading zero words from
* the internal representation of the BigNum. Use is unclear.
*/
extern void (*bnNorm)(struct BigNum *bn);
/*
* Move bytes between the given buffer and the given BigNum encoded in
* base 256. I.e. after either of these, the buffer will be equal to
* (bn / 256^lsbyte) % 256^len. The difference is which is altered to
* match the other!
*/
extern void (*bnExtractBigBytes)(struct BigNum const *bn,
unsigned char *dest, unsigned lsbyte, unsigned len);
extern int (*bnInsertBigBytes)(struct BigNum *bn, unsigned char const *src,
unsigned lsbyte, unsigned len);
/* The same, but the buffer is little-endian. */
extern void (*bnExtractLittleBytes)(struct BigNum const *bn,
unsigned char *dest, unsigned lsbyte, unsigned len);
extern int (*bnInsertLittleBytes)(struct BigNum *bn, unsigned char const *src,
unsigned lsbyte, unsigned len);
/* Return the least-significant bits (at least 16) of the BigNum */
extern unsigned (*bnLSWord)(struct BigNum const *src);
/* Return the selected bit of the BigNum (bit 0 is bn mod 2) */
extern int (*bnReadBit)(struct BigNum const *bn, unsigned bit);
/*
* Return the number of significant bits in the BigNum.
* 0 or 1+floor(log2(src))
*/
extern unsigned (*bnBits)(struct BigNum const *src);
#define bnBytes(bn) ((bnBits(bn)+7)/8)
/*
* dest += src. dest and src may be the same. Guaranteed not to
* allocate memory unnecessarily, so if you're sure bnBits(dest)
* won't change, you don't need to check the return value.
*/
extern int (*bnAdd)(struct BigNum *dest, struct BigNum const *src);
/*
* dest -= src. dest and src may be the same, but bnSetQ(dest, 0) is faster.
* if dest < src, returns +1 and sets dest = src-dest.
*/
extern int (*bnSub)(struct BigNum *dest, struct BigNum const *src);
/* Return sign (-1, 0, +1) of a-b. a <=> b --> bnCmpQ(a, b) <=> 0 */
extern int (*bnCmpQ)(struct BigNum const *a, unsigned b);
/* dest = src, where 0 <= src < 2^16. */
extern int (*bnSetQ)(struct BigNum *dest, unsigned src);
/* dest += src, where 0 <= src < 2^16 */
extern int (*bnAddQ)(struct BigNum *dest, unsigned src);
/* dest -= src, where 0 <= src < 2^16 */
extern int (*bnSubQ)(struct BigNum *dest, unsigned src);
/* Return sign (-1, 0, +1) of a-b. a <=> b --> bnCmp(a, b) <=> 0 */
extern int (*bnCmp)(struct BigNum const *a, struct BigNum const *b);
/* dest = src^2. dest may be the same as src, but it costs time. */
extern int (*bnSquare)(struct BigNum *dest, struct BigNum const *src);
/* dest = a * b. dest may be the same as a or b, but it costs time. */
extern int (*bnMul)(struct BigNum *dest, struct BigNum const *a,
struct BigNum const *b);
/* dest = a * b, where 0 <= b < 2^16. dest and a may be the same. */
extern int (*bnMulQ)(struct BigNum *dest, struct BigNum const *a, unsigned b);
/*
* q = n/d, r = n%d. r may be the same as n, but not d,
* and q may not be the same as n or d.
* re-entrancy issue: this temporarily modifies d, but restores
* it for return.
*/
extern int (*bnDivMod)(struct BigNum *q, struct BigNum *r,
struct BigNum const *n, struct BigNum const *d);
/*
* dest = src % d. dest and src may be the same, but not dest and d.
* re-entrancy issue: this temporarily modifies d, but restores
* it for return.
*/
extern int (*bnMod)(struct BigNum *dest, struct BigNum const *src,
struct BigNum const *d);
/* return src % d, where 0 <= d < 2^16. */
extern unsigned int (*bnModQ)(struct BigNum const *src, unsigned d);
/* n = n^exp, modulo "mod" "mod" *must* be odd */
extern int (*bnExpMod)(struct BigNum *result, struct BigNum const *n,
struct BigNum const *exp, struct BigNum const *mod);
/*
* dest = n1^e1 * n2^e2, modulo "mod". "mod" *must* be odd.
* dest may be the same as n1 or n2.
*/
extern int (*bnDoubleExpMod)(struct BigNum *dest,
struct BigNum const *n1, struct BigNum const *e1,
struct BigNum const *n2, struct BigNum const *e2,
struct BigNum const *mod);
/* n = 2^exp, modulo "mod" "mod" *must* be odd */
extern int (*bnTwoExpMod)(struct BigNum *n, struct BigNum const *exp,
struct BigNum const *mod);
/* dest = gcd(a, b). The inputs may overlap arbitrarily. */
extern int (*bnGcd)(struct BigNum *dest, struct BigNum const *a,
struct BigNum const *b);
/* dest = src^-1, modulo "mod". dest may be the same as src. */
extern int (*bnInv)(struct BigNum *dest, struct BigNum const *src,
struct BigNum const *mod);
/* Shift dest left "amt" places */
extern int (*bnLShift)(struct BigNum *dest, unsigned amt);
/* Shift dest right "amt" places, discarding low-order bits */
extern void (*bnRShift)(struct BigNum *dest, unsigned amt);
/* For the largest 2^k that divides n, divide n by it and return k. */
extern unsigned (*bnMakeOdd)(struct BigNum *n);
/*
* Precomputed data for rapid base^exp (mod mod) computation with fixed
* base and mod.
*/
struct BnBasePrecomp {
void *array; /* Ponter to array of pointers to words */
unsigned msize; /* Words in modulis (normalized) */
unsigned bits; /* Bits per array element */
unsigned maxebits; /* Maximum exponent bits */
unsigned entries; /* Number of entries */
unsigned arraysize;
};
extern int (*bnBasePrecompBegin)(struct BnBasePrecomp *pre,
struct BigNum const *base, struct BigNum const *mod,
unsigned maxebits);
extern void (*bnBasePrecompEnd)(struct BnBasePrecomp *pre);
extern int (*bnBasePrecompExpMod)(struct BigNum *dest,
struct BnBasePrecomp const *pre, struct BigNum const *exp,
struct BigNum const *mod);
extern int (*bnDoubleBasePrecompExpMod)(struct BigNum *dest,
struct BnBasePrecomp const *pre1, struct BigNum const *exp1,
struct BnBasePrecomp const *pre2, struct BigNum const *exp2,
struct BigNum const *mod);
#endif /* SWIF */
#ifdef __cplusplus
}
#endif
#endif/* !BN_H */
/*
* bn00.c - auto-size-detecting bn??.c file.
*
* Written in 1995 by Colin Plumb.
* For licensing and other legal details, see the file legal.c.
*/
#include "bnsize00.h"
#if BNSIZE64
/* Include all of the C source file by reference */
#include "bn64.c"
#include "bninit64.c"
#elif BNSIZE32
/* Include all of the C source file by reference */
#include "bn32.c"
#include "bninit32.c"
#else /* BNSIZE16 */
/* Include all of the C source file by reference */
#include "bn16.c"
#include "bninit16.c"
#endif
This diff is collapsed.
/*
* bn16.h - interface to 16-bit bignum routines.
*/
struct BigNum;
struct BnBasePrecomp;
void bnInit_16(void);
void bnEnd_16(struct BigNum *bn);
int bnPrealloc_16(struct BigNum *bn, unsigned bits);
int bnCopy_16(struct BigNum *dest, struct BigNum const *src);
int bnSwap_16(struct BigNum *a, struct BigNum *b);
void bnNorm_16(struct BigNum *bn);
void bnExtractBigBytes_16(struct BigNum const *bn, unsigned char *dest,
unsigned lsbyte, unsigned dlen);
int bnInsertBigBytes_16(struct BigNum *bn, unsigned char const *src,
unsigned lsbyte, unsigned len);
void bnExtractLittleBytes_16(struct BigNum const *bn, unsigned char *dest,
unsigned lsbyte, unsigned dlen);
int bnInsertLittleBytes_16(struct BigNum *bn, unsigned char const *src,
unsigned lsbyte, unsigned len);
unsigned bnLSWord_16(struct BigNum const *src);
int bnReadBit_16(struct BigNum const *bn, unsigned bit);
unsigned bnBits_16(struct BigNum const *src);
int bnAdd_16(struct BigNum *dest, struct BigNum const *src);
int bnSub_16(struct BigNum *dest, struct BigNum const *src);
int bnCmpQ_16(struct BigNum const *a, unsigned b);
int bnSetQ_16(struct BigNum *dest, unsigned src);
int bnAddQ_16(struct BigNum *dest, unsigned src);
int bnSubQ_16(struct BigNum *dest, unsigned src);
int bnCmp_16(struct BigNum const *a, struct BigNum const *b);
int bnSquare_16(struct BigNum *dest, struct BigNum const *src);
int bnMul_16(struct BigNum *dest, struct BigNum const *a,
struct BigNum const *b);
int bnMulQ_16(struct BigNum *dest, struct BigNum const *a, unsigned b);
int bnDivMod_16(struct BigNum *q, struct BigNum *r, struct BigNum const *n,
struct BigNum const *d);
int bnMod_16(struct BigNum *dest, struct BigNum const *src,
struct BigNum const *d);
unsigned bnModQ_16(struct BigNum const *src, unsigned d);
int bnExpMod_16(struct BigNum *dest, struct BigNum const *n,
struct BigNum const *exp, struct BigNum const *mod);
int bnDoubleExpMod_16(struct BigNum *dest,
struct BigNum const *n1, struct BigNum const *e1,
struct BigNum const *n2, struct BigNum const *e2,
struct BigNum const *mod);
int bnTwoExpMod_16(struct BigNum *n, struct BigNum const *exp,
struct BigNum const *mod);
int bnGcd_16(struct BigNum *dest, struct BigNum const *a,
struct BigNum const *b);
int bnInv_16(struct BigNum *dest, struct BigNum const *src,
struct BigNum const *mod);
int bnLShift_16(struct BigNum *dest, unsigned amt);
void bnRShift_16(struct BigNum *dest, unsigned amt);
unsigned bnMakeOdd_16(struct BigNum *n);
int bnBasePrecompBegin_16(struct BnBasePrecomp *pre, struct BigNum const *base,
struct BigNum const *mod, unsigned maxebits);
void bnBasePrecompEnd_16(struct BnBasePrecomp *pre);
int bnBasePrecompExpMod_16(struct BigNum *dest, struct BnBasePrecomp const *pre,
struct BigNum const *exp, struct BigNum const *mod);
int bnDoubleBasePrecompExpMod_16(struct BigNum *dest,
struct BnBasePrecomp const *pre1, struct BigNum const *exp1,
struct BnBasePrecomp const *pre2, struct BigNum const *exp2,
struct BigNum const *mod);
This diff is collapsed.
/*
* bn32.h - interface to 32-bit bignum routines.
*/
struct BigNum;
struct BnBasePrecomp;
void bnInit_32(void);
void bnEnd_32(struct BigNum *bn);
int bnPrealloc_32(struct BigNum *bn, unsigned bits);
int bnCopy_32(struct BigNum *dest, struct BigNum const *src);
int bnSwap_32(struct BigNum *a, struct BigNum *b);
void bnNorm_32(struct BigNum *bn);
void bnExtractBigBytes_32(struct BigNum const *bn, unsigned char *dest,
unsigned lsbyte, unsigned dlen);
int bnInsertBigBytes_32(struct BigNum *bn, unsigned char const *src,
unsigned lsbyte, unsigned len);
void bnExtractLittleBytes_32(struct BigNum const *bn, unsigned char *dest,
unsigned lsbyte, unsigned dlen);
int bnInsertLittleBytes_32(struct BigNum *bn, unsigned char const *src,
unsigned lsbyte, unsigned len);
unsigned bnLSWord_32(struct BigNum const *src);
int bnReadBit_32(struct BigNum const *bn, unsigned bit);
unsigned bnBits_32(struct BigNum const *src);
int bnAdd_32(struct BigNum *dest, struct BigNum const *src);
int bnSub_32(struct BigNum *dest, struct BigNum const *src);
int bnCmpQ_32(struct BigNum const *a, unsigned b);
int bnSetQ_32(struct BigNum *dest, unsigned src);
int bnAddQ_32(struct BigNum *dest, unsigned src);
int bnSubQ_32(struct BigNum *dest, unsigned src);
int bnCmp_32(struct BigNum const *a, struct BigNum const *b);
int bnSquare_32(struct BigNum *dest, struct BigNum const *src);
int bnMul_32(struct BigNum *dest, struct BigNum const *a,
struct BigNum const *b);
int bnMulQ_32(struct BigNum *dest, struct BigNum const *a, unsigned b);
int bnDivMod_32(struct BigNum *q, struct BigNum *r, struct BigNum const *n,
struct BigNum const *d);
int bnMod_32(struct BigNum *dest, struct BigNum const *src,
struct BigNum const *d);
unsigned bnModQ_32(struct BigNum const *src, unsigned d);
int bnExpMod_32(struct BigNum *dest, struct BigNum const *n,
struct BigNum const *exp, struct BigNum const *mod);
int bnDoubleExpMod_32(struct BigNum *dest,
struct BigNum const *n1, struct BigNum const *e1,
struct BigNum const *n2, struct BigNum const *e2,
struct BigNum const *mod);
int bnTwoExpMod_32(struct BigNum *n, struct BigNum const *exp,
struct BigNum const *mod);
int bnGcd_32(struct BigNum *dest, struct BigNum const *a,
struct BigNum const *b);
int bnInv_32(struct BigNum *dest, struct BigNum const *src,
struct BigNum const *mod);
int bnLShift_32(struct BigNum *dest, unsigned amt);
void bnRShift_32(struct BigNum *dest, unsigned amt);
unsigned bnMakeOdd_32(struct BigNum *n);
int bnBasePrecompBegin_32(struct BnBasePrecomp *pre, struct BigNum const *base,
struct BigNum const *mod, unsigned maxebits);
void bnBasePrecompEnd_32(struct BnBasePrecomp *pre);
int bnBasePrecompExpMod_32(struct BigNum *dest, struct BnBasePrecomp const *pre,
struct BigNum const *exp, struct BigNum const *mod);
int bnDoubleBasePrecompExpMod_32(struct BigNum *dest,
struct BnBasePrecomp const *pre1, struct BigNum const *exp1,
struct BnBasePrecomp const *pre2, struct BigNum const *exp2,
struct BigNum const *mod);
This diff is collapsed.
/*
* bn64.h - interface to 64-bit bignum routines.
*/
struct BigNum;
struct BnBasePrecomp;
void bnInit_64(void);
void bnEnd_64(struct BigNum *bn);
int bnPrealloc_64(struct BigNum *bn, unsigned bits);
int bnCopy_64(struct BigNum *dest, struct BigNum const *src);
int bnSwap_64(struct BigNum *a, struct BigNum *b);
void bnNorm_64(struct BigNum *bn);
void bnExtractBigBytes_64(struct BigNum const *bn, unsigned char *dest,
unsigned lsbyte, unsigned dlen);
int bnInsertBigBytes_64(struct BigNum *bn, unsigned char const *src,
unsigned lsbyte, unsigned len);
void bnExtractLittleBytes_64(struct BigNum const *bn, unsigned char *dest,
unsigned lsbyte, unsigned dlen);
int bnInsertLittleBytes_64(struct BigNum *bn, unsigned char const *src,
unsigned lsbyte, unsigned len);
unsigned bnLSWord_64(struct BigNum const *src);
int bnReadBit_64(struct BigNum const *bn, unsigned bit);
unsigned bnBits_64(struct BigNum const *src);
int bnAdd_64(struct BigNum *dest, struct BigNum const *src);
int bnSub_64(struct BigNum *dest, struct BigNum const *src);
int bnCmpQ_64(struct BigNum const *a, unsigned b);
int bnSetQ_64(struct BigNum *dest, unsigned src);
int bnAddQ_64(struct BigNum *dest, unsigned src);
int bnSubQ_64(struct BigNum *dest, unsigned src);
int bnCmp_64(struct BigNum const *a, struct BigNum const *b);
int bnSquare_64(struct BigNum *dest, struct BigNum const *src);
int bnMul_64(struct BigNum *dest, struct BigNum const *a,
struct BigNum const *b);
int bnMulQ_64(struct BigNum *dest, struct BigNum const *a, unsigned b);
int bnDivMod_64(struct BigNum *q, struct BigNum *r, struct BigNum const *n,
struct BigNum const *d);
int bnMod_64(struct BigNum *dest, struct BigNum const *src,
struct BigNum const *d);
unsigned bnModQ_64(struct BigNum const *src, unsigned d);
int bnExpMod_64(struct BigNum *dest, struct BigNum const *n,
struct BigNum const *exp, struct BigNum const *mod);
int bnDoubleExpMod_64(struct BigNum *dest,
struct BigNum const *n1, struct BigNum const *e1,
struct BigNum const *n2, struct BigNum const *e2,
struct BigNum const *mod);
int bnTwoExpMod_64(struct BigNum *n, struct BigNum const *exp,
struct BigNum const *mod);
int bnGcd_64(struct BigNum *dest, struct BigNum const *a,
struct BigNum const *b);
int bnInv_64(struct BigNum *dest, struct BigNum const *src,
struct BigNum const *mod);
int bnLShift_64(struct BigNum *dest, unsigned amt);
void bnRShift_64(struct BigNum *dest, unsigned amt);
unsigned bnMakeOdd_64(struct BigNum *n);
int bnBasePrecompBegin_64(struct BnBasePrecomp *pre, struct BigNum const *base,
struct BigNum const *mod, unsigned maxebits);
void bnBasePrecompEnd_64(struct BnBasePrecomp *pre);
int bnBasePrecompExpMod_64(struct BigNum *dest, struct BnBasePrecomp const *pre,
struct BigNum const *exp, struct BigNum const *mod);
int bnDoubleBasePrecompExpMod_64(struct BigNum *dest,
struct BnBasePrecomp const *pre1, struct BigNum const *exp1,
struct BnBasePrecomp const *pre2, struct BigNum const *exp2,
struct BigNum const *mod);
/*
* bnconfig.h.cmake -- Configuration file for BigNum library.
*
* cmake processes this file.
*/
#ifndef _BNCONFIG_H
#define _BNCONFIG_H
/* Checks for the presence and absence of various header files */
#cmakedefine HAVE_ASSERT_H 1
#define NO_ASSERT_H !HAVE_ASSERT_H
#cmakedefine HAVE_LIMITS_H 1
#define NO_LIMITS_H !HAVE_LIMITS_H
#cmakedefine HAVE_STDLIB_H 1
#define NO_STDLIB_H !HAVE_STDLIB_H
#cmakedefine HAVE_STRING_H 1
#define NO_STRING_H !HAVE_STRING_H
#cmakedefine HAVE_STRINGS_H 1
#cmakedefine NEED_MEMORY_H 1
/* We go to some trouble to find accurate times... */
/* Define if you have Posix.4 glock_gettime() */
#cmakedefine HAVE_CLOCK_GETTIME 1
/* Define if you have Solaris-style gethrvtime() */
#cmakedefine HAVE_GETHRVTIME 1
/* Define if you have getrusage() */
#cmakedefine HAVE_GETRUSAGE 1
/* Define if you have clock() */
#cmakedefine HAVE_CLOCK 1
/* Define if you have time() */
#cmakedefine HAVE_TIME 1
/*
* Define as 0 if #including <sys/time.h> automatically
* #includes <time.h>, and doing so explicitly causes an
* error.
*/
#define TIME_WITH_SYS_TIME 0
/* Defines for various kinds of library brokenness */
/* Define if <stdio.h> is missing prototypes (= lots of warnings!) */
#cmakedefine NO_STDIO_PROTOS 1
/* Define if <assert.h> depends on <stdio.h> and breaks without it */
#cmakedefine ASSERT_NEEDS_STDIO 1
/* Define if <assert.h> depends on <stdlib.h> and complains without it */
#cmakedefine ASSERT_NEEDS_STDLIB 1
/*
* Define if <string.h> delcares the mem* functions to take char *
* instead of void * parameters (= lots of warnings)
*/
#cmakedefine MEM_PROTOS_BROKEN 1
/* If not available, bcopy() is substituted */
#cmakedefine HAVE_MEMMOVE 1
#define NO_MEMMOVE !HAVE_MEMMOVE
#cmakedefine HAVE_MEMCPY 1
#define NO_MEMCPY !HAVE_MEMCPY
#endif /* _BNCONFIG_H */
/*
* bninit16.c - Provide an init function that sets things up for 16-bit
* operation. This is a seaparate tiny file so you can compile two bn
* packages into the library and write a custom init routine.
*
* Written in 1995 by Colin Plumb.
*/
#include "bn.h"
#include "bn16.h"
void
bnInit(void)
{
bnInit_16();
}
/*
* bninit32.c - Provide an init function that sets things up for 32-bit
* operation. This is a seaparate tiny file so you can compile two bn
* packages into the library and write a custom init routine.
*
* Written in 1995 by Colin Plumb.
*/
#include "bn.h"
#include "bn32.h"
void
bnInit(void)
{
bnInit_32();
}
/*
* bninit64.c - Provide an init function that sets things up for 64-bit
* operation. This is a seaparate tiny file so you can compile two bn
* packages into the library and write a custom init routine.
*
* Written in 1995 by Colin Plumb.
*/
#include "bn.h"
#include "bn64.h"
void
bnInit(void)
{
bnInit_64();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment