Compile and test methods latest libsrtp library

1. Environment

In Ubuntu TLS 16.4.5 version to compile and test.

Download the latest source code needs to git, git if not installed can use the following command to install:

sudo apt-get install git -y

2. Compile and install

2.1 Download Source

git clone https://github.com/cisco/libsrtp.git

2.2 into the source directory

cd libsrtp

2.3 Configuration

Configuration commands are as follows:

./configure

The results are as follows:

cgs@ubuntu:~/libsrtp$ ./configure
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for ar... ar
checking the archiver (ar) interface... ar
checking for ranlib... ranlib
checking for a BSD-compatible install... /usr/bin/install -c
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether byte ordering is bigendian... no
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking whether gcc accepts -Werror... yes
checking whether gcc accepts -fPIC... yes
checking whether gcc accepts -Wall... yes
checking whether gcc accepts -pedantic... yes
checking whether gcc accepts -Wstrict-prototypes... yes
checking whether gcc accepts -O4... yes
checking whether gcc accepts -fexpensive-optimizations... yes
checking whether gcc accepts -funroll-loops... yes
checking whether gcc accepts -Wno-language-extension-token... no
checking for ANSI C header files... (cached) yes
checking for unistd.h... (cached) yes
checking for byteswap.h... yes
checking for stdint.h... (cached) yes
checking for sys/uio.h... yes
checking for inttypes.h... (cached) yes
checking for sys/types.h... (cached) yes
checking for machine/types.h... no
checking for sys/int_types.h... no
checking for sys/socket.h... yes
checking for netinet/in.h... yes
checking for arpa/inet.h... yes
checking for windows.h... no
checking for int8_t... yes
checking for uint8_t... yes
checking for int16_t... yes
checking for uint16_t... yes
checking for int32_t... yes
checking for uint32_t... yes
checking for uint64_t... yes
checking size of unsigned long... 8
checking size of unsigned long long... 8
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for size_t... yes
checking for socket... yes
checking for inet_aton... yes
checking for usleep... yes
checking for sigaction... yes
checking whether to enable debug logging in all modules... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking whether to leverage OpenSSL crypto... no
checking whether to leverage NSS crypto... no
checking for pcap_create in -lpcap... no
checking for pcap_create in -lwpcap... no
checking whether to redirect logging to stdout... no
checking wheather to use a file for logging... no
checking for extra C compiler flags... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating crypto/Makefile
config.status: creating doc/Makefile
config.status: creating libsrtp2.pc
config.status: creating crypto/include/config.h

Configuration commands additional parameters, the following format:

./configure [ options ]

options optional parameters as follows:

Option Description
–help -h Display help
–enable-debug-logging Enable debug logging in all modules
–enable-log-stdout Enable logging to stdout
–enable-openssl Enable OpenSSL crypto engine
–enable-openssl-kdf Enable OpenSSL KDF algorithm
–with-log-file Use file for logging
–with-openssl-dir Location of OpenSSL installation

2.4 compiler

Compiler command is as follows:

make

The results are as follows:

cgs@ubuntu:~/libsrtp$ make
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -c srtp/srtp.c -o srtp/srtp.o
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -c srtp/ekt.c -o srtp/ekt.o
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -c crypto/cipher/cipher.c -o crypto/cipher/cipher.o
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -c crypto/cipher/null_cipher.c -o crypto/cipher/null_cipher.o
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -c crypto/cipher/aes_icm.c -o crypto/cipher/aes_icm.o
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -c crypto/cipher/aes.c -o crypto/cipher/aes.o
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -c crypto/hash/null_auth.c -o crypto/hash/null_auth.o
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -c crypto/hash/auth.c -o crypto/hash/auth.o
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -c crypto/hash/hmac.c -o crypto/hash/hmac.o
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -c crypto/hash/sha1.c -o crypto/hash/sha1.o
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -c crypto/math/datatypes.c -o crypto/math/datatypes.o
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -c crypto/math/stat.c -o crypto/math/stat.o
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -c crypto/kernel/crypto_kernel.c -o crypto/kernel/crypto_kernel.o
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -c crypto/kernel/alloc.c -o crypto/kernel/alloc.o
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -c crypto/kernel/key.c -o crypto/kernel/key.o
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -c crypto/kernel/err.c -o crypto/kernel/err.o
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -c crypto/replay/rdb.c -o crypto/replay/rdb.o
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -c crypto/replay/rdbx.c -o crypto/replay/rdbx.o
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -c crypto/replay/ut_sim.c -o crypto/replay/ut_sim.o
ar cr libsrtp2.a srtp/srtp.o srtp/ekt.o crypto/cipher/cipher.o crypto/cipher/null_cipher.o crypto/cipher/aes_icm.o crypto/cipher/aes.o crypto/hash/null_auth.o crypto/hash/auth.o crypto/hash/hmac.o crypto/hash/sha1.o crypto/math/datatypes.o crypto/math/stat.o crypto/kernel/crypto_kernel.o crypto/kernel/alloc.o crypto/kernel/key.o crypto/kernel/err.o crypto/replay/rdb.o crypto/replay/rdbx.o crypto/replay/ut_sim.o
ranlib libsrtp2.a
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -I./test -L.  -o crypto/test/aes_calc crypto/test/aes_calc.c test/util.c libsrtp2.a  -lsrtp2
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -L.  -o crypto/test/cipher_driver crypto/test/cipher_driver.c test/getopt_s.c libsrtp2.a  -lsrtp2
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -I./test -L.  -o crypto/test/datatypes_driver crypto/test/datatypes_driver.c test/util.c libsrtp2.a  -lsrtp2
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -L.  -o crypto/test/kernel_driver crypto/test/kernel_driver.c test/getopt_s.c libsrtp2.a  -lsrtp2
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -I./test -L.  -o crypto/test/sha1_driver crypto/test/sha1_driver.c test/util.c libsrtp2.a  -lsrtp2
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -L.  crypto/test/stat_driver.c -o crypto/test/stat_driver -lsrtp2 
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -L.  -o crypto/test/env crypto/test/env.c test/getopt_s.c libsrtp2.a  -lsrtp2
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -L.  -o test/srtp_driver test/srtp_driver.c test/util.c test/getopt_s.c libsrtp2.a  -lsrtp2
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -L.  test/replay_driver.c -o test/replay_driver -lsrtp2 
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -L.  test/roc_driver.c -o test/roc_driver -lsrtp2 
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -L.  -o test/rdbx_driver test/rdbx_driver.c test/getopt_s.c libsrtp2.a  -lsrtp2
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -L.  -o test/rtpw test/rtpw.c test/rtp.c test/util.c test/getopt_s.c crypto/math/datatypes.c libsrtp2.a  -lsrtp2
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -L.  -o test/dtls_srtp_driver test/dtls_srtp_driver.c test/getopt_s.c test/util.c libsrtp2.a  -lsrtp2
gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include  -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -I./test -L.  -o test/test_srtp test/test_srtp.c libsrtp2.a  -lsrtp2
Build done. Please run 'make runtest' to run self tests.

2.5 Test results compiled

Use the following command to compile test results (last prompted run the command successfully compiled)

make runtest

The results are as follows:

cgs@ubuntu:~/libsrtp$ make runtest
Build done. Please run 'make runtest' to run self tests.
running libsrtp2 test applications...
crypto/test/cipher_driver -v >/dev/null
crypto/test/kernel_driver -v >/dev/null
test/test_srtp >/dev/null
test/rdbx_driver -v >/dev/null
test/srtp_driver -v >/dev/null
test/roc_driver -v >/dev/null
test/replay_driver -v >/dev/null
test/dtls_srtp_driver >/dev/null
cd test;  /home/cgs/workspace/libsrtp/test/rtpw_test.sh -w /home/cgs/workspace/libsrtp/test/words.txt >/dev/null
libsrtp2 test applications passed.
make -C crypto runtest
make[1]: Entering directory '/home/cgs/workspace/libsrtp/crypto'
test/env # print out information on the build environment
CPU set to little-endian		(WORDS_BIGENDIAN == 0)
CPU set to CISC				(CPU_CISC == 1)
using native 64-bit type		(NO_64_BIT_MATH == 0)
running crypto test applications...
test `test/aes_calc 000102030405060708090a0b0c0d0e0f 00112233445566778899aabbccddeeff` = 69c4e0d86a7b0430d8cdb78070b4c55a
test `test/aes_calc 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f 00112233445566778899aabbccddeeff` = 8ea2b7ca516745bfeafc49904b496089
test/cipher_driver -v >/dev/null
test/datatypes_driver -v >/dev/null
test/stat_driver >/dev/null
test/sha1_driver -v >/dev/null
test/kernel_driver -v >/dev/null
crypto test applications passed.
make[1]: Leaving directory '/home/cgs/workspace/libsrtp/crypto'

2.6 Installation

Installation command as follows (Of particular note in front of sudo , or installation error occurs):

sudo make install

The results are as follows:

cgs@ubuntu:~/libsrtp$ sudo make install
[sudo] password for cgs: 
/usr/bin/install -c -d /usr/local/include/srtp2
/usr/bin/install -c -d /usr/local/lib
cp ./include/srtp.h /usr/local/include/srtp2
cp ./crypto/include/cipher.h /usr/local/include/srtp2
cp ./crypto/include/auth.h /usr/local/include/srtp2
cp ./crypto/include/crypto_types.h /usr/local/include/srtp2
if [ -f libsrtp2.a ]; then cp libsrtp2.a /usr/local/lib/; fi
if [ -f libsrtp2.dll.a ]; then cp libsrtp2.dll.a /usr/local/lib/; fi
if [ -f libsrtp2.so.1 ]; then \
	/usr/bin/install -c -d /usr/local/lib; \
	cp libsrtp2.so.1 /usr/local/lib/; \
	cp libsrtp2.so /usr/local/lib/; \
	if [ -n "1" ]; then \
		ln -sfn libsrtp2.so.1 /usr/local/lib/libsrtp2.so; \
	fi; \
fi
/usr/bin/install -c -d /usr/local/lib/pkgconfig
cp ./libsrtp2.pc /usr/local/lib/pkgconfig/

At this point, compiling the installation is complete.

3. Test

First, go to libsrtp test file directory

cd test

Then, test the following command

./rtpw_test.sh

The results are as follows:

cgs@ubuntu:~/libsrtp$ cd test
cgs@ubuntu:~/libsrtp/test$ ./rtpw_test.sh
./rtpw_test.sh : starting rtpw receiver process...
./rtpw_test.sh : receiver PID = 23269
Using libsrtp2 2.3.0-pre [0x2030000]
security services: confidentiality message authentication
set master key/salt to 2b2edc5034f61a72345ca5986d7bfd01/89aa6dc2ecab32fd9af74df6dfc6
0
./rtpw_test.sh : starting rtpw sender process...
./rtpw_test.sh : sender PID = 23273
Using libsrtp2 2.3.0-pre [0x2030000]
security services: confidentiality message authentication
set master key/salt to 2b2edc5034f61a72345ca5986d7bfd01/89aa6dc2ecab32fd9af74df6dfc6
	word: abducing

sending word: abducing
0
sending word: acidheads
	word: acidheads

sending word: acidness
	word: acidness

sending word: actons
	word: actons

sending word: admixtures
	word: admixtures

sending word: affidavit
	word: affidavit

sending word: agelastic
	word: agelastic

./rtpw_test.sh : starting rtpw receiver process... 
./rtpw_test.sh : receiver PID = 23277
Using libsrtp2 2.3.0-pre [0x2030000]
security services: confidentiality message authentication
set master key/salt to 033490ba9e82994fc210133957390389/92b2edc5034f61a72345ca598d7b
0
./rtpw_test.sh : starting rtpw sender process...
./rtpw_test.sh : sender PID = 23281
Using libsrtp2 2.3.0-pre [0x2030000]
security services: confidentiality message authentication
set master key/salt to 033490ba9e82994fc210133957390389/92b2edc5034f61a72345ca598d7b
	word: abducing

sending word: abducing
0
sending word: acidheads
	word: acidheads

sending word: acidness
	word: acidness

sending word: actons
	word: actons

sending word: admixtures
	word: admixtures

sending word: affidavit
	word: affidavit

sending word: agelastic
	word: agelastic

./rtpw_test.sh : done (test passed)

4. Frequently Asked Questions

Q: perform the installation command make install, appear the installation fails, the following error message:

cgs@ubuntu:~/libsrtp$ make install
/usr/bin/install -c -d /usr/local/include/srtp2
/usr/bin/install: cannot change permissions of ‘/usr/local/include/srtp2’: No such file or directory
Makefile:268: recipe for target 'install' failed
make: *** [install] Error 1

A: Because of the need to install /usr/bin, /usr/localcatalog copy files, etc., need su privileges, so it is necessary to adjust the install command sudo make install, a command that is added to the preceding sudo , su and follow the prompts to enter your password to install.

5. References

官方文档《Installing and Building libSRTP》
https://github.com/cisco/libsrtp#installing-and-building-libsrtp

Compile and test methods libsrtp library
https://blog.csdn.net/stone_overlooking/article/details/73896198

Guess you like

Origin blog.csdn.net/cgs1999/article/details/89704359