Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

Commit a91cf1e

Browse files
committed
Initial commit for libaxolotl-c
This library is a C implementation of the Axolotl encryption protocol, which aims for full compatibility with libaxolotl-java. It should be current as of the state of the Java library on Sep 15, 2015.
0 parents  commit a91cf1e

File tree

147 files changed

+40686
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+40686
-0
lines changed

.gitattributes

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Set default behaviour, in case users don't have core.autocrlf set.
2+
* text=auto
3+
4+
# Explicitly declare text files we want to always be normalized and converted
5+
# to native line endings on checkout.
6+
*.txt text
7+
*.c text
8+
*.cpp text
9+
*.h text
10+
*.hpp text

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Compiled source
2+
build/
3+
*.o
4+
*.so
5+
*.so.*
6+
*.a
7+
8+
# IDE-related files
9+
10+
# OS generated files
11+
.DS_Store*
12+
Thumbs.db
13+
14+
# Other
15+
*~
16+
.*
17+
*.swp
18+
core
19+
*.log
20+
*.zip

CMakeLists.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
cmake_minimum_required(VERSION 2.8.4)
2+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")
3+
project(axolotl-c)
4+
5+
INCLUDE(CheckSymbolExists)
6+
7+
CHECK_SYMBOL_EXISTS(memset_s "string.h" HAVE_MEMSET_S)
8+
9+
IF(CMAKE_SYSTEM_NAME MATCHES "Windows")
10+
CHECK_SYMBOL_EXISTS(SecureZeroMemory "Windows.h;WinBase.h" HAVE_SECUREZEROMEMORY)
11+
ENDIF(CMAKE_SYSTEM_NAME MATCHES "Windows")
12+
13+
IF(BUILD_TESTING)
14+
enable_testing()
15+
ENDIF(BUILD_TESTING)
16+
17+
IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
18+
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0 -Wall -Wmissing-field-initializers -Wno-missing-braces -Wparentheses")
19+
ENDIF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
20+
21+
IF(CMAKE_COMPILER_IS_GNUCC)
22+
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wsign-compare -Wsign-conversion")
23+
ENDIF(CMAKE_COMPILER_IS_GNUCC)
24+
25+
IF(CMAKE_C_COMPILER_ID MATCHES "Clang")
26+
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wswitch -Wunused-variable -Wunused-value -Wshadow -Wint-conversion -Wpointer-sign -Wprotocol -Wshorten-64-to-32")
27+
ENDIF(CMAKE_C_COMPILER_ID MATCHES "Clang")
28+
29+
IF(HAVE_MEMSET_S)
30+
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_MEMSET_S=1")
31+
ENDIF(HAVE_MEMSET_S)
32+
33+
add_subdirectory(src)
34+
35+
IF(BUILD_TESTING)
36+
add_subdirectory(tests)
37+
ENDIF(BUILD_TESTING)
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
# ------------------------------------------------------------------------------
2+
# BlackBerry CMake toolchain file, for use with the BlackBerry 10 NDK
3+
# Requires cmake 2.6.3 or newer (2.8.3 or newer is recommended).
4+
#
5+
# Usage Linux:
6+
# $ source /absolute/path/to/the/bbndk/bbndk-env.sh
7+
# $ mkdir build
8+
# $ cd build
9+
# $ cmake .. -DCMAKE_TOOLCHAIN_FILE="../CMake/toolchain/blackberry.toolchain.cmake" -DTargetPlatform="BlackBerry" -DBLACKBERRY_ARCHITECTURE=arm -DOGRE_DEPENDENCIES_DIR="../BlackBerryDependencies" -DOGRE_BUILD_RENDERSYSTEM_GLES2=TRUE -DOGRE_STATIC=TRUE -DOGRE_BUILD_COMPONENT_PAGING=TRUE -DOGRE_BUILD_COMPONENT_TERRAIN=TRUE -DOGRE_BUILD_COMPONENT_RTSHADERSYSTEM=TRUE -DOGRE_BUILD_PLUGIN_BSP=FALSE -DOGRE_BUILD_PLUGIN_PCZ=FALSE -DOGRE_BUILD_RENDERSYSTEM_GLES=FALSE -DOGRE_BUILD_TESTS=FALSE -DOGRE_BUILD_TOOLS=FALSE -DCMAKE_VERBOSE_MAKEFILE=TRUE -G "Eclipse CDT4 - Unix Makefiles"
10+
# $ make -j8
11+
#
12+
# Usage Mac:
13+
# Same as the steps on Linux
14+
#
15+
# Usage Windows:
16+
# > /absolute/path/to/the/bbndk/bbndk-env.bat
17+
# > mkdir build
18+
# > cd build
19+
# > cmake .. -DCMAKE_TOOLCHAIN_FILE="../CMake/toolchain/blackberry.toolchain.cmake" -DTargetPlatform="BlackBerry" -DBLACKBERRY_ARCHITECTURE=arm -DOGRE_DEPENDENCIES_DIR="../BlackBerryDependencies" -DOGRE_BUILD_RENDERSYSTEM_GLES2=TRUE -DOGRE_STATIC=TRUE -DOGRE_BUILD_COMPONENT_PAGING=TRUE -DOGRE_BUILD_COMPONENT_TERRAIN=TRUE -DOGRE_BUILD_COMPONENT_RTSHADERSYSTEM=TRUE -DOGRE_BUILD_PLUGIN_BSP=FALSE -DOGRE_BUILD_PLUGIN_PCZ=FALSE -DOGRE_BUILD_RENDERSYSTEM_GLES=FALSE -DOGRE_BUILD_TESTS=FALSE -DOGRE_BUILD_TOOLS=FALSE -DCMAKE_VERBOSE_MAKEFILE=TRUE -G "Eclipse CDT4 - Unix Makefiles"
20+
# > make -j8
21+
#
22+
23+
cmake_minimum_required( VERSION 2.6.3 )
24+
25+
if( DEFINED CMAKE_CROSSCOMPILING )
26+
# Subsequent toolchain loading is not really needed
27+
return()
28+
endif()
29+
30+
set( BLACKBERRY_TOOLCHAIN_ROOT "$ENV{QNX_HOST}" )
31+
set( BLACKBERRY_TARGET_ROOT "$ENV{QNX_TARGET}" )
32+
set( CMAKE_SYSTEM_NAME Linux )
33+
set( CMAKE_SYSTEM_VERSION 1 )
34+
35+
# STL version: by default gnustl_static will be used
36+
set( BLACKBERRY_USE_STLPORT FALSE CACHE BOOL "Experimental: use stlport_static instead of gnustl_static")
37+
mark_as_advanced( BLACKBERRY_USE_STLPORT )
38+
39+
# Detect host platform
40+
set( TOOL_OS_SUFFIX "" )
41+
if( CMAKE_HOST_APPLE )
42+
set( BLACKBERRY_NDK_HOST_SYSTEM_NAME "darwin-x86" )
43+
elseif( CMAKE_HOST_WIN32 )
44+
set( BLACKBERRY_NDK_HOST_SYSTEM_NAME "windows" )
45+
set( TOOL_OS_SUFFIX ".exe" )
46+
elseif( CMAKE_HOST_UNIX )
47+
set(BLACKBERRY_NDK_HOST_SYSTEM_NAME "linux-x86" )
48+
else()
49+
message( FATAL_ERROR "Cross-compilation on your platform is not supported by this cmake toolchain" )
50+
endif()
51+
52+
# Specify the cross compiler
53+
set( CMAKE_C_COMPILER "$ENV{QNX_HOST}/usr/bin/qcc${TOOL_OS_SUFFIX}" CACHE PATH "gcc" )
54+
set( CMAKE_CXX_COMPILER "$ENV{QNX_HOST}/usr/bin/qcc${TOOL_OS_SUFFIX}" CACHE PATH "g++" )
55+
set( CMAKE_ASM_COMPILER "$ENV{QNX_HOST}/usr/bin/qcc${TOOL_OS_SUFFIX}" CACHE PATH "Assembler" )
56+
if( CMAKE_VERSION VERSION_LESS 2.8.5 )
57+
set( CMAKE_ASM_COMPILER_ARG1 "-c" )
58+
endif()
59+
60+
# There may be a way to make cmake reduce these TODO
61+
if( BLACKBERRY_ARCHITECTURE STREQUAL "arm" )
62+
set( NEUTRINO_ARCH "v7" )
63+
else()
64+
set( NEUTRINO_ARCH "" )
65+
endif()
66+
set( CMAKE_STRIP "$ENV{QNX_HOST}/usr/bin/nto${BLACKBERRY_ARCHITECTURE}-strip${TOOL_OS_SUFFIX}" CACHE PATH "strip" )
67+
set( CMAKE_AR "$ENV{QNX_HOST}/usr/bin/nto${BLACKBERRY_ARCHITECTURE}-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive" )
68+
set( CMAKE_LINKER "$ENV{QNX_HOST}/usr/bin/nto${BLACKBERRY_ARCHITECTURE}${NEUTRINO_ARCH}-ld${TOOL_OS_SUFFIX}" CACHE PATH "linker" )
69+
set( CMAKE_NM "$ENV{QNX_HOST}/usr/bin/nto${BLACKBERRY_ARCHITECTURE}${NEUTRINO_ARCH}-nm${TOOL_OS_SUFFIX}" CACHE PATH "nm" )
70+
set( CMAKE_OBJCOPY "$ENV{QNX_HOST}/usr/bin/nto${BLACKBERRY_ARCHITECTURE}${NEUTRINO_ARCH}-objcopy${TOOL_OS_SUFFIX}" CACHE PATH "objcopy" )
71+
set( CMAKE_OBJDUMP "$ENV{QNX_HOST}/usr/bin/nto${BLACKBERRY_ARCHITECTURE}${NEUTRINO_ARCH}-objdump${TOOL_OS_SUFFIX}" CACHE PATH "objdump" )
72+
set( CMAKE_RANLIB "$ENV{QNX_HOST}/usr/bin/nto${BLACKBERRY_ARCHITECTURE}-ranlib${TOOL_OS_SUFFIX}" CACHE PATH "ranlib" )
73+
74+
# Installer
75+
#if( APPLE )
76+
# find_program( CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool )
77+
# if( NOT CMAKE_INSTALL_NAME_TOOL )
78+
# message( FATAL_ERROR "Could not find install_name_tool, please check your #installation." )
79+
# endif()
80+
# mark_as_advanced( CMAKE_INSTALL_NAME_TOOL )
81+
# endif()
82+
83+
# Setup output directories
84+
set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_SOURCE_DIR} CACHE PATH "root for library output, set this to change where android libs are installed to" )
85+
set( CMAKE_INSTALL_PREFIX "${BLACKBERRY_TOOLCHAIN_ROOT}/user" CACHE STRING "path for installing" )
86+
87+
if( EXISTS "${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt" )
88+
set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for applications" )
89+
else()
90+
set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin" CACHE PATH "Output directory for applications" )
91+
endif()
92+
93+
# Includes
94+
list( APPEND BLACKBERRY_SYSTEM_INCLUDE_DIRS "${BLACKBERRY_TARGET_ROOT}/qnx6/usr/include" )
95+
96+
# Flags and preprocessor definitions
97+
if( BLACKBERRY_ARCHITECTURE STREQUAL "arm" )
98+
set( BLACKBERRY_CC_FLAGS " -V4.6.3,gcc_ntoarmv7le -D__QNX__" )
99+
set( BLACKBERRY_CXX_FLAGS " -V4.6.3,gcc_ntoarmv7le -Y_gpp -D__QNX__" )
100+
else()
101+
set( BLACKBERRY_CC_FLAGS " -V4.6.3,gcc_ntox86 -D__QNX__" )
102+
set( BLACKBERRY_CXX_FLAGS " -V4.6.3,gcc_ntox86 -Y_gpp -D__QNX__" )
103+
endif()
104+
set( BLACKBERRY 1 )
105+
106+
# NDK flags
107+
set( CMAKE_CXX_FLAGS "${BLACKBERRY_CXX_FLAGS}" )
108+
set( CMAKE_C_FLAGS "${BLACKBERRY_CC_FLAGS}" )
109+
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions" )
110+
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions" )
111+
112+
# Release and Debug flags
113+
if( BLACKBERRY_ARCHITECTURE STREQUAL "arm" )
114+
set( CMAKE_CXX_FLAGS_RELEASE "-mthumb -O3" )
115+
set( CMAKE_C_FLAGS_RELEASE "-mthumb -O3" )
116+
set( CMAKE_CXX_FLAGS_DEBUG "-g -marm -Os -finline-limit=64" )
117+
set( CMAKE_C_FLAGS_DEBUG "-g -marm -Os -finline-limit=64" )
118+
else()
119+
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i486" )
120+
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i486" )
121+
endif()
122+
123+
# Cache flags
124+
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags" )
125+
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags" )
126+
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "c++ Release flags" )
127+
set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "c Release flags" )
128+
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "c++ Debug flags" )
129+
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" CACHE STRING "c Debug flags" )
130+
set( CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "linker flags" )
131+
SET( CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "" CACHE STRING "linker flags")
132+
SET( CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "" CACHE STRING "linker flags")
133+
set( CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "linker flags" )
134+
set( CMAKE_EXE_LINKER_FLAGS "-lstdc++ -lm -lEGL -lGLESv2 -lbps -lscreen" CACHE STRING "linker flags" )
135+
136+
# Finish flags
137+
set( BLACKBERRY_CXX_FLAGS "${BLACKBERRY_CXX_FLAGS}" CACHE INTERNAL "Extra BlackBerry compiler flags")
138+
set( BLACKBERRY_LINKER_FLAGS "${BLACKBERRY_LINKER_FLAGS}" CACHE INTERNAL "Extra BlackBerry linker flags")
139+
set( CMAKE_CXX_FLAGS "${BLACKBERRY_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" )
140+
set( CMAKE_C_FLAGS "${BLACKBERRY_CXX_FLAGS} ${CMAKE_C_FLAGS}" )
141+
142+
# Global flags for cmake client scripts to change behavior
143+
set( BLACKBERRY True )
144+
# Find the Target environment
145+
set( CMAKE_FIND_ROOT_PATH "${CMAKE_SOURCE_DIR}" "${BLACKBERRY_TARGET_ROOT}" "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_PREFIX}/share" )
146+
# Search for libraries and includes in the ndk toolchain
147+
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
148+
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
149+
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
150+
151+
# Macro to find packages on the host OS
152+
macro( find_host_package )
153+
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
154+
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
155+
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
156+
if( CMAKE_HOST_WIN32 )
157+
SET( WIN32 1 )
158+
SET( UNIX )
159+
elseif( CMAKE_HOST_APPLE )
160+
SET( APPLE 1 )
161+
SET( UNIX )
162+
endif()
163+
find_package( ${ARGN} )
164+
SET( WIN32 )
165+
SET( APPLE )
166+
SET( UNIX 1 )
167+
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
168+
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
169+
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
170+
endmacro()
171+
172+
# Macro to find programs on the host OS
173+
macro( find_host_program )
174+
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
175+
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
176+
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
177+
if( CMAKE_HOST_WIN32 )
178+
SET( WIN32 1 )
179+
SET( UNIX )
180+
elseif( CMAKE_HOST_APPLE )
181+
SET( APPLE 1 )
182+
SET( UNIX )
183+
endif()
184+
find_program( ${ARGN} )
185+
SET( WIN32 )
186+
SET( APPLE )
187+
SET( UNIX 1 )
188+
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
189+
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
190+
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
191+
endmacro()
192+
193+
# We are doing cross compiling, reset the OS information of the Building system
194+
UNSET( APPLE )
195+
UNSET( WIN32 )
196+
UNSET( UNIX )

CMakeModules/FindCheck.cmake

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# - Try to find the CHECK libraries
2+
# Once done this will define
3+
#
4+
# CHECK_FOUND - system has check
5+
# CHECK_INCLUDE_DIRS - the check include directory
6+
# CHECK_LIBRARIES - check library
7+
#
8+
# Copyright (c) 2007 Daniel Gollub <[email protected]>
9+
# Copyright (c) 2007-2009 Bjoern Ricks <[email protected]>
10+
#
11+
# Redistribution and use is allowed according to the terms of the New
12+
# BSD license.
13+
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
14+
15+
16+
INCLUDE( FindPkgConfig )
17+
18+
IF ( Check_FIND_REQUIRED )
19+
SET( _pkgconfig_REQUIRED "REQUIRED" )
20+
ELSE( Check_FIND_REQUIRED )
21+
SET( _pkgconfig_REQUIRED "" )
22+
ENDIF ( Check_FIND_REQUIRED )
23+
24+
IF ( CHECK_MIN_VERSION )
25+
PKG_SEARCH_MODULE( CHECK ${_pkgconfig_REQUIRED} check>=${CHECK_MIN_VERSION} )
26+
ELSE ( CHECK_MIN_VERSION )
27+
PKG_SEARCH_MODULE( CHECK ${_pkgconfig_REQUIRED} check )
28+
ENDIF ( CHECK_MIN_VERSION )
29+
30+
# Look for CHECK include dir and libraries
31+
IF( NOT CHECK_FOUND AND NOT PKG_CONFIG_FOUND )
32+
33+
FIND_PATH( CHECK_INCLUDE_DIRS check.h )
34+
35+
FIND_LIBRARY( CHECK_LIBRARIES NAMES check )
36+
37+
IF ( CHECK_INCLUDE_DIRS AND CHECK_LIBRARIES )
38+
SET( CHECK_FOUND 1 )
39+
IF ( NOT Check_FIND_QUIETLY )
40+
MESSAGE ( STATUS "Found CHECK: ${CHECK_LIBRARIES}" )
41+
ENDIF ( NOT Check_FIND_QUIETLY )
42+
ELSE ( CHECK_INCLUDE_DIRS AND CHECK_LIBRARIES )
43+
IF ( Check_FIND_REQUIRED )
44+
MESSAGE( FATAL_ERROR "Could NOT find CHECK" )
45+
ELSE ( Check_FIND_REQUIRED )
46+
IF ( NOT Check_FIND_QUIETLY )
47+
MESSAGE( STATUS "Could NOT find CHECK" )
48+
ENDIF ( NOT Check_FIND_QUIETLY )
49+
ENDIF ( Check_FIND_REQUIRED )
50+
ENDIF ( CHECK_INCLUDE_DIRS AND CHECK_LIBRARIES )
51+
ENDIF( NOT CHECK_FOUND AND NOT PKG_CONFIG_FOUND )
52+
53+
# Hide advanced variables from CMake GUIs
54+
MARK_AS_ADVANCED( CHECK_INCLUDE_DIRS CHECK_LIBRARIES )
55+

0 commit comments

Comments
 (0)