75 virtual unsigned getSize(
void) = 0;
83 virtual unsigned getDigest(
unsigned char *buffer) = 0;
91 virtual void putDigest(
const unsigned char *buffer,
unsigned length) = 0;
98 virtual std::ostream &strDigest(std::ostream &os) = 0;
107 virtual void initDigest(
void) = 0;
112 #ifdef HAVE_OLD_IOSTREAM
118 #ifdef HAVE_OLD_IOSTREAM
146 std::ostream &
strDigest(std::ostream &os);
156 unsigned getDigest(
unsigned char *buffer);
158 void putDigest(
const unsigned char *buffer,
unsigned len);
182 static inline unsigned long rotate_left(
unsigned long x,
unsigned long n)
185 #if ~0lu != 0xfffffffflu
186 return (x << n) | ((x & 0xffffffffu) >> (32-n));
188 return (x << n) | (x >> (32-n));
192 static inline unsigned long F(
unsigned long x,
unsigned long y,
unsigned long z)
194 return (x & y) | (~x & z);
197 static inline unsigned long G(
unsigned long x,
unsigned long y,
unsigned long z)
199 return (x & z) | (y & ~z);
202 static inline unsigned long H(
unsigned long x,
unsigned long y,
unsigned long z)
207 static inline unsigned long md5I(
unsigned long x,
unsigned long y,
unsigned long z)
213 static void FF(
unsigned long &a,
unsigned long b,
unsigned long c,
unsigned long d,
unsigned long x,
unsigned long s,
unsigned long ac)
215 a += F(b, c, d) + x + ac;
216 a = rotate_left(a, s) + b;
219 static void GG(
unsigned long &a,
unsigned long b,
unsigned long c,
unsigned long d,
unsigned long x,
unsigned long s,
unsigned long ac)
221 a += G(b, c, d) + x + ac;
222 a = rotate_left(a, s) + b;
225 static void HH(
unsigned long &a,
unsigned long b,
unsigned long c,
unsigned long d,
unsigned long x,
unsigned long s,
unsigned long ac)
227 a += H(b, c, d) + x + ac;
228 a = rotate_left(a, s) + b;
231 static void II(
unsigned long &a,
unsigned long b,
unsigned long c,
unsigned long d,
unsigned long x,
unsigned long s,
unsigned long ac)
233 a += md5I(b, c, d) + x + ac;
234 a = rotate_left(a, s) + b;
247 state[0] = 0x67452301;
248 state[1] = 0xefcdab89;
249 state[2] = 0x98badcfe;
250 state[3] = 0x10325476;
253 setp((
char*)
buf,(
char*)
buf+64);
259 bpos = (
unsigned char*)pptr()-
buf;
263 buf[
bpos++] = (
unsigned char)c;
271 unsigned long x[16], a, b, c, d;
281 if((
count[0] += 512) < 512)
289 for(i = 0; i < 16; ++i)
290 x[i] = (
unsigned long)(
buf[i * 4]) |
291 (
unsigned long)(
buf[i * 4 + 1] << 8) |
292 (
unsigned long)(
buf[i * 4 + 2] << 16) |
293 (
unsigned long)(
buf[i * 4 + 3] << 24);
295 FF(a, b, c, d, x[ 0],
S11, 0xd76aa478);
296 FF(d, a, b, c, x[ 1],
S12, 0xe8c7b756);
297 FF(c, d, a, b, x[ 2],
S13, 0x242070db);
298 FF(b, c, d, a, x[ 3],
S14, 0xc1bdceee);
299 FF(a, b, c, d, x[ 4],
S11, 0xf57c0faf);
300 FF(d, a, b, c, x[ 5],
S12, 0x4787c62a);
301 FF(c, d, a, b, x[ 6],
S13, 0xa8304613);
302 FF(b, c, d, a, x[ 7],
S14, 0xfd469501);
303 FF(a, b, c, d, x[ 8],
S11, 0x698098d8);
304 FF(d, a, b, c, x[ 9],
S12, 0x8b44f7af);
305 FF(c, d, a, b, x[10],
S13, 0xffff5bb1);
306 FF(b, c, d, a, x[11],
S14, 0x895cd7be);
307 FF(a, b, c, d, x[12],
S11, 0x6b901122);
308 FF(d, a, b, c, x[13],
S12, 0xfd987193);
309 FF(c, d, a, b, x[14],
S13, 0xa679438e);
310 FF(b, c, d, a, x[15],
S14, 0x49b40821);
312 GG(a, b, c, d, x[ 1],
S21, 0xf61e2562);
313 GG(d, a, b, c, x[ 6],
S22, 0xc040b340);
314 GG(c, d, a, b, x[11],
S23, 0x265e5a51);
315 GG(b, c, d, a, x[ 0],
S24, 0xe9b6c7aa);
316 GG(a, b, c, d, x[ 5],
S21, 0xd62f105d);
317 GG(d, a, b, c, x[10],
S22, 0x2441453);
318 GG(c, d, a, b, x[15],
S23, 0xd8a1e681);
319 GG(b, c, d, a, x[ 4],
S24, 0xe7d3fbc8);
320 GG(a, b, c, d, x[ 9],
S21, 0x21e1cde6);
321 GG(d, a, b, c, x[14],
S22, 0xc33707d6);
322 GG(c, d, a, b, x[ 3],
S23, 0xf4d50d87);
323 GG(b, c, d, a, x[ 8],
S24, 0x455a14ed);
324 GG(a, b, c, d, x[13],
S21, 0xa9e3e905);
325 GG(d, a, b, c, x[ 2],
S22, 0xfcefa3f8);
326 GG(c, d, a, b, x[ 7],
S23, 0x676f02d9);
327 GG(b, c, d, a, x[12],
S24, 0x8d2a4c8a);
329 HH(a, b, c, d, x[ 5],
S31, 0xfffa3942);
330 HH(d, a, b, c, x[ 8],
S32, 0x8771f681);
331 HH(c, d, a, b, x[11],
S33, 0x6d9d6122);
332 HH(b, c, d, a, x[14],
S34, 0xfde5380c);
333 HH(a, b, c, d, x[ 1],
S31, 0xa4beea44);
334 HH(d, a, b, c, x[ 4],
S32, 0x4bdecfa9);
335 HH(c, d, a, b, x[ 7],
S33, 0xf6bb4b60);
336 HH(b, c, d, a, x[10],
S34, 0xbebfbc70);
337 HH(a, b, c, d, x[13],
S31, 0x289b7ec6);
338 HH(d, a, b, c, x[ 0],
S32, 0xeaa127fa);
339 HH(c, d, a, b, x[ 3],
S33, 0xd4ef3085);
340 HH(b, c, d, a, x[ 6],
S34, 0x4881d05);
341 HH(a, b, c, d, x[ 9],
S31, 0xd9d4d039);
342 HH(d, a, b, c, x[12],
S32, 0xe6db99e5);
343 HH(c, d, a, b, x[15],
S33, 0x1fa27cf8);
344 HH(b, c, d, a, x[ 2],
S34, 0xc4ac5665);
346 II(a, b, c, d, x[ 0],
S41, 0xf4292244);
347 II(d, a, b, c, x[ 7],
S42, 0x432aff97);
348 II(c, d, a, b, x[14],
S43, 0xab9423a7);
349 II(b, c, d, a, x[ 5],
S44, 0xfc93a039);
350 II(a, b, c, d, x[12],
S41, 0x655b59c3);
351 II(d, a, b, c, x[ 3],
S42, 0x8f0ccc92);
352 II(c, d, a, b, x[10],
S43, 0xffeff47d);
353 II(b, c, d, a, x[ 1],
S44, 0x85845dd1);
354 II(a, b, c, d, x[ 8],
S41, 0x6fa87e4f);
355 II(d, a, b, c, x[15],
S42, 0xfe2ce6e0);
356 II(c, d, a, b, x[ 6],
S43, 0xa3014314);
357 II(b, c, d, a, x[13],
S44, 0x4e0811a1);
358 II(a, b, c, d, x[ 4],
S41, 0xf7537e82);
359 II(d, a, b, c, x[11],
S42, 0xbd3af235);
360 II(c, d, a, b, x[ 2],
S43, 0x2ad7d2bb);
361 II(b, c, d, a, x[ 9],
S44, 0xeb86d391);
372 unsigned char cbuf[8];
373 unsigned long i, len;
375 static unsigned char pad[64]={
376 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
377 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
378 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
380 bpos = (
unsigned char*)pptr()-
buf;
385 if(
count[0] < (
unsigned long)(
bpos << 3))
388 for(i = 0; i < 2; ++i) {
389 cbuf[i * 4] = (
unsigned char)
count[i] & 0xff;
390 cbuf[i * 4 + 1] = (
unsigned char)((
count[i] >> 8) & 0xff);
391 cbuf[i * 4 + 2] = (
unsigned char)((
count[i] >> 16) & 0xff);
392 cbuf[i * 4 + 3] = (
unsigned char)((
count[i] >> 24) & 0xff);
395 i = (unsigned) ((
count[0] >> 3) & 0x3f);
396 len = (i < 56) ? (56 - i) : (120 - i);
402 for(i = 0; i < 4; ++i) {
403 md5[i * 4] = (
unsigned char)
state[i] & 0xff;
404 md5[i * 4 + 1] = (
unsigned char)((
state[i] >> 8) & 0xff);
405 md5[i * 4 + 2] = (
unsigned char)((
state[i] >> 16) & 0xff);
406 md5[i * 4 + 3] = (
unsigned char)((
state[i] >> 24) & 0xff);
415 memcpy(buffer,
md5, 16);
421 bpos = (
unsigned char*)pptr()-
buf;
439 for(i = 0; i < 16; ++i)
441 sprintf(dbuf + 2 * i,
"%02x",
md5[i]);
443 std::sprintf(dbuf + 2 * i,
"%02x",
md5[i]);
449 static uint32 MD5BasedRandom32()
452 typedef timeval md5time_t;
470 SysTime::gettimeofday(&(message.data.time),NULL);
472 static_cast<uint8
>(message.data.time.tv_sec *
473 message.data.time.tv_usec);
475 message.data.address = &message;
476 memcpy(message.data.cname,
481 md5.
putDigest(reinterpret_cast<unsigned char*>(message.array),
483 md5.
getDigest(reinterpret_cast<unsigned char*>(digest.buf8));
487 for (
int i = 0; i < 4; i ++ )
488 result ^= digest.buf32[i];
499 int fd = open(
"/dev/urandom",O_RDONLY);
503 if ( read(fd,&number,
sizeof(number)) !=
sizeof(number) ) {
510 number = MD5BasedRandom32();
517 uint16 r16 = r32 & (r32 >> 16);
563 #ifdef CCXX_EXCEPTIONS
568 #ifdef CCXX_EXCEPTIONS
580 SysTime::gettimeofday(&now,NULL);
Generic RTP input/output queues.
RTPDataQueue(uint32 size=defaultMembersHashSize)
Constructor.
Best-effort network service.
ITU-T G.711. mu-law audio 8 Khz (RFC 1890)
Canonical end-point identifier.
bool setPayloadFormat(const PayloadFormat &pf)
Set the payload format in use, for timing and payload type identification purposes.
Queue for incoming RTP data packets in an RTP session.
static const uint32 defaultSessionBw
timeval getInitialTime() const
Declaration of ccRTP internal stuff.
void putDigest(const unsigned char *buffer, unsigned len)
Put data into the digest bypassing the stream subsystem.
void endQueue()
This method ends the queue.
virtual std::ostream & strDigest(std::ostream &os)=0
print a digest string for export.
void initDigest(void)
Reset the digest table to an initial default value.
Base classes for RTP queues.
void setLocalSSRC(uint32 ssrc)
A md5 collection/computation accululator class.
void purgeOutgoingQueue()
A virtual base class for RTP queue hierarchies.
std::ostream & strDigest(std::ostream &os)
print a digest string for export.
RTPQueueBase(uint32 *ssrc=NULL)
uint32 getCurrentTimestamp() const
Get the timestamp that should be given for a packet whose payload sampling instant corresponds to the...
void purgeIncomingQueue()
void removeOutQueueCryptoContext(CryptoContext *cc)
Remove output queue CryptoContext.
uint32 getCurrentRTPClockRate() const
Get the clock rate in RTP clock units (for instance, 8000 units per second for PCMU, or 90000 units per second for MP2T).
void initQueue()
Global queue initialization.
friend std::ostream & operator<<(std::ostream &os, Digest &ia)
A generic outgoing RTP data queue supporting multiple destinations.
__EXPORT RTPApplication & defaultApplication()
Get the RTPApplication object for the "default" application (the only one used by common applications...
void removeInQueueCryptoContext(CryptoContext *cc)
Remove input queue CryptoContext.
unsigned getSize(void)
Get the size of a digest in octets.
uint32 getDefaultSessionBandwidth() const
unsigned getDigest(unsigned char *buffer)
Copy the binary digest buffer to user memory.
The digest base class is used for implementing and deriving one way hashing functions.
volatile bool dataServiceActive