[Live-devel] Please check this case in Mikey parser.
김태호(TAEHO KIM)
taeho07.kim at hanwha.com
Thu Apr 14 18:57:08 PDT 2022
Hello.
I’m working on Hanwha Techwin for developing IP Cameras.
Now days, I found out that your live555 supports SRTP with MIKEY.
Actually, My company’s camera products also support SRTP with MIKEY since 2018(Please check the compatibility with ours).
So. I’m testing your mikey parse code with test program “mikeyParser”
I found that your test program prints something wrong in CS ID map info like below.
whatisit at Zeppelin ~/test/live555/live/testProgs master ± ./mikeyParse AQAAAMKhB/cBAABH6Yn/AAAAAA==
Base64Data "AQAAAMKhB/cBAABH6Yn/AAAAAA==" produces 19 bytes of MIKEY data:
:01:00:00:00:c2:a1:07:f7:01:00:00:47:e9:89:ff:00:00:00:00
HDR:
version: 1
data type: 0 (Initiator's pre-shared key message)
next payload: 0 (Last payload)
V:0; PRF:0 (MIKEY-1)
CSB ID:0xc2a107f7
#CS:1
CS ID map type:0 (SRTP-ID)
CS ID map info:
Policy_no_1: 0; SSRC_1: 0xff000000; ROC_1: 0x0047e989
Actual SSRC_1 and ROC_1 are 0x47e989ff and 0x00000000.
I think this is caused the evaluation order of fprintf’s arguments.
So I fix it in the function “Boolean parseMikeyHDR()” like below.
Please see the final fprintf function.
Boolean parseMikeyHDR(u_int8_t const*& ptr, u_int8_t const* endPtr, u_int8_t& nextPayloadType) {
testSize(10); // up to the start of "CS ID map info"
fprintf(stderr, "\tversion: %d\n", getByte(ptr));
u_int8_t const dataType = getByte(ptr);
fprintf(stderr, "\tdata type: %d (%s)\n", dataType, dataTypeComment[dataType]);
nextPayloadType = getByte(ptr);
fprintf(stderr, "\tnext payload: %d (%s)\n", nextPayloadType, payloadTypeName[nextPayloadType]);
u_int8_t const V_PRF = getByte(ptr);
u_int8_t const PRF = V_PRF&0x7F;
fprintf(stderr, "\tV:%d; PRF:%d (%s)\n", V_PRF>>7, PRF, PRF == 0 ? "MIKEY-1" : "unknown");
fprintf(stderr, "\tCSB ID:0x%08x\n", get4Bytes(ptr));
u_int8_t numCryptoSessions = getByte(ptr);
fprintf(stderr, "\t#CS:%d\n", numCryptoSessions);
u_int8_t const CS_ID_map_type = getByte(ptr);
fprintf(stderr, "\tCS ID map type:%d (%s)\n",
CS_ID_map_type, CS_ID_map_type == 0 ? "SRTP-ID" : "unknown");
if (CS_ID_map_type != 0) return False;
fprintf(stderr, "\tCS ID map info:\n");
testSize(numCryptoSessions * (1+4+4)); // the size of the "CS ID map info"
for (u_int8_t i = 1; i <= numCryptoSessions; ++i) {
u_int8_t policy_no = getByte(ptr);
u_int32_t ssrc = get4Bytes(ptr);
u_int32_t roc = get4Bytes(ptr);
fprintf(stderr, "\tPolicy_no_%d: %d;\tSSRC_%d: 0x%08x; ROC_%d: 0x%08x\n",
i, policy_no,
i, ssrc,
i, roc);
}
return True;
}
Thank you.
PS. In get4Bytes() and get2Bytes() function, is there no need to use ntohl() and ntohs() functions?
Test Environment :
whatisit at Zeppelin ~/test/live555/live/testProgs master ± uname -a
Linux Zeppelin 4.2.0-27-generic #32~14.04.1-Ubuntu SMP Fri Jan 22 15:32:26 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
insert_eventHandler(EV_NEW_TASK, [&](TaskEvent* event)->bool
{
return do_moreSmartCode (event);
});
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20220415/e891a088/attachment-0001.htm>
More information about the live-devel
mailing list