Switch commoncpp2 to ucommon to solve dependency conflicts.
libccrtp was depending on commoncpp2, and have been replaced by a version
depending on ucommon as well.
diff --git a/jni/libzrtp/sources/demo/CMakeLists.txt b/jni/libzrtp/sources/demo/CMakeLists.txt
index c253d9f..e75a63a 100755
--- a/jni/libzrtp/sources/demo/CMakeLists.txt
+++ b/jni/libzrtp/sources/demo/CMakeLists.txt
@@ -1,27 +1,22 @@
#to make sure includes are first taken - it contains config.h
include_directories(BEFORE ${CMAKE_BINARY_DIR})
-include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_SOURCE_DIR}/zrtp
- ${CMAKE_SOURCE_DIR}/clients/ccrtp)
+include_directories (${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../zrtp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../clients/ccrtp)
-if (CCRTP)
- ########### next target ###############
+########### next target ###############
- add_executable(zrtptest zrtptest.cpp)
- target_link_libraries(zrtptest ${zrtplibName})
- add_dependencies(zrtptest ${zrtplibName})
+add_executable(zrtptest zrtptest.cpp)
+target_link_libraries(zrtptest zrtpcpp ccrtp commoncpp)
+add_dependencies(zrtptest zrtpcpp)
- ########### next target ###############
+########### next target ###############
- add_executable(zrtptestMulti zrtptestMulti.cpp)
- target_link_libraries(zrtptestMulti ${zrtplibName})
- add_dependencies(zrtptestMulti ${zrtplibName})
-else()
- add_executable(sdestest sdestest.cpp)
- target_link_libraries(sdestest ${zrtplibName})
- add_dependencies(sdestest ${zrtplibName})
-endif()
+add_executable(zrtptestMulti zrtptestMulti.cpp)
+target_link_libraries(zrtptestMulti zrtpcpp ccrtp commoncpp)
+add_dependencies(zrtptestMulti zrtpcpp)
+
########### next target ###############
#add_executable(wrappertest wrappertest.c)
diff --git a/jni/libzrtp/sources/demo/sdestest.cpp b/jni/libzrtp/sources/demo/sdestest.cpp
deleted file mode 100644
index a329e8d..0000000
--- a/jni/libzrtp/sources/demo/sdestest.cpp
+++ /dev/null
@@ -1,231 +0,0 @@
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <crypto/hmac256.h>
-
-/*
-HKDF-Expand(PRK, info, L)
-
-Description in RFC 5869
-
- HKDF-Expand(PRK, info, L) -> OKM
-
- Options:
- Hash a hash function; HashLen denotes the length of the
- hash function output in octets
- Inputs:
- PRK a pseudorandom key of at least HashLen octets
- (usually, the output from the extract step)
- info optional context and application specific information
- (can be a zero-length string)
- L length of output keying material in octets
- (<= 255*HashLen)
-
- Output:
- OKM output keying material (of L octets)
-
- The output OKM is calculated as follows:
-
- N = ceil(L/HashLen)
- T = T(1) | T(2) | T(3) | ... | T(N)
- OKM = first L octets of T
-
- where:
- T(0) = empty string (zero length)
- T(1) = HMAC-Hash(PRK, T(0) | info | 0x01)
- T(2) = HMAC-Hash(PRK, T(1) | info | 0x02)
- T(3) = HMAC-Hash(PRK, T(2) | info | 0x03)
- ...
-
- (where the constant concatenated to the end of each T(n) is a
- single octet.)
-
-
- A.1. Test Case 1
-
- Basic test case with SHA-256
-
- Hash = SHA-256
- IKM = 0x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b (22 octets)
- salt = 0x000102030405060708090a0b0c (13 octets)
- info = 0xf0f1f2f3f4f5f6f7f8f9 (10 octets)
- L = 42
-
- PRK = 0x077709362c2e32df0ddc3f0dc47bba63
- 90b6c73bb50f9c3122ec844ad7c2b3e5 (32 octets)
- OKM = 0x3cb25f25faacd57a90434f64d0362f2a
- 2d2d0a90cf1a5a4c5db02d56ecc4c5bf
- 34007208d5b887185865 (42 octets)
-
-A.2. Test Case 2
-
- Test with SHA-256 and longer inputs/outputs
-
- Hash = SHA-256
- IKM = 0x000102030405060708090a0b0c0d0e0f
- 101112131415161718191a1b1c1d1e1f
- 202122232425262728292a2b2c2d2e2f
- 303132333435363738393a3b3c3d3e3f
- 404142434445464748494a4b4c4d4e4f (80 octets)
- salt = 0x606162636465666768696a6b6c6d6e6f
- 707172737475767778797a7b7c7d7e7f
- 808182838485868788898a8b8c8d8e8f
- 909192939495969798999a9b9c9d9e9f
- a0a1a2a3a4a5a6a7a8a9aaabacadaeaf (80 octets)
- info = 0xb0b1b2b3b4b5b6b7b8b9babbbcbdbebf
- c0c1c2c3c4c5c6c7c8c9cacbcccdcecf
- d0d1d2d3d4d5d6d7d8d9dadbdcdddedf
- e0e1e2e3e4e5e6e7e8e9eaebecedeeef
- f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff (80 octets)
- L = 82
-
- PRK = 0x06a6b88c5853361a06104c9ceb35b45c
- ef760014904671014a193f40c15fc244 (32 octets)
- OKM = 0xb11e398dc80327a1c8e7f78c596a4934
- 4f012eda2d4efad8a050cc4c19afa97c
- 59045a99cac7827271cb41c65e590e09
- da3275600c2f09b8367793a9aca3db71
- cc30c58179ec3e87c14c01d5c1f3434f
- 1d87 (82 octets)
-
-A.3. Test Case 3
-
- Test with SHA-256 and zero-length salt/info
-
- Hash = SHA-256
- IKM = 0x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b (22 octets)
- salt = (0 octets)
- info = (0 octets)
- L = 42
-
- PRK = 0x19ef24a32c717b167f33a91d6f648bdf
- 96596776afdb6377ac434c1c293ccb04 (32 octets)
- OKM = 0x8da4e775a563c18f715f802a063c5a31
- b8a11f5c5ee1879ec3454e5f3c738d2d
- 9d201395faa4b61a96c8 (42 octets)
-
-*/
-
-static void hexdump(const char* title, const unsigned char *s, int l)
-{
- int n=0;
-
- if (s == NULL) return;
-
- fprintf(stderr, "%s",title);
- for( ; n < l ; ++n) {
- if((n%16) == 0)
- fprintf(stderr, "\n%04x",n);
- fprintf(stderr, " %02x",s[n]);
- }
- fprintf(stderr, "\n");
-}
-
-
-static uint8_t info_A1[] = {
- 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9};
-
-static int32_t L_A1 = 42;
-
-static uint8_t PRK_A1[] = {
- 0x07, 0x77, 0x09, 0x36, 0x2c, 0x2e, 0x32, 0xdf, 0x0d, 0xdc, 0x3f, 0x0d, 0xc4, 0x7b, 0xba, 0x63,
- 0x90, 0xb6, 0xc7, 0x3b, 0xb5, 0x0f, 0x9c, 0x31, 0x22, 0xec, 0x84, 0x4a, 0xd7, 0xc2, 0xb3, 0xe5};
-
-static uint8_t OKM_A1[] = {
- 0x3c, 0xb2, 0x5f, 0x25, 0xfa, 0xac, 0xd5, 0x7a, 0x90, 0x43, 0x4f, 0x64, 0xd0, 0x36, 0x2f, 0x2a,
- 0x2d, 0x2d, 0x0a, 0x90, 0xcf, 0x1a, 0x5a, 0x4c, 0x5d, 0xb0, 0x2d, 0x56, 0xec, 0xc4, 0xc5, 0xbf,
- 0x34, 0x00, 0x72, 0x08, 0xd5, 0xb8, 0x87, 0x18, 0x58, 0x65}; // (42 octets)
-
-
-static int32_t L_A3 = 42;
-
-static uint8_t PRK_A3[] = {
- 0x19, 0xef, 0x24, 0xa3, 0x2c, 0x71, 0x7b, 0x16, 0x7f, 0x33, 0xa9, 0x1d, 0x6f, 0x64, 0x8b, 0xdf,
- 0x96, 0x59, 0x67, 0x76, 0xaf, 0xdb, 0x63, 0x77, 0xac, 0x43, 0x4c, 0x1c, 0x29, 0x3c, 0xcb, 0x04}; // (32 octets)
-
-static uint8_t OKM_A3[] = {
- 0x8d, 0xa4, 0xe7, 0x75, 0xa5, 0x63, 0xc1, 0x8f, 0x71, 0x5f, 0x80, 0x2a, 0x06, 0x3c, 0x5a, 0x31,
- 0xb8, 0xa1, 0x1f, 0x5c, 0x5e, 0xe1, 0x87, 0x9e, 0xc3, 0x45, 0x4e, 0x5f, 0x3c, 0x73, 0x8d, 0x2d,
- 0x9d, 0x20, 0x13, 0x95, 0xfa, 0xa4, 0xb6, 0x1a, 0x96, 0xc8}; // (42 octets)
-
-
-
-void* createSha256HmacContext(uint8_t* key, int32_t keyLength);
-void freeSha256HmacContext(void* ctx);
-void hmacSha256Ctx(void* ctx, const uint8_t* data[], uint32_t dataLength[], uint8_t* mac, int32_t* macLength );
-
-
-static int expand(uint8_t* prk, uint32_t prkLen, uint8_t* info, int32_t infoLen, int32_t L, uint32_t hashLen, uint8_t* outbuffer)
-{
- int32_t n;
- uint8_t *T;
- void* hmacCtx;
-
- const uint8_t* data[4]; // Data pointers for HMAC data, max. 3 plus terminating NULL
- uint32_t dataLen[4];
- int32_t dataIdx = 0;
-
- uint8_t counter;
- int32_t macLength;
-
- if (prkLen < hashLen)
- return -1;
-
- n = (L + (hashLen-1)) / hashLen;
-
- // T points to buffer that holds concatenated T(1) || T(2) || ... T(N))
- T = reinterpret_cast<uint8_t*>(malloc(n * hashLen));
-
- // Prepare the HMAC
- hmacCtx = createSha256HmacContext(prk, prkLen);
-
- // Prepare first HMAC. T(0) has zero length, thus we ignore it in first run.
- // After first run use its output (T(1)) as first data in next HMAC run.
- for (int i = 1; i <= n; i++) {
- if (infoLen > 0 && info != NULL) {
- data[dataIdx] = info;
- dataLen[dataIdx++] = infoLen;
- }
- counter = i & 0xff;
- data[dataIdx] = &counter;
- dataLen[dataIdx++] = 1;
-
- data[dataIdx] = NULL;
- dataLen[dataIdx++] = 0;
-
- hmacSha256Ctx(hmacCtx, data, dataLen, T + ((i-1) * hashLen), &macLength);
-
- dataIdx = 0;
- data[dataIdx] = T + ((i-1) * hashLen);
- dataLen[dataIdx++] = hashLen;
- }
- freeSha256HmacContext(hmacCtx);
- memcpy(outbuffer, T, L);
- free(T);
- return 0;
-}
-
-int main(int argc, char *argv[])
-{
- uint8_t buffer[500];
- expand(PRK_A1, sizeof(PRK_A1), info_A1, sizeof(info_A1), L_A1, SHA256_DIGEST_LENGTH, buffer);
- if (memcmp(buffer, OKM_A1, L_A1) != 0) {
- fprintf(stderr, "ERROR: Test result A1 mismatch");
- hexdump("Computed result of expand A1", buffer, L_A1);
- hexdump("Expected result of expand A1", OKM_A1, L_A1);
- return 1;
- }
-
- expand(PRK_A3, sizeof(PRK_A3), NULL, 0, L_A3, SHA256_DIGEST_LENGTH, buffer);
- if (memcmp(buffer, OKM_A3, L_A3) != 0) {
- fprintf(stderr, "ERROR: Test result A3 mismatch");
- hexdump("Computed result of expand A3", buffer, L_A3);
- hexdump("Expected result of expand A3", OKM_A3, L_A3);
- return 1;
- }
-
- printf("Done\n");
- return 0;
-}
diff --git a/jni/libzrtp/sources/demo/zrtptest.cpp b/jni/libzrtp/sources/demo/zrtptest.cpp
index 0595543..fc3490d 100644
--- a/jni/libzrtp/sources/demo/zrtptest.cpp
+++ b/jni/libzrtp/sources/demo/zrtptest.cpp
@@ -16,6 +16,9 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#include <commoncpp/string.h>
+
+
#include <cstdlib>
#include <map>
#include <zrtpccrtp.h>
@@ -28,36 +31,40 @@
class PacketsPattern
{
public:
- inline const InetHostAddress& getReceiverAddress() const { return *receiverAddress; }
- inline const InetHostAddress& getSenderAddress() const { return *senderAddress; }
+ inline const InetHostAddress&
+ getDestinationAddress() const
+ { return destinationAddress; }
- inline void setReceiverAddress(InetHostAddress *addr) const { delete receiverAddress; receiverAddress = addr; }
- inline void setSenderAddress(InetHostAddress *addr) const { delete senderAddress; senderAddress = addr; }
+ inline const tpport_t
+ getDestinationPort() const
+ { return destinationPort; }
- inline const tpport_t getReceiverPort() const { return receiverPort; }
- inline const tpport_t getSenderPort() const { return senderPort; }
+ uint32
+ getPacketsNumber() const
+ { return packetsNumber; }
- uint32 getPacketsNumber() const { return packetsNumber; }
+ uint32
+ getSsrc() const
+ { return 0xdeadbeef; }
- uint32 getSsrc() const { return 0xdeadbeef; }
+ const unsigned char*
+ getPacketData(uint32 i)
+ { return data[i%2]; }
- const unsigned char*getPacketData(uint32 i) { return data[i%2]; }
-
- const size_t getPacketSize(uint32 i) { return strlen((char*)data[i%2]) + 1 ; }
+ const size_t
+ getPacketSize(uint32 i)
+ { return strlen((char*)data[i%2]) + 1 ; }
private:
- static const InetHostAddress *receiverAddress;
- static const InetHostAddress *senderAddress;
-
- static const uint16 receiverPort = 5002;
- static const uint16 senderPort = 5004;
+ static const InetHostAddress destinationAddress;
+ static const uint16 destinationPort = 5002;
static const uint32 packetsNumber = 10;
static const uint32 packetsSize = 12;
static const unsigned char* data[];
};
-const InetHostAddress *PacketsPattern::receiverAddress = new InetHostAddress("localhost");
-const InetHostAddress *PacketsPattern::senderAddress = new InetHostAddress("localhost");
+const InetHostAddress PacketsPattern::destinationAddress =
+ InetHostAddress("localhost");
const unsigned char* PacketsPattern::data[] = {
(unsigned char*)"0123456789\n",
@@ -69,7 +76,7 @@
class ExtZrtpSession : public SymmetricZRTPSession {
// ExtZrtpSession(InetMcastAddress& ima, tpport_t port) :
// RTPSession(ima,port) {}
-//
+//
// ExtZrtpSession(InetHostAddress& ia, tpport_t port) :
// RTPSession(ia,port) {}
@@ -111,13 +118,6 @@
};
-/*
- * The following classes use:
- * - localAddress and destination port+2 for the sender classes
- * - destinationAddress and destination port for the receiver classes.
- *
- */
-
/**
* SymmetricZRTPSession in non-security mode (RTPSession compatible).
*
@@ -135,7 +135,7 @@
int doTest() {
// should be valid?
//RTPSession tx();
- ExtZrtpSession tx(pattern.getSsrc(), pattern.getSenderAddress(), pattern.getSenderPort());
+ ExtZrtpSession tx(pattern.getSsrc(), InetHostAddress("localhost"));
// SymmetricZRTPSession tx(pattern.getSsrc(), InetHostAddress("localhost"));
tx.setSchedulingTimeout(10000);
tx.setExpireTimeout(1000000);
@@ -143,9 +143,8 @@
tx.startRunning();
tx.setPayloadFormat(StaticPayloadFormat(sptPCMU));
-
- // We are sender:
- if (!tx.addDestination(pattern.getReceiverAddress(), pattern.getReceiverPort()) ) {
+ if (!tx.addDestination(pattern.getDestinationAddress(),
+ pattern.getDestinationPort()) ) {
return 1;
}
@@ -178,7 +177,8 @@
int
doTest() {
- ExtZrtpSession rx(pattern.getSsrc()+1, pattern.getReceiverAddress(), pattern.getReceiverPort());
+ ExtZrtpSession rx(pattern.getSsrc()+1, pattern.getDestinationAddress(),
+ pattern.getDestinationPort());
// SymmetricZRTPSession rx(pattern.getSsrc()+1, pattern.getDestinationAddress(),
// pattern.getDestinationPort());
@@ -188,7 +188,8 @@
rx.startRunning();
rx.setPayloadFormat(StaticPayloadFormat(sptPCMU));
// arbitrary number of loops to provide time to start transmitter
- if (!rx.addDestination(pattern.getSenderAddress(), pattern.getSenderPort()) ) {
+ if (!rx.addDestination(pattern.getDestinationAddress(),
+ pattern.getDestinationPort()+2) ) {
return 1;
}
for ( int i = 0; i < 5000 ; i++ ) {
@@ -227,8 +228,8 @@
int doTest() {
// should be valid?
//RTPSession tx();
- // Initialize with local address and Local port is detination port +2 - keep RTP/RTCP port pairs
- ExtZrtpSession tx(pattern.getSsrc(), pattern.getSenderAddress(), pattern.getSenderPort());
+ ExtZrtpSession tx(pattern.getSsrc(), pattern.getDestinationAddress(),
+ pattern.getDestinationPort()+2);
tx.initialize("test_t.zid");
tx.setSchedulingTimeout(10000);
@@ -237,7 +238,8 @@
tx.startRunning();
tx.setPayloadFormat(StaticPayloadFormat(sptPCMU));
- if (!tx.addDestination(pattern.getReceiverAddress(), pattern.getReceiverPort()) ) {
+ if (!tx.addDestination(pattern.getDestinationAddress(),
+ pattern.getDestinationPort()) ) {
return 1;
}
tx.startZrtp();
@@ -269,7 +271,8 @@
int
doTest() {
- ExtZrtpSession rx(pattern.getSsrc()+1, pattern.getReceiverAddress(), pattern.getReceiverPort());
+ ExtZrtpSession rx(pattern.getSsrc()+1, pattern.getDestinationAddress(),
+ pattern.getDestinationPort());
rx.initialize("test_r.zid");
@@ -279,7 +282,8 @@
rx.startRunning();
rx.setPayloadFormat(StaticPayloadFormat(sptPCMU));
// arbitrary number of loops to provide time to start transmitter
- if (!rx.addDestination(pattern.getSenderAddress(), pattern.getSenderPort()) ) {
+ if (!rx.addDestination(pattern.getDestinationAddress(),
+ pattern.getDestinationPort()+2) ) {
return 1;
}
rx.startZrtp();
@@ -344,8 +348,6 @@
warningMap.insert(pair<int32, std::string*>(WarningCRCmismatch, new string("Internal ZRTP packet checksum mismatch - packet dropped")));
warningMap.insert(pair<int32, std::string*>(WarningSRTPauthError, new string("Dropping packet because SRTP authentication failed!")));
warningMap.insert(pair<int32, std::string*>(WarningSRTPreplayError, new string("Dropping packet because SRTP replay check failed!")));
- warningMap.insert(pair<int32, std::string*>(WarningNoExpectedRSMatch, new string("No RS match found - but ZRTP expected a match.")));
- warningMap.insert(pair<int32, std::string*>(WarningNoExpectedAuxMatch, new string("The auxlliary secrets do not match.")));
severeMap.insert(pair<int32, std::string*>(SevereHelloHMACFailed, new string("Hash HMAC check of Hello failed!")));
severeMap.insert(pair<int32, std::string*>(SevereCommitHMACFailed, new string("Hash HMAC check of Commit failed!")));
@@ -451,8 +453,6 @@
bool MyUserCallback::initialized = false;
-static unsigned char transmAuxSecret[] = {1,2,3,4,5,6,7,8,9,0};
-
/**
* SymmetricZRTPSession in security mode and using a callback class.
*
@@ -471,52 +471,38 @@
ZrtpConfigure config;
- void run() {
+ void run()
+ {
doTest();
}
- int doTest() {
+ int doTest()
+ {
// should be valid?
//RTPSession tx();
- ExtZrtpSession tx(/*pattern.getSsrc(),*/ pattern.getSenderAddress(), pattern.getSenderPort());
- config.clear();
+ ExtZrtpSession tx(/*pattern.getSsrc(),*/ pattern.getDestinationAddress(),
+ pattern.getDestinationPort()+2);
+// config.clear();
// config.setStandardConfig();
-// config.addAlgo(PubKeyAlgorithm, zrtpPubKeys.getByName("DH2k"));
-// config.addAlgo(PubKeyAlgorithm, zrtpPubKeys.getByName("DH3k"));
-
- // This ordering prefers NIST
+ config.addAlgo(PubKeyAlgorithm, zrtpPubKeys.getByName("DH2k"));
config.addAlgo(PubKeyAlgorithm, zrtpPubKeys.getByName("EC38"));
- config.addAlgo(PubKeyAlgorithm, zrtpPubKeys.getByName("E414"));
-
config.addAlgo(PubKeyAlgorithm, zrtpPubKeys.getByName("EC25"));
- config.addAlgo(PubKeyAlgorithm, zrtpPubKeys.getByName("E255"));
- config.addAlgo(HashAlgorithm, zrtpHashes.getByName("S384"));
- config.addAlgo(HashAlgorithm, zrtpHashes.getByName("SKN3"));
+ config.addAlgo(HashAlgorithm, zrtpHashes.getByName("S384"));
- config.addAlgo(CipherAlgorithm, zrtpSymCiphers.getByName("AES3"));
- config.addAlgo(CipherAlgorithm, zrtpSymCiphers.getByName("2FS3"));
+// config.addAlgo(CipherAlgorithm, zrtpSymCiphers.getByName("2FS3"));
+// config.addAlgo(CipherAlgorithm, zrtpSymCiphers.getByName("AES3"));
config.addAlgo(SasType, zrtpSasTypes.getByName("B256"));
- config.addAlgo(AuthLength, zrtpAuthLengths.getByName("HS32"));
- config.addAlgo(AuthLength, zrtpAuthLengths.getByName("HS80"));
- config.addAlgo(AuthLength, zrtpAuthLengths.getByName("SK32"));
- config.addAlgo(AuthLength, zrtpAuthLengths.getByName("SK64"));
-
tx.initialize("test_t.zid", true, &config);
// At this point the Hello hash is available. See ZRTP specification
// chapter 9.1 for further information when an how to use the Hello
// hash.
- int numSupportedVersion = tx.getNumberSupportedVersions();
- cout << "TX Hello hash 0: " << tx.getHelloHash(0) << endl;
- cout << "TX Hello hash 0 length: " << tx.getHelloHash(0).length() << endl;
- if (numSupportedVersion > 1) {
- cout << "TX Hello hash 1: " << tx.getHelloHash(1) << endl;
- cout << "TX Hello hash 1 length: " << tx.getHelloHash(1).length() << endl;
- }
+ cout << "TX Hello hash: " << tx.getHelloHash() << endl;
+ cout << "TX Hello hash length: " << tx.getHelloHash().length() << endl;
+
tx.setUserCallback(new MyUserCallback(&tx));
- tx.setAuxSecret(transmAuxSecret, sizeof(transmAuxSecret));
tx.setSchedulingTimeout(10000);
tx.setExpireTimeout(1000000);
@@ -524,8 +510,8 @@
tx.startRunning();
tx.setPayloadFormat(StaticPayloadFormat(sptPCMU));
-
- if (!tx.addDestination(pattern.getReceiverAddress(), pattern.getReceiverPort()) ) {
+ if (!tx.addDestination(pattern.getDestinationAddress(),
+ pattern.getDestinationPort()) ) {
return 1;
}
tx.startZrtp();
@@ -549,49 +535,29 @@
}
};
-static unsigned char recvAuxSecret[] = {1,2,3,4,5,6,7,8,9,9};
class
ZrtpRecvPacketTransmissionTestCB: public Thread
{
public:
- ZrtpConfigure config;
-
- void run() {
+ void
+ run() {
doTest();
}
- int doTest() {
- ExtZrtpSession rx( /*pattern.getSsrc()+1,*/ pattern.getReceiverAddress(), pattern.getReceiverPort());
- config.clear();
-// config.setStandardConfig();
-// config.addAlgo(PubKeyAlgorithm, zrtpPubKeys.getByName("DH3k"));
+ int
+ doTest() {
+ ExtZrtpSession rx( /*pattern.getSsrc()+1,*/ pattern.getDestinationAddress(),
+ pattern.getDestinationPort());
- config.addAlgo(PubKeyAlgorithm, zrtpPubKeys.getByName("E414"));
- config.addAlgo(PubKeyAlgorithm, zrtpPubKeys.getByName("EC38"));
-
- config.addAlgo(HashAlgorithm, zrtpHashes.getByName("S384"));
- config.addAlgo(HashAlgorithm, zrtpHashes.getByName("SKN3"));
-
-// config.addAlgo(CipherAlgorithm, zrtpSymCiphers.getByName("2FS3"));
-// config.addAlgo(CipherAlgorithm, zrtpSymCiphers.getByName("AES3"));
-
- config.addAlgo(SasType, zrtpSasTypes.getByName("B256"));
-
-
- rx.initialize("test_r.zid", true, &config);
+ rx.initialize("test_r.zid");
// At this point the Hello hash is available. See ZRTP specification
// chapter 9.1 for further information when an how to use the Hello
// hash.
- int numSupportedVersion = rx.getNumberSupportedVersions();
- cout << "RX Hello hash 0: " << rx.getHelloHash(0) << endl;
- cout << "RX Hello hash 0 length: " << rx.getHelloHash(0).length() << endl;
- if (numSupportedVersion > 1) {
- cout << "RX Hello hash 1: " << rx.getHelloHash(1) << endl;
- cout << "RX Hello hash 1 length: " << rx.getHelloHash(1).length() << endl;
- }
+ cout << "RX Hello hash: " << rx.getHelloHash() << endl;
+ cout << "RX Hello hash length: " << rx.getHelloHash().length() << endl;
+
rx.setUserCallback(new MyUserCallback(&rx));
- rx.setAuxSecret(recvAuxSecret, sizeof(recvAuxSecret));
rx.setSchedulingTimeout(10000);
rx.setExpireTimeout(1000000);
@@ -599,7 +565,8 @@
rx.startRunning();
rx.setPayloadFormat(StaticPayloadFormat(sptPCMU));
// arbitrary number of loops to provide time to start transmitter
- if (!rx.addDestination(pattern.getSenderAddress(), pattern.getSenderPort()) ) {
+ if (!rx.addDestination(pattern.getDestinationAddress(),
+ pattern.getDestinationPort()+2) ) {
return 1;
}
rx.startZrtp();
@@ -631,7 +598,7 @@
/* check args */
while (1) {
- c = getopt(argc, argv, "rsR:S:");
+ c = getopt(argc, argv, "rs");
if (c == -1) {
break;
}
@@ -642,12 +609,6 @@
case 's':
send = true;
break;
- case 'R':
- pattern.setReceiverAddress(new InetHostAddress(optarg));
- break;
- case 'S':
- pattern.setSenderAddress(new InetHostAddress(optarg));
- break;
default:
cerr << "Wrong Arguments, only -s and -r are accepted" << endl;
}
diff --git a/jni/libzrtp/sources/demo/zrtptestMulti.cpp b/jni/libzrtp/sources/demo/zrtptestMulti.cpp
index d7042ed..8fd288b 100644
--- a/jni/libzrtp/sources/demo/zrtptestMulti.cpp
+++ b/jni/libzrtp/sources/demo/zrtptestMulti.cpp
@@ -488,8 +488,7 @@
if (!multiParams.empty()) {
tx = new SymmetricZRTPSession(pattern.getDestinationAddress(),
pattern.getDestinationPort()+2+10);
-
- // tx->initialize("test_t.zid", true, &config);
+// tx->initialize("test_t.zid", true, &config);
tx->initialize("test_t.zid", true);
tx->setMultiStrParams(multiParams);
@@ -500,12 +499,13 @@
else {
tx = new SymmetricZRTPSession(pattern.getDestinationAddress(),
pattern.getDestinationPort()+2);
+ //config.addHashAlgo(Sha384);
+// tx->initialize("test_t.zid", true, &config);
if (mitm) { // Act as trusted MitM - could be enrolled
tx->setMitmMode(true);
}
tx->setSignSas(signsas);
-// tx->initialize("test_t.zid", true, &config);
tx->initialize("test_t.zid", true);
if (enroll) // act as PBX enrollement service
@@ -518,13 +518,8 @@
// At this point the Hello hash is available. See ZRTP specification
// chapter 9.1 for further information when an how to use the Hello
// hash.
- int numSupportedVersion = tx->getNumberSupportedVersions();
- cout << "TX Hello hash 0: " << tx->getHelloHash(0) << endl;
- cout << "TX Hello hash 0 length: " << tx->getHelloHash(0).length() << endl;
- if (numSupportedVersion > 1) {
- cout << "TX Hello hash 1: " << tx->getHelloHash(1) << endl;
- cout << "TX Hello hash 1 length: " << tx->getHelloHash(1).length() << endl;
- }
+ cout << prefix << "Hello hash: " << tx->getHelloHash() << endl;
+ cout << prefix << "Hello hash length: " << tx->getHelloHash().length() << endl;
tx->setUserCallback(mcb);
tx->setSchedulingTimeout(10000);
tx->setExpireTimeout(1000000);
@@ -588,14 +583,12 @@
rx = new SymmetricZRTPSession(pattern.getDestinationAddress(),
pattern.getDestinationPort());
config.setStandardConfig();
-// config.clear();
-// config.addAlgo(SasType, zrtpSasTypes.getByName("B256"));
-
if (enroll)
config.setTrustedMitM(true); // allow a trusted MitM to start enrollment process
rx->setSignSas(signsas);
+ // config.addHashAlgo(Sha384);
rx->initialize("test_r.zid", true, &config);
// rx->initialize("test_r.zid", true);
@@ -606,13 +599,8 @@
// At this point the Hello hash is available. See ZRTP specification
// chapter 9.1 for further information when an how to use the Hello
// hash.
- int numSupportedVersion = rx->getNumberSupportedVersions();
- cout << "RX Hello hash 0: " << rx->getHelloHash(0) << endl;
- cout << "RX Hello hash 0 length: " << rx->getHelloHash(0).length() << endl;
- if (numSupportedVersion > 1) {
- cout << "RX Hello hash 1: " << rx->getHelloHash(1) << endl;
- cout << "RX Hello hash 1 length: " << rx->getHelloHash(1).length() << endl;
- }
+ cout << prefix << "Hello hash: " << rx->getHelloHash() << endl;
+ cout << prefix << "Hello hash length: " << rx->getHelloHash().length() << endl;
rx->setUserCallback(mcb);
rx->setSchedulingTimeout(10000);
rx->setExpireTimeout(1000000);