Commit 0b4f6afe authored by johan's avatar johan

Initial non functional commit

parents
Copyright 2014 Belledonne Communications SARL.
Johan Pascal
This diff is collapsed.
This diff is collapsed.
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src include test
test:
cd test && $(MAKE) test
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libbzrtp.pc
bzrtp is an opensource implementation of ZRTP keys exchange protocol.
The library written in C 89 is fully portable and can be executed on many platforms including both ARM processor and x86.
Licensing: The source code is licensed under GPLv2.
By default, the upstream package installs into /usr/local. Please use
'./configure --prefix' to change it
Linphone plugin is compiled if both mediastremer2 and ortp are installed
#!/bin/sh
#AM_VERSION="1.11"
if ! type aclocal-$AM_VERSION 1>/dev/null 2>&1; then
AUTOMAKE=automake
ACLOCAL=aclocal
else
ACLOCAL=aclocal-${AM_VERSION}
AUTOMAKE=automake-${AM_VERSION}
fi
if test -f /opt/local/bin/glibtoolize ; then
# darwin
LIBTOOLIZE=/opt/local/bin/glibtoolize
else
LIBTOOLIZE=libtoolize
fi
if test -d /opt/local/share/aclocal ; then
ACLOCAL_ARGS="-I /opt/local/share/aclocal"
fi
echo "Generating build scripts for BZRtp: ZRTP engine"
set -x
$LIBTOOLIZE --copy --force
$ACLOCAL $ACLOCAL_ARGS
#autoheader
$AUTOMAKE --force-missing --add-missing --copy
autoconf
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_INIT([bzrtp],[0.1])
AC_PREREQ(2.63)
AC_CONFIG_SRCDIR([src/bzrtp.c])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([tar-ustar --warnings=no-portability])
AC_PROG_LIBTOOL
AC_PROG_CC
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_ARG_ENABLE(strict,
[ --enable-strict Enable error on compilation warning [default=yes]],
[wall_werror=$enableval],
[wall_werror=yes]
)
# configure option to disable the tests
PKG_CHECK_MODULES(CUNIT, cunit, [found_cunit=yes],[found_cunit=no])
if test "$found_cunit" = "no" ; then
AC_CHECK_HEADERS(CUnit/CUnit.h,
[
AC_CHECK_LIB(cunit,CU_add_suite,[
found_cunit=yes
CUNIT_LIBS+=" -lcunit"
])
])
fi
if test "$found_cunit" = "no" ; then
AC_MSG_WARN([Could not find cunit framework, tests are not compiled.])
else
AC_CHECK_LIB(cunit,CU_get_suite,[
AC_DEFINE(HAVE_CU_GET_SUITE,1,[defined when CU_get_suite is available])
],[foo=bar],[$CUNIT_LIBS])
AC_CHECK_LIB(cunit,CU_curses_run_tests,[
AC_DEFINE(HAVE_CU_CURSES,1,[defined when CU_curses_run_tests is available])
],[foo=bar],[$CUNIT_LIBS])
fi
AC_ARG_ENABLE(tests,
[AS_HELP_STRING([--disable-tests], [Disable compilation of tests])],
[case "${enableval}" in
yes) tests_enabled=true ;;
no) tests_enabled=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --disable-tests) ;;
esac],
[tests_enabled=yes]
)
AM_CONDITIONAL(ENABLE_TESTS, test x$tests_enabled = xyes && test x$found_cunit = xyes)
CFLAGS="$CFLAGS -Wall -std=c89"
if test $GCC = yes && test $wall_werror = yes; then
CFLAGS="$CFLAGS -Werror "
fi
LIBS="$LIBS -lpolarssl -lm"
# Create the following files from their .in counterparts
AC_CONFIG_FILES([
Makefile
src/Makefile
include/Makefile
include/bzrtp/Makefile
test/Makefile
libbzrtp.pc
])
AC_OUTPUT
SUBDIRS = bzrtp
bzrtp_includedir=$(includedir)/bzrtp
bzrtp_include_HEADERS= bzrtp.h
EXTRA_DIST=$(bzrtp_include_HEADERS)
/**
@file bzrtp.h
@brief Public entry points to the ZRTP implementation
@author Johan Pascal
@copyright Copyright (C) 2014 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef BZRTP_H
#define BZRTP_H
typedef struct bzrtpContext_struct bzrtpContext;
#include <stdint.h>
/**
* brief The data structure containing the keys and algorithms to be used by srtp */
typedef struct bzrtpSrtpSecrets_struct {
uint8_t *selfSrtpKey; /**< The key used by local part to encrypt */
uint8_t selfSrtpKeyLength; /**< The length in byte of the key */
uint8_t *selfSrtpSalt; /**< The salt used by local part to encrypt */
uint8_t selfSrtpSaltLength; /**< The length in byte of the salt */
uint8_t *peerSrtpKey; /**< The key used by local part to decrypt */
uint8_t peerSrtpKeyLength; /**< The length in byte of the key */
uint8_t *peerSrtpSalt; /**< The salt used by local part to decrypt */
uint8_t peerSrtpSaltLength; /**< The length in byte of the salt */
} bzrtpSrtpSecrets_t;
#define ZRTP_MAGIC_COOKIE 0x5a525450
#define ZRTP_VERSION "1.10"
/*#define ZRTP_CLIENT_IDENTIFIER "LINPHONEZRTP0.01"*/
#define ZRTP_CLIENT_IDENTIFIER "LINPHONE-ZRTPCPP"
/* error code definition */
#define BZRTP_ERROR_INVALIDCALLBACKID 0x0001
/**
* @brief bzrtpContext_t The ZRTP engine context
* Store current state, timers, HMAC and encryption keys
*/
typedef struct bzrtpContext_struct bzrtpContext_t;
/**
* Create context structure and initialise it
* @return The ZRTP engine context data
*
*/
__attribute__ ((visibility ("default"))) bzrtpContext_t *bzrtp_createBzrtpContext();
/**
* @brief Perform some initialisation which can't be done without some callback functions:
* - get ZID
*
* @param[in] context The context to initialise
*/
__attribute__ ((visibility ("default"))) void bzrtp_initBzrtpContext(bzrtpContext_t *context);
/**
* Free memory of context structure
* @param[in] context BZRtp context to be destroyed.
*
*/
__attribute__ ((visibility ("default"))) void bzrtp_destroyBzrtpContext(bzrtpContext_t *context);
#define ZRTP_CALLBACK_READCACHE 0x0101
#define ZRTP_CALLBACK_WRITECACHE 0x0102
#define ZRTP_CALLBACK_SETCACHEPOSITION 0x0104
#define ZRTP_CALLBACK_GETCACHEPOSITION 0x0108
/**
* @brief Allocate a function pointer to the callback function identified by his id
* @param[in] functionPointer The pointer to the function to bind as callback.
* @param[in] functionID The ID as defined above to identify which callback to be set.
*
* @return 0 on success
*
*/
__attribute__ ((visibility ("default"))) int bzrtp_setCallback(bzrtpContext_t *context, int (*functionPointer)(), uint16_t functionID);
#endif /* ifndef BZRTP_H */
/**
@file cryptoUtils.h
@brief Prototypes for security related functions
- Key Derivation Function
- CRC
- Base32
- Key agreement algorithm negociation
@author Johan Pascal
@copyright Copyright (C) 2014 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef CRYPTOUTILS_H
#define CRYPTOUTILS_H
#include "packetParser.h"
#include "typedef.h"
/**
*
* @brief ZRTP Key Derivation Function as in rfc 4.5.1
*
* KDF(KI, Label, Context, L) = HMAC(KI, i || Label ||
* 0x00 || Context || L)
* where
* - i is a 32-bits integer fixed to 0x00000001
* - L is a 32-bit big-endian positive
* integer, not to exceed the length in bits of the output of the HMAC.
* The output of the KDF is truncated to the leftmost L bits.
*
* @param[in] key The key for HMAC
* @param[in] keyLength Length of the key in bytes
* @param[in] label A string to be included in the hash
* @param[in] labelLength Length of the label in bytes
* @param[in] context a context string for the key derivation
* @param[in] contextLength Length of the context string in bytes
* @param[in] hmacLength The output of the KDF is the HMAC truncated to the leftmost L bytes
* @param[in] hmacFunction The hashmac function to be used to compute the KDF
* @param[out] output A buffer to store the hmacLength bytes of output
*
* @return 0 on succes, error code otherwise
*/
int bzrtp_keyDerivationFunction(uint8_t *key, uint16_t keyLength,
uint8_t *label, uint16_t labelLength,
uint8_t *context, uint16_t contextLength,
uint16_t hmacLength,
void (*hmacFunction)(uint8_t *, uint8_t, uint8_t *, uint32_t, uint8_t, uint8_t *),
uint8_t *output);
/**
* @brief SAS rendering from 32 bits to 4 characters
* Function defined in rfc section 5.1.6
*
* @param[in] sas The 32 bits SAS
* @param[out] output The 4 chars string to be displayed to user for vocal confirmation
*
*/
void bzrtp_base32(uint32_t sas, char output[4]);
/**
* @brief CRC32 as defined in RFC4960 Appendix B - Polynomial is 0x1EDC6F41
*
* CRC is computed in reverse bit mode (least significant bit first within each byte)
* reversed value of polynom (0x82F63B78) was used to compute the lookup table (source
* http://en.wikipedia.org/wiki/Cyclic_redundancy_check#Commonly_used_and_standardized_CRCs)
*
* @param[in] input input data
* @param[in] length length of data in bytes
*
* @return the 32 bits CRC value
*
*/
uint32_t bzrtp_CRC32(uint8_t *input, uint16_t length);
/* error code for the cryptoAlgoAgreement and function pointer update functions */
#define ZRTP_CRYPTOAGREEMENT_INVALIDCONTEXT 0x1001
#define ZRTP_CRYPTOAGREEMENT_INVALIDMESSAGE 0x1002
#define ZRTP_CRYPTOAGREEMENT_INVALIDSELFALGO 0x1003
#define ZRTP_CRYPTOAGREEMENT_NOCOMMONALGOFOUND 0x1004
#define ZRTP_CRYPTOAGREEMENT_INVALIDCIPHER 0x1005
#define ZRTP_CRYPTOAGREEMENT_INVALIDHASH 0x1006
#define ZRTP_CRYPTOAGREEMENT_INVALIDAUTHTAG 0x1007
#define ZRTP_CRYPTOAGREEMENT_INVALIDSAS 0x1008
/**
* @brief select a key agreement algorithm from the one available in context and the one provided by
* peer in Hello Message as described in rfc section 4.1.2
* - other algorithm are selected according to availability and selected key agreement as described in
* rfc section 5.1.5
* The other algorithm choice will finally be set by the endpoint acting as initiator in the commit packet
*
* @param[in/out] zrtpContext The context contains the list of available algo and is set with the selected ones
* @param[in] peerHelloMessage The peer hello message containing his set of available algos
*
* return 0 on succes, error code otherwise
*
*/
int crypoAlgoAgreement(bzrtpContext_t *zrtpContext, bzrtpHelloMessage_t *peerHelloMessage);
/**
* @brief Update context crypto function pointer according to related values of choosen algorithms fields (hashAlgo, cipherAlgo, etc..)
*
* @param[in/out] context The bzrtp context to be updated
*
* @return 0 on succes
*/
int updateCryptoFunctionPointers(bzrtpContext_t *context);
/**
* @brief Map the string description of algo type to an int defined in cryptoWrapper.h
*
* @param[in] algoType A 4 chars string containing the algo type as listed in rfc sections 5.1.2 to 5.1.6
* @param[in] algoFamily The integer mapped algo family (ZRTP_HASH_TYPE, ZRTP_CIPHERBLOCK_TYPE, ZRTP_AUTHTAG_TYPE,
* ZRTP_KEYAGREEMENT_TYPE or ZRTP_SAS_TYPE)
* @return The int value mapped to the algo type, ZRTP_UNSET_ALGO on error
*/
uint8_t cryptoAlgoTypeStringToInt(uint8_t algoType[4], uint8_t algoFamily);
/**
* @brief Unmap the string description of algo type to an int defined in cryptoWrapper.h
*
* @param[in] algoTypeInt The integer algo type defined in crypoWrapper.h
* @param[in] algoFamily The string code for the algorithm as defined in rfc 5.1.2 to 5.1.6
*/
void cryptoAlgoTypeIntToString(uint8_t algoTypeInt, uint8_t algoTypeString[4]);
/**
* @brief Destroy a key by setting it to a random number
* Key is not freed, caller must deal with memory management
*
* @param[in/out] key The key to be destroyed
* @param[in] keyLength The keyLength in bytes
* @param[in] rngContext The context for RNG
*/
void bzrtp_DestroyKey(uint8_t *key, uint8_t keyLength, void *rngContext);
#endif /* CRYPTOUTILS_H */
/**
@file cryptoWrapper.h
@brief This file contains all functions prototypes to the needed cryptographic operations:
- SHA256
- HMAC-SHA256
- AES128-CFB128
- Diffie-Hellman-Merkle 2048 and 3072 bits
- Random number generator
This functions are implemented by an external lib(polarssl but it can be other) and the functions
wrapper depends on the external lib API.
@author Johan Pascal
@copyright Copyright (C) 2014 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef CRYPTOWRAPPER_H
#define CRYPTOWRAPPER_H
#include <stdint.h>
/* define different types of crypto functions */
#define ZRTP_HASH_TYPE 0x01
#define ZRTP_CIPHERBLOCK_TYPE 0x02
#define ZRTP_AUTHTAG_TYPE 0x04
#define ZRTP_KEYAGREEMENT_TYPE 0x08
#define ZRTP_SAS_TYPE 0x10
/* map the differents algorithm (some may not be available) to integer */
#define ZRTP_UNSET_ALGO 0x00
#define ZRTP_HASH_S256 0x11
#define ZRTP_HASH_S384 0x12
#define ZRTP_HASH_N256 0x13
#define ZRTP_HASH_N384 0x14
#define ZRTP_CIPHER_AES1 0x21
#define ZRTP_CIPHER_AES2 0x22
#define ZRTP_CIPHER_AES3 0x23
#define ZRTP_CIPHER_2FS1 0x24
#define ZRTP_CIPHER_2FS2 0x25
#define ZRTP_CIPHER_2FS3 0x26
#define ZRTP_AUTHTAG_HS32 0x31
#define ZRTP_AUTHTAG_HS80 0x32
#define ZRTP_AUTHTAG_SK32 0x33
#define ZRTP_AUTHTAG_SK64 0x34
/* WARNING : it is very important to keep the key agreement defined in that order
* as it is used to easily sort them from faster(DH2k) to slower(EC52)
*/
#define ZRTP_KEYAGREEMENT_DH2k 0x41
#define ZRTP_KEYAGREEMENT_EC25 0x42
#define ZRTP_KEYAGREEMENT_DH3k 0x43
#define ZRTP_KEYAGREEMENT_EC38 0x44
#define ZRTP_KEYAGREEMENT_EC52 0x45
#define ZRTP_KEYAGREEMENT_Prsh 0x46
#define ZRTP_KEYAGREEMENT_Mult 0x47
#define ZRTP_SAS_B32 0x51
#define ZRTP_SAS_B256 0x52
/**
* @brief Get the available crypto functions
* - Hash function
* - Cipher Block
* - Auth Tag (this depends on SRTP implementation, thus returns only mandatory types: "HS32" and "HS80" HMAC-SHA1)
* - Key agreement
* - SAS
*
* @param[in] algoType mapped to defines, must be in [ZRTP_HASH_TYPE, ZRTP_CIPHERBLOCK_TYPE, ZRTP_AUTHTAG_TYPE, ZRTP_KEYAGREEMENT_TYPE or ZRTP_SAS_TYPE]
* @param[out] availableTypes mapped to uint8_t value of the 4 char strings giving the available types as string according to rfc section 5.1.2 to 5.1.6
*
* @return number of available types, 0 on error
*/
uint8_t bzrtpCrypto_getAvailableCryptoTypes(uint8_t algoType, uint8_t availableTypes[7]);
/**
*
* @brief The context structure to the Random Number Generator
* actually just holds a pointer to the crypto module implementation context
*
*/
typedef struct bzrtpRNGContext_struct {
void *cryptoModuleData; /**< a context needed by the actual implementation */
} bzrtpRNGContext_t;
/**
*
* @brief Initialise the random number generator
*
* @param[in] entropyString Any string providing more entropy to the RNG
* @param[in] entropyStringLength Length of previous parameter
* @return The context initialised. NULL on error
*
*/
bzrtpRNGContext_t *bzrtpCrypto_startRNG(const uint8_t *entropyString, uint16_t entropyStringLength);
/**
*
* @brief Generate a random number
* @param[in] context The RNG context
* @param[out] output The random generated
* @param[in] outputLength The length(in bytes) of random number to be generated
* @return 0 on success.
*
*/
int bzrtpCrypto_getRandom(bzrtpRNGContext_t *context, uint8_t *output, int16_t outputLength);
/**
*
* @brief Destroy the RNG context
*
* @param[in] context The context to be destroyed
* @return 0 on success.
*
*/
int bzrtpCrypto_destroyRNG(bzrtpRNGContext_t *context);
/**
* @brief HMAC-SHA256 wrapper
* @param[in] key HMAC secret key
* @param[in] keyLength HMAC key length in bytes
* @param[in] input Input data buffer
* @param[in] inputLength Input data length in bytes
* @param[in] hmacLength Lenght of output required in bytes, HMAC output is truncated to the hmacLenght left bytes. 32 bytes maximum
* @param[out] output Output data buffer.
*
*/
void bzrtpCrypto_hmacSha256(const uint8_t *key,
uint8_t keyLength,
const uint8_t *input,
uint32_t inputLength,
uint8_t hmacLength,
uint8_t *output);
/**
* @brief SHA256 wrapper
* @param[in] input Input data buffer
* @param[in] inputLength Input data length in bytes
* @param[in] hmacLength Lenght of output required in bytes, SHA256 output is truncated to the hashLenght left bytes. 32 bytes maximum
* @param[out] output Output data buffer.
*
*/
void bzrtpCrypto_sha256(const uint8_t *input,
uint32_t inputLength,
uint8_t hashLength,
uint8_t *output);
/**
* @brief HMAC-SHA1 wrapper
* @param[in] key HMAC secret key
* @param[in] keyLength HMAC key length
* @param[in] input Input data buffer
* @param[in] inputLength Input data length
* @param[in] hmacLength Lenght of output required in bytes, HMAC output is truncated to the hmacLenght left bytes. 32 bytes maximum
* @param[out] output Output data buffer
*
*/
void bzrtpCrypto_hmacSha1(const uint8_t *key,
uint8_t keyLength,
const uint8_t *input,
uint32_t inputLength,
uint8_t hmacLength,
uint8_t *output);
/**
* @brief Wrapper for AES-128 in CFB128 mode encryption
* Both key and IV must be 16 bytes long
*
* @param[in] key encryption key, 128 bits long
* @param[in] IV Initialisation vector, 128 bits long, is not modified by this function.
* @param[in] input Input data buffer
* @param[in] inputLength Input data length
* @param[out] output Output data buffer
*
*/
void bzrtpCrypto_aes128CfbEncrypt(const uint8_t *key,
const uint8_t *IV,
const uint8_t *input,
uint16_t inputLength,
uint8_t *output);
/**
* @brief Wrapper for AES-128 in CFB128 mode decryption
* Both key and IV must be 16 bytes long
*
* @param[in] key decryption key, 128 bits long
* @param[in] IV Initialisation vector, 128 bits long, is not modified by this function.
* @param[in] input Input data buffer
* @param[in] inputLength Input data length
* @param[out] output Output data buffer
*
*/
void bzrtpCrypto_aes128CfbDecrypt(const uint8_t *key,
const uint8_t *IV,
const uint8_t *input,
uint16_t inputLength,
uint8_t *output);
/**
* @brief Context for the Diffie-Hellman-Merkle key exchange
* ZRTP specifies the use of RFC3526 values for G and P so we do not need to store them in this context
*/
typedef struct bzrtpDHMContext_struct {
uint8_t algo; /**< Algorithm used for the key exchange mapped to an int */
uint16_t primeLength; /**< Prime number length in bytes(256 or 384)*/
uint8_t *secret; /**< the random secret (X), this field may not be used if the crypto module implementation already store this value in his context */
uint8_t secretLength; /**< in bytes. Shall be twice the AES key length used (rfc 5.1.5) */
uint8_t *key; /**< the key exchanged (G^Y)^X mod P */
uint8_t *self; /**< this side of the public exchange G^X mod P */
uint8_t *peer; /**< the other side of the public exchange G^Y mod P */
void *cryptoModuleData; /**< a context needed by the crypto implementation */
}bzrtpDHMContext_t;
/**
*
* @brief Create a context for the DHM key exchange
* This function will also instantiate the context needed by the actual implementation of the crypto module
*
* @param[in] DHMAlgo The algorithm type(ZRTP_KEYAGREEMENT_DH2k or ZRTP_KEYAGREEMENT_DH3k)
* @param[in] secretLength The length in byte of the random secret(X). Shall be twice the AES key length used(rfc 5.1.5)
*
* @return The initialised context for the DHM calculation(must then be freed calling the destroyDHMContext function), NULL on error
*
*/
bzrtpDHMContext_t *bzrtpCrypto_CreateDHMContext(uint8_t DHMAlgo, uint8_t secretLength);
/**
*
* @brief Generate the private secret X and compute the public value G^X mod P
* G, P and X length have been set by previous call to DHM_CreateDHMContext
*
* @param[in/out] context DHM context, will store the public value in ->self after this call
* @param[in] rngFunction pointer to a random number generator used to create the secret X
* @param[in] rngContext pointer to the rng context if neeeded
*
*/
void bzrtpCrypto_DHMCreatePublic(bzrtpDHMContext_t *context, int (*rngFunction)(void *, uint8_t *, uint16_t), void *rngContext);
/**
*
* @brief Compute the secret key G^X^Y mod p
* G^X mod P has been computed in previous call to DHMCreatePublic
* G^Y mod P must have been set in context->peer
*
* @param[in/out] context Read the public values from context, export the key to context->key
* @param[in] rngFunction Pointer to a random number generation function, used for blinding countermeasure, may be NULL
* @param[in] rngContext Pointer to the RNG function context
*
*/
void bzrtpCrypto_DHMComputeSecret(bzrtpDHMContext_t *context, int (*rngFunction)(void *, uint8_t *, uint16_t), void *rngContext);
/**
*
* @brief Clean DHM context
*
* @param context The context to deallocate
*
*/
void bzrtpCrypto_DestroyDHMContext(bzrtpDHMContext_t *context);
#endif /* ifndef CRYPTOWRAPPER_H */
This diff is collapsed.
/**
@file typedef.h
@author Johan Pascal
@copyright Copyright (C) 2014 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef TYPEDEF_H
#define TYPEDEF_H
/* aux secret may rarely be used define his maximum length in bytes */
#define MAX_AUX_SECRET_LENGTH 64
/* the context will store some of the sent or received packets */
#define PACKET_STORAGE_CAPACITY 3
#define HELLO_MESSAGE_STORE_ID 0
#define COMMIT_MESSAGE_STORE_ID 1
#define DHPART2_MESSAGE_STORE_ID 2
/* role mapping */
#define INITIATOR 0
#define RESPONDER 1
#include <stdint.h>
#include <stdio.h>
#include "cryptoWrapper.h"
#include "packetParser.h"
/**
* @brief A set of cached secrets retrieved from the cache as defined
*/
typedef struct cachedSecrets_struct {
uint8_t *rs1; /**< retained secret 1 */
uint8_t rs1Length; /**< retained secret 1 length in bytes */
uint8_t *rs2; /**< retained secret 2 */
uint8_t rs2Length; /**< retained secret 2 length in bytes */
uint8_t *auxsecret; /**< auxiliary secret */
uint8_t auxsecretLength; /**< auxiliary secret length in bytes */
uint8_t *pbxsecret; /**< PBX secret */
uint8_t pbxsecretLength; /**< PBX secret length in bytes */
} cachedSecrets_t;
/**
* @brief The hash of cached secret truncated to the 64 leftmost bits
*/
typedef struct cachedSecretsHash_struct {
uint8_t rs1ID[8]; /**< retained secret 1 Hash */
uint8_t rs2ID[8]; /**< retained secret 2 Hash */
uint8_t auxsecretID[8]; /**< auxiliary secret Hash */
uint8_t pbxsecretID[8]; /**< pbx secret Hash */
} cachedSecretsHash_t;
/**
* @brief All the callback functions provided by the client needed by the ZRTP engine
*/
typedef struct zrtpCallbacks_struct {
int (* bzrtp_readCache)(uint8_t *output, uint16_t size); /**< Cache related function : read size bytes from cache, shall return the number of bytes read */
int (* bzrtp_writeCache)(uint8_t *input, uint16_t size); /**< Cache related function : write size bytes to cache */
int (* bzrtp_setCachePosition)(long position); /**< Cache related function : set cache position in cache file, rewind when passing 0 */
int (* bzrtp_getCachePosition)(long *position); /**< Cache related function : get the current cache position in cache file */
} zrtpCallbacks_t;
/**
* @struct bzrtpContext_t structure of the ZRTP engine
* Store current state, timers, HMAC and encryption keys
*/
typedef struct bzrtpContext_struct {
/* contexts */
bzrtpRNGContext_t *RNGContext; /**< context for random number generation */