cisco / libsrtp

Library for SRTP (Secure Realtime Transport Protocol)
Other
1.21k stars 474 forks source link

rtpw can not receive data in srtp 1.4.4 #221

Closed openluopworld closed 7 years ago

openluopworld commented 7 years ago

Hi, I use srtp 1.4.4 in Ubuntu 14.04. After compiling, I execute the program rtpw with the example in libSRTP 1.4.4 Overview and Reference Manual. It can send data, but nothing can be received. Here are the steps.

  1. Compile
    ./configure
    make
  2. get the key
    ./crypto/test/rand_gen -n 30
    9a390d7e4c1b5abf91a523dbf987cbc981a5f40c8e319cebe35091834067
  3. Then I send data and the result is below.
    ./test/rtpw -s -k 9a390d7e4c1b5abf91a523dbf987cbc981a5f40c8e319cebe35091834067 -e -a 0.0.0.0 9999
    security services: confidentiality message authentication
    set master key/salt to 9a390d7e4c1b5abf91a523dbf987cbc9/81a5f40c8e319cebe35091834067
    sending word: A
    sending word: A's
    sending word: AA's
    sending word: AB's
    sending word: ABM's
    sending word: AC's
    ...
  4. But nothing received when I try to execute the following command in another shell.
    ./test/rtpw -r -k 9a390d7e4c1b5abf91a523dbf987cbc981a5f40c8e319cebe35091834067 -e -a 0.0.0.0 9999
    security services: confidentiality message authentication
    set master key/salt to 9a390d7e4c1b5abf91a523dbf987cbc9/81a5f40c8e319cebe35091834067

    Does someone know the reason or do I miss something? Thanks.

paulej commented 7 years ago

I assume you figured it out?

openluopworld commented 7 years ago

Yeah, since the function rtp_recvfrom returns an unsigned int. It can not be compared with -1.

unsigned int rtp_recvfrom(rtp_receiver_t receiver, void *msg, int *len);
// line 473 of rtpw.c in version 1.4.4
if (rtp_recvfrom(rcvr, word, &len) > -1) {