Skip to content
Snippets Groups Projects
Commit 26131ec2 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#1722] Use a vector<string> instead of a simgle string when init crypto attribute

parent 30f31c93
No related branches found
No related tags found
No related merge requests found
...@@ -62,10 +62,12 @@ AudioSrtpSession::AudioSrtpSession (ManagerImpl * manager, SIPCall * sipcall) : ...@@ -62,10 +62,12 @@ AudioSrtpSession::AudioSrtpSession (ManagerImpl * manager, SIPCall * sipcall) :
} }
std::string AudioSrtpSession::getLocalCryptoInfo() { std::vector<std::string> AudioSrtpSession::getLocalCryptoInfo() {
_debug("Get Cryptographic info from this rtp session"); _debug("Get Cryptographic info from this rtp session");
std::vector<std::string> crypto_vector;
// @TODO we should return a vector containing supported // @TODO we should return a vector containing supported
// cryptographic context tagged 1, 2, 3... // cryptographic context tagged 1, 2, 3...
std::string tag = "1"; std::string tag = "1";
...@@ -79,13 +81,15 @@ std::string AudioSrtpSession::getLocalCryptoInfo() { ...@@ -79,13 +81,15 @@ std::string AudioSrtpSession::getLocalCryptoInfo() {
srtp_keys.append("|2^20|1:32"); srtp_keys.append("|2^20|1:32");
// generate crypto attribute // generate crypto attribute
std::string crypto = tag.append(" "); std::string crypto_attr = tag.append(" ");
crypto += crypto_suite.append(" "); crypto_attr += crypto_suite.append(" ");
crypto += srtp_keys; crypto_attr += srtp_keys;
_debug("%s", crypto_attr.c_str());
_debug("%s", crypto.c_str()); crypto_vector.push_back(crypto_attr);
return crypto; return crypto_vector;
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "sip/SdesNegotiator.h" #include "sip/SdesNegotiator.h"
#include <ccrtp/CryptoContext.h> #include <ccrtp/CryptoContext.h>
#include <vector>
class SdesNegotiator; class SdesNegotiator;
class ManagerImpl; class ManagerImpl;
...@@ -68,7 +69,7 @@ namespace sfl { ...@@ -68,7 +69,7 @@ namespace sfl {
AudioSrtpSession(ManagerImpl * manager, SIPCall * sipcall); AudioSrtpSession(ManagerImpl * manager, SIPCall * sipcall);
std::string getLocalCryptoInfo(void); std::vector<std::string> getLocalCryptoInfo(void);
void setRemoteCryptoInfo(sfl::SdesNegotiator& nego); void setRemoteCryptoInfo(sfl::SdesNegotiator& nego);
......
...@@ -365,12 +365,16 @@ void Sdp::sdp_add_media_description() ...@@ -365,12 +365,16 @@ void Sdp::sdp_add_media_description()
} }
// @TODO crypto should be a vector of string // @TODO crypto should be a vector of string
void Sdp::sdp_add_sdes_attribute (std::string crypto) void Sdp::sdp_add_sdes_attribute (std::vector<std::string>& crypto)
{ {
// temporary buffer used to store crypto attribute // temporary buffer used to store crypto attribute
char tempbuf[256]; char tempbuf[256];
std::vector<std::string>::iterator iter = crypto.begin();
while(iter != crypto.end()) {
// the attribute to add to sdp // the attribute to add to sdp
pjmedia_sdp_attr *attribute = (pjmedia_sdp_attr*) pj_pool_zalloc(_pool, sizeof(pjmedia_sdp_attr)); pjmedia_sdp_attr *attribute = (pjmedia_sdp_attr*) pj_pool_zalloc(_pool, sizeof(pjmedia_sdp_attr));
...@@ -380,7 +384,7 @@ void Sdp::sdp_add_sdes_attribute (std::string crypto) ...@@ -380,7 +384,7 @@ void Sdp::sdp_add_sdes_attribute (std::string crypto)
int len = pj_ansi_snprintf(tempbuf, sizeof(tempbuf), int len = pj_ansi_snprintf(tempbuf, sizeof(tempbuf),
"%.*s",(int)crypto.size(), crypto.c_str()); "%.*s",(int)(*iter).size(), (*iter).c_str());
attribute->value.slen = len; attribute->value.slen = len;
attribute->value.ptr = (char*) pj_pool_alloc (_pool, attribute->value.slen+1); attribute->value.ptr = (char*) pj_pool_alloc (_pool, attribute->value.slen+1);
...@@ -398,6 +402,9 @@ void Sdp::sdp_add_sdes_attribute (std::string crypto) ...@@ -398,6 +402,9 @@ void Sdp::sdp_add_sdes_attribute (std::string crypto)
} }
} }
iter++;
}
} }
......
...@@ -108,7 +108,7 @@ class Sdp { ...@@ -108,7 +108,7 @@ class Sdp {
/* Set the srtp _master_key /* Set the srtp _master_key
* @param mk The Master Key of a srtp session. * @param mk The Master Key of a srtp session.
*/ */
inline void set_srtp_crypto(const std::string& mk) { _srtp_crypto = mk; } inline void set_srtp_crypto(const std::vector<std::string> lc) { _srtp_crypto = lc; }
/* /*
* On building an invite outside a dialog, build the local offer and create the * On building an invite outside a dialog, build the local offer and create the
...@@ -258,8 +258,8 @@ class Sdp { ...@@ -258,8 +258,8 @@ class Sdp {
std::string _zrtp_hello_hash; std::string _zrtp_hello_hash;
/** "a=crypto" sdes attribute obtained from AudioSrtpSession */ /** "a=crypto" sdes local attributes obtained from AudioSrtpSession */
std::string _srtp_crypto; std::vector<std::string> _srtp_crypto;
Sdp(const Sdp&); //No Copy Constructor Sdp(const Sdp&); //No Copy Constructor
Sdp& operator=(const Sdp&); //No Assignment Operator Sdp& operator=(const Sdp&); //No Assignment Operator
...@@ -355,7 +355,7 @@ class Sdp { ...@@ -355,7 +355,7 @@ class Sdp {
* *
* @param media The media to add the srtp attribute to * @param media The media to add the srtp attribute to
*/ */
void sdp_add_sdes_attribute(std::string crypto); void sdp_add_sdes_attribute(std::vector<std::string>& crypto);
/* /*
* Adds a zrtp-hash attribute to * Adds a zrtp-hash attribute to
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment