62
62
//a=crypto:tag 1*WSP crypto-suite 1*WSP key-params *(1*WSP session-param)
64
std::tr1::shared_ptr<Pattern> generalSyntaxPattern, tagPattern, cryptoSuitePattern,
64
std::unique_ptr<Pattern> generalSyntaxPattern, tagPattern, cryptoSuitePattern,
68
68
// used to match white space (which are used as separator)
69
generalSyntaxPattern.reset(new Pattern("[\x20\x09]+", "g"));
69
generalSyntaxPattern.reset(new Pattern("[\x20\x09]+", true));
71
tagPattern.reset(new Pattern("^a=crypto:(?P<tag>[0-9]{1,9})"));
71
tagPattern.reset(new Pattern("^a=crypto:(?P<tag>[0-9]{1,9})", false));
73
73
cryptoSuitePattern.reset(new Pattern(
74
74
"(?P<cryptoSuite>AES_CM_128_HMAC_SHA1_80|" \
75
75
"AES_CM_128_HMAC_SHA1_32|" \
76
76
"F8_128_HMAC_SHA1_80|" \
77
"[A-Za-z0-9_]+)")); // srtp-crypto-suite-ext
77
"[A-Za-z0-9_]+)", false)); // srtp-crypto-suite-ext
79
79
keyParamsPattern.reset(new Pattern(
80
80
"(?P<srtpKeyMethod>inline|[A-Za-z0-9_]+)\\:" \
81
81
"(?P<srtpKeyInfo>[A-Za-z0-9\x2B\x2F\x3D]+)" \
82
82
"(\\|2\\^(?P<lifetime>[0-9]+)\\|" \
83
83
"(?P<mkiValue>[0-9]+)\\:" \
84
"(?P<mkiLength>[0-9]{1,3})\\;?)?", "g"));
84
"(?P<mkiLength>[0-9]{1,3})\\;?)?", true));
86
86
} catch (const CompileError& exception) {
87
87
throw ParseError("A compile exception occured on a pattern.");
91
90
// Take each line from the vector
92
91
// and parse its content
94
93
std::vector<CryptoAttribute *> cryptoAttributeVector;
96
for (std::vector<std::string>::iterator iter = remoteAttribute_.begin();
97
iter != remoteAttribute_.end(); ++iter) {
95
for (const auto &item : remoteAttribute_) {
99
97
// Split the line into its component
100
98
// that we will analyze further down.
101
99
std::vector<std::string> sdesLine;
103
*generalSyntaxPattern << (*iter);
101
generalSyntaxPattern->updateSubject(item);
106
104
sdesLine = generalSyntaxPattern->split();
142
140
return cryptoAttributeVector;
144
142
// Parse one or more key-params field.
145
*keyParamsPattern << sdesLine.at(2);
143
keyParamsPattern->updateSubject(sdesLine.at(2));
147
145
std::string srtpKeyInfo;
148
146
std::string srtpKeyMethod;