>From da0456f19bf616c737f08c06224198e9175dce5d Mon Sep 17 00:00:00 2001 From: Ben Sartor
Date: Wed, 14 Jan 2015 23:55:43 +0100 Subject: [PATCH 05/15] added getter and setter for supported crypto types --- include/bzrtp/bzrtp.h | 22 ++++++++++++++ src/bzrtp.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) diff --git a/include/bzrtp/bzrtp.h b/include/bzrtp/bzrtp.h index 190d8b7..dd7a3c5 100644 --- a/include/bzrtp/bzrtp.h +++ b/include/bzrtp/bzrtp.h @@ -260,6 +260,28 @@ BZRTP_EXPORT void bzrtp_resetSASVerified(bzrtpContext_t *zrtpContext); */ BZRTP_EXPORT int bzrtp_resetRetransmissionTimer(bzrtpContext_t *zrtpContext, uint32_t selfSSRC); +/** + * @brief Get the supported crypto types + * + * @param[int] zrtpContext The ZRTP context we're dealing with + * @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] supportedTypes mapped to uint8_t value of the 4 char strings giving the supported types as string according to rfc section 5.1.2 to 5.1.6 + * + * @return number of supported types, 0 on error + */ +BZRTP_EXPORT uint8_t bzrtp_getSupportedCryptoTypes(bzrtpContext_t *zrtpContext, uint8_t algoType, uint8_t supportedTypes[7]); + +/** + * @brief set the supported crypto types + * + * @param[int/out] zrtpContext The ZRTP context we're dealing with + * @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[in] supportedTypes mapped to uint8_t value of the 4 char strings giving the supported types as string according to rfc section 5.1.2 to 5.1.6 + * @param[in] supportedTypesCount number of supported crypto types + */ +BZRTP_EXPORT void bzrtp_setSupportedCryptoTypes(bzrtpContext_t *zrtpContext, uint8_t algoType, uint8_t supportedTypes[7], uint8_t supportedTypesCount); + + #define BZRTP_CUSTOMCACHE_USEKDF 1 #define BZRTP_CUSTOMCACHE_PLAINDATA 0 diff --git a/src/bzrtp.c b/src/bzrtp.c index f1cc2a8..4845d22 100644 --- a/src/bzrtp.c +++ b/src/bzrtp.c @@ -760,3 +760,83 @@ void bzrtp_destroyChannelContext(bzrtpContext_t *zrtpContext, bzrtpChannelContex /* free the channel context */ free(zrtpChannelContext); } + +static uint8_t copyCryptoTypes(uint8_t destination[7], uint8_t source[7], uint8_t size) +{ + int i; + + for (i=0; i